20230322
[build-config.git] / shlib / lxr.y
blobed623784eb46465b5b6b7dfbe5bbcda6fbb27bbf
1 ##############################################################################
2 # lxr.y
3 # $$: return value. the label used in other place, should return a value for
4 # that.
5 # $N: the N'th paramter. if it is not a token generated from lexer, it must be
6 # a grammar-define in other place, and it should return a value.
7 # xxx_list: list extension. it include some grammar-define in a totoal grammer-
8 # define list. eg: multi-statement in a block.
9 # xxx_tree: tree structure defination. eg: calc/judgement expr.
10 # xxx_stmt: statement. maybe with xxx_blk.
11 # xxx_blk: block, it include a xxx_list in it. or all content in it is a txt
12 # block. totaol file is a big block. block can be associated with a
13 # statement or not.
14 ##############################################################################
16 lxr_section: [ T_WORD ] nl { $$=$2; add_section($2); }
18 lxr_def_list:
19 lxr_charset nl { $$=$1; }
20 | lxr_token nl { $$=$1; }
21 | lxr_state nl { $$=$1; }
22 | lxr_def_list nl { $$=$1; }
24 lxr_charset: T_WORD T_WORD nl { $$=add_charset(state, $1, $2);}
26 lxr_response:
27 RESP ( T_WORD ) nl { $$=new_resp(); $$.proc=$3; }
28 | RESP ( T_WORD ) nl { $$=new_resp(); $$.id = $3; }
29 | T_BLOCKTEXT nl { $$=new_resp(); $$.script = $1; }
31 lxr_opr:
32 T_AND nl { $$=$1; }
33 | nl T_AND { $$=$2; }
34 | nl T_AND nl { $$=$3; }
35 | T_AND { $$=$1; }
36 | nl T_OR nl { $$=$2; }
37 | T_OR nl { $$=$1; }
38 | nl T_OR { $$=$2; }
39 | T_OR { $$=$1; }
40 | T_XOR { $$=$1; }
41 | T_XOR nl { $$=$1; }
42 | nl T_XOR { $$=$2; }
43 | nl T_XOR nl { $$=$2; }
45 /*
46 * new expr, append current to it.
47 * new expr node alloced, append to $1,
48 * return new expr node as curr.
49 * root node is paramter $1 of lxr_token.
51 lxr_str_expr:
52 T_WORD { $$=$1; }
53 | nl T_NOT T_WORD { $$=new_str_expr(NULL, $2, $3); }
54 | T_NOT nl T_WORD { $$=new_str_expr(NULL, $1, $3); }
55 | nl T_NOT nl T_WORD { $$=new_str_expr(NULL, $2, $4); }
56 | lxr_str_expr lxr_opr T_WORD { $$=new_str_expr($1, $2, $3); }
58 lxr_token: lxr_str_expr lxr_response {
59 type=get_token_type($1);
60 if (type == RSV_WORD)
61 token = add_rsv_word(state, $1, $2);
62 else
63 token = add_lxr_def(state, $1, $2);
65 //add_token_def(token, $1, $2);
68 lxr_state_name: < T_WORD > {
69 push_state(state);
70 /* create new state "$2", append it to state */
71 state=add_new_state(state, $2);
74 lxr_state:
75 lxr_state_name { lxr_def_list } nl { state=pop_state(); }
76 | lxr_state_name { nl lxr_def_list } nl { state=pop_state(); }
77 | lxr_state_name nl { lxr_def_list } nl { state=pop_state(); }
78 | lxr_state_name nl { nl lxr_def_list } nl { state=pop_state(); }