⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proparser.java.bak

📁 使用antlr实现c和pascal的转换
💻 BAK
📖 第 1 页 / 共 5 页
字号:
            	    	    {            	    	    match(input,SEPARATOR,FOLLOW_SEPARATOR_in_declarations164); if (failed) return place;            	    	    }            	    	    break;            	    	default :            	    	    break loop8;            	        }            	    } while (true);            	    pushFollow(FOLLOW_type_in_declarations167);            	    type1=type();            	    _fsp--;            	    if (failed) return place;            	    // PRO.g:55:81: ( SEPARATOR )*            	    loop9:            	    do {            	        int alt9=2;            	        int LA9_0 = input.LA(1);            	        if ( (LA9_0==SEPARATOR) ) {            	            alt9=1;            	        }            	        switch (alt9) {            	    	case 1 :            	    	    // PRO.g:0:0: SEPARATOR            	    	    {            	    	    match(input,SEPARATOR,FOLLOW_SEPARATOR_in_declarations169); if (failed) return place;            	    	    }            	    	    break;            	    	default :            	    	    break loop9;            	        }            	    } while (true);            	    match(input,49,FOLLOW_49_in_declarations172); if (failed) return place;            	    if ( backtracking==0 ) {            	      place+=type1+" "+identifier_list2+";\n";            	    }            	    }            	    break;            	default :            	    break loop10;                }            } while (true);            }        }        catch (RecognitionException re) {            reportError(re);            recover(input,re);        }        finally {        }        return place;    }    // $ANTLR end declarations    // $ANTLR start identifier_list    // PRO.g:57:1: identifier_list returns [String place] : (e= ID ) ( ( SEPARATOR )* ',' ( SEPARATOR )* f= ID )* ;    public final String identifier_list() throws RecognitionException {        String place = null;        Token e=null;        Token f=null;        try {            // PRO.g:58:3: ( (e= ID ) ( ( SEPARATOR )* ',' ( SEPARATOR )* f= ID )* )            // PRO.g:58:3: (e= ID ) ( ( SEPARATOR )* ',' ( SEPARATOR )* f= ID )*            {            // PRO.g:58:3: (e= ID )            // PRO.g:58:4: e= ID            {            e=(Token)input.LT(1);            match(input,ID,FOLLOW_ID_in_identifier_list192); if (failed) return place;            if ( backtracking==0 ) {              place =e.getText();            }            }            // PRO.g:58:27: ( ( SEPARATOR )* ',' ( SEPARATOR )* f= ID )*            loop13:            do {                int alt13=2;                int LA13_0 = input.LA(1);                if ( (LA13_0==SEPARATOR) ) {                    int LA13_2 = input.LA(2);                    if ( (LA13_2==SEPARATOR) ) {                        int LA13_6 = input.LA(3);                        if ( (LA13_6==SEPARATOR) ) {                            int LA13_9 = input.LA(4);                            if ( (LA13_9==SEPARATOR) ) {                                int LA13_12 = input.LA(5);                                if ( (LA13_12==SEPARATOR) ) {                                    int LA13_15 = input.LA(6);                                    if ( (LA13_15==SEPARATOR) ) {                                        int LA13_18 = input.LA(7);                                        if ( (LA13_18==SEPARATOR) ) {                                            int LA13_21 = input.LA(8);                                            if ( (LA13_21==SEPARATOR) ) {                                                int LA13_24 = input.LA(9);                                                if ( (LA13_24==SEPARATOR) ) {                                                    int LA13_27 = input.LA(10);                                                    if ( (synpred13()) ) {                                                        alt13=1;                                                    }                                                }                                                else if ( (LA13_24==50) ) {                                                    alt13=1;                                                }                                            }                                            else if ( (LA13_21==50) ) {                                                alt13=1;                                            }                                        }                                        else if ( (LA13_18==50) ) {                                            alt13=1;                                        }                                    }                                    else if ( (LA13_15==50) ) {                                        alt13=1;                                    }                                }                                else if ( (LA13_12==50) ) {                                    alt13=1;                                }                            }                            else if ( (LA13_9==50) ) {                                alt13=1;                            }                        }                        else if ( (LA13_6==50) ) {                            alt13=1;                        }                    }                    else if ( (LA13_2==50) ) {                        alt13=1;                    }                }                else if ( (LA13_0==50) ) {                    alt13=1;                }                switch (alt13) {            	case 1 :            	    // PRO.g:58:28: ( SEPARATOR )* ',' ( SEPARATOR )* f= ID            	    {            	    // PRO.g:58:28: ( SEPARATOR )*            	    loop11:            	    do {            	        int alt11=2;            	        int LA11_0 = input.LA(1);            	        if ( (LA11_0==SEPARATOR) ) {            	            alt11=1;            	        }            	        switch (alt11) {            	    	case 1 :            	    	    // PRO.g:0:0: SEPARATOR            	    	    {            	    	    match(input,SEPARATOR,FOLLOW_SEPARATOR_in_identifier_list197); if (failed) return place;            	    	    }            	    	    break;            	    	default :            	    	    break loop11;            	        }            	    } while (true);            	    match(input,50,FOLLOW_50_in_identifier_list200); if (failed) return place;            	    // PRO.g:58:43: ( SEPARATOR )*            	    loop12:            	    do {            	        int alt12=2;            	        int LA12_0 = input.LA(1);            	        if ( (LA12_0==SEPARATOR) ) {            	            alt12=1;            	        }            	        switch (alt12) {            	    	case 1 :            	    	    // PRO.g:0:0: SEPARATOR            	    	    {            	    	    match(input,SEPARATOR,FOLLOW_SEPARATOR_in_identifier_list202); if (failed) return place;            	    	    }            	    	    break;            	    	default :            	    	    break loop12;            	        }            	    } while (true);            	    f=(Token)input.LT(1);            	    match(input,ID,FOLLOW_ID_in_identifier_list207); if (failed) return place;            	    if ( backtracking==0 ) {            	      place+=","+f.getText();            	    }            	    }            	    break;            	default :            	    break loop13;                }            } while (true);            }        }        catch (RecognitionException re) {            reportError(re);            recover(input,re);        }        finally {        }        return place;    }    // $ANTLR end identifier_list    // $ANTLR start type    // PRO.g:60:1: type returns [String place] : ( standard_type | ARRAY '[' e= NUM '..' f= NUM ']' 'OF' standard_type );    public final String type() throws RecognitionException {        String place = null;        Token e=null;        Token f=null;        String standard_type3 = null;        String standard_type4 = null;        try {            // PRO.g:61:3: ( standard_type | ARRAY '[' e= NUM '..' f= NUM ']' 'OF' standard_type )            int alt14=2;            int LA14_0 = input.LA(1);            if ( ((LA14_0>=INTEGER && LA14_0<=REAL)) ) {                alt14=1;            }            else if ( (LA14_0==ARRAY) ) {                alt14=2;            }            else {                if (backtracking>0) {failed=true; return place;}                NoViableAltException nvae =                    new NoViableAltException("60:1: type returns [String place] : ( standard_type | ARRAY '[' e= NUM '..' f= NUM ']' 'OF' standard_type );", 14, 0, input);                throw nvae;            }            switch (alt14) {                case 1 :                    // PRO.g:61:3: standard_type                    {                    pushFollow(FOLLOW_standard_type_in_type228);                    standard_type3=standard_type();                    _fsp--;                    if (failed) return place;                    if ( backtracking==0 ) {                      place =standard_type3;                    }                    }                    break;                case 2 :                    // PRO.g:62:3: ARRAY '[' e= NUM '..' f= NUM ']' 'OF' standard_type                    {                    match(input,ARRAY,FOLLOW_ARRAY_in_type234); if (failed) return place;                    match(input,51,FOLLOW_51_in_type236); if (failed) return place;                    e=(Token)input.LT(1);                    match(input,NUM,FOLLOW_NUM_in_type240); if (failed) return place;                    match(input,52,FOLLOW_52_in_type242); if (failed) return place;                    f=(Token)input.LT(1);                    match(input,NUM,FOLLOW_NUM_in_type246); if (failed) return place;                    match(input,53,FOLLOW_53_in_type248); if (failed) return place;                    match(input,54,FOLLOW_54_in_type250); if (failed) return place;                    pushFollow(FOLLOW_standard_type_in_type252);                    standard_type4=standard_type();                    _fsp--;                    if (failed) return place;                    if ( backtracking==0 ) {                      place =standard_type4+"["+Integer.toString(Integer.parseInt(e.getText())-Integer.parseInt(f.getText())+1)+"]";                    }                    }                    break;            }        }        catch (RecognitionException re) {            reportError(re);            recover(input,re);        }        finally {        }        return place;    }    // $ANTLR end type    // $ANTLR start standard_type    // PRO.g:64:1: standard_type returns [String place] : ( INTEGER | REAL );    public final String standard_type() throws RecognitionException {        String place = null;        try {            // PRO.g:65:3: ( INTEGER | REAL )            int alt15=2;            int LA15_0 = input.LA(1);            if ( (LA15_0==INTEGER) ) {                alt15=1;            }            else if ( (LA15_0==REAL) ) {                alt15=2;            }            else {                if (backtracking>0) {failed=true; return place;}                NoViableAltException nvae =                    new NoViableAltException("64:1: standard_type returns [String place] : ( INTEGER | REAL );", 15, 0, input);                throw nvae;            }            switch (alt15) {                case 1 :                    // PRO.g:65:3: INTEGER                    {                    match(input,INTEGER,FOLLOW_INTEGER_in_standard_type268); if (failed) return place;                    if ( backtracking==0 ) {                      place ="int";                    }                    }                    break;                case 2 :                    // PRO.g:66:3: REAL                    {                    match(input,REAL,FOLLOW_REAL_in_standard_type273); if (failed) return place;                    if ( backtracking==0 ) {                      place ="float";                    }                    }                    break;            }        }        catch (RecognitionException re) {            reportError(re);            recover(input,re);        }        finally {        }        return place;    }    // $ANTLR end standard_type    // $ANTLR start subprogram_declarations    // PRO.g:68:1: subprogram_declarations : () ( ( SEPARATOR )* subprogram__declaration ( SEPARATOR )* ';' ( SEPARATOR )* )* ;    public final void subprogram_declarations() throws RecognitionException {        try {            // PRO.g:69:3: ( () ( ( SEPARATOR )* subprogram__declaration ( SEPARATOR )* ';' ( SEPARATOR )* )* )            // PRO.g:69:3: () ( ( SEPARATOR )* subprogram__declaration ( SEPARATOR )* ';' ( SEPARATOR )* )*            {            // PRO.g:69:3: ()            // PRO.g:69:4:             {            }            // PRO.g:69:6: ( ( SEPARATOR )* subprogram__declaration ( SEPARATOR )* ';' ( SEPARATOR )* )*            loop19:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -