• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1parser grammar VecMath_Parser;
2
3options {
4    output=AST;
5}
6
7tokens {
8    SHIFT;
9    VEC;
10}
11
12public
13prog
14   : stat+ ;
15
16stat
17   : ID EQUAL expr -> ^( EQUAL ID expr )
18   | PRINT^ expr
19   ;
20
21expr
22   : multExpr ( PLUS^ multExpr )*
23   ;
24
25multExpr
26   : primary ( ( MULT^ | DOT^ ) primary )*
27   ;
28
29primary
30   :   INT
31   |   ID
32   |   OPEN_SQUARE expr ( COMMA expr )* CLOSE_SQUARE -> ^( VEC expr+ )
33   |   OPEN_BRACE expr CLOSE_BRACE             -> expr
34   ;
35
36