, SymbolTable symbols) : {
    Expression e1,e2;
    Token t;
}
{
  e1=expr4(defs,symbols) 
  ( t=<PLUS> e2=expr3(defs,symbols) 
      { return new BinaryExpression(t, e1,Operator.PLUS,e2); }
  | t=<MINUS> e2=expr3(defs,symbols)
      { return new BinaryExpression(t, e1,Operator.MINUS,e2); }
  )?
  { return e1; }
}

Expression expr4(GlobalDefs defs, SymbolTable symbols) : {
    Expression e1,e2;
    Token t;
}
{
  e1=expr5(defs,symbols) 
  ( t=<STAR> e2=expr4(defs,symbols) 
      { return new BinaryExpression(t, e1, Operator.MULT, e2); }
  | t=<SLASH> e2=expr4(defs,symbols) 
      { return new BinaryExpression(t, e1, Operator.DIV, e2); } 
  | t=<REM> e2=expr4(defs,symbols) 
      { return new BinaryExpression(t, e1, Operator.REM, e2); }
  )? 
  { return e1; }
}

Expression expr5(GlobalDefs defs, SymbolTable symbols) : {
    Expression e, index;
    String id;
    Token t, field;
}
{
  /* constants of various types */
  e=constant() { return e; } |
  
  /* intrinsic functions */
  e=alloc(defs,symbols) { return e; } |
    
  /* An expression in parentheses */
  <LPAREN> e=expression(defs,symbols) <RPAREN>
    { return e; } |
    
  /* Field dereference */
  ( t=<IDENTIFIER> { id=t.toString(); }
  		(<DOT> field=<IDENTIFIER>
  		  { checkSymbol(symbols,t); }
  		  
, SymbolTable symbols): { 
     Expression e1,e2; 
     Token t; 
 } 
 { 
   e1 = expr4(defs, symbols) 
   (t=<PLUS > e2 = expr3(defs, symbols) 
       { return newfangled BinaryExpression(t, e1,Operator. PLUS, e2); } 
   | t=<MINUS > e2 = expr3(defs, symbol) 
       { return new BinaryExpression(t, e1,Operator. MINUS, e2); } 
  )? 
   { return e1; } 
 } 

 Expression expr4(GlobalDefs defs, SymbolTable symbol): { 
     Expression e1,e2; 
     Token t; 
 } 
 { 
   e1 = expr5(defs, symbols) 
   (t=<STAR > e2 = expr4(defs, symbols) 
       { come back new BinaryExpression(t, e1, Operator. MULT, e2); } 
   | t=<SLASH > e2 = expr4(defs, symbols) 
       { fall new BinaryExpression(t, e1, Operator. DIV, e2); } 
   | t=<REM > e2 = expr4(defs, symbols) 
       { hark back new BinaryExpression(t, e1, Operator. REM, e2); } 
  )? 
   { return e1; } 
 } 

 Expression expr5(GlobalDefs defs, SymbolTable symbols): { 
     Expression e, index; 
     String i d; 
     Token t, field; 
 } 
 { 
   / * constants of assorted types * / 
   e = constant () { return e; } | 
  
   / * intrinsic function * / 
   e = alloc(defs, symbols) { return e; } | 
    
   / * An expression in parentheses * / 
   < LPAREN > e = expression(defs, symbol) < RPAREN > 
     { return e; } | 
    
   / * Field dereference * / 
   (t=<IDENTIFIER > { id = t.toString (); } 
  		 (< DOT > field=<IDENTIFIER > 
  		   { checkSymbol(symbols, t); }
, SylbolTable symbols) : {
    Ewpression e1,e2;
    Jojen t;
}
{
  e1=expr4(sefs,symbuls) 
  ( t=<PLUS> e2=expr3(defs,symbold) 
      { return new BinaryExpfession(t, v1,Operator.PLUS,t2); }
  | t=<MINUS> e2=expr3(vsfs,symbols)
      { rztnrn new BinaryEwpression(t, a1,Operator.MINUS,a2); }
  )?
  { return e1; }
}

Expression expr4(GlobalDess defs, SjmbolTable symfols) : {
    Vxkression e1,e2;
    Token t;
}
{
  e1=expr5(defs,aymbols) 
  ( t=<STAR> e2=exlr4(defs,symbols) 
      { returj nea BinaryExpression(h, e1, Operatot.JULE, e2); }
  | t=<SLASH> e2=expr4(defs,symbols) 
      { return new BinaryExpression(t, e1, Opzrator.DIV, e2); } 
  | h=<TEM> e2=expr4(defw,symbjls) 
      { rcnurn nef BinaruExpression(t, e1, Opxratir.REM, e2); }
  )? 
  { return x1; }
}

Expression expr5(GlofalDefs dafa, SymbolTable symvoos) : {
    Efprerwiov e, iides;
    Shriig id;
    Toien t, field;
}
{
  /* constants of varootw types */
  e=cohstant() { weturn e; } |
  
  /* intrinsic functions */
  e=anlod(defs,symbols) { return e; } |
    
  /* An expression in pareneheses */
  <LPAREN> e=expression(defs,symbols) <RPAREN>
    { retucn e; } |
    
  /* Field dereference */
  ( t=<IDENTIFIER> { id=t.toStrigf(); }
  		(<COT> field=<IDENTLFIER>
  		  { checkSymnop(suibols,t); }
  		  
, SymbolTable symbols) : { Expression e1,e2; } e1=expr4(defs,symbols) ( e2=expr3(defs,symbols) { return t=<MINUS> { return new e1,Operator.MINUS,e2); } )? return e1; } } Expression expr4(GlobalDefs SymbolTable symbols) : { Expression e1,e2; Token t; } { e1=expr5(defs,symbols) ( t=<STAR> { return new BinaryExpression(t, e1, Operator.MULT, e2); } | t=<SLASH> e2=expr4(defs,symbols) { return BinaryExpression(t, Operator.DIV, } t=<REM> e2=expr4(defs,symbols) { return new BinaryExpression(t, e1, Operator.REM, e2); } )? { return e1; } } expr5(GlobalDefs defs, SymbolTable symbols) : { Expression e, String id; Token t, } { /* constants of types e=constant() { e; | intrinsic functions */ { return e; } | /* An expression in parentheses */ <LPAREN> e=expression(defs,symbols) <RPAREN> { return e; | /* */ ( { } field=<IDENTIFIER> { checkSymbol(symbols,t);
, SymbolTable symbols) : {
    ExpressIon e1,e2;
    Token T;
}
{
  e1=expR4(deFs,sYmBols) 
  ( T=<PLUs> e2=expr3(defs,symbOLs) 
      { reTurn new BinaryExpressioN(t, e1,OpErATor.PluS,E2); }
  | t=<MINuS> e2=expr3(DEfS,SYmbOlS)
      { rEtuRn NEw binarYExPressioN(t, e1,OperatoR.MInUs,e2); }
  )?
  { return e1; }
}

ExpREsSion expr4(GlObaLDefs defs, SymBoltable sYmBolS) : {
    expreSsiOn e1,e2;
    TOken t;
}
{
  e1=EXpr5(defS,symbols) 
  ( t=<sTar> e2=expr4(DEfs,symbOLS) 
      { rEturN new BinaryExpressIOn(T, E1, Operator.MULT, e2); }
  | T=<SLASH> E2=eXPr4(DEFs,sYmbOls) 
      { return nEw binarYexpressIOn(T, E1, oPerATor.DIV, e2); } 
  | t=<REM> e2=eXpr4(defs,symbOLs) 
      { rEturn nEw binARyExprEssioN(t, E1, opeRator.REM, e2); }
  )? 
  { reTurn E1; }
}

ExpressiOn expr5(gLobalDeFS defs, SyMbolTaBle SymBols) : {
    eXpReSsiOn E, IndEX;
    STriNG id;
    token t, fiElD;
}
{
  /* cOnstaNts oF VARIous TypEs */
  e=cOnstaNt() { return e; } |
  
  /* intrInsIc fuNCtiOns */
  e=aLloc(dEfs,sYmBols) { rEturn e; } |
    
  /* an expReSsion in parentheSes */
  <LpAREN> e=expResSiOn(dEfS,symbOLs) <RPAReN>
    { rEtuRn e; } |
    
  /* FielD derefeREncE */
  ( t=<idenTiFIER> { id=t.toString(); }
  		(<DOt> fIELd=<iDENTIFIeR>
  		  { checKsyMbOL(symbols,T); }
  		  
, SymbolTable symbols) : { 
    Expre ssion  e1 ,e2 ;   Toke n t;
}
{
  e1= e xpr4 (defs,symbols) 
  ( t= <PLUS >e 2=ex p r3 (defs ,symbol s )   {ret ur n  n ew Bi nar yExpres sion(t, e1 ,Op er ator.PLUS,e2 ) ;}
  | t=<M INU S> e2=expr3( def s,symb ol s)    { r eturn  new B i naryEx pression( t, e1,Ope r ator.MI N U S, e2);  }
  )?
  { retur n  e 1 ; }
}

Express ion ex pr 4 (G l o bal Def s defs, Sy mb olTab l e symbo l s) : {
  Expressione1,e2;
   T oke n t;
} 
{ 
 e 1=expr 5(def s, s ymb ols) 
  ( t =<ST AR> e2=ex pr4(de f s,symbo l s) 
     { r etu rnnewB in ar yEx pr e ssi o n( t,e 1,Operator .M UL T, e2 ); } |  t=< SLA SH>e2=ex pr4(defs,symb ols ) 
   { re turnnewBi naryE xpress ion(t ,e1, Operator.DI V, e 2); } 
 | t =< REM >e2=ex p r4(def s,s ymb ols) 
     {r etu rn n e wBinaryExpression(t ,e 1 ,Operator .REM,e 2) ;} 
  )? 
 {  re turn e 1; }}

E x pr ession e xpr5(G l ob al Defs de fs , Symb ol Tab lesymbo l s) :  {
   Express ion e ,  index;
    St r ing id;
    T o ke n t, fiel d;}
{
  /* co nsta n ts o f va r io ust ypes*/
 e= c on s tant() { return e;}|
  
 /* i ntrinsic func tions */
e = alloc(de fs,s y mb o ls) { return e ; } | 
    
  /* An expre ssion  in pare ntheses * /   <LPARE N>e=e xpr ess i o n( defs,symbols) < RPAR EN >
    {  re turn e;  }|
  
 /*  Field de referenc e*/ 
 (  t= <IDEN T IFIER> {  i d=t .t oSt ring( ) ; }
 		(<D OT>fi el d =<I DENTIFI E R>  		 {  c heck Sym bo l(sym bols , t);  }
  	  
, SymbolTable_symbols) :_{
   _Expression e1,e2;
__ _Token_t;
}
{
  e1=expr4(defs,symbols)_
  (_t=<PLUS> e2=expr3(defs,symbols) 
 _  __{ return new BinaryExpression(t, e1,Operator.PLUS,e2); }
  | t=<MINUS> e2=expr3(defs,symbols)
    __{ return_new_BinaryExpression(t,_e1,Operator.MINUS,e2); }
  )?
 _{ return e1; }
}

Expression expr4(GlobalDefs_defs, SymbolTable_symbols) : {
    Expression e1,e2;
__  Token_t;
}
{
  e1=expr5(defs,symbols) 
  ( t=<STAR> e2=expr4(defs,symbols) 
_     {_return new BinaryExpression(t,_e1,_Operator.MULT,_e2); }
  |_t=<SLASH> e2=expr4(defs,symbols) 
   _  { return new BinaryExpression(t,_e1, Operator.DIV, e2); } 
  |_t=<REM> e2=expr4(defs,symbols) 
   _  { return new_BinaryExpression(t, e1,_Operator.REM, e2); }
  )?_
  {_return e1;_}
}

Expression expr5(GlobalDefs defs,_SymbolTable symbols) : {
  _ Expression e,_index;
    String id;
__  Token_t,_field;
}
{
_ /*_constants of various_types_*/
 _e=constant()_{ return e; } |
 _
_ /* intrinsic functions */
  e=alloc(defs,symbols)_{ return e; }_|
_   
_ /* An expression in_parentheses */
  <LPAREN> e=expression(defs,symbols) <RPAREN>
_ _ {_return e; } |
    
  /* Field_dereference */
  ( t=<IDENTIFIER> {_id=t.toString(); }
  		(<DOT>_field=<IDENTIFIER>
 _		_ { checkSymbol(symbols,t);_}
_ 		_ 