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