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

📄 prolexer.java

📁 使用antlr实现c和pascal的转换
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    throw nvae;                }            }            else if ( (LA18_0=='a') ) {                alt18=3;            }            else {                NoViableAltException nvae =                    new NoViableAltException("195:1: AND : ( 'AND' | 'And' | 'and' );", 18, 0, input);                throw nvae;            }            switch (alt18) {                case 1 :                    // PRO.g:195:7: 'AND'                    {                    match("AND");                     }                    break;                case 2 :                    // PRO.g:195:13: 'And'                    {                    match("And");                     }                    break;                case 3 :                    // PRO.g:195:19: 'and'                    {                    match("and");                     }                    break;            }            this.type = _type;        }        finally {        }    }    // $ANTLR end AND    // $ANTLR start ASSIGNOP    public final void mASSIGNOP() throws RecognitionException {        try {            int _type = ASSIGNOP;            // PRO.g:196:11: ( ':=' )            // PRO.g:196:11: ':='            {            match(":=");             }            this.type = _type;        }        finally {        }    }    // $ANTLR end ASSIGNOP    // $ANTLR start INTEGER    public final void mINTEGER() throws RecognitionException {        try {            int _type = INTEGER;            // PRO.g:197:11: ( 'INTEGER' | 'Integer' | 'integer' )            int alt19=3;            int LA19_0 = input.LA(1);            if ( (LA19_0=='I') ) {                int LA19_1 = input.LA(2);                if ( (LA19_1=='N') ) {                    alt19=1;                }                else if ( (LA19_1=='n') ) {                    alt19=2;                }                else {                    NoViableAltException nvae =                        new NoViableAltException("197:1: INTEGER : ( 'INTEGER' | 'Integer' | 'integer' );", 19, 1, input);                    throw nvae;                }            }            else if ( (LA19_0=='i') ) {                alt19=3;            }            else {                NoViableAltException nvae =                    new NoViableAltException("197:1: INTEGER : ( 'INTEGER' | 'Integer' | 'integer' );", 19, 0, input);                throw nvae;            }            switch (alt19) {                case 1 :                    // PRO.g:197:11: 'INTEGER'                    {                    match("INTEGER");                     }                    break;                case 2 :                    // PRO.g:197:21: 'Integer'                    {                    match("Integer");                     }                    break;                case 3 :                    // PRO.g:197:31: 'integer'                    {                    match("integer");                     }                    break;            }            this.type = _type;        }        finally {        }    }    // $ANTLR end INTEGER    // $ANTLR start REAL    public final void mREAL() throws RecognitionException {        try {            int _type = REAL;            // PRO.g:198:8: ( 'REAL' | 'Real' | 'real' )            int alt20=3;            int LA20_0 = input.LA(1);            if ( (LA20_0=='R') ) {                int LA20_1 = input.LA(2);                if ( (LA20_1=='E') ) {                    alt20=1;                }                else if ( (LA20_1=='e') ) {                    alt20=2;                }                else {                    NoViableAltException nvae =                        new NoViableAltException("198:1: REAL : ( 'REAL' | 'Real' | 'real' );", 20, 1, input);                    throw nvae;                }            }            else if ( (LA20_0=='r') ) {                alt20=3;            }            else {                NoViableAltException nvae =                    new NoViableAltException("198:1: REAL : ( 'REAL' | 'Real' | 'real' );", 20, 0, input);                throw nvae;            }            switch (alt20) {                case 1 :                    // PRO.g:198:8: 'REAL'                    {                    match("REAL");                     }                    break;                case 2 :                    // PRO.g:198:15: 'Real'                    {                    match("Real");                     }                    break;                case 3 :                    // PRO.g:198:22: 'real'                    {                    match("real");                     }                    break;            }            this.type = _type;        }        finally {        }    }    // $ANTLR end REAL    // $ANTLR start SEPARATOR    public final void mSEPARATOR() throws RecognitionException {        try {            int _type = SEPARATOR;            // PRO.g:200:4: ( ( ' ' | '\\t' | NEWLINE )+ )            // PRO.g:200:4: ( ' ' | '\\t' | NEWLINE )+            {            // PRO.g:200:4: ( ' ' | '\\t' | NEWLINE )+            int cnt21=0;            loop21:            do {                int alt21=4;                switch ( input.LA(1) ) {                case ' ':                    {                    alt21=1;                    }                    break;                case '\t':                    {                    alt21=2;                    }                    break;                case '\n':                case '\r':                    {                    alt21=3;                    }                    break;                }                switch (alt21) {            	case 1 :            	    // PRO.g:200:5: ' '            	    {            	    match(' ');             	    }            	    break;            	case 2 :            	    // PRO.g:200:9: '\\t'            	    {            	    match('\t');             	    }            	    break;            	case 3 :            	    // PRO.g:200:14: NEWLINE            	    {            	    mNEWLINE();             	    }            	    break;            	default :            	    if ( cnt21 >= 1 ) break loop21;                        EarlyExitException eee =                            new EarlyExitException(21, input);                        throw eee;                }                cnt21++;            } while (true);            }            this.type = _type;        }        finally {        }    }    // $ANTLR end SEPARATOR    // $ANTLR start NEWLINE    public final void mNEWLINE() throws RecognitionException {        try {            int _type = NEWLINE;            // PRO.g:201:11: ( ( '\\r' )? '\\n' )            // PRO.g:201:11: ( '\\r' )? '\\n'            {            // PRO.g:201:11: ( '\\r' )?            int alt22=2;            int LA22_0 = input.LA(1);            if ( (LA22_0=='\r') ) {                alt22=1;            }            switch (alt22) {                case 1 :                    // PRO.g:201:11: '\\r'                    {                    match('\r');                     }                    break;            }            match('\n');             }            this.type = _type;        }        finally {        }    }    // $ANTLR end NEWLINE    // $ANTLR start NUM    public final void mNUM() throws RecognitionException {        try {            int _type = NUM;            // PRO.g:202:7: ( DIGITS OPTIONAL_FRACTION OPTIONAL_EXPONENT )            // PRO.g:202:7: DIGITS OPTIONAL_FRACTION OPTIONAL_EXPONENT            {            mDIGITS();             mOPTIONAL_FRACTION();             mOPTIONAL_EXPONENT();             }            this.type = _type;        }        finally {        }    }    // $ANTLR end NUM    // $ANTLR start OPTIONAL_FRACTION    public final void mOPTIONAL_FRACTION() throws RecognitionException {        try {            int _type = OPTIONAL_FRACTION;            // PRO.g:204:4: ( '.' DIGITS | )            int alt23=2;            int LA23_0 = input.LA(1);            if ( (LA23_0=='.') ) {                alt23=1;            }            else {                alt23=2;}            switch (alt23) {                case 1 :                    // PRO.g:204:4: '.' DIGITS                    {                    match('.');                     mDIGITS();                     }                    break;                case 2 :                    // PRO.g:204:14:                     {                    }                    break;            }            this.type = _type;        }        finally {        }    }    // $ANTLR end OPTIONAL_FRACTION    // $ANTLR start OPTIONAL_EXPONENT    public final void mOPTIONAL_EXPONENT() throws RecognitionException {        try {            int _type = OPTIONAL_EXPONENT;            // PRO.g:206:4: ( ( 'E' ( '+' | '-' | ) DIGITS ) | )            int alt25=2;            int LA25_0 = input.LA(1);            if ( (LA25_0=='E') ) {                alt25=1;            }            else {                alt25=2;}            switch (alt25) {                case 1 :                    // PRO.g:206:4: ( 'E' ( '+' | '-' | ) DIGITS )                    {                    // PRO.g:206:4: ( 'E' ( '+' | '-' | ) DIGITS )                    // PRO.g:206:5: 'E' ( '+' | '-' | ) DIGITS                    {                    match('E');                     // PRO.g:206:9: ( '+' | '-' | )                    int alt24=3;                    switch ( input.LA(1) ) {                    case '+':                        {                        alt24=1;                        }                        break;                    case '-':                        {                        alt24=2;                        }                        break;                    case '0':                    case '1':                    case '2':                    case '3':                    case '4':                    case '5':                    case '6':                    case '7':                    case '8':                    case '9':                        {                        alt24=3;                        }                        break;                    default:                        NoViableAltException nvae =                            new NoViableAltException("206:9: ( '+' | '-' | )", 24, 0, input);                        throw nvae;                    }                    switch (alt24) {                        case 1 :                            // PRO.g:206:10: '+'                            {                            match('+');                             }                            break;                        case 2 :                            // PRO.g:206:14: '-'                            {                            match('-');                             }                            break;                        case 3 :                            // PRO.g:206:18:                             {                            }                            break;                    }                    mDIGITS();                     }                    }                    break;                case 2 :                    // PRO.g:206:27:                     {                    }                    break;            }            this.type = _type;        }        finally {        }    }    // $ANTLR end OPTIONAL_EXPONENT    // $ANTLR start ID    public final void mID() throws RecognitionException {        try {            int _type = ID;            // PRO.g:207:6: ( LETTER ( LETTER | DIGIT )* )            // PRO.g:207:6: LETTER ( LETTER | DIGIT )*            {            mLETTER();             // PRO.g:207:12: ( LETTER | DIGIT )*            loop26:            do {                int alt26=2;                int LA26_0 = input.LA(1);                if ( ((LA26_0>='0' && LA26_0<='9')||(LA26_0>='A' && LA26_0<='Z')||(LA26_0>='a' && LA26_0<='z')) ) {                    alt26=1;                }                switch (alt26) {            	case 1 :            	    // PRO.g:            	    {            	    if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='Z')||(input.LA(1)>='a' && input.LA(1)<='z') ) {            	        input.consume();            	    }            	    else {            	        MismatchedSetException mse =            	            new MismatchedSetException(null,input);            	        recover(mse);    throw mse;            	    }            	    }            	    break;            	default :            	    break loop26;                }            } while (true);            }            this.type = _type;        }        finally {        }    }    // $ANTLR end ID    // $ANTLR start DIGITS    public final void mDIGITS() throws RecognitionException {        try {            int _type = DIGITS;            // PRO.g:208:10: ( DIGIT ( DIGIT )* )            // PRO.g:208:10: DIGIT ( DIGIT )*            {            mDIGIT();             // PRO.g:208:16: ( DIGIT )*            loop27:            do {                int alt27=2;                int LA27_0 = input.LA(1);                if ( ((LA27_0>='0' && LA27_0<='9')) ) {                    alt27=1;                }

⌨️ 快捷键说明

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