thirdparty/google_appengine/google/appengine/cron/GrocParser.py
changeset 828 f5fd65cc3bf3
child 2309 be1b94099f2d
equal deleted inserted replaced
827:88c186556a80 828:f5fd65cc3bf3
       
     1 #!/usr/bin/env python
       
     2 #
       
     3 # Copyright 2007 Google Inc.
       
     4 #
       
     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
       
     8 #
       
     9 #     http://www.apache.org/licenses/LICENSE-2.0
       
    10 #
       
    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.
       
    16 #
       
    17 
       
    18 import sys
       
    19 from antlr3 import *
       
    20 from antlr3.compat import set, frozenset
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 allOrdinals = set([1, 2, 3, 4, 5])
       
    27 numOrdinals = len(allOrdinals)
       
    28 
       
    29 
       
    30 
       
    31 
       
    32 HIDDEN = BaseRecognizer.HIDDEN
       
    33 
       
    34 THIRD=12
       
    35 SEPTEMBER=34
       
    36 FOURTH=13
       
    37 SECOND=11
       
    38 WEDNESDAY=20
       
    39 NOVEMBER=36
       
    40 SATURDAY=23
       
    41 JULY=32
       
    42 APRIL=29
       
    43 DIGITS=8
       
    44 OCTOBER=35
       
    45 MAY=30
       
    46 EVERY=6
       
    47 FEBRUARY=27
       
    48 MONDAY=18
       
    49 SUNDAY=24
       
    50 JUNE=31
       
    51 MARCH=28
       
    52 OF=4
       
    53 EOF=-1
       
    54 JANUARY=26
       
    55 MONTH=25
       
    56 FRIDAY=22
       
    57 FIFTH=14
       
    58 MINUTES=17
       
    59 TIME=5
       
    60 WS=39
       
    61 QUARTER=38
       
    62 THURSDAY=21
       
    63 COMMA=9
       
    64 DECEMBER=37
       
    65 AUGUST=33
       
    66 DIGIT=7
       
    67 TUESDAY=19
       
    68 HOURS=16
       
    69 FIRST=10
       
    70 FOURTH_OR_FIFTH=15
       
    71 
       
    72 tokenNames = [
       
    73     "<invalid>", "<EOR>", "<DOWN>", "<UP>",
       
    74     "OF", "TIME", "EVERY", "DIGIT", "DIGITS", "COMMA", "FIRST", "SECOND",
       
    75     "THIRD", "FOURTH", "FIFTH", "FOURTH_OR_FIFTH", "HOURS", "MINUTES", "MONDAY",
       
    76     "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY",
       
    77     "MONTH", "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY",
       
    78     "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER", "QUARTER",
       
    79     "WS"
       
    80 ]
       
    81 
       
    82 
       
    83 
       
    84 
       
    85 class GrocParser(Parser):
       
    86     grammarFileName = "Groc.g"
       
    87     antlr_version = version_str_to_tuple("3.1.1")
       
    88     antlr_version_str = "3.1.1"
       
    89     tokenNames = tokenNames
       
    90 
       
    91     def __init__(self, input, state=None):
       
    92         if state is None:
       
    93             state = RecognizerSharedState()
       
    94 
       
    95         Parser.__init__(self, input, state)
       
    96 
       
    97 
       
    98 
       
    99 
       
   100 
       
   101         self.ordinal_set = set()
       
   102         self.weekday_set = set()
       
   103         self.month_set = set()
       
   104         self.time_string = '';
       
   105         self.interval_mins = 0;
       
   106         self.period_string = '';
       
   107 
       
   108 
       
   109 
       
   110 
       
   111 
       
   112 
       
   113 
       
   114 
       
   115 
       
   116 
       
   117     valuesDict = {
       
   118         SUNDAY: 0,
       
   119         FIRST: 1,
       
   120         MONDAY: 1,
       
   121         JANUARY: 1,
       
   122         TUESDAY: 2,
       
   123         SECOND: 2,
       
   124         FEBRUARY: 2,
       
   125         WEDNESDAY: 3,
       
   126         THIRD: 3,
       
   127         MARCH: 3,
       
   128         THURSDAY: 4,
       
   129         FOURTH: 4,
       
   130         APRIL: 4,
       
   131         FRIDAY: 5,
       
   132         FIFTH: 5,
       
   133         MAY: 5,
       
   134         SATURDAY: 6,
       
   135         JUNE: 6,
       
   136         JULY: 7,
       
   137         AUGUST: 8,
       
   138         SEPTEMBER: 9,
       
   139         OCTOBER: 10,
       
   140         NOVEMBER: 11,
       
   141         DECEMBER: 12,
       
   142       }
       
   143 
       
   144     def ValueOf(self, token_type):
       
   145       return self.valuesDict.get(token_type, -1)
       
   146 
       
   147 
       
   148 
       
   149 
       
   150     def timespec(self, ):
       
   151 
       
   152         try:
       
   153             try:
       
   154                 pass
       
   155                 alt1 = 2
       
   156                 LA1_0 = self.input.LA(1)
       
   157 
       
   158                 if (LA1_0 == EVERY) :
       
   159                     LA1_1 = self.input.LA(2)
       
   160 
       
   161                     if ((DIGIT <= LA1_1 <= DIGITS)) :
       
   162                         alt1 = 2
       
   163                     elif ((MONDAY <= LA1_1 <= SUNDAY)) :
       
   164                         alt1 = 1
       
   165                     else:
       
   166                         nvae = NoViableAltException("", 1, 1, self.input)
       
   167 
       
   168                         raise nvae
       
   169 
       
   170                 elif ((FIRST <= LA1_0 <= FOURTH_OR_FIFTH)) :
       
   171                     alt1 = 1
       
   172                 else:
       
   173                     nvae = NoViableAltException("", 1, 0, self.input)
       
   174 
       
   175                     raise nvae
       
   176 
       
   177                 if alt1 == 1:
       
   178                     pass
       
   179                     self._state.following.append(self.FOLLOW_specifictime_in_timespec44)
       
   180                     self.specifictime()
       
   181 
       
   182                     self._state.following.pop()
       
   183 
       
   184 
       
   185                 elif alt1 == 2:
       
   186                     pass
       
   187                     self._state.following.append(self.FOLLOW_interval_in_timespec48)
       
   188                     self.interval()
       
   189 
       
   190                     self._state.following.pop()
       
   191 
       
   192 
       
   193 
       
   194 
       
   195 
       
   196 
       
   197 
       
   198             except RecognitionException, re:
       
   199                 self.reportError(re)
       
   200                 self.recover(self.input, re)
       
   201         finally:
       
   202 
       
   203             pass
       
   204 
       
   205         return
       
   206 
       
   207 
       
   208 
       
   209     def specifictime(self, ):
       
   210 
       
   211         TIME1 = None
       
   212 
       
   213         try:
       
   214             try:
       
   215                 pass
       
   216                 pass
       
   217                 pass
       
   218                 pass
       
   219                 pass
       
   220                 self._state.following.append(self.FOLLOW_ordinals_in_specifictime69)
       
   221                 self.ordinals()
       
   222 
       
   223                 self._state.following.pop()
       
   224                 self._state.following.append(self.FOLLOW_weekdays_in_specifictime71)
       
   225                 self.weekdays()
       
   226 
       
   227                 self._state.following.pop()
       
   228 
       
   229 
       
   230 
       
   231 
       
   232 
       
   233 
       
   234                 self.match(self.input, OF, self.FOLLOW_OF_in_specifictime75)
       
   235                 alt2 = 2
       
   236                 LA2_0 = self.input.LA(1)
       
   237 
       
   238                 if ((MONTH <= LA2_0 <= DECEMBER)) :
       
   239                     alt2 = 1
       
   240                 elif ((FIRST <= LA2_0 <= THIRD) or LA2_0 == QUARTER) :
       
   241                     alt2 = 2
       
   242                 else:
       
   243                     nvae = NoViableAltException("", 2, 0, self.input)
       
   244 
       
   245                     raise nvae
       
   246 
       
   247                 if alt2 == 1:
       
   248                     pass
       
   249                     self._state.following.append(self.FOLLOW_monthspec_in_specifictime78)
       
   250                     self.monthspec()
       
   251 
       
   252                     self._state.following.pop()
       
   253 
       
   254 
       
   255                 elif alt2 == 2:
       
   256                     pass
       
   257                     self._state.following.append(self.FOLLOW_quarterspec_in_specifictime80)
       
   258                     self.quarterspec()
       
   259 
       
   260                     self._state.following.pop()
       
   261 
       
   262 
       
   263 
       
   264 
       
   265 
       
   266 
       
   267                 TIME1=self.match(self.input, TIME, self.FOLLOW_TIME_in_specifictime93)
       
   268                 self.time_string = TIME1.text
       
   269 
       
   270 
       
   271 
       
   272 
       
   273 
       
   274 
       
   275 
       
   276             except RecognitionException, re:
       
   277                 self.reportError(re)
       
   278                 self.recover(self.input, re)
       
   279         finally:
       
   280 
       
   281             pass
       
   282 
       
   283         return
       
   284 
       
   285 
       
   286 
       
   287     def interval(self, ):
       
   288 
       
   289         intervalnum = None
       
   290         period2 = None
       
   291 
       
   292 
       
   293         try:
       
   294             try:
       
   295                 pass
       
   296                 pass
       
   297                 self.match(self.input, EVERY, self.FOLLOW_EVERY_in_interval112)
       
   298                 intervalnum = self.input.LT(1)
       
   299                 if (DIGIT <= self.input.LA(1) <= DIGITS):
       
   300                     self.input.consume()
       
   301                     self._state.errorRecovery = False
       
   302 
       
   303                 else:
       
   304                     mse = MismatchedSetException(None, self.input)
       
   305                     raise mse
       
   306 
       
   307 
       
   308 
       
   309                 self.interval_mins = int(intervalnum.text)
       
   310 
       
   311                 self._state.following.append(self.FOLLOW_period_in_interval138)
       
   312                 period2 = self.period()
       
   313 
       
   314                 self._state.following.pop()
       
   315 
       
   316                 if ((period2 is not None) and [self.input.toString(period2.start,period2.stop)] or [None])[0] == "hours":
       
   317                   self.period_string = "hours"
       
   318                 else:
       
   319                   self.period_string = "minutes"
       
   320 
       
   321 
       
   322 
       
   323 
       
   324 
       
   325 
       
   326 
       
   327 
       
   328             except RecognitionException, re:
       
   329                 self.reportError(re)
       
   330                 self.recover(self.input, re)
       
   331         finally:
       
   332 
       
   333             pass
       
   334 
       
   335         return
       
   336 
       
   337 
       
   338 
       
   339     def ordinals(self, ):
       
   340 
       
   341         try:
       
   342             try:
       
   343                 pass
       
   344                 alt4 = 2
       
   345                 LA4_0 = self.input.LA(1)
       
   346 
       
   347                 if (LA4_0 == EVERY) :
       
   348                     alt4 = 1
       
   349                 elif ((FIRST <= LA4_0 <= FOURTH_OR_FIFTH)) :
       
   350                     alt4 = 2
       
   351                 else:
       
   352                     nvae = NoViableAltException("", 4, 0, self.input)
       
   353 
       
   354                     raise nvae
       
   355 
       
   356                 if alt4 == 1:
       
   357                     pass
       
   358                     self.match(self.input, EVERY, self.FOLLOW_EVERY_in_ordinals157)
       
   359                     self.ordinal_set = self.ordinal_set.union(allOrdinals)
       
   360 
       
   361 
       
   362                 elif alt4 == 2:
       
   363                     pass
       
   364                     pass
       
   365                     self._state.following.append(self.FOLLOW_ordinal_in_ordinals173)
       
   366                     self.ordinal()
       
   367 
       
   368                     self._state.following.pop()
       
   369                     while True:
       
   370                         alt3 = 2
       
   371                         LA3_0 = self.input.LA(1)
       
   372 
       
   373                         if (LA3_0 == COMMA) :
       
   374                             alt3 = 1
       
   375 
       
   376 
       
   377                         if alt3 == 1:
       
   378                             pass
       
   379                             self.match(self.input, COMMA, self.FOLLOW_COMMA_in_ordinals176)
       
   380                             self._state.following.append(self.FOLLOW_ordinal_in_ordinals178)
       
   381                             self.ordinal()
       
   382 
       
   383                             self._state.following.pop()
       
   384 
       
   385 
       
   386                         else:
       
   387                             break
       
   388 
       
   389 
       
   390 
       
   391 
       
   392 
       
   393 
       
   394 
       
   395 
       
   396 
       
   397 
       
   398 
       
   399 
       
   400             except RecognitionException, re:
       
   401                 self.reportError(re)
       
   402                 self.recover(self.input, re)
       
   403         finally:
       
   404 
       
   405             pass
       
   406 
       
   407         return
       
   408 
       
   409 
       
   410 
       
   411     def ordinal(self, ):
       
   412 
       
   413         ord = None
       
   414 
       
   415         try:
       
   416             try:
       
   417                 pass
       
   418                 ord = self.input.LT(1)
       
   419                 if (FIRST <= self.input.LA(1) <= FOURTH_OR_FIFTH):
       
   420                     self.input.consume()
       
   421                     self._state.errorRecovery = False
       
   422 
       
   423                 else:
       
   424                     mse = MismatchedSetException(None, self.input)
       
   425                     raise mse
       
   426 
       
   427 
       
   428 
       
   429                 self.ordinal_set.add(self.ValueOf(ord.type));
       
   430 
       
   431 
       
   432 
       
   433 
       
   434 
       
   435             except RecognitionException, re:
       
   436                 self.reportError(re)
       
   437                 self.recover(self.input, re)
       
   438         finally:
       
   439 
       
   440             pass
       
   441 
       
   442         return
       
   443 
       
   444 
       
   445     class period_return(ParserRuleReturnScope):
       
   446         def __init__(self):
       
   447             ParserRuleReturnScope.__init__(self)
       
   448 
       
   449 
       
   450 
       
   451 
       
   452 
       
   453     def period(self, ):
       
   454 
       
   455         retval = self.period_return()
       
   456         retval.start = self.input.LT(1)
       
   457 
       
   458         try:
       
   459             try:
       
   460                 pass
       
   461                 if (HOURS <= self.input.LA(1) <= MINUTES):
       
   462                     self.input.consume()
       
   463                     self._state.errorRecovery = False
       
   464 
       
   465                 else:
       
   466                     mse = MismatchedSetException(None, self.input)
       
   467                     raise mse
       
   468 
       
   469 
       
   470 
       
   471 
       
   472 
       
   473                 retval.stop = self.input.LT(-1)
       
   474 
       
   475 
       
   476             except RecognitionException, re:
       
   477                 self.reportError(re)
       
   478                 self.recover(self.input, re)
       
   479         finally:
       
   480 
       
   481             pass
       
   482 
       
   483         return retval
       
   484 
       
   485 
       
   486 
       
   487     def weekdays(self, ):
       
   488 
       
   489         try:
       
   490             try:
       
   491                 pass
       
   492                 pass
       
   493                 self._state.following.append(self.FOLLOW_weekday_in_weekdays261)
       
   494                 self.weekday()
       
   495 
       
   496                 self._state.following.pop()
       
   497                 while True:
       
   498                     alt5 = 2
       
   499                     LA5_0 = self.input.LA(1)
       
   500 
       
   501                     if (LA5_0 == COMMA) :
       
   502                         alt5 = 1
       
   503 
       
   504 
       
   505                     if alt5 == 1:
       
   506                         pass
       
   507                         self.match(self.input, COMMA, self.FOLLOW_COMMA_in_weekdays264)
       
   508                         self._state.following.append(self.FOLLOW_weekday_in_weekdays266)
       
   509                         self.weekday()
       
   510 
       
   511                         self._state.following.pop()
       
   512 
       
   513 
       
   514                     else:
       
   515                         break
       
   516 
       
   517 
       
   518 
       
   519 
       
   520 
       
   521 
       
   522 
       
   523 
       
   524 
       
   525             except RecognitionException, re:
       
   526                 self.reportError(re)
       
   527                 self.recover(self.input, re)
       
   528         finally:
       
   529 
       
   530             pass
       
   531 
       
   532         return
       
   533 
       
   534 
       
   535 
       
   536     def weekday(self, ):
       
   537 
       
   538         dayname = None
       
   539 
       
   540         try:
       
   541             try:
       
   542                 pass
       
   543                 dayname = self.input.LT(1)
       
   544                 if (MONDAY <= self.input.LA(1) <= SUNDAY):
       
   545                     self.input.consume()
       
   546                     self._state.errorRecovery = False
       
   547 
       
   548                 else:
       
   549                     mse = MismatchedSetException(None, self.input)
       
   550                     raise mse
       
   551 
       
   552 
       
   553 
       
   554                 self.weekday_set.add(self.ValueOf(dayname.type))
       
   555 
       
   556 
       
   557 
       
   558 
       
   559 
       
   560             except RecognitionException, re:
       
   561                 self.reportError(re)
       
   562                 self.recover(self.input, re)
       
   563         finally:
       
   564 
       
   565             pass
       
   566 
       
   567         return
       
   568 
       
   569 
       
   570 
       
   571     def monthspec(self, ):
       
   572 
       
   573         try:
       
   574             try:
       
   575                 pass
       
   576                 alt6 = 2
       
   577                 LA6_0 = self.input.LA(1)
       
   578 
       
   579                 if (LA6_0 == MONTH) :
       
   580                     alt6 = 1
       
   581                 elif ((JANUARY <= LA6_0 <= DECEMBER)) :
       
   582                     alt6 = 2
       
   583                 else:
       
   584                     nvae = NoViableAltException("", 6, 0, self.input)
       
   585 
       
   586                     raise nvae
       
   587 
       
   588                 if alt6 == 1:
       
   589                     pass
       
   590                     self.match(self.input, MONTH, self.FOLLOW_MONTH_in_monthspec344)
       
   591 
       
   592                     self.month_set = self.month_set.union(set([
       
   593                         self.ValueOf(JANUARY), self.ValueOf(FEBRUARY), self.ValueOf(MARCH),
       
   594                         self.ValueOf(APRIL), self.ValueOf(MAY), self.ValueOf(JUNE),
       
   595                         self.ValueOf(JULY), self.ValueOf(AUGUST), self.ValueOf(SEPTEMBER),
       
   596                         self.ValueOf(OCTOBER), self.ValueOf(NOVEMBER),
       
   597                         self.ValueOf(DECEMBER)]))
       
   598 
       
   599 
       
   600 
       
   601                 elif alt6 == 2:
       
   602                     pass
       
   603                     self._state.following.append(self.FOLLOW_months_in_monthspec354)
       
   604                     self.months()
       
   605 
       
   606                     self._state.following.pop()
       
   607 
       
   608 
       
   609 
       
   610 
       
   611 
       
   612 
       
   613 
       
   614             except RecognitionException, re:
       
   615                 self.reportError(re)
       
   616                 self.recover(self.input, re)
       
   617         finally:
       
   618 
       
   619             pass
       
   620 
       
   621         return
       
   622 
       
   623 
       
   624 
       
   625     def months(self, ):
       
   626 
       
   627         try:
       
   628             try:
       
   629                 pass
       
   630                 pass
       
   631                 self._state.following.append(self.FOLLOW_month_in_months371)
       
   632                 self.month()
       
   633 
       
   634                 self._state.following.pop()
       
   635                 while True:
       
   636                     alt7 = 2
       
   637                     LA7_0 = self.input.LA(1)
       
   638 
       
   639                     if (LA7_0 == COMMA) :
       
   640                         alt7 = 1
       
   641 
       
   642 
       
   643                     if alt7 == 1:
       
   644                         pass
       
   645                         self.match(self.input, COMMA, self.FOLLOW_COMMA_in_months374)
       
   646                         self._state.following.append(self.FOLLOW_month_in_months376)
       
   647                         self.month()
       
   648 
       
   649                         self._state.following.pop()
       
   650 
       
   651 
       
   652                     else:
       
   653                         break
       
   654 
       
   655 
       
   656 
       
   657 
       
   658 
       
   659 
       
   660 
       
   661 
       
   662 
       
   663             except RecognitionException, re:
       
   664                 self.reportError(re)
       
   665                 self.recover(self.input, re)
       
   666         finally:
       
   667 
       
   668             pass
       
   669 
       
   670         return
       
   671 
       
   672 
       
   673 
       
   674     def month(self, ):
       
   675 
       
   676         monthname = None
       
   677 
       
   678         try:
       
   679             try:
       
   680                 pass
       
   681                 monthname = self.input.LT(1)
       
   682                 if (JANUARY <= self.input.LA(1) <= DECEMBER):
       
   683                     self.input.consume()
       
   684                     self._state.errorRecovery = False
       
   685 
       
   686                 else:
       
   687                     mse = MismatchedSetException(None, self.input)
       
   688                     raise mse
       
   689 
       
   690 
       
   691                 self.month_set.add(self.ValueOf(monthname.type));
       
   692 
       
   693 
       
   694 
       
   695 
       
   696             except RecognitionException, re:
       
   697                 self.reportError(re)
       
   698                 self.recover(self.input, re)
       
   699         finally:
       
   700 
       
   701             pass
       
   702 
       
   703         return
       
   704 
       
   705 
       
   706 
       
   707     def quarterspec(self, ):
       
   708 
       
   709         try:
       
   710             try:
       
   711                 pass
       
   712                 alt8 = 2
       
   713                 LA8_0 = self.input.LA(1)
       
   714 
       
   715                 if (LA8_0 == QUARTER) :
       
   716                     alt8 = 1
       
   717                 elif ((FIRST <= LA8_0 <= THIRD)) :
       
   718                     alt8 = 2
       
   719                 else:
       
   720                     nvae = NoViableAltException("", 8, 0, self.input)
       
   721 
       
   722                     raise nvae
       
   723 
       
   724                 if alt8 == 1:
       
   725                     pass
       
   726                     self.match(self.input, QUARTER, self.FOLLOW_QUARTER_in_quarterspec468)
       
   727 
       
   728                     self.month_set = self.month_set.union(set([
       
   729                         self.ValueOf(JANUARY), self.ValueOf(APRIL), self.ValueOf(JULY),
       
   730                         self.ValueOf(OCTOBER)]))
       
   731 
       
   732 
       
   733                 elif alt8 == 2:
       
   734                     pass
       
   735                     pass
       
   736                     self._state.following.append(self.FOLLOW_quarter_ordinals_in_quarterspec480)
       
   737                     self.quarter_ordinals()
       
   738 
       
   739                     self._state.following.pop()
       
   740                     self.match(self.input, MONTH, self.FOLLOW_MONTH_in_quarterspec482)
       
   741                     self.match(self.input, OF, self.FOLLOW_OF_in_quarterspec484)
       
   742                     self.match(self.input, QUARTER, self.FOLLOW_QUARTER_in_quarterspec486)
       
   743 
       
   744 
       
   745 
       
   746 
       
   747 
       
   748 
       
   749 
       
   750 
       
   751 
       
   752 
       
   753             except RecognitionException, re:
       
   754                 self.reportError(re)
       
   755                 self.recover(self.input, re)
       
   756         finally:
       
   757 
       
   758             pass
       
   759 
       
   760         return
       
   761 
       
   762 
       
   763 
       
   764     def quarter_ordinals(self, ):
       
   765 
       
   766         try:
       
   767             try:
       
   768                 pass
       
   769                 pass
       
   770                 self._state.following.append(self.FOLLOW_month_of_quarter_ordinal_in_quarter_ordinals505)
       
   771                 self.month_of_quarter_ordinal()
       
   772 
       
   773                 self._state.following.pop()
       
   774                 while True:
       
   775                     alt9 = 2
       
   776                     LA9_0 = self.input.LA(1)
       
   777 
       
   778                     if (LA9_0 == COMMA) :
       
   779                         alt9 = 1
       
   780 
       
   781 
       
   782                     if alt9 == 1:
       
   783                         pass
       
   784                         self.match(self.input, COMMA, self.FOLLOW_COMMA_in_quarter_ordinals508)
       
   785                         self._state.following.append(self.FOLLOW_month_of_quarter_ordinal_in_quarter_ordinals510)
       
   786                         self.month_of_quarter_ordinal()
       
   787 
       
   788                         self._state.following.pop()
       
   789 
       
   790 
       
   791                     else:
       
   792                         break
       
   793 
       
   794 
       
   795 
       
   796 
       
   797 
       
   798 
       
   799 
       
   800 
       
   801 
       
   802             except RecognitionException, re:
       
   803                 self.reportError(re)
       
   804                 self.recover(self.input, re)
       
   805         finally:
       
   806 
       
   807             pass
       
   808 
       
   809         return
       
   810 
       
   811 
       
   812 
       
   813     def month_of_quarter_ordinal(self, ):
       
   814 
       
   815         offset = None
       
   816 
       
   817         try:
       
   818             try:
       
   819                 pass
       
   820                 offset = self.input.LT(1)
       
   821                 if (FIRST <= self.input.LA(1) <= THIRD):
       
   822                     self.input.consume()
       
   823                     self._state.errorRecovery = False
       
   824 
       
   825                 else:
       
   826                     mse = MismatchedSetException(None, self.input)
       
   827                     raise mse
       
   828 
       
   829 
       
   830 
       
   831                 jOffset = self.ValueOf(offset.type) - 1
       
   832                 self.month_set = self.month_set.union(set([
       
   833                     jOffset + self.ValueOf(JANUARY), jOffset + self.ValueOf(APRIL),
       
   834                     jOffset + self.ValueOf(JULY), jOffset + self.ValueOf(OCTOBER)]))
       
   835 
       
   836 
       
   837 
       
   838 
       
   839             except RecognitionException, re:
       
   840                 self.reportError(re)
       
   841                 self.recover(self.input, re)
       
   842         finally:
       
   843 
       
   844             pass
       
   845 
       
   846         return
       
   847 
       
   848 
       
   849 
       
   850 
       
   851 
       
   852 
       
   853 
       
   854     FOLLOW_specifictime_in_timespec44 = frozenset([1])
       
   855     FOLLOW_interval_in_timespec48 = frozenset([1])
       
   856     FOLLOW_ordinals_in_specifictime69 = frozenset([18, 19, 20, 21, 22, 23, 24])
       
   857     FOLLOW_weekdays_in_specifictime71 = frozenset([4])
       
   858     FOLLOW_OF_in_specifictime75 = frozenset([10, 11, 12, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38])
       
   859     FOLLOW_monthspec_in_specifictime78 = frozenset([5])
       
   860     FOLLOW_quarterspec_in_specifictime80 = frozenset([5])
       
   861     FOLLOW_TIME_in_specifictime93 = frozenset([1])
       
   862     FOLLOW_EVERY_in_interval112 = frozenset([7, 8])
       
   863     FOLLOW_set_in_interval122 = frozenset([16, 17])
       
   864     FOLLOW_period_in_interval138 = frozenset([1])
       
   865     FOLLOW_EVERY_in_ordinals157 = frozenset([1])
       
   866     FOLLOW_ordinal_in_ordinals173 = frozenset([1, 9])
       
   867     FOLLOW_COMMA_in_ordinals176 = frozenset([10, 11, 12, 13, 14, 15])
       
   868     FOLLOW_ordinal_in_ordinals178 = frozenset([1, 9])
       
   869     FOLLOW_set_in_ordinal199 = frozenset([1])
       
   870     FOLLOW_set_in_period238 = frozenset([1])
       
   871     FOLLOW_weekday_in_weekdays261 = frozenset([1, 9])
       
   872     FOLLOW_COMMA_in_weekdays264 = frozenset([18, 19, 20, 21, 22, 23, 24])
       
   873     FOLLOW_weekday_in_weekdays266 = frozenset([1, 9])
       
   874     FOLLOW_set_in_weekday285 = frozenset([1])
       
   875     FOLLOW_MONTH_in_monthspec344 = frozenset([1])
       
   876     FOLLOW_months_in_monthspec354 = frozenset([1])
       
   877     FOLLOW_month_in_months371 = frozenset([1, 9])
       
   878     FOLLOW_COMMA_in_months374 = frozenset([25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37])
       
   879     FOLLOW_month_in_months376 = frozenset([1, 9])
       
   880     FOLLOW_set_in_month395 = frozenset([1])
       
   881     FOLLOW_QUARTER_in_quarterspec468 = frozenset([1])
       
   882     FOLLOW_quarter_ordinals_in_quarterspec480 = frozenset([25])
       
   883     FOLLOW_MONTH_in_quarterspec482 = frozenset([4])
       
   884     FOLLOW_OF_in_quarterspec484 = frozenset([38])
       
   885     FOLLOW_QUARTER_in_quarterspec486 = frozenset([1])
       
   886     FOLLOW_month_of_quarter_ordinal_in_quarter_ordinals505 = frozenset([1, 9])
       
   887     FOLLOW_COMMA_in_quarter_ordinals508 = frozenset([10, 11, 12, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38])
       
   888     FOLLOW_month_of_quarter_ordinal_in_quarter_ordinals510 = frozenset([1, 9])
       
   889     FOLLOW_set_in_month_of_quarter_ordinal529 = frozenset([1])
       
   890 
       
   891 
       
   892 
       
   893 def main(argv, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr):
       
   894     from antlr3.main import ParserMain
       
   895     main = ParserMain("GrocLexer", GrocParser)
       
   896     main.stdin = stdin
       
   897     main.stdout = stdout
       
   898     main.stderr = stderr
       
   899     main.execute(argv)
       
   900 
       
   901 
       
   902 if __name__ == '__main__':
       
   903     main(sys.argv)