initial
[prop.git] / app / setl-pe / setl-syntax.pcc
blob671fdeb4d1588dcfb9fe829e8b8dfa6f50b974dd
1 #include <stdlib.h>
2 #include "setl-lexeme.ph"
3 #include "setl-syntax.ph"
4 #include "setl-ast.ph"
6 syntax SETLSyntax
7 {  
8    left: 2 '[' '{' '(' ;
9    left: 3 '*' '/' "mod" "div";
10    left: 4 '+' '-';
11    left: 5 ":=" "with" "less";
13    exp(Exp):    literal                 { $$ = LITexp($1); }
14         |       '(' exp ')'             { $$ = $2; }
15         |       exp '+' exp
16         |       exp '-' exp
17         |       exp '*' exp
18         |       exp '/' exp
19         |       exp "mod" exp
20         |       exp "div" exp
21         |       '-' exp
22         |       '{' exp_list '}'
23         |       '[' exp_list ']'
24         |       exp '(' exp ')'
25         |       exp '{' exp '}'
26         |       exp '[' exp ']'
27         |       exp "with" exp
28         |       exp "less" exp
29         |       "arb" exp
30         |       exp ":=" exp
31         |       exp "with" ":=" exp
32         |       exp "less" ":=" exp
33         ;
35    exp_list(Exps):                      { $$ = #[]; }
36         |       exp_list_1              { $$ = $1; }
37         ;
39    exp_list_1(Exps):    exp             { $$ = #[ $1 ]; }
40         |       exp ',' exp_list_1      { $$ = #[ $1 ... $3 ]; }
41         ;
43    literal Literal:
44                 integer                 { $$ = INTlit($1); } 
45         |       real                    { $$ = REALlit($1); }
46         |       character               { $$ = CHARlit($1); }
47         |       string                  { $$ = STRINGlit($1); }
48         ;
50    integer(int):        INTEGER         { $$ = atol(lexer_buf.text()); };
51    real(double):        REAL;
52    character(char):     CHARACTER;
53    string(const char*): STRING;