//! Generated from armenian.sbl by Snowball 3.0.0 - https://snowballstem.org/

#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(unused_mut)]
#![allow(unused_parens)]
#![allow(unused_variables)]
use crate::snowball::Among;
use crate::snowball::SnowballEnv;

#[derive(Clone)]
struct Context {
    i_p2: i32,
    i_pV: i32,
}

static A_0: &'static [Among<Context>; 23] = &[
    Among("բար", -1, 1, None),
    Among("րորդ", -1, 1, None),
    Among("երորդ", 1, 1, None),
    Among("ալի", -1, 1, None),
    Among("ակի", -1, 1, None),
    Among("որակ", -1, 1, None),
    Among("եղ", -1, 1, None),
    Among("վուն", -1, 1, None),
    Among("արան", -1, 1, None),
    Among("ական", -1, 1, None),
    Among("են", -1, 1, None),
    Among("երեն", 10, 1, None),
    Among("եկեն", 10, 1, None),
    Among("որէն", -1, 1, None),
    Among("ին", -1, 1, None),
    Among("գին", 14, 1, None),
    Among("ովին", 14, 1, None),
    Among("լայն", -1, 1, None),
    Among("պես", -1, 1, None),
    Among("իվ", -1, 1, None),
    Among("ատ", -1, 1, None),
    Among("ավետ", -1, 1, None),
    Among("կոտ", -1, 1, None),
];

static A_1: &'static [Among<Context>; 71] = &[
    Among("ար", -1, 1, None),
    Among("ացար", 0, 1, None),
    Among("եցար", 0, 1, None),
    Among("ացրիր", -1, 1, None),
    Among("ացիր", -1, 1, None),
    Among("եցիր", -1, 1, None),
    Among("վեցիր", 5, 1, None),
    Among("ալուց", -1, 1, None),
    Among("ելուց", -1, 1, None),
    Among("աց", -1, 1, None),
    Among("եց", -1, 1, None),
    Among("ացրեց", 10, 1, None),
    Among("ալու", -1, 1, None),
    Among("ելու", -1, 1, None),
    Among("աք", -1, 1, None),
    Among("ցաք", 14, 1, None),
    Among("ացաք", 15, 1, None),
    Among("ացրիք", -1, 1, None),
    Among("ացիք", -1, 1, None),
    Among("եցիք", -1, 1, None),
    Among("վեցիք", 19, 1, None),
    Among("անք", -1, 1, None),
    Among("ցանք", 21, 1, None),
    Among("ացանք", 22, 1, None),
    Among("ացրինք", -1, 1, None),
    Among("ացինք", -1, 1, None),
    Among("եցինք", -1, 1, None),
    Among("վեցինք", 26, 1, None),
    Among("ա", -1, 1, None),
    Among("ացա", 28, 1, None),
    Among("եցա", 28, 1, None),
    Among("վե", -1, 1, None),
    Among("ացրի", -1, 1, None),
    Among("ացի", -1, 1, None),
    Among("եցի", -1, 1, None),
    Among("վեցի", 34, 1, None),
    Among("ալ", -1, 1, None),
    Among("ըալ", 36, 1, None),
    Among("ացնալ", 36, 1, None),
    Among("անալ", 36, 1, None),
    Among("ենալ", 36, 1, None),
    Among("ել", -1, 1, None),
    Among("ըել", 41, 1, None),
    Among("նել", 41, 1, None),
    Among("ցնել", 43, 1, None),
    Among("եցնել", 44, 1, None),
    Among("չել", 41, 1, None),
    Among("վել", 41, 1, None),
    Among("ացվել", 47, 1, None),
    Among("եցվել", 47, 1, None),
    Among("տել", 41, 1, None),
    Among("ատել", 50, 1, None),
    Among("ոտել", 50, 1, None),
    Among("կոտել", 52, 1, None),
    Among("ված", -1, 1, None),
    Among("ում", -1, 1, None),
    Among("վում", 55, 1, None),
    Among("ան", -1, 1, None),
    Among("ցան", 57, 1, None),
    Among("ացան", 58, 1, None),
    Among("ացրին", -1, 1, None),
    Among("ացին", -1, 1, None),
    Among("եցին", -1, 1, None),
    Among("վեցին", 62, 1, None),
    Among("ալիս", -1, 1, None),
    Among("ելիս", -1, 1, None),
    Among("ավ", -1, 1, None),
    Among("ացավ", 66, 1, None),
    Among("եցավ", 66, 1, None),
    Among("ալով", -1, 1, None),
    Among("ելով", -1, 1, None),
];

static A_2: &'static [Among<Context>; 40] = &[
    Among("գար", -1, 1, None),
    Among("վոր", -1, 1, None),
    Among("ավոր", 1, 1, None),
    Among("անօց", -1, 1, None),
    Among("ոց", -1, 1, None),
    Among("ու", -1, 1, None),
    Among("ք", -1, 1, None),
    Among("արք", 6, 1, None),
    Among("չեք", 6, 1, None),
    Among("իք", 6, 1, None),
    Among("ալիք", 9, 1, None),
    Among("անիք", 9, 1, None),
    Among("վածք", 6, 1, None),
    Among("ույք", 6, 1, None),
    Among("ունք", 6, 1, None),
    Among("մունք", 14, 1, None),
    Among("ենք", 6, 1, None),
    Among("ոնք", 6, 1, None),
    Among("իչք", 6, 1, None),
    Among("որդ", -1, 1, None),
    Among("ույթ", -1, 1, None),
    Among("ցի", -1, 1, None),
    Among("ուհի", -1, 1, None),
    Among("իլ", -1, 1, None),
    Among("ուկ", -1, 1, None),
    Among("ակ", -1, 1, None),
    Among("յակ", 25, 1, None),
    Among("անակ", 25, 1, None),
    Among("իկ", -1, 1, None),
    Among("յուն", -1, 1, None),
    Among("ություն", 29, 1, None),
    Among("ան", -1, 1, None),
    Among("արան", 31, 1, None),
    Among("պան", 31, 1, None),
    Among("ստան", 31, 1, None),
    Among("եղէն", -1, 1, None),
    Among("ածո", -1, 1, None),
    Among("իչ", -1, 1, None),
    Among("ուս", -1, 1, None),
    Among("ուստ", -1, 1, None),
];

static A_3: &'static [Among<Context>; 57] = &[
    Among("եր", -1, 1, None),
    Among("ներ", 0, 1, None),
    Among("ց", -1, 1, None),
    Among("ուց", 2, 1, None),
    Among("ից", 2, 1, None),
    Among("երից", 4, 1, None),
    Among("ներից", 5, 1, None),
    Among("ցից", 4, 1, None),
    Among("վանից", 4, 1, None),
    Among("ոջից", 4, 1, None),
    Among("վից", 4, 1, None),
    Among("ոց", 2, 1, None),
    Among("սա", -1, 1, None),
    Among("վա", -1, 1, None),
    Among("ամբ", -1, 1, None),
    Among("դ", -1, 1, None),
    Among("երդ", 15, 1, None),
    Among("ներդ", 16, 1, None),
    Among("ուդ", 15, 1, None),
    Among("անդ", 15, 1, None),
    Among("ությանդ", 19, 1, None),
    Among("վանդ", 19, 1, None),
    Among("ոջդ", 15, 1, None),
    Among("ը", -1, 1, None),
    Among("երը", 23, 1, None),
    Among("ները", 24, 1, None),
    Among("անը", 23, 1, None),
    Among("ությանը", 26, 1, None),
    Among("վանը", 26, 1, None),
    Among("ոջը", 23, 1, None),
    Among("ի", -1, 1, None),
    Among("երի", 30, 1, None),
    Among("ների", 31, 1, None),
    Among("վի", 30, 1, None),
    Among("երում", -1, 1, None),
    Among("ներում", 34, 1, None),
    Among("անում", -1, 1, None),
    Among("ն", -1, 1, None),
    Among("երն", 37, 1, None),
    Among("ներն", 38, 1, None),
    Among("ուն", 37, 1, None),
    Among("ան", 37, 1, None),
    Among("ության", 41, 1, None),
    Among("վան", 41, 1, None),
    Among("ին", 37, 1, None),
    Among("երին", 44, 1, None),
    Among("ներին", 45, 1, None),
    Among("ությանն", 37, 1, None),
    Among("ոջ", -1, 1, None),
    Among("ությանս", -1, 1, None),
    Among("վանս", -1, 1, None),
    Among("ոջս", -1, 1, None),
    Among("ով", -1, 1, None),
    Among("երով", 52, 1, None),
    Among("ներով", 53, 1, None),
    Among("անով", 52, 1, None),
    Among("վով", 52, 1, None),
];

static G_v: &'static [u8; 5] = &[209, 4, 128, 0, 18];

fn r_mark_regions(env: &mut SnowballEnv, context: &mut Context) -> bool {
    context.i_pV = env.limit;
    context.i_p2 = env.limit;
    let v_1 = env.cursor;
    'lab0: loop {
        if !env.go_out_grouping(G_v, 1377, 1413) {
            break 'lab0;
        }
        env.next_char();
        context.i_pV = env.cursor;
        if !env.go_in_grouping(G_v, 1377, 1413) {
            break 'lab0;
        }
        env.next_char();
        if !env.go_out_grouping(G_v, 1377, 1413) {
            break 'lab0;
        }
        env.next_char();
        if !env.go_in_grouping(G_v, 1377, 1413) {
            break 'lab0;
        }
        env.next_char();
        context.i_p2 = env.cursor;
        break 'lab0;
    }
    env.cursor = v_1;
    return true;
}

fn r_R2(env: &mut SnowballEnv, context: &mut Context) -> bool {
    return context.i_p2 <= env.cursor;
}

fn r_adjective(env: &mut SnowballEnv, context: &mut Context) -> bool {
    env.ket = env.cursor;
    if env.find_among_b(A_0, context) == 0 {
        return false;
    }
    env.bra = env.cursor;
    env.slice_del();
    return true;
}

fn r_verb(env: &mut SnowballEnv, context: &mut Context) -> bool {
    env.ket = env.cursor;
    if env.find_among_b(A_1, context) == 0 {
        return false;
    }
    env.bra = env.cursor;
    env.slice_del();
    return true;
}

fn r_noun(env: &mut SnowballEnv, context: &mut Context) -> bool {
    env.ket = env.cursor;
    if env.find_among_b(A_2, context) == 0 {
        return false;
    }
    env.bra = env.cursor;
    env.slice_del();
    return true;
}

fn r_ending(env: &mut SnowballEnv, context: &mut Context) -> bool {
    env.ket = env.cursor;
    if env.find_among_b(A_3, context) == 0 {
        return false;
    }
    env.bra = env.cursor;
    if !r_R2(env, context) {
        return false;
    }
    env.slice_del();
    return true;
}

pub fn stem(env: &mut SnowballEnv) -> bool {
    let mut context = &mut Context { i_p2: 0, i_pV: 0 };
    r_mark_regions(env, context);
    env.limit_backward = env.cursor;
    env.cursor = env.limit;
    if env.cursor < context.i_pV {
        return false;
    }
    let v_1 = env.limit_backward;
    env.limit_backward = context.i_pV;
    let v_2 = env.limit - env.cursor;
    r_ending(env, context);
    env.cursor = env.limit - v_2;
    let v_3 = env.limit - env.cursor;
    r_verb(env, context);
    env.cursor = env.limit - v_3;
    let v_4 = env.limit - env.cursor;
    r_adjective(env, context);
    env.cursor = env.limit - v_4;
    let v_5 = env.limit - env.cursor;
    r_noun(env, context);
    env.cursor = env.limit - v_5;
    env.limit_backward = v_1;
    env.cursor = env.limit_backward;
    return true;
}
