// $ANTLR 2.7.7 (2006-11-01): "grammar-as-semant.g" -> "SfalParser.java"$

import antlr.TokenBuffer;
import antlr.TokenStreamException;
import antlr.TokenStreamIOException;
import antlr.ANTLRException;
import antlr.LLkParser;
import antlr.Token;
import antlr.TokenStream;
import antlr.RecognitionException;
import antlr.NoViableAltException;
import antlr.MismatchedTokenException;
import antlr.SemanticException;
import antlr.ParserSharedInputState;
import antlr.collections.impl.BitSet;
import antlr.collections.AST;
import java.util.Hashtable;
import antlr.ASTFactory;
import antlr.ASTPair;
import antlr.collections.impl.ASTArray;

/***************************************************************

	SfalParser 
	
	program -> (statement)*
	
	statement ->
		if-stmt |
		assignment |
		func-call-stmt |
		loop_stmt |
		animator ;
	
	if-stmt -> 'if' '(' expression ')' block-stmt ( 'else' block-stmt )?
	
	block-stmt -> '{' (statement)* '}'
	
	assignment -> l-value ('=') expression ';'
	
	func-call-stmt -> func-call ';'
	
	func-call -> ID '(' expr-list ')'
	
	expr-list -> expression (',' expression)* | e
	
	animator -> 'animate' block-stmt
	
	loop_stmt -> 'loop' '(' expression ')' block-stmt
        
	expression -> logic-term ( '||' logic-term )*
	
	logic-term -> logic-factor ( '&&' logic-factor )*
	
	logic-factor -> ('not')? relat-expr
	
	relat-expr -> arith-expr ( ('>=' | '<=' | '>' | '<' | '==' | '!=') arith-expr )?
	
	arith-expr -> arith-term ( ('+' | '-') arith-term )*
	
	arith-term -> arith-factor ( ('*' | '/' | '%') arith-factor )*
	
	arith-factor -> ('-') r-value
	
	r-value -> l-value | func-call | constant 
	
	l-value -> ID
	
	constant -> NUMBER | HEXNUM

 ***************************************************************/
public class SfalParser extends antlr.LLkParser       implements SfalTokenTypes
 {

protected SfalParser(TokenBuffer tokenBuf, int k) {
  super(tokenBuf,k);
  tokenNames = _tokenNames;
  buildTokenTypeASTClassMap();
  astFactory = new ASTFactory(getTokenTypeToASTClassMap());
}

public SfalParser(TokenBuffer tokenBuf) {
  this(tokenBuf,2);
}

protected SfalParser(TokenStream lexer, int k) {
  super(lexer,k);
  tokenNames = _tokenNames;
  buildTokenTypeASTClassMap();
  astFactory = new ASTFactory(getTokenTypeToASTClassMap());
}

public SfalParser(TokenStream lexer) {
  this(lexer,2);
}

public SfalParser(ParserSharedInputState state) {
  super(state,2);
  tokenNames = _tokenNames;
  buildTokenTypeASTClassMap();
  astFactory = new ASTFactory(getTokenTypeToASTClassMap());
}

	public final void program() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST program_AST = null;
		
		try {      // for error handling
			{
			_loop60:
			do {
				if ((_tokenSet_0.member(LA(1)))) {
					statement();
					astFactory.addASTChild(currentAST, returnAST);
				}
				else {
					break _loop60;
				}
				
			} while (true);
			}
			program_AST = (AST)currentAST.root;
			program_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(PROG,"PROG")).add(program_AST));
			currentAST.root = program_AST;
			currentAST.child = program_AST!=null &&program_AST.getFirstChild()!=null ?
				program_AST.getFirstChild() : program_AST;
			currentAST.advanceChildToEnd();
			program_AST = (AST)currentAST.root;
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_1);
		}
		returnAST = program_AST;
	}
	
	public final void statement() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST statement_AST = null;
		
		try {      // for error handling
			switch ( LA(1)) {
			case LITERAL_if:
			{
				if_stmt();
				astFactory.addASTChild(currentAST, returnAST);
				statement_AST = (AST)currentAST.root;
				break;
			}
			case LITERAL_loop:
			{
				loop_stmt();
				astFactory.addASTChild(currentAST, returnAST);
				statement_AST = (AST)currentAST.root;
				break;
			}
			case LITERAL_animate:
			{
				animator();
				astFactory.addASTChild(currentAST, returnAST);
				statement_AST = (AST)currentAST.root;
				break;
			}
			default:
				if ((LA(1)==ID) && (LA(2)==ASGN)) {
					assignment();
					astFactory.addASTChild(currentAST, returnAST);
					statement_AST = (AST)currentAST.root;
				}
				else if ((LA(1)==ID) && (LA(2)==LPAREN)) {
					func_call_stmt();
					astFactory.addASTChild(currentAST, returnAST);
					statement_AST = (AST)currentAST.root;
				}
			else {
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_2);
		}
		returnAST = statement_AST;
	}
	
	public final void if_stmt() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST if_stmt_AST = null;
		
		try {      // for error handling
			AST tmp26_AST = null;
			tmp26_AST = astFactory.create(LT(1));
			astFactory.makeASTRoot(currentAST, tmp26_AST);
			match(LITERAL_if);
			match(LPAREN);
			expression();
			astFactory.addASTChild(currentAST, returnAST);
			match(RPAREN);
			{
			switch ( LA(1)) {
			case LBRACE:
			{
				block_stmt();
				astFactory.addASTChild(currentAST, returnAST);
				break;
			}
			case ID:
			case LITERAL_if:
			case LITERAL_animate:
			case LITERAL_loop:
			{
				statement();
				astFactory.addASTChild(currentAST, returnAST);
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
			}
			{
			if ((LA(1)==LITERAL_else) && (_tokenSet_3.member(LA(2)))) {
				match(LITERAL_else);
				{
				switch ( LA(1)) {
				case LBRACE:
				{
					block_stmt();
					astFactory.addASTChild(currentAST, returnAST);
					break;
				}
				case ID:
				case LITERAL_if:
				case LITERAL_animate:
				case LITERAL_loop:
				{
					statement();
					astFactory.addASTChild(currentAST, returnAST);
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				}
				}
			}
			else if ((_tokenSet_2.member(LA(1))) && (_tokenSet_4.member(LA(2)))) {
			}
			else {
				throw new NoViableAltException(LT(1), getFilename());
			}
			
			}
			if_stmt_AST = (AST)currentAST.root;
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_2);
		}
		returnAST = if_stmt_AST;
	}
	
	public final void assignment() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST assignment_AST = null;
		
		try {      // for error handling
			l_value();
			astFactory.addASTChild(currentAST, returnAST);
			{
			AST tmp30_AST = null;
			tmp30_AST = astFactory.create(LT(1));
			astFactory.makeASTRoot(currentAST, tmp30_AST);
			match(ASGN);
			}
			expression();
			astFactory.addASTChild(currentAST, returnAST);
			match(SEMI);
			assignment_AST = (AST)currentAST.root;
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_2);
		}
		returnAST = assignment_AST;
	}
	
	public final void func_call_stmt() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST func_call_stmt_AST = null;
		
		try {      // for error handling
			func_call();
			astFactory.addASTChild(currentAST, returnAST);
			match(SEMI);
			func_call_stmt_AST = (AST)currentAST.root;
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_2);
		}
		returnAST = func_call_stmt_AST;
	}
	
	public final void loop_stmt() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST loop_stmt_AST = null;
		
		try {      // for error handling
			AST tmp33_AST = null;
			tmp33_AST = astFactory.create(LT(1));
			astFactory.makeASTRoot(currentAST, tmp33_AST);
			match(LITERAL_loop);
			match(LPAREN);
			expr_list();
			astFactory.addASTChild(currentAST, returnAST);
			match(RPAREN);
			block_stmt();
			astFactory.addASTChild(currentAST, returnAST);
			loop_stmt_AST = (AST)currentAST.root;
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_2);
		}
		returnAST = loop_stmt_AST;
	}
	
	public final void animator() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST animator_AST = null;
		
		try {      // for error handling
			AST tmp36_AST = null;
			tmp36_AST = astFactory.create(LT(1));
			astFactory.makeASTRoot(currentAST, tmp36_AST);
			match(LITERAL_animate);
			block_stmt();
			astFactory.addASTChild(currentAST, returnAST);
			animator_AST = (AST)currentAST.root;
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_2);
		}
		returnAST = animator_AST;
	}
	
/***************************************************************

	Expressions

 ***************************************************************/
	public final void expression() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST expression_AST = null;
		
		try {      // for error handling
			logic_term();
			astFactory.addASTChild(currentAST, returnAST);
			{
			_loop80:
			do {
				if ((LA(1)==OR)) {
					AST tmp37_AST = null;
					tmp37_AST = astFactory.create(LT(1));
					astFactory.makeASTRoot(currentAST, tmp37_AST);
					match(OR);
					logic_term();
					astFactory.addASTChild(currentAST, returnAST);
				}
				else {
					break _loop80;
				}
				
			} while (true);
			}
			expression_AST = (AST)currentAST.root;
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_5);
		}
		returnAST = expression_AST;
	}
	
	public final void block_stmt() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST block_stmt_AST = null;
		
		try {      // for error handling
			match(LBRACE);
			{
			_loop68:
			do {
				if ((_tokenSet_0.member(LA(1)))) {
					statement();
					astFactory.addASTChild(currentAST, returnAST);
				}
				else {
					break _loop68;
				}
				
			} while (true);
			}
			match(RBRACE);
			block_stmt_AST = (AST)currentAST.root;
			block_stmt_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(BLOCK_STMT,"BLOCK_STMT")).add(block_stmt_AST));
			currentAST.root = block_stmt_AST;
			currentAST.child = block_stmt_AST!=null &&block_stmt_AST.getFirstChild()!=null ?
				block_stmt_AST.getFirstChild() : block_stmt_AST;
			currentAST.advanceChildToEnd();
			block_stmt_AST = (AST)currentAST.root;
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_2);
		}
		returnAST = block_stmt_AST;
	}
	
	public final void l_value() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST l_value_AST = null;
		
		try {      // for error handling
			AST tmp40_AST = null;
			tmp40_AST = astFactory.create(LT(1));
			astFactory.addASTChild(currentAST, tmp40_AST);
			match(ID);
			l_value_AST = (AST)currentAST.root;
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_6);
		}
		returnAST = l_value_AST;
	}
	
	public final void func_call() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST func_call_AST = null;
		
		try {      // for error handling
			AST tmp41_AST = null;
			tmp41_AST = astFactory.create(LT(1));
			astFactory.addASTChild(currentAST, tmp41_AST);
			match(ID);
			match(LPAREN);
			expr_list();
			astFactory.addASTChild(currentAST, returnAST);
			match(RPAREN);
			func_call_AST = (AST)currentAST.root;
			func_call_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(FUNC_CALL,"FUNC_CALL")).add(func_call_AST));
			currentAST.root = func_call_AST;
			currentAST.child = func_call_AST!=null &&func_call_AST.getFirstChild()!=null ?
				func_call_AST.getFirstChild() : func_call_AST;
			currentAST.advanceChildToEnd();
			func_call_AST = (AST)currentAST.root;
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_7);
		}
		returnAST = func_call_AST;
	}
	
	public final void expr_list() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST expr_list_AST = null;
		
		try {      // for error handling
			switch ( LA(1)) {
			case HEXNUM:
			case ID:
			case NUMBER:
			case LPAREN:
			case PLUS:
			case MINUS:
			case STRING:
			case LITERAL_not:
			case LITERAL_true:
			case LITERAL_false:
			{
				expression();
				astFactory.addASTChild(currentAST, returnAST);
				{
				_loop75:
				do {
					if ((LA(1)==COMMA)) {
						match(COMMA);
						expression();
						astFactory.addASTChild(currentAST, returnAST);
					}
					else {
						break _loop75;
					}
					
				} while (true);
				}
				expr_list_AST = (AST)currentAST.root;
				expr_list_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(EXPR_LIST,"EXPR_LIST")).add(expr_list_AST));
				currentAST.root = expr_list_AST;
				currentAST.child = expr_list_AST!=null &&expr_list_AST.getFirstChild()!=null ?
					expr_list_AST.getFirstChild() : expr_list_AST;
				currentAST.advanceChildToEnd();
				expr_list_AST = (AST)currentAST.root;
				break;
			}
			case RPAREN:
			{
				expr_list_AST = (AST)currentAST.root;
				expr_list_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(EXPR_LIST,"EXPR_LIST")).add(expr_list_AST));
				currentAST.root = expr_list_AST;
				currentAST.child = expr_list_AST!=null &&expr_list_AST.getFirstChild()!=null ?
					expr_list_AST.getFirstChild() : expr_list_AST;
				currentAST.advanceChildToEnd();
				expr_list_AST = (AST)currentAST.root;
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_8);
		}
		returnAST = expr_list_AST;
	}
	
	public final void logic_term() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST logic_term_AST = null;
		
		try {      // for error handling
			logic_factor();
			astFactory.addASTChild(currentAST, returnAST);
			{
			_loop83:
			do {
				if ((LA(1)==AND)) {
					AST tmp45_AST = null;
					tmp45_AST = astFactory.create(LT(1));
					astFactory.makeASTRoot(currentAST, tmp45_AST);
					match(AND);
					logic_factor();
					astFactory.addASTChild(currentAST, returnAST);
				}
				else {
					break _loop83;
				}
				
			} while (true);
			}
			logic_term_AST = (AST)currentAST.root;
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_9);
		}
		returnAST = logic_term_AST;
	}
	
	public final void logic_factor() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST logic_factor_AST = null;
		
		try {      // for error handling
			{
			switch ( LA(1)) {
			case LITERAL_not:
			{
				AST tmp46_AST = null;
				tmp46_AST = astFactory.create(LT(1));
				astFactory.makeASTRoot(currentAST, tmp46_AST);
				match(LITERAL_not);
				break;
			}
			case HEXNUM:
			case ID:
			case NUMBER:
			case LPAREN:
			case PLUS:
			case MINUS:
			case STRING:
			case LITERAL_true:
			case LITERAL_false:
			{
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
			}
			relat_expr();
			astFactory.addASTChild(currentAST, returnAST);
			logic_factor_AST = (AST)currentAST.root;
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_10);
		}
		returnAST = logic_factor_AST;
	}
	
	public final void relat_expr() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST relat_expr_AST = null;
		
		try {      // for error handling
			arith_expr();
			astFactory.addASTChild(currentAST, returnAST);
			{
			switch ( LA(1)) {
			case GE:
			case LE:
			case GT:
			case LT:
			case EQ:
			case NEQ:
			{
				{
				switch ( LA(1)) {
				case GE:
				{
					AST tmp47_AST = null;
					tmp47_AST = astFactory.create(LT(1));
					astFactory.makeASTRoot(currentAST, tmp47_AST);
					match(GE);
					break;
				}
				case LE:
				{
					AST tmp48_AST = null;
					tmp48_AST = astFactory.create(LT(1));
					astFactory.makeASTRoot(currentAST, tmp48_AST);
					match(LE);
					break;
				}
				case GT:
				{
					AST tmp49_AST = null;
					tmp49_AST = astFactory.create(LT(1));
					astFactory.makeASTRoot(currentAST, tmp49_AST);
					match(GT);
					break;
				}
				case LT:
				{
					AST tmp50_AST = null;
					tmp50_AST = astFactory.create(LT(1));
					astFactory.makeASTRoot(currentAST, tmp50_AST);
					match(LT);
					break;
				}
				case EQ:
				{
					AST tmp51_AST = null;
					tmp51_AST = astFactory.create(LT(1));
					astFactory.makeASTRoot(currentAST, tmp51_AST);
					match(EQ);
					break;
				}
				case NEQ:
				{
					AST tmp52_AST = null;
					tmp52_AST = astFactory.create(LT(1));
					astFactory.makeASTRoot(currentAST, tmp52_AST);
					match(NEQ);
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				}
				}
				arith_expr();
				astFactory.addASTChild(currentAST, returnAST);
				break;
			}
			case RPAREN:
			case SEMI:
			case COMMA:
			case OR:
			case AND:
			{
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
			}
			relat_expr_AST = (AST)currentAST.root;
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_10);
		}
		returnAST = relat_expr_AST;
	}
	
	public final void arith_expr() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST arith_expr_AST = null;
		
		try {      // for error handling
			arith_term();
			astFactory.addASTChild(currentAST, returnAST);
			{
			_loop92:
			do {
				if ((LA(1)==PLUS||LA(1)==MINUS)) {
					{
					switch ( LA(1)) {
					case PLUS:
					{
						AST tmp53_AST = null;
						tmp53_AST = astFactory.create(LT(1));
						astFactory.makeASTRoot(currentAST, tmp53_AST);
						match(PLUS);
						break;
					}
					case MINUS:
					{
						AST tmp54_AST = null;
						tmp54_AST = astFactory.create(LT(1));
						astFactory.makeASTRoot(currentAST, tmp54_AST);
						match(MINUS);
						break;
					}
					default:
					{
						throw new NoViableAltException(LT(1), getFilename());
					}
					}
					}
					arith_term();
					astFactory.addASTChild(currentAST, returnAST);
				}
				else {
					break _loop92;
				}
				
			} while (true);
			}
			arith_expr_AST = (AST)currentAST.root;
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_11);
		}
		returnAST = arith_expr_AST;
	}
	
	public final void arith_term() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST arith_term_AST = null;
		
		try {      // for error handling
			arith_factor();
			astFactory.addASTChild(currentAST, returnAST);
			{
			_loop96:
			do {
				if ((_tokenSet_12.member(LA(1)))) {
					{
					switch ( LA(1)) {
					case MULT:
					{
						AST tmp55_AST = null;
						tmp55_AST = astFactory.create(LT(1));
						astFactory.makeASTRoot(currentAST, tmp55_AST);
						match(MULT);
						break;
					}
					case LDV:
					{
						AST tmp56_AST = null;
						tmp56_AST = astFactory.create(LT(1));
						astFactory.makeASTRoot(currentAST, tmp56_AST);
						match(LDV);
						break;
					}
					case MOD:
					{
						AST tmp57_AST = null;
						tmp57_AST = astFactory.create(LT(1));
						astFactory.makeASTRoot(currentAST, tmp57_AST);
						match(MOD);
						break;
					}
					case DIV:
					{
						AST tmp58_AST = null;
						tmp58_AST = astFactory.create(LT(1));
						astFactory.makeASTRoot(currentAST, tmp58_AST);
						match(DIV);
						break;
					}
					default:
					{
						throw new NoViableAltException(LT(1), getFilename());
					}
					}
					}
					arith_factor();
					astFactory.addASTChild(currentAST, returnAST);
				}
				else {
					break _loop96;
				}
				
			} while (true);
			}
			arith_term_AST = (AST)currentAST.root;
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_13);
		}
		returnAST = arith_term_AST;
	}
	
	public final void arith_factor() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST arith_factor_AST = null;
		
		try {      // for error handling
			switch ( LA(1)) {
			case PLUS:
			{
				match(PLUS);
				r_value();
				astFactory.addASTChild(currentAST, returnAST);
				arith_factor_AST = (AST)currentAST.root;
				arith_factor_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(UPLUS,"UPLUS")).add(arith_factor_AST));
				currentAST.root = arith_factor_AST;
				currentAST.child = arith_factor_AST!=null &&arith_factor_AST.getFirstChild()!=null ?
					arith_factor_AST.getFirstChild() : arith_factor_AST;
				currentAST.advanceChildToEnd();
				arith_factor_AST = (AST)currentAST.root;
				break;
			}
			case MINUS:
			{
				match(MINUS);
				r_value();
				astFactory.addASTChild(currentAST, returnAST);
				arith_factor_AST = (AST)currentAST.root;
				arith_factor_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(UMINUS,"UMINUS")).add(arith_factor_AST));
				currentAST.root = arith_factor_AST;
				currentAST.child = arith_factor_AST!=null &&arith_factor_AST.getFirstChild()!=null ?
					arith_factor_AST.getFirstChild() : arith_factor_AST;
				currentAST.advanceChildToEnd();
				arith_factor_AST = (AST)currentAST.root;
				break;
			}
			case HEXNUM:
			case ID:
			case NUMBER:
			case LPAREN:
			case STRING:
			case LITERAL_true:
			case LITERAL_false:
			{
				r_value();
				astFactory.addASTChild(currentAST, returnAST);
				arith_factor_AST = (AST)currentAST.root;
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_7);
		}
		returnAST = arith_factor_AST;
	}
	
	public final void r_value() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST r_value_AST = null;
		
		try {      // for error handling
			switch ( LA(1)) {
			case NUMBER:
			{
				AST tmp61_AST = null;
				tmp61_AST = astFactory.create(LT(1));
				astFactory.addASTChild(currentAST, tmp61_AST);
				match(NUMBER);
				r_value_AST = (AST)currentAST.root;
				break;
			}
			case STRING:
			{
				AST tmp62_AST = null;
				tmp62_AST = astFactory.create(LT(1));
				astFactory.addASTChild(currentAST, tmp62_AST);
				match(STRING);
				r_value_AST = (AST)currentAST.root;
				break;
			}
			case LITERAL_true:
			{
				AST tmp63_AST = null;
				tmp63_AST = astFactory.create(LT(1));
				astFactory.addASTChild(currentAST, tmp63_AST);
				match(LITERAL_true);
				r_value_AST = (AST)currentAST.root;
				break;
			}
			case LITERAL_false:
			{
				AST tmp64_AST = null;
				tmp64_AST = astFactory.create(LT(1));
				astFactory.addASTChild(currentAST, tmp64_AST);
				match(LITERAL_false);
				r_value_AST = (AST)currentAST.root;
				break;
			}
			case HEXNUM:
			{
				AST tmp65_AST = null;
				tmp65_AST = astFactory.create(LT(1));
				astFactory.addASTChild(currentAST, tmp65_AST);
				match(HEXNUM);
				r_value_AST = (AST)currentAST.root;
				break;
			}
			case LPAREN:
			{
				match(LPAREN);
				expression();
				astFactory.addASTChild(currentAST, returnAST);
				match(RPAREN);
				r_value_AST = (AST)currentAST.root;
				break;
			}
			default:
				if ((LA(1)==ID) && (_tokenSet_7.member(LA(2)))) {
					l_value();
					astFactory.addASTChild(currentAST, returnAST);
					r_value_AST = (AST)currentAST.root;
				}
				else if ((LA(1)==ID) && (LA(2)==LPAREN)) {
					func_call();
					astFactory.addASTChild(currentAST, returnAST);
					r_value_AST = (AST)currentAST.root;
				}
			else {
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
		}
		catch (RecognitionException ex) {
			reportError(ex);
			recover(ex,_tokenSet_7);
		}
		returnAST = r_value_AST;
	}
	
	
	public static final String[] _tokenNames = {
		"<0>",
		"EOF",
		"<2>",
		"NULL_TREE_LOOKAHEAD",
		"ALPHA",
		"DIGIT",
		"HEX",
		"HEXNUM",
		"ID",
		"NUMBER",
		"WS",
		"NL",
		"COMMENT",
		"LPAREN",
		"RPAREN",
		"LBRACE",
		"RBRACE",
		"MULT",
		"PLUS",
		"MINUS",
		"DIV",
		"MOD",
		"SEMI",
		"ASGN",
		"COMMA",
		"GE",
		"LE",
		"GT",
		"LT",
		"EQ",
		"NEQ",
		"OR",
		"AND",
		"STRING",
		"PROG",
		"STATEMENT",
		"BLOCK_STMT",
		"FUNC_CALL",
		"EXPR_LIST",
		"UPLUS",
		"UMINUS",
		"\"if\"",
		"\"else\"",
		"\"animate\"",
		"\"loop\"",
		"\"not\"",
		"LDV",
		"\"true\"",
		"\"false\""
	};
	
	protected void buildTokenTypeASTClassMap() {
		tokenTypeToASTClassMap=null;
	};
	
	private static final long[] mk_tokenSet_0() {
		long[] data = { 28587302322432L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
	private static final long[] mk_tokenSet_1() {
		long[] data = { 2L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
	private static final long[] mk_tokenSet_2() {
		long[] data = { 32985348899074L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
	private static final long[] mk_tokenSet_3() {
		long[] data = { 28587302355200L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
	private static final long[] mk_tokenSet_4() {
		long[] data = { 32985357328642L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_4 = new BitSet(mk_tokenSet_4());
	private static final long[] mk_tokenSet_5() {
		long[] data = { 20987904L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_5 = new BitSet(mk_tokenSet_5());
	private static final long[] mk_tokenSet_6() {
		long[] data = { 70377333997568L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_6 = new BitSet(mk_tokenSet_6());
	private static final long[] mk_tokenSet_7() {
		long[] data = { 70377325608960L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_7 = new BitSet(mk_tokenSet_7());
	private static final long[] mk_tokenSet_8() {
		long[] data = { 16384L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_8 = new BitSet(mk_tokenSet_8());
	private static final long[] mk_tokenSet_9() {
		long[] data = { 2168471552L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_9 = new BitSet(mk_tokenSet_9());
	private static final long[] mk_tokenSet_10() {
		long[] data = { 6463438848L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_10 = new BitSet(mk_tokenSet_10());
	private static final long[] mk_tokenSet_11() {
		long[] data = { 8577368064L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_11 = new BitSet(mk_tokenSet_11());
	private static final long[] mk_tokenSet_12() {
		long[] data = { 70368747454464L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_12 = new BitSet(mk_tokenSet_12());
	private static final long[] mk_tokenSet_13() {
		long[] data = { 8578154496L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_13 = new BitSet(mk_tokenSet_13());
	
	}
