// $ANTLR 3.0.1 /Users/take/Documents/workspace/Gem4c/src/Gem4c.g 2009-07-18 18:46:50

import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

public class Gem4cParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "ID", "CONST", "WS", "'int'", "','", "';'", "'{'", "'}'", "'='", "'led'", "'('", "')'", "'out'", "'cmpl'", "'shift'", "'shts'", "'sound'", "'timer'", "'$A'", "'+'", "'key'", "'-'", "'if'", "'while'", "'$Z'", "'>'", "'=='"
    };
    public static final int CONST=5;
    public static final int WS=6;
    public static final int EOF=-1;
    public static final int ID=4;

        public Gem4cParser(TokenStream input) {
            super(input);
        }
        

    public String[] getTokenNames() { return tokenNames; }
    public String getGrammarFileName() { return "/Users/take/Documents/workspace/Gem4c/src/Gem4c.g"; }



    // $ANTLR start prog
    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:3:1: prog : ( declaration )* ( statement )+ ;
    public final void prog() throws RecognitionException {
        try {
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:7:2: ( ( declaration )* ( statement )+ )
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:7:4: ( declaration )* ( statement )+
            {
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:7:4: ( declaration )*
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( (LA1_0==7) ) {
                    alt1=1;
                }


                switch (alt1) {
            	case 1 :
            	    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:7:4: declaration
            	    {
            	    pushFollow(FOLLOW_declaration_in_prog18);
            	    declaration();
            	    _fsp--;


            	    }
            	    break;

            	default :
            	    break loop1;
                }
            } while (true);

            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:8:4: ( statement )+
            int cnt2=0;
            loop2:
            do {
                int alt2=2;
                int LA2_0 = input.LA(1);

                if ( ((LA2_0>=ID && LA2_0<=CONST)||(LA2_0>=9 && LA2_0<=10)||LA2_0==13||(LA2_0>=16 && LA2_0<=22)||LA2_0==24||(LA2_0>=26 && LA2_0<=27)) ) {
                    alt2=1;
                }


                switch (alt2) {
            	case 1 :
            	    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:9:4: statement
            	    {
            	    pushFollow(FOLLOW_statement_in_prog32);
            	    statement();
            	    _fsp--;


            	    }
            	    break;

            	default :
            	    if ( cnt2 >= 1 ) break loop2;
                        EarlyExitException eee =
                            new EarlyExitException(2, input);
                        throw eee;
                }
                cnt2++;
            } while (true);


            	  		String label = Main.genLabel();
            	  		System.out.println("CAL ENDS");	  
            	  		System.out.println(label + ": JUMP\t" + label);		
            	  	

            }


            			System.exit(0);
            		
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end prog


    // $ANTLR start declaration
    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:18:1: declaration : 'int' (i= ID ) ( ',' (i= ID ) )* ';' ;
    public final void declaration() throws RecognitionException {
        Token i=null;

        try {
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:19:2: ( 'int' (i= ID ) ( ',' (i= ID ) )* ';' )
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:19:4: 'int' (i= ID ) ( ',' (i= ID ) )* ';'
            {
            match(input,7,FOLLOW_7_in_declaration57); 
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:19:10: (i= ID )
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:19:11: i= ID
            {
            i=(Token)input.LT(1);
            match(input,ID,FOLLOW_ID_in_declaration62); 

            }


            			Main.addVar(i.getText());
            		
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:23:2: ( ',' (i= ID ) )*
            loop3:
            do {
                int alt3=2;
                int LA3_0 = input.LA(1);

                if ( (LA3_0==8) ) {
                    alt3=1;
                }


                switch (alt3) {
            	case 1 :
            	    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:23:4: ',' (i= ID )
            	    {
            	    match(input,8,FOLLOW_8_in_declaration72); 
            	    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:23:8: (i= ID )
            	    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:23:9: i= ID
            	    {
            	    i=(Token)input.LT(1);
            	    match(input,ID,FOLLOW_ID_in_declaration77); 

            	    }


            	    			Main.addVar(i.getText());
            	    		

            	    }
            	    break;

            	default :
            	    break loop3;
                }
            } while (true);

            match(input,9,FOLLOW_9_in_declaration88); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end declaration


    // $ANTLR start compoundStatement
    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:30:1: compoundStatement : '{' ( statement )+ '}' ;
    public final void compoundStatement() throws RecognitionException {
        try {
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:31:2: ( '{' ( statement )+ '}' )
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:31:4: '{' ( statement )+ '}'
            {
            match(input,10,FOLLOW_10_in_compoundStatement99); 
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:31:8: ( statement )+
            int cnt4=0;
            loop4:
            do {
                int alt4=2;
                int LA4_0 = input.LA(1);

                if ( ((LA4_0>=ID && LA4_0<=CONST)||(LA4_0>=9 && LA4_0<=10)||LA4_0==13||(LA4_0>=16 && LA4_0<=22)||LA4_0==24||(LA4_0>=26 && LA4_0<=27)) ) {
                    alt4=1;
                }


                switch (alt4) {
            	case 1 :
            	    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:31:8: statement
            	    {
            	    pushFollow(FOLLOW_statement_in_compoundStatement101);
            	    statement();
            	    _fsp--;


            	    }
            	    break;

            	default :
            	    if ( cnt4 >= 1 ) break loop4;
                        EarlyExitException eee =
                            new EarlyExitException(4, input);
                        throw eee;
                }
                cnt4++;
            } while (true);

            match(input,11,FOLLOW_11_in_compoundStatement104); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end compoundStatement


    // $ANTLR start statement
    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:34:1: statement : ( expr ';' | (i= ID ) '=' expr ';' | ';' | compoundStatement | ifStm | whileStm | 'led' '(' expr ')' ';' | 'out' '(' expr ')' ';' | 'cmpl' '(' expr ')' ';' | 'shift' '(' expr ')' ';' | 'shts' '(' ')' ';' | 'sound' '(' expr ')' ';' | 'timer' '(' expr ')' ';' );
    public final void statement() throws RecognitionException {
        Token i=null;

        try {
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:35:2: ( expr ';' | (i= ID ) '=' expr ';' | ';' | compoundStatement | ifStm | whileStm | 'led' '(' expr ')' ';' | 'out' '(' expr ')' ';' | 'cmpl' '(' expr ')' ';' | 'shift' '(' expr ')' ';' | 'shts' '(' ')' ';' | 'sound' '(' expr ')' ';' | 'timer' '(' expr ')' ';' )
            int alt5=13;
            switch ( input.LA(1) ) {
            case CONST:
            case 22:
            case 24:
                {
                alt5=1;
                }
                break;
            case ID:
                {
                int LA5_2 = input.LA(2);

                if ( (LA5_2==9||LA5_2==23||LA5_2==25) ) {
                    alt5=1;
                }
                else if ( (LA5_2==12) ) {
                    alt5=2;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("34:1: statement : ( expr ';' | (i= ID ) '=' expr ';' | ';' | compoundStatement | ifStm | whileStm | 'led' '(' expr ')' ';' | 'out' '(' expr ')' ';' | 'cmpl' '(' expr ')' ';' | 'shift' '(' expr ')' ';' | 'shts' '(' ')' ';' | 'sound' '(' expr ')' ';' | 'timer' '(' expr ')' ';' );", 5, 2, input);

                    throw nvae;
                }
                }
                break;
            case 9:
                {
                alt5=3;
                }
                break;
            case 10:
                {
                alt5=4;
                }
                break;
            case 26:
                {
                alt5=5;
                }
                break;
            case 27:
                {
                alt5=6;
                }
                break;
            case 13:
                {
                alt5=7;
                }
                break;
            case 16:
                {
                alt5=8;
                }
                break;
            case 17:
                {
                alt5=9;
                }
                break;
            case 18:
                {
                alt5=10;
                }
                break;
            case 19:
                {
                alt5=11;
                }
                break;
            case 20:
                {
                alt5=12;
                }
                break;
            case 21:
                {
                alt5=13;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("34:1: statement : ( expr ';' | (i= ID ) '=' expr ';' | ';' | compoundStatement | ifStm | whileStm | 'led' '(' expr ')' ';' | 'out' '(' expr ')' ';' | 'cmpl' '(' expr ')' ';' | 'shift' '(' expr ')' ';' | 'shts' '(' ')' ';' | 'sound' '(' expr ')' ';' | 'timer' '(' expr ')' ';' );", 5, 0, input);

                throw nvae;
            }

            switch (alt5) {
                case 1 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:35:4: expr ';'
                    {
                    pushFollow(FOLLOW_expr_in_statement117);
                    expr();
                    _fsp--;

                    match(input,9,FOLLOW_9_in_statement119); 

                    }
                    break;
                case 2 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:36:4: (i= ID ) '=' expr ';'
                    {
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:36:4: (i= ID )
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:36:5: i= ID
                    {
                    i=(Token)input.LT(1);
                    match(input,ID,FOLLOW_ID_in_statement128); 

                    }

                    match(input,12,FOLLOW_12_in_statement131); 
                    pushFollow(FOLLOW_expr_in_statement133);
                    expr();
                    _fsp--;

                    match(input,9,FOLLOW_9_in_statement135); 

                    			System.out.println("TIY\t" + Main.varHexIndex(i.getText()));
                    			System.out.println("AM");
                    		

                    }
                    break;
                case 3 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:41:4: ';'
                    {
                    match(input,9,FOLLOW_9_in_statement144); 

                    }
                    break;
                case 4 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:42:4: compoundStatement
                    {
                    pushFollow(FOLLOW_compoundStatement_in_statement149);
                    compoundStatement();
                    _fsp--;


                    }
                    break;
                case 5 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:43:4: ifStm
                    {
                    pushFollow(FOLLOW_ifStm_in_statement154);
                    ifStm();
                    _fsp--;


                    }
                    break;
                case 6 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:44:4: whileStm
                    {
                    pushFollow(FOLLOW_whileStm_in_statement159);
                    whileStm();
                    _fsp--;


                    }
                    break;
                case 7 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:45:4: 'led' '(' expr ')' ';'
                    {
                    match(input,13,FOLLOW_13_in_statement164); 
                    match(input,14,FOLLOW_14_in_statement166); 
                    pushFollow(FOLLOW_expr_in_statement168);
                    expr();
                    _fsp--;

                    match(input,15,FOLLOW_15_in_statement170); 
                    match(input,9,FOLLOW_9_in_statement172); 
                    	
                    			System.out.println("TIY E");
                    			System.out.println("AM");
                    			System.out.println("CAL DSPR");	
                    		

                    }
                    break;
                case 8 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:51:4: 'out' '(' expr ')' ';'
                    {
                    match(input,16,FOLLOW_16_in_statement181); 
                    match(input,14,FOLLOW_14_in_statement183); 
                    pushFollow(FOLLOW_expr_in_statement185);
                    expr();
                    _fsp--;

                    match(input,15,FOLLOW_15_in_statement187); 
                    match(input,9,FOLLOW_9_in_statement189); 
                    	System.out.println("AO");	

                    }
                    break;
                case 9 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:53:4: 'cmpl' '(' expr ')' ';'
                    {
                    match(input,17,FOLLOW_17_in_statement198); 
                    match(input,14,FOLLOW_14_in_statement200); 
                    pushFollow(FOLLOW_expr_in_statement202);
                    expr();
                    _fsp--;

                    match(input,15,FOLLOW_15_in_statement204); 
                    match(input,9,FOLLOW_9_in_statement206); 
                    	System.out.println("CAL CMPL");	

                    }
                    break;
                case 10 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:55:4: 'shift' '(' expr ')' ';'
                    {
                    match(input,18,FOLLOW_18_in_statement215); 
                    match(input,14,FOLLOW_14_in_statement217); 
                    pushFollow(FOLLOW_expr_in_statement219);
                    expr();
                    _fsp--;

                    match(input,15,FOLLOW_15_in_statement221); 
                    match(input,9,FOLLOW_9_in_statement223); 
                    	System.out.println("CAL SIFT");	

                    }
                    break;
                case 11 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:57:4: 'shts' '(' ')' ';'
                    {
                    match(input,19,FOLLOW_19_in_statement232); 
                    match(input,14,FOLLOW_14_in_statement234); 
                    match(input,15,FOLLOW_15_in_statement236); 
                    match(input,9,FOLLOW_9_in_statement238); 
                    	System.out.println("CAL SHTS");	

                    }
                    break;
                case 12 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:59:4: 'sound' '(' expr ')' ';'
                    {
                    match(input,20,FOLLOW_20_in_statement247); 
                    match(input,14,FOLLOW_14_in_statement249); 
                    pushFollow(FOLLOW_expr_in_statement251);
                    expr();
                    _fsp--;

                    match(input,15,FOLLOW_15_in_statement253); 
                    match(input,9,FOLLOW_9_in_statement255); 
                    	System.out.println("CAL SOUND");	

                    }
                    break;
                case 13 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:61:4: 'timer' '(' expr ')' ';'
                    {
                    match(input,21,FOLLOW_21_in_statement264); 
                    match(input,14,FOLLOW_14_in_statement266); 
                    pushFollow(FOLLOW_expr_in_statement268);
                    expr();
                    _fsp--;

                    match(input,15,FOLLOW_15_in_statement270); 
                    match(input,9,FOLLOW_9_in_statement272); 
                    	System.out.println("CAL TIMR");	

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end statement


    // $ANTLR start expr
    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:65:1: expr : ( '$A' | term ( '+' (c= CONST ) | '+' (i= ID ) )* | 'key' '(' ')' | (i= ID ) '-' (c= CONST ) | (a= ID ) '-' (b= ID ) );
    public final void expr() throws RecognitionException {
        Token c=null;
        Token i=null;
        Token a=null;
        Token b=null;

        try {
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:66:2: ( '$A' | term ( '+' (c= CONST ) | '+' (i= ID ) )* | 'key' '(' ')' | (i= ID ) '-' (c= CONST ) | (a= ID ) '-' (b= ID ) )
            int alt7=5;
            switch ( input.LA(1) ) {
            case 22:
                {
                alt7=1;
                }
                break;
            case CONST:
                {
                alt7=2;
                }
                break;
            case ID:
                {
                int LA7_3 = input.LA(2);

                if ( (LA7_3==25) ) {
                    int LA7_5 = input.LA(3);

                    if ( (LA7_5==ID) ) {
                        alt7=5;
                    }
                    else if ( (LA7_5==CONST) ) {
                        alt7=4;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("65:1: expr : ( '$A' | term ( '+' (c= CONST ) | '+' (i= ID ) )* | 'key' '(' ')' | (i= ID ) '-' (c= CONST ) | (a= ID ) '-' (b= ID ) );", 7, 5, input);

                        throw nvae;
                    }
                }
                else if ( (LA7_3==9||LA7_3==15||LA7_3==23) ) {
                    alt7=2;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("65:1: expr : ( '$A' | term ( '+' (c= CONST ) | '+' (i= ID ) )* | 'key' '(' ')' | (i= ID ) '-' (c= CONST ) | (a= ID ) '-' (b= ID ) );", 7, 3, input);

                    throw nvae;
                }
                }
                break;
            case 24:
                {
                alt7=3;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("65:1: expr : ( '$A' | term ( '+' (c= CONST ) | '+' (i= ID ) )* | 'key' '(' ')' | (i= ID ) '-' (c= CONST ) | (a= ID ) '-' (b= ID ) );", 7, 0, input);

                throw nvae;
            }

            switch (alt7) {
                case 1 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:66:4: '$A'
                    {
                    match(input,22,FOLLOW_22_in_expr287); 

                    }
                    break;
                case 2 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:67:4: term ( '+' (c= CONST ) | '+' (i= ID ) )*
                    {
                    pushFollow(FOLLOW_term_in_expr292);
                    term();
                    _fsp--;

                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:67:9: ( '+' (c= CONST ) | '+' (i= ID ) )*
                    loop6:
                    do {
                        int alt6=3;
                        int LA6_0 = input.LA(1);

                        if ( (LA6_0==23) ) {
                            int LA6_2 = input.LA(2);

                            if ( (LA6_2==ID) ) {
                                alt6=2;
                            }
                            else if ( (LA6_2==CONST) ) {
                                alt6=1;
                            }


                        }


                        switch (alt6) {
                    	case 1 :
                    	    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:68:6: '+' (c= CONST )
                    	    {
                    	    match(input,23,FOLLOW_23_in_expr302); 
                    	    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:68:10: (c= CONST )
                    	    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:68:11: c= CONST
                    	    {
                    	    c=(Token)input.LT(1);
                    	    match(input,CONST,FOLLOW_CONST_in_expr307); 

                    	    }


                    	    			System.out.println("AIA\t" + Main.toHexString(c.getText()));
                    	    		

                    	    }
                    	    break;
                    	case 2 :
                    	    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:72:6: '+' (i= ID )
                    	    {
                    	    match(input,23,FOLLOW_23_in_expr319); 
                    	    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:72:10: (i= ID )
                    	    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:72:11: i= ID
                    	    {
                    	    i=(Token)input.LT(1);
                    	    match(input,ID,FOLLOW_ID_in_expr324); 

                    	    }


                    	    			System.out.println("TIY\t" + Main.varHexIndex(i.getText()));
                    	    			System.out.println("M+");	  		
                    	    	  	

                    	    }
                    	    break;

                    	default :
                    	    break loop6;
                        }
                    } while (true);


                    }
                    break;
                case 3 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:78:4: 'key' '(' ')'
                    {
                    match(input,24,FOLLOW_24_in_expr342); 
                    match(input,14,FOLLOW_14_in_expr344); 
                    match(input,15,FOLLOW_15_in_expr346); 
                    	System.out.println("KA");	

                    }
                    break;
                case 4 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:80:4: (i= ID ) '-' (c= CONST )
                    {
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:80:4: (i= ID )
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:80:5: i= ID
                    {
                    i=(Token)input.LT(1);
                    match(input,ID,FOLLOW_ID_in_expr358); 

                    }

                    match(input,25,FOLLOW_25_in_expr361); 
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:80:15: (c= CONST )
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:80:16: c= CONST
                    {
                    c=(Token)input.LT(1);
                    match(input,CONST,FOLLOW_CONST_in_expr366); 

                    }


                    			System.out.println("TIY\t" + Main.varHexIndex(i.getText()));
                    			System.out.println("TIA\t" + Main.toHexString(c.getText()));
                    			System.out.println("M-");	  		
                    		

                    }
                    break;
                case 5 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:86:4: (a= ID ) '-' (b= ID )
                    {
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:86:4: (a= ID )
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:86:5: a= ID
                    {
                    a=(Token)input.LT(1);
                    match(input,ID,FOLLOW_ID_in_expr379); 

                    }

                    match(input,25,FOLLOW_25_in_expr382); 
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:86:15: (b= ID )
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:86:16: b= ID
                    {
                    b=(Token)input.LT(1);
                    match(input,ID,FOLLOW_ID_in_expr387); 

                    }


                    			System.out.println("TIY\t" + Main.varHexIndex(b.getText()));
                    			System.out.println("MA");
                    			System.out.println("TIY\t" + Main.varHexIndex(a.getText()));
                    			System.out.println("M-");	  		
                    		

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end expr


    // $ANTLR start term
    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:95:1: term : ( (c= CONST ) | (i= ID ) );
    public final void term() throws RecognitionException {
        Token c=null;
        Token i=null;

        try {
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:96:2: ( (c= CONST ) | (i= ID ) )
            int alt8=2;
            int LA8_0 = input.LA(1);

            if ( (LA8_0==CONST) ) {
                alt8=1;
            }
            else if ( (LA8_0==ID) ) {
                alt8=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("95:1: term : ( (c= CONST ) | (i= ID ) );", 8, 0, input);

                throw nvae;
            }
            switch (alt8) {
                case 1 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:96:4: (c= CONST )
                    {
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:96:4: (c= CONST )
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:96:5: c= CONST
                    {
                    c=(Token)input.LT(1);
                    match(input,CONST,FOLLOW_CONST_in_term406); 

                    }

                    	System.out.println("TIA\t" + Main.toHexString(c.getText()));	

                    }
                    break;
                case 2 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:98:4: (i= ID )
                    {
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:98:4: (i= ID )
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:98:5: i= ID
                    {
                    i=(Token)input.LT(1);
                    match(input,ID,FOLLOW_ID_in_term419); 

                    }


                    			System.out.println("TIY\t" + Main.varHexIndex(i.getText()));
                    			System.out.println("MA");
                    		

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end term


    // $ANTLR start ifStm
    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:105:1: ifStm : 'if' '(' comparisonExpr ')' statement ;
    public final void ifStm() throws RecognitionException {
        	
        			String label = Main.genLabel();
        		
        try {
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:112:2: ( 'if' '(' comparisonExpr ')' statement )
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:112:4: 'if' '(' comparisonExpr ')' statement
            {
            match(input,26,FOLLOW_26_in_ifStm450); 
            match(input,14,FOLLOW_14_in_ifStm452); 
            pushFollow(FOLLOW_comparisonExpr_in_ifStm454);
            comparisonExpr();
            _fsp--;

            match(input,15,FOLLOW_15_in_ifStm456); 

            			System.out.println("JUMP\t" + label);
            		
            pushFollow(FOLLOW_statement_in_ifStm466);
            statement();
            _fsp--;


            }


            			System.out.print(label + ": ");
            		
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end ifStm


    // $ANTLR start whileStm
    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:120:1: whileStm : 'while' '(' comparisonExpr ')' statement ;
    public final void whileStm() throws RecognitionException {

        			String label1 = Main.genLabel();
        			String label2 = Main.genLabel();
        		
        try {
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:129:2: ( 'while' '(' comparisonExpr ')' statement )
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:129:4: 'while' '(' comparisonExpr ')' statement
            {
            match(input,27,FOLLOW_27_in_whileStm494); 
            	System.out.print(label1 + ": ");	
            match(input,14,FOLLOW_14_in_whileStm504); 
            pushFollow(FOLLOW_comparisonExpr_in_whileStm506);
            comparisonExpr();
            _fsp--;

            match(input,15,FOLLOW_15_in_whileStm508); 
            	System.out.println("JUMP\t" + label2); 	
            pushFollow(FOLLOW_statement_in_whileStm520);
            statement();
            _fsp--;


            }


            			System.out.println("JUMP\t" + label1);
            			System.out.print(label2 + ": ");
            		
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end whileStm


    // $ANTLR start comparisonExpr
    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:136:1: comparisonExpr : ( '$Z' | 'key' '(' ')' | (i= ID ) '>' (c= CONST ) | term ( '==' (c= CONST ) | '==' (i= ID ) ) );
    public final void comparisonExpr() throws RecognitionException {
        Token i=null;
        Token c=null;

        try {
            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:137:2: ( '$Z' | 'key' '(' ')' | (i= ID ) '>' (c= CONST ) | term ( '==' (c= CONST ) | '==' (i= ID ) ) )
            int alt10=4;
            switch ( input.LA(1) ) {
            case 28:
                {
                alt10=1;
                }
                break;
            case 24:
                {
                alt10=2;
                }
                break;
            case ID:
                {
                int LA10_3 = input.LA(2);

                if ( (LA10_3==29) ) {
                    alt10=3;
                }
                else if ( (LA10_3==30) ) {
                    alt10=4;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("136:1: comparisonExpr : ( '$Z' | 'key' '(' ')' | (i= ID ) '>' (c= CONST ) | term ( '==' (c= CONST ) | '==' (i= ID ) ) );", 10, 3, input);

                    throw nvae;
                }
                }
                break;
            case CONST:
                {
                alt10=4;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("136:1: comparisonExpr : ( '$Z' | 'key' '(' ')' | (i= ID ) '>' (c= CONST ) | term ( '==' (c= CONST ) | '==' (i= ID ) ) );", 10, 0, input);

                throw nvae;
            }

            switch (alt10) {
                case 1 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:137:4: '$Z'
                    {
                    match(input,28,FOLLOW_28_in_comparisonExpr532); 

                    }
                    break;
                case 2 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:138:4: 'key' '(' ')'
                    {
                    match(input,24,FOLLOW_24_in_comparisonExpr537); 
                    match(input,14,FOLLOW_14_in_comparisonExpr539); 
                    match(input,15,FOLLOW_15_in_comparisonExpr541); 
                    	System.out.println("KA");	

                    }
                    break;
                case 3 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:141:4: (i= ID ) '>' (c= CONST )
                    {
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:141:4: (i= ID )
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:141:5: i= ID
                    {
                    i=(Token)input.LT(1);
                    match(input,ID,FOLLOW_ID_in_comparisonExpr556); 

                    }

                    match(input,29,FOLLOW_29_in_comparisonExpr559); 
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:141:15: (c= CONST )
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:141:16: c= CONST
                    {
                    c=(Token)input.LT(1);
                    match(input,CONST,FOLLOW_CONST_in_comparisonExpr564); 

                    }

                    	
                    	  		System.out.println("TIY\t" + Main.varHexIndex(i.getText()));	
                    	  		System.out.println("TIA\t" + Main.toHexString(c.getText()));
                    	  		System.out.println("AIA\t1");
                    	  		System.out.println("M-");	  		
                    	  	

                    }
                    break;
                case 4 :
                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:148:4: term ( '==' (c= CONST ) | '==' (i= ID ) )
                    {
                    pushFollow(FOLLOW_term_in_comparisonExpr579);
                    term();
                    _fsp--;

                    // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:148:9: ( '==' (c= CONST ) | '==' (i= ID ) )
                    int alt9=2;
                    int LA9_0 = input.LA(1);

                    if ( (LA9_0==30) ) {
                        int LA9_1 = input.LA(2);

                        if ( (LA9_1==ID) ) {
                            alt9=2;
                        }
                        else if ( (LA9_1==CONST) ) {
                            alt9=1;
                        }
                        else {
                            NoViableAltException nvae =
                                new NoViableAltException("148:9: ( '==' (c= CONST ) | '==' (i= ID ) )", 9, 1, input);

                            throw nvae;
                        }
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("148:9: ( '==' (c= CONST ) | '==' (i= ID ) )", 9, 0, input);

                        throw nvae;
                    }
                    switch (alt9) {
                        case 1 :
                            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:149:6: '==' (c= CONST )
                            {
                            match(input,30,FOLLOW_30_in_comparisonExpr588); 
                            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:149:11: (c= CONST )
                            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:149:12: c= CONST
                            {
                            c=(Token)input.LT(1);
                            match(input,CONST,FOLLOW_CONST_in_comparisonExpr593); 

                            }

                            	System.out.println("CIA\t" + Main.toHexString(c.getText()));	

                            }
                            break;
                        case 2 :
                            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:151:6: '==' (i= ID )
                            {
                            match(input,30,FOLLOW_30_in_comparisonExpr608); 
                            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:151:11: (i= ID )
                            // /Users/take/Documents/workspace/Gem4c/src/Gem4c.g:151:12: i= ID
                            {
                            i=(Token)input.LT(1);
                            match(input,ID,FOLLOW_ID_in_comparisonExpr613); 

                            }

                            	System.out.println("CIY\t" + Main.varHexIndex(i.getText()));		

                            }
                            break;

                    }


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end comparisonExpr


 

    public static final BitSet FOLLOW_declaration_in_prog18 = new BitSet(new long[]{0x000000000D7F26B0L});
    public static final BitSet FOLLOW_statement_in_prog32 = new BitSet(new long[]{0x000000000D7F2632L});
    public static final BitSet FOLLOW_7_in_declaration57 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_ID_in_declaration62 = new BitSet(new long[]{0x0000000000000300L});
    public static final BitSet FOLLOW_8_in_declaration72 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_ID_in_declaration77 = new BitSet(new long[]{0x0000000000000300L});
    public static final BitSet FOLLOW_9_in_declaration88 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_10_in_compoundStatement99 = new BitSet(new long[]{0x000000000D7F2630L});
    public static final BitSet FOLLOW_statement_in_compoundStatement101 = new BitSet(new long[]{0x000000000D7F2E30L});
    public static final BitSet FOLLOW_11_in_compoundStatement104 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_expr_in_statement117 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_9_in_statement119 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_statement128 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_12_in_statement131 = new BitSet(new long[]{0x0000000001400030L});
    public static final BitSet FOLLOW_expr_in_statement133 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_9_in_statement135 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_9_in_statement144 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_compoundStatement_in_statement149 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ifStm_in_statement154 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_whileStm_in_statement159 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_13_in_statement164 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_14_in_statement166 = new BitSet(new long[]{0x0000000001400030L});
    public static final BitSet FOLLOW_expr_in_statement168 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_statement170 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_9_in_statement172 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_16_in_statement181 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_14_in_statement183 = new BitSet(new long[]{0x0000000001400030L});
    public static final BitSet FOLLOW_expr_in_statement185 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_statement187 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_9_in_statement189 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_17_in_statement198 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_14_in_statement200 = new BitSet(new long[]{0x0000000001400030L});
    public static final BitSet FOLLOW_expr_in_statement202 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_statement204 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_9_in_statement206 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_18_in_statement215 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_14_in_statement217 = new BitSet(new long[]{0x0000000001400030L});
    public static final BitSet FOLLOW_expr_in_statement219 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_statement221 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_9_in_statement223 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_19_in_statement232 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_14_in_statement234 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_statement236 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_9_in_statement238 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_20_in_statement247 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_14_in_statement249 = new BitSet(new long[]{0x0000000001400030L});
    public static final BitSet FOLLOW_expr_in_statement251 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_statement253 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_9_in_statement255 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_21_in_statement264 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_14_in_statement266 = new BitSet(new long[]{0x0000000001400030L});
    public static final BitSet FOLLOW_expr_in_statement268 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_statement270 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_9_in_statement272 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_22_in_expr287 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_term_in_expr292 = new BitSet(new long[]{0x0000000000800002L});
    public static final BitSet FOLLOW_23_in_expr302 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_CONST_in_expr307 = new BitSet(new long[]{0x0000000000800002L});
    public static final BitSet FOLLOW_23_in_expr319 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_ID_in_expr324 = new BitSet(new long[]{0x0000000000800002L});
    public static final BitSet FOLLOW_24_in_expr342 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_14_in_expr344 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_expr346 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_expr358 = new BitSet(new long[]{0x0000000002000000L});
    public static final BitSet FOLLOW_25_in_expr361 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_CONST_in_expr366 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_expr379 = new BitSet(new long[]{0x0000000002000000L});
    public static final BitSet FOLLOW_25_in_expr382 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_ID_in_expr387 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_CONST_in_term406 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_term419 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_26_in_ifStm450 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_14_in_ifStm452 = new BitSet(new long[]{0x0000000011000030L});
    public static final BitSet FOLLOW_comparisonExpr_in_ifStm454 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_ifStm456 = new BitSet(new long[]{0x000000000D7F2630L});
    public static final BitSet FOLLOW_statement_in_ifStm466 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_27_in_whileStm494 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_14_in_whileStm504 = new BitSet(new long[]{0x0000000011000030L});
    public static final BitSet FOLLOW_comparisonExpr_in_whileStm506 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_whileStm508 = new BitSet(new long[]{0x000000000D7F2630L});
    public static final BitSet FOLLOW_statement_in_whileStm520 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_28_in_comparisonExpr532 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_24_in_comparisonExpr537 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_14_in_comparisonExpr539 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_comparisonExpr541 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_comparisonExpr556 = new BitSet(new long[]{0x0000000020000000L});
    public static final BitSet FOLLOW_29_in_comparisonExpr559 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_CONST_in_comparisonExpr564 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_term_in_comparisonExpr579 = new BitSet(new long[]{0x0000000040000000L});
    public static final BitSet FOLLOW_30_in_comparisonExpr588 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_CONST_in_comparisonExpr593 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_30_in_comparisonExpr608 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_ID_in_comparisonExpr613 = new BitSet(new long[]{0x0000000000000002L});

}