3 # Copyright 2007 Google Inc.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
20 from antlr3
.compat
import set, frozenset
23 HIDDEN
= BaseRecognizer
.HIDDEN
65 class GrocLexer(Lexer
):
67 grammarFileName
= "Groc.g"
68 antlr_version
= version_str_to_tuple("3.1.1")
69 antlr_version_str
= "3.1.1"
71 def __init__(self
, input=None, state
=None):
73 state
= RecognizerSharedState()
74 Lexer
.__init
__(self
, input, state
)
76 self
.dfa25
= self
.DFA25(
82 accept
= self
.DFA25_accept
,
83 special
= self
.DFA25_special
,
84 transition
= self
.DFA25_transition
96 _channel
= DEFAULT_CHANNEL
100 LA1
= self
.input.LA(1)
102 LA1_1
= self
.input.LA(2)
106 elif ((48 <= LA1_1
<= 57)) :
109 nvae
= NoViableAltException("", 1, 1, self
.input)
114 LA1_2
= self
.input.LA(2)
118 elif ((48 <= LA1_2
<= 57)) :
121 nvae
= NoViableAltException("", 1, 2, self
.input)
126 LA1_3
= self
.input.LA(2)
128 if ((48 <= LA1_3
<= 51)) :
133 nvae
= NoViableAltException("", 1, 3, self
.input)
137 elif LA1
== 51 or LA1
== 52 or LA1
== 53 or LA1
== 54 or LA1
== 55 or LA1
== 56 or LA1
== 57:
140 nvae
= NoViableAltException("", 1, 0, self
.input)
173 self
.matchRange(48, 51)
182 self
.matchRange(48, 53)
190 self
._state
.type = _type
191 self
._state
.channel
= _channel
204 _channel
= DEFAULT_CHANNEL
208 LA2_0
= self
.input.LA(1)
212 elif (LA2_0
== 102) :
215 nvae
= NoViableAltException("", 2, 0, self
.input)
233 self
._state
.type = _type
234 self
._state
.channel
= _channel
247 _channel
= DEFAULT_CHANNEL
251 LA3_0
= self
.input.LA(1)
255 elif (LA3_0
== 115) :
258 nvae
= NoViableAltException("", 3, 0, self
.input)
276 self
._state
.type = _type
277 self
._state
.channel
= _channel
290 _channel
= DEFAULT_CHANNEL
294 LA4_0
= self
.input.LA(1)
298 elif (LA4_0
== 116) :
301 nvae
= NoViableAltException("", 4, 0, self
.input)
319 self
._state
.type = _type
320 self
._state
.channel
= _channel
333 _channel
= DEFAULT_CHANNEL
344 self
._state
.type = _type
345 self
._state
.channel
= _channel
358 _channel
= DEFAULT_CHANNEL
369 self
._state
.type = _type
370 self
._state
.channel
= _channel
379 def mFOURTH_OR_FIFTH(self
, ):
382 _type
= FOURTH_OR_FIFTH
383 _channel
= DEFAULT_CHANNEL
387 LA5_0
= self
.input.LA(1)
390 LA5_1
= self
.input.LA(2)
394 elif (LA5_1
== 105) :
397 nvae
= NoViableAltException("", 5, 1, self
.input)
402 nvae
= NoViableAltException("", 5, 0, self
.input)
430 self
._state
.type = _type
431 self
._state
.channel
= _channel
444 _channel
= DEFAULT_CHANNEL
451 self
._state
.type = _type
452 self
._state
.channel
= _channel
465 _channel
= DEFAULT_CHANNEL
470 LA6_0
= self
.input.LA(1)
483 self
._state
.type = _type
484 self
._state
.channel
= _channel
493 def mTUESDAY(self
, ):
497 _channel
= DEFAULT_CHANNEL
502 LA7_0
= self
.input.LA(1)
515 self
._state
.type = _type
516 self
._state
.channel
= _channel
525 def mWEDNESDAY(self
, ):
529 _channel
= DEFAULT_CHANNEL
534 LA8_0
= self
.input.LA(1)
547 self
._state
.type = _type
548 self
._state
.channel
= _channel
557 def mTHURSDAY(self
, ):
561 _channel
= DEFAULT_CHANNEL
566 LA9_0
= self
.input.LA(1)
579 self
._state
.type = _type
580 self
._state
.channel
= _channel
593 _channel
= DEFAULT_CHANNEL
598 LA10_0
= self
.input.LA(1)
611 self
._state
.type = _type
612 self
._state
.channel
= _channel
621 def mSATURDAY(self
, ):
625 _channel
= DEFAULT_CHANNEL
630 LA11_0
= self
.input.LA(1)
643 self
._state
.type = _type
644 self
._state
.channel
= _channel
657 _channel
= DEFAULT_CHANNEL
662 LA12_0
= self
.input.LA(1)
675 self
._state
.type = _type
676 self
._state
.channel
= _channel
685 def mJANUARY(self
, ):
689 _channel
= DEFAULT_CHANNEL
694 LA13_0
= self
.input.LA(1)
707 self
._state
.type = _type
708 self
._state
.channel
= _channel
717 def mFEBRUARY(self
, ):
721 _channel
= DEFAULT_CHANNEL
726 LA14_0
= self
.input.LA(1)
739 self
._state
.type = _type
740 self
._state
.channel
= _channel
753 _channel
= DEFAULT_CHANNEL
758 LA15_0
= self
.input.LA(1)
771 self
._state
.type = _type
772 self
._state
.channel
= _channel
785 _channel
= DEFAULT_CHANNEL
790 LA16_0
= self
.input.LA(1)
803 self
._state
.type = _type
804 self
._state
.channel
= _channel
817 _channel
= DEFAULT_CHANNEL
824 self
._state
.type = _type
825 self
._state
.channel
= _channel
838 _channel
= DEFAULT_CHANNEL
843 LA17_0
= self
.input.LA(1)
856 self
._state
.type = _type
857 self
._state
.channel
= _channel
870 _channel
= DEFAULT_CHANNEL
875 LA18_0
= self
.input.LA(1)
888 self
._state
.type = _type
889 self
._state
.channel
= _channel
902 _channel
= DEFAULT_CHANNEL
907 LA19_0
= self
.input.LA(1)
920 self
._state
.type = _type
921 self
._state
.channel
= _channel
930 def mSEPTEMBER(self
, ):
934 _channel
= DEFAULT_CHANNEL
939 LA20_0
= self
.input.LA(1)
952 self
._state
.type = _type
953 self
._state
.channel
= _channel
962 def mOCTOBER(self
, ):
966 _channel
= DEFAULT_CHANNEL
971 LA21_0
= self
.input.LA(1)
984 self
._state
.type = _type
985 self
._state
.channel
= _channel
994 def mNOVEMBER(self
, ):
998 _channel
= DEFAULT_CHANNEL
1003 LA22_0
= self
.input.LA(1)
1005 if (LA22_0
== 101) :
1016 self
._state
.type = _type
1017 self
._state
.channel
= _channel
1026 def mDECEMBER(self
, ):
1030 _channel
= DEFAULT_CHANNEL
1035 LA23_0
= self
.input.LA(1)
1037 if (LA23_0
== 101) :
1048 self
._state
.type = _type
1049 self
._state
.channel
= _channel
1062 _channel
= DEFAULT_CHANNEL
1073 self
._state
.type = _type
1074 self
._state
.channel
= _channel
1083 def mQUARTER(self
, ):
1087 _channel
= DEFAULT_CHANNEL
1091 self
.match("quarter")
1098 self
._state
.type = _type
1099 self
._state
.channel
= _channel
1112 _channel
= DEFAULT_CHANNEL
1123 self
._state
.type = _type
1124 self
._state
.channel
= _channel
1137 _channel
= DEFAULT_CHANNEL
1148 self
._state
.type = _type
1149 self
._state
.channel
= _channel
1158 def mMINUTES(self
, ):
1162 _channel
= DEFAULT_CHANNEL
1166 LA24_0
= self
.input.LA(1)
1168 if (LA24_0
== 109) :
1169 LA24_1
= self
.input.LA(2)
1171 if (LA24_1
== 105) :
1172 LA24_2
= self
.input.LA(3)
1174 if (LA24_2
== 110) :
1175 LA24_3
= self
.input.LA(4)
1177 if (LA24_3
== 115) :
1179 elif (LA24_3
== 117) :
1182 nvae
= NoViableAltException("", 24, 3, self
.input)
1187 nvae
= NoViableAltException("", 24, 2, self
.input)
1192 nvae
= NoViableAltException("", 24, 1, self
.input)
1197 nvae
= NoViableAltException("", 24, 0, self
.input)
1208 self
.match("minutes")
1215 self
._state
.type = _type
1216 self
._state
.channel
= _channel
1229 _channel
= DEFAULT_CHANNEL
1240 self
._state
.type = _type
1241 self
._state
.channel
= _channel
1254 _channel
= DEFAULT_CHANNEL
1265 self
._state
.type = _type
1266 self
._state
.channel
= _channel
1279 _channel
= DEFAULT_CHANNEL
1282 if (9 <= self
.input.LA(1) <= 10) or self
.input.LA(1) == 13 or self
.input.LA(1) == 32:
1283 self
.input.consume()
1285 mse
= MismatchedSetException(None, self
.input)
1293 self
._state
.type = _type
1294 self
._state
.channel
= _channel
1307 _channel
= DEFAULT_CHANNEL
1311 self
.matchRange(48, 57)
1318 self
._state
.type = _type
1319 self
._state
.channel
= _channel
1328 def mDIGITS(self
, ):
1332 _channel
= DEFAULT_CHANNEL
1344 self
._state
.type = _type
1345 self
._state
.channel
= _channel
1356 alt25
= self
.dfa25
.predict(self
.input)
1389 self
.mFOURTH_OR_FIFTH()
1548 DFA25_eot
= DFA
.unpack(
1549 u
"\1\uffff\4\30\2\uffff\1\30\1\uffff\2\30\14\uffff\1\36\3\uffff\2"
1550 u
"\36\33\uffff\1\76\6\uffff"
1553 DFA25_eof
= DFA
.unpack(
1557 DFA25_min
= DFA
.unpack(
1558 u
"\1\11\4\60\1\145\1\141\1\60\1\150\2\60\2\141\1\uffff\1\141\1\160"
1559 u
"\1\143\6\uffff\1\72\3\uffff\2\72\3\uffff\1\146\3\uffff\1\143\3"
1560 u
"\uffff\1\151\4\uffff\1\156\1\162\2\uffff\1\154\6\uffff\1\164\6"
1564 DFA25_max
= DFA
.unpack(
1565 u
"\1\167\1\72\1\163\1\156\2\162\1\165\1\164\1\165\1\164\1\72\1\145"
1566 u
"\1\157\1\uffff\2\165\1\146\6\uffff\1\72\3\uffff\2\72\3\uffff\1"
1567 u
"\162\3\uffff\1\160\3\uffff\1\165\4\uffff\1\156\1\171\2\uffff\1"
1568 u
"\156\6\uffff\1\164\6\uffff"
1571 DFA25_accept
= DFA
.unpack(
1572 u
"\15\uffff\1\13\3\uffff\1\32\1\35\1\36\1\37\1\41\1\43\1\uffff\1"
1573 u
"\44\1\1\1\2\2\uffff\1\3\1\45\1\4\1\uffff\1\7\1\15\1\21\1\uffff"
1574 u
"\1\16\1\17\1\5\1\uffff\1\12\1\6\1\10\1\33\2\uffff\1\40\1\20\1\uffff"
1575 u
"\1\23\1\27\1\31\1\42\1\30\1\14\1\uffff\1\22\1\24\1\25\1\26\1\34"
1579 DFA25_special
= DFA
.unpack(
1584 DFA25_transition
= [
1585 DFA
.unpack(u
"\2\26\2\uffff\1\26\22\uffff\1\26\13\uffff\1\25\3\uffff"
1586 u
"\1\1\1\2\1\3\1\4\1\7\1\11\4\12\47\uffff\1\17\2\uffff\1\13\1\23"
1587 u
"\1\5\1\uffff\1\24\1\uffff\1\16\2\uffff\1\14\1\21\1\20\1\uffff\1"
1588 u
"\22\1\uffff\1\6\1\10\2\uffff\1\15"),
1589 DFA
.unpack(u
"\12\27\1\31"),
1590 DFA
.unpack(u
"\12\33\1\31\70\uffff\1\32"),
1591 DFA
.unpack(u
"\4\34\6\36\1\31\63\uffff\1\35"),
1592 DFA
.unpack(u
"\12\36\1\31\67\uffff\1\37"),
1593 DFA
.unpack(u
"\1\43\3\uffff\1\40\5\uffff\1\41\2\uffff\1\42"),
1594 DFA
.unpack(u
"\1\45\3\uffff\1\44\17\uffff\1\46"),
1595 DFA
.unpack(u
"\12\36\1\31\71\uffff\1\47"),
1596 DFA
.unpack(u
"\1\50\14\uffff\1\51"),
1597 DFA
.unpack(u
"\12\36\1\31\71\uffff\1\52"),
1598 DFA
.unpack(u
"\12\36\1\31"),
1599 DFA
.unpack(u
"\1\53\3\uffff\1\54"),
1600 DFA
.unpack(u
"\1\56\7\uffff\1\57\5\uffff\1\55"),
1602 DFA
.unpack(u
"\1\60\23\uffff\1\61"),
1603 DFA
.unpack(u
"\1\62\4\uffff\1\63"),
1604 DFA
.unpack(u
"\1\64\2\uffff\1\65"),
1611 DFA
.unpack(u
"\1\31"),
1615 DFA
.unpack(u
"\1\31"),
1616 DFA
.unpack(u
"\1\31"),
1620 DFA
.unpack(u
"\1\41\13\uffff\1\32"),
1624 DFA
.unpack(u
"\1\35\14\uffff\1\66"),
1628 DFA
.unpack(u
"\1\37\13\uffff\1\67"),
1633 DFA
.unpack(u
"\1\70"),
1634 DFA
.unpack(u
"\1\71\6\uffff\1\72"),
1637 DFA
.unpack(u
"\1\74\1\uffff\1\73"),
1644 DFA
.unpack(u
"\1\75"),
1659 def main(argv
, stdin
=sys
.stdin
, stdout
=sys
.stdout
, stderr
=sys
.stderr
):
1660 from antlr3
.main
import LexerMain
1661 main
= LexerMain(GrocLexer
)
1663 main
.stdout
= stdout
1664 main
.stderr
= stderr
1668 if __name__
== '__main__':