You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.6 KiB
63 lines
1.6 KiB
/* Jaroslaw Staniek:
|
|
TAKEN FROM his compiler's parser
|
|
AS EXAMPLE FOR LUCIJAN'S KEXISQL PARSER */
|
|
|
|
|
|
|
|
exp: exp3 { $$->prn(); }
|
|
| exp OR exp3 { $$ = new NOpLog($1,OR,$3); $$->prn(); }
|
|
;
|
|
exp3: exp3n {/*default*/}
|
|
| exp3 AND exp3n { $$ = new NOpLog($1,AND,$3); }
|
|
;
|
|
exp3n: exp2 {/*default*/}
|
|
| NOT exp3n { $$ = new NOp1arg(NOT,$2); }
|
|
;
|
|
exp2: exp1 {/*default*/}
|
|
| exp1 op_rel exp1 { $$ = new NOpRel($1,$2,$3); }
|
|
;
|
|
exp1: exp0 {/*default*/}
|
|
| exp1 op_ar1 exp0 { $$ = new NOpAr($1,$2,$3); }
|
|
;
|
|
exp0: exp_poj {/*default*/}
|
|
| exp0 op_ar0 exp_poj { $$ = new NOpAr($1,$2,$3); }
|
|
;
|
|
|
|
|
|
|
|
|
|
* prior.2 - relational oper. */
|
|
op_rel: '=' { $$='='; }
|
|
| '<' { $$='<'; }
|
|
| '>' { $$='>'; }
|
|
| "<=" { $$=REL_LESS_EQ; }
|
|
| ">=" { $$=REL_GREAT_EQ; }
|
|
| "<>" { $$=REL_NOT_EQ; }
|
|
;
|
|
/* prior.1 - arytmetic oper. +,- */
|
|
op_ar1: '+' { $$='+'; }
|
|
| '-' { $$='-'; }
|
|
;
|
|
/* prior.0 - arytmetic oper. *,/ */
|
|
op_ar0: '*' { $$='*'; }
|
|
| '/' { $$='/'; }
|
|
;
|
|
exp_single: single {/*default*/}
|
|
| '(' exp ')' { /*$$=new NOp1arg(0, $2);*/ $$=$2; }
|
|
| '-' exp_single %prec OP_MINUS { $$=new NOp1arg('-', $2); }
|
|
| '+' exp_single %prec OP_PLUS { $$=new NOp1arg('+', $2); }
|
|
;
|
|
single: const {/*default*/}
|
|
| variable {/*default*/ }
|
|
| function_call {/*default*/}
|
|
|
|
const: CONST_BOOL { $$ = new NConstBool(yylval.bval); }
|
|
| CONST_INT { $$ = new NConstInt(yylval.ival); }
|
|
| CONST_STR { $$ = new NConstStr(yylval.sval); }
|
|
;
|
|
|
|
|
|
|
|
|
|
|