options {
  IGNORE_CASE=true;
  MULTI=true;	// This will generate one AST class for each non-suppressed non-terminal
  VISITOR=true;	// This won't be used until the next assignment, but will be needed to make your assignment compile properly
  JJTREE_OUTPUT_DIRECTORY="AST";  // This will put all your AST classes in the AST directory
  
}

PARSER_BEGIN(HL)

public class HL {
}

PARSER_END(HL)

TOKEN_MGR_DECLS : 
{
}

SKIP : {
  " "     
  | "\t"    
  | "\n"    
  | "\r"    
  }

TOKEN : 
{
	< PRINT:"PRINT">
|	< INTEGER:	(["0"-"9"])+ >
}


// ===========================================================================
//                                 P A R S E R   
// ===========================================================================

SimpleNode start	()  #void :
{}
{  statement()  { return (SimpleNode) (jjtree.popNode()); }
| < EOF > {throw new ParseException("End of File.");}
}

void statement()  #void :
{}
{ assignment() ";" 
| print_stat() ";"
}

void assignment  () :
{}
{  Identifier() "=" expression()
}

void print_stat() #void:
{}
{	<PRINT> expression() #print
}

void expression() #void:
{}
{  (term() ("+" term())*)  #sum(>1)
}

void term() #void :
{}
{	Identifier()
| Integer()
}

void Identifier() #void :
{}
{ "a"  #a
| "b"  #b
| "c"  #c
}

void Integer () :
{Token t;}
{  t=<INTEGER>  {jjtThis.jjtSetValue(t.getValue());}
}