// $ANTLR 3.2 Sep 23, 2009 12:02:23 Ebnf.g 2010-03-06 12:36:09 /******************************************************************************* * Copyright (c) 2007, 2008 Edgar Espina. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * *******************************************************************************/ package net.hydromatic.clapham.parser.ebnf; import org.antlr.runtime.*; import java.util.Stack; import java.util.List; import java.util.ArrayList; public class EbnfLexer extends Lexer { public static final int ESC=7; public static final int LITERAL_CHAR=6; public static final int ID=4; public static final int EOF=-1; public static final int T__19=19; public static final int T__16=16; public static final int STRING_LITERAL=5; public static final int WS=9; public static final int T__15=15; public static final int T__18=18; public static final int T__17=17; public static final int T__12=12; public static final int T__11=11; public static final int T__14=14; public static final int T__13=13; public static final int XDIGIT=8; public static final int T__10=10; // delegates // delegators public EbnfLexer() {;} public EbnfLexer(CharStream input) { this(input, new RecognizerSharedState()); } public EbnfLexer(CharStream input, RecognizerSharedState state) { super(input,state); } public String getGrammarFileName() { return "Ebnf.g"; } // $ANTLR start "T__10" public final void mT__10() throws RecognitionException { try { int _type = T__10; int _channel = DEFAULT_TOKEN_CHANNEL; // Ebnf.g:19:7: ( '::=' ) // Ebnf.g:19:9: '::=' { match("::="); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__10" // $ANTLR start "T__11" public final void mT__11() throws RecognitionException { try { int _type = T__11; int _channel = DEFAULT_TOKEN_CHANNEL; // Ebnf.g:20:7: ( '|' ) // Ebnf.g:20:9: '|' { match('|'); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__11" // $ANTLR start "T__12" public final void mT__12() throws RecognitionException { try { int _type = T__12; int _channel = DEFAULT_TOKEN_CHANNEL; // Ebnf.g:21:7: ( '+' ) // Ebnf.g:21:9: '+' { match('+'); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__12" // $ANTLR start "T__13" public final void mT__13() throws RecognitionException { try { int _type = T__13; int _channel = DEFAULT_TOKEN_CHANNEL; // Ebnf.g:22:7: ( '?' ) // Ebnf.g:22:9: '?' { match('?'); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__13" // $ANTLR start "T__14" public final void mT__14() throws RecognitionException { try { int _type = T__14; int _channel = DEFAULT_TOKEN_CHANNEL; // Ebnf.g:23:7: ( '*' ) // Ebnf.g:23:9: '*' { match('*'); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__14" // $ANTLR start "T__15" public final void mT__15() throws RecognitionException { try { int _type = T__15; int _channel = DEFAULT_TOKEN_CHANNEL; // Ebnf.g:24:7: ( '.' ) // Ebnf.g:24:9: '.' { match('.'); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__15" // $ANTLR start "T__16" public final void mT__16() throws RecognitionException { try { int _type = T__16; int _channel = DEFAULT_TOKEN_CHANNEL; // Ebnf.g:25:7: ( '(' ) // Ebnf.g:25:9: '(' { match('('); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__16" // $ANTLR start "T__17" public final void mT__17() throws RecognitionException { try { int _type = T__17; int _channel = DEFAULT_TOKEN_CHANNEL; // Ebnf.g:26:7: ( ')' ) // Ebnf.g:26:9: ')' { match(')'); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__17" // $ANTLR start "T__18" public final void mT__18() throws RecognitionException { try { int _type = T__18; int _channel = DEFAULT_TOKEN_CHANNEL; // Ebnf.g:27:7: ( '~' ) // Ebnf.g:27:9: '~' { match('~'); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__18" // $ANTLR start "T__19" public final void mT__19() throws RecognitionException { try { int _type = T__19; int _channel = DEFAULT_TOKEN_CHANNEL; // Ebnf.g:28:7: ( '??' ) // Ebnf.g:28:9: '??' { match("??"); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__19" // $ANTLR start "STRING_LITERAL" public final void mSTRING_LITERAL() throws RecognitionException { try { int _type = STRING_LITERAL; int _channel = DEFAULT_TOKEN_CHANNEL; // Ebnf.g:142:3: ( '\\'' LITERAL_CHAR ( LITERAL_CHAR )* '\\'' ) // Ebnf.g:143:3: '\\'' LITERAL_CHAR ( LITERAL_CHAR )* '\\'' { match('\''); mLITERAL_CHAR(); // Ebnf.g:143:21: ( LITERAL_CHAR )* loop1: do { int alt1=2; int LA1_0 = input.LA(1); if ( ((LA1_0>='\u0000' && LA1_0<='&')||(LA1_0>='(' && LA1_0<='\uFFFF')) ) { alt1=1; } switch (alt1) { case 1 : // Ebnf.g:143:21: LITERAL_CHAR { mLITERAL_CHAR(); } break; default : break loop1; } } while (true); match('\''); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "STRING_LITERAL" // $ANTLR start "LITERAL_CHAR" public final void mLITERAL_CHAR() throws RecognitionException { try { // Ebnf.g:148:3: ( ESC | ~ ( '\\'' | '\\\\' ) ) int alt2=2; int LA2_0 = input.LA(1); if ( (LA2_0=='\\') ) { alt2=1; } else if ( ((LA2_0>='\u0000' && LA2_0<='&')||(LA2_0>='(' && LA2_0<='[')||(LA2_0>=']' && LA2_0<='\uFFFF')) ) { alt2=2; } else { NoViableAltException nvae = new NoViableAltException("", 2, 0, input); throw nvae; } switch (alt2) { case 1 : // Ebnf.g:149:3: ESC { mESC(); } break; case 2 : // Ebnf.g:151:3: ~ ( '\\'' | '\\\\' ) { if ( (input.LA(1)>='\u0000' && input.LA(1)<='&')||(input.LA(1)>='(' && input.LA(1)<='[')||(input.LA(1)>=']' && input.LA(1)<='\uFFFF') ) { input.consume(); } else { MismatchedSetException mse = new MismatchedSetException(null,input); recover(mse); throw mse;} } break; } } finally { } } // $ANTLR end "LITERAL_CHAR" // $ANTLR start "ESC" public final void mESC() throws RecognitionException { try { // Ebnf.g:159:3: ( '\\\\' ( 'n' | 'r' | 't' | 'b' | 'f' | '\"' | '\\'' | '\\\\' | '>' | 'u' XDIGIT XDIGIT XDIGIT XDIGIT | . ) ) // Ebnf.g:160:3: '\\\\' ( 'n' | 'r' | 't' | 'b' | 'f' | '\"' | '\\'' | '\\\\' | '>' | 'u' XDIGIT XDIGIT XDIGIT XDIGIT | . ) { match('\\'); // Ebnf.g:161:3: ( 'n' | 'r' | 't' | 'b' | 'f' | '\"' | '\\'' | '\\\\' | '>' | 'u' XDIGIT XDIGIT XDIGIT XDIGIT | . ) int alt3=11; alt3 = dfa3.predict(input); switch (alt3) { case 1 : // Ebnf.g:162:5: 'n' { match('n'); } break; case 2 : // Ebnf.g:163:7: 'r' { match('r'); } break; case 3 : // Ebnf.g:164:7: 't' { match('t'); } break; case 4 : // Ebnf.g:165:7: 'b' { match('b'); } break; case 5 : // Ebnf.g:166:7: 'f' { match('f'); } break; case 6 : // Ebnf.g:167:7: '\"' { match('\"'); } break; case 7 : // Ebnf.g:168:7: '\\'' { match('\''); } break; case 8 : // Ebnf.g:169:7: '\\\\' { match('\\'); } break; case 9 : // Ebnf.g:170:7: '>' { match('>'); } break; case 10 : // Ebnf.g:171:7: 'u' XDIGIT XDIGIT XDIGIT XDIGIT { match('u'); mXDIGIT(); mXDIGIT(); mXDIGIT(); mXDIGIT(); } break; case 11 : // Ebnf.g:172:7: . { matchAny(); } break; } } } finally { } } // $ANTLR end "ESC" // $ANTLR start "ID" public final void mID() throws RecognitionException { try { int _type = ID; int _channel = DEFAULT_TOKEN_CHANNEL; // Ebnf.g:177:3: ( ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '-' | '_' )* ) // Ebnf.g:178:3: ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '-' | '_' )* { if ( (input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { input.consume(); } else { MismatchedSetException mse = new MismatchedSetException(null,input); recover(mse); throw mse;} // Ebnf.g:183:3: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '-' | '_' )* loop4: do { int alt4=2; int LA4_0 = input.LA(1); if ( (LA4_0=='-'||(LA4_0>='0' && LA4_0<='9')||(LA4_0>='A' && LA4_0<='Z')||LA4_0=='_'||(LA4_0>='a' && LA4_0<='z')) ) { alt4=1; } switch (alt4) { case 1 : // Ebnf.g: { if ( input.LA(1)=='-'||(input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { input.consume(); } else { MismatchedSetException mse = new MismatchedSetException(null,input); recover(mse); throw mse;} } break; default : break loop4; } } while (true); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "ID" // $ANTLR start "XDIGIT" public final void mXDIGIT() throws RecognitionException { try { // Ebnf.g:194:3: ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' ) // Ebnf.g: { if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='F')||(input.LA(1)>='a' && input.LA(1)<='f') ) { input.consume(); } else { MismatchedSetException mse = new MismatchedSetException(null,input); recover(mse); throw mse;} } } finally { } } // $ANTLR end "XDIGIT" // $ANTLR start "WS" public final void mWS() throws RecognitionException { try { int _type = WS; int _channel = DEFAULT_TOKEN_CHANNEL; // Ebnf.g:201:3: ( ( ' ' | '\\t' | ( '\\r' )? '\\n' )+ ) // Ebnf.g:202:3: ( ' ' | '\\t' | ( '\\r' )? '\\n' )+ { // Ebnf.g:202:3: ( ' ' | '\\t' | ( '\\r' )? '\\n' )+ int cnt6=0; loop6: do { int alt6=4; switch ( input.LA(1) ) { case ' ': { alt6=1; } break; case '\t': { alt6=2; } break; case '\n': case '\r': { alt6=3; } break; } switch (alt6) { case 1 : // Ebnf.g:203:5: ' ' { match(' '); } break; case 2 : // Ebnf.g:204:7: '\\t' { match('\t'); } break; case 3 : // Ebnf.g:205:7: ( '\\r' )? '\\n' { // Ebnf.g:205:7: ( '\\r' )? int alt5=2; int LA5_0 = input.LA(1); if ( (LA5_0=='\r') ) { alt5=1; } switch (alt5) { case 1 : // Ebnf.g:205:7: '\\r' { match('\r'); } break; } match('\n'); } break; default : if ( cnt6 >= 1 ) break loop6; EarlyExitException eee = new EarlyExitException(6, input); throw eee; } cnt6++; } while (true); _channel=HIDDEN; } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "WS" public void mTokens() throws RecognitionException { // Ebnf.g:1:8: ( T__10 | T__11 | T__12 | T__13 | T__14 | T__15 | T__16 | T__17 | T__18 | T__19 | STRING_LITERAL | ID | WS ) int alt7=13; alt7 = dfa7.predict(input); switch (alt7) { case 1 : // Ebnf.g:1:10: T__10 { mT__10(); } break; case 2 : // Ebnf.g:1:16: T__11 { mT__11(); } break; case 3 : // Ebnf.g:1:22: T__12 { mT__12(); } break; case 4 : // Ebnf.g:1:28: T__13 { mT__13(); } break; case 5 : // Ebnf.g:1:34: T__14 { mT__14(); } break; case 6 : // Ebnf.g:1:40: T__15 { mT__15(); } break; case 7 : // Ebnf.g:1:46: T__16 { mT__16(); } break; case 8 : // Ebnf.g:1:52: T__17 { mT__17(); } break; case 9 : // Ebnf.g:1:58: T__18 { mT__18(); } break; case 10 : // Ebnf.g:1:64: T__19 { mT__19(); } break; case 11 : // Ebnf.g:1:70: STRING_LITERAL { mSTRING_LITERAL(); } break; case 12 : // Ebnf.g:1:85: ID { mID(); } break; case 13 : // Ebnf.g:1:88: WS { mWS(); } break; } } protected DFA3 dfa3 = new DFA3(this); protected DFA7 dfa7 = new DFA7(this); static final String DFA3_eotS = "\12\uffff\1\13\2\uffff"; static final String DFA3_eofS = "\15\uffff"; static final String DFA3_minS = "\1\0\11\uffff\1\60\2\uffff"; static final String DFA3_maxS = "\1\uffff\11\uffff\1\146\2\uffff"; static final String DFA3_acceptS = "\1\uffff\1\1\1\2\1\3\1\4\1\5\1\6\1\7\1\10\1\11\1\uffff\1\13\1\12"; static final String DFA3_specialS = "\1\0\14\uffff}>"; static final String[] DFA3_transitionS = { "\42\13\1\6\4\13\1\7\26\13\1\11\35\13\1\10\5\13\1\4\3\13\1\5"+ "\7\13\1\1\3\13\1\2\1\13\1\3\1\12\uff8a\13", "", "", "", "", "", "", "", "", "", "\12\14\7\uffff\6\14\32\uffff\6\14", "", "" }; static final short[] DFA3_eot = DFA.unpackEncodedString(DFA3_eotS); static final short[] DFA3_eof = DFA.unpackEncodedString(DFA3_eofS); static final char[] DFA3_min = DFA.unpackEncodedStringToUnsignedChars(DFA3_minS); static final char[] DFA3_max = DFA.unpackEncodedStringToUnsignedChars(DFA3_maxS); static final short[] DFA3_accept = DFA.unpackEncodedString(DFA3_acceptS); static final short[] DFA3_special = DFA.unpackEncodedString(DFA3_specialS); static final short[][] DFA3_transition; static { int numStates = DFA3_transitionS.length; DFA3_transition = new short[numStates][]; for (int i=0; i<numStates; i++) { DFA3_transition[i] = DFA.unpackEncodedString(DFA3_transitionS[i]); } } class DFA3 extends DFA { public DFA3(BaseRecognizer recognizer) { this.recognizer = recognizer; this.decisionNumber = 3; this.eot = DFA3_eot; this.eof = DFA3_eof; this.min = DFA3_min; this.max = DFA3_max; this.accept = DFA3_accept; this.special = DFA3_special; this.transition = DFA3_transition; } public String getDescription() { return "161:3: ( 'n' | 'r' | 't' | 'b' | 'f' | '\"' | '\\'' | '\\\\' | '>' | 'u' XDIGIT XDIGIT XDIGIT XDIGIT | . )"; } public int specialStateTransition(int s, IntStream _input) throws NoViableAltException { IntStream input = _input; int _s = s; switch ( s ) { case 0 : int LA3_0 = input.LA(1); s = -1; if ( (LA3_0=='n') ) {s = 1;} else if ( (LA3_0=='r') ) {s = 2;} else if ( (LA3_0=='t') ) {s = 3;} else if ( (LA3_0=='b') ) {s = 4;} else if ( (LA3_0=='f') ) {s = 5;} else if ( (LA3_0=='\"') ) {s = 6;} else if ( (LA3_0=='\'') ) {s = 7;} else if ( (LA3_0=='\\') ) {s = 8;} else if ( (LA3_0=='>') ) {s = 9;} else if ( (LA3_0=='u') ) {s = 10;} else if ( ((LA3_0>='\u0000' && LA3_0<='!')||(LA3_0>='#' && LA3_0<='&')||(LA3_0>='(' && LA3_0<='=')||(LA3_0>='?' && LA3_0<='[')||(LA3_0>=']' && LA3_0<='a')||(LA3_0>='c' && LA3_0<='e')||(LA3_0>='g' && LA3_0<='m')||(LA3_0>='o' && LA3_0<='q')||LA3_0=='s'||(LA3_0>='v' && LA3_0<='\uFFFF')) ) {s = 11;} if ( s>=0 ) return s; break; } NoViableAltException nvae = new NoViableAltException(getDescription(), 3, _s, input); error(nvae); throw nvae; } } static final String DFA7_eotS = "\4\uffff\1\16\12\uffff"; static final String DFA7_eofS = "\17\uffff"; static final String DFA7_minS = "\1\11\3\uffff\1\77\12\uffff"; static final String DFA7_maxS = "\1\176\3\uffff\1\77\12\uffff"; static final String DFA7_acceptS = "\1\uffff\1\1\1\2\1\3\1\uffff\1\5\1\6\1\7\1\10\1\11\1\13\1\14\1\15"+ "\1\12\1\4"; static final String DFA7_specialS = "\17\uffff}>"; static final String[] DFA7_transitionS = { "\2\14\2\uffff\1\14\22\uffff\1\14\6\uffff\1\12\1\7\1\10\1\5\1"+ "\3\2\uffff\1\6\13\uffff\1\1\4\uffff\1\4\1\uffff\32\13\4\uffff"+ "\1\13\1\uffff\32\13\1\uffff\1\2\1\uffff\1\11", "", "", "", "\1\15", "", "", "", "", "", "", "", "", "", "" }; static final short[] DFA7_eot = DFA.unpackEncodedString(DFA7_eotS); static final short[] DFA7_eof = DFA.unpackEncodedString(DFA7_eofS); static final char[] DFA7_min = DFA.unpackEncodedStringToUnsignedChars(DFA7_minS); static final char[] DFA7_max = DFA.unpackEncodedStringToUnsignedChars(DFA7_maxS); static final short[] DFA7_accept = DFA.unpackEncodedString(DFA7_acceptS); static final short[] DFA7_special = DFA.unpackEncodedString(DFA7_specialS); static final short[][] DFA7_transition; static { int numStates = DFA7_transitionS.length; DFA7_transition = new short[numStates][]; for (int i=0; i<numStates; i++) { DFA7_transition[i] = DFA.unpackEncodedString(DFA7_transitionS[i]); } } class DFA7 extends DFA { public DFA7(BaseRecognizer recognizer) { this.recognizer = recognizer; this.decisionNumber = 7; this.eot = DFA7_eot; this.eof = DFA7_eof; this.min = DFA7_min; this.max = DFA7_max; this.accept = DFA7_accept; this.special = DFA7_special; this.transition = DFA7_transition; } public String getDescription() { return "1:1: Tokens : ( T__10 | T__11 | T__12 | T__13 | T__14 | T__15 | T__16 | T__17 | T__18 | T__19 | STRING_LITERAL | ID | WS );"; } } }