summaryrefslogtreecommitdiffstats
path: root/kexi/doc/dev/kexisql_grammar_notes.txt
blob: 9f80ed693c3b189672a584e0b4d77c8067d9eb2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* 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); }
        ;