@Test public void shouldPass6() throws RecognitionException, TokenStreamException { String date =" 1991 - 1992 "; DatesParser p = new DatesParser(new DateLexer(new StringReader(date))); Date parsed = p.dates(); Assert.assertTrue("expecting year 1992 ",field(parsed,Calendar.YEAR) == 1992); }
public final Date dates() throws RecognitionException, TokenStreamException { Date d; d=null; Date rd=null,dd=null,rm=null,m=null; int ry=0,y=0; boolean synPredMatched3 = false; if (((LA(1)==DIGIT))) { int _m3 = mark(); synPredMatched3 = true; inputState.guessing++; try { { rangeday(); } } catch (RecognitionException pe) { synPredMatched3 = false; } rewind(_m3); inputState.guessing--; } if ( synPredMatched3 ) { rd=rangeday(); if ( inputState.guessing==0 ) { d=rd; } } else { boolean synPredMatched5 = false; if (((LA(1)==DIGIT))) { int _m5 = mark(); synPredMatched5 = true; inputState.guessing++; try { { day(); } } catch (RecognitionException pe) { synPredMatched5 = false; } rewind(_m5); inputState.guessing--; } if ( synPredMatched5 ) { dd=day(); if ( inputState.guessing==0 ) { d=dd; } } else { boolean synPredMatched7 = false; if (((LA(1)==DIGIT))) { int _m7 = mark(); synPredMatched7 = true; inputState.guessing++; try { { rangemonth(); } } catch (RecognitionException pe) { synPredMatched7 = false; } rewind(_m7); inputState.guessing--; } if ( synPredMatched7 ) { rm=rangemonth(); if ( inputState.guessing==0 ) { d=rm; } } else { boolean synPredMatched9 = false; if (((LA(1)==DIGIT))) { int _m9 = mark(); synPredMatched9 = true; inputState.guessing++; try { { month(); } } catch (RecognitionException pe) { synPredMatched9 = false; } rewind(_m9); inputState.guessing--; } if ( synPredMatched9 ) { m=month(); if ( inputState.guessing==0 ) { d = m; } } else { boolean synPredMatched11 = false; if (((LA(1)==DIGIT))) { int _m11 = mark(); synPredMatched11 = true; inputState.guessing++; try { { rangeyear(); } } catch (RecognitionException pe) { synPredMatched11 = false; } rewind(_m11); inputState.guessing--; } if ( synPredMatched11 ) { ry=rangeyear(); if ( inputState.guessing==0 ) { d=yearToDate(ry); } } else if ((LA(1)==DIGIT)) { y=year(); if ( inputState.guessing==0 ) { d=yearToDate(y); } match(Token.EOF_TYPE); } else { throw new NoViableAltException(LT(1), getFilename()); } }}}} return d; }
DatesParser extends antlr.LLkParser implements DatesParserTokenTypes { public final Date dates() throws RecognitionException, TokenStreamException { Date d; d=null; Date rd=null,dd=null,rm=null,m=null; int ry=0,y=0; boolean synPredMatched3 = false; if (((LA(1)==DIGIT))) { int _m3 = mark(); synPredMatched3 = true; inputState.guessing++; try { { rangeday(); } } catch (RecognitionException pe) { synPredMatched3 = false; } rewind(_m3); inputState.guessing--; } if ( synPredMatched3 ) { rd=rangeday(); if ( inputState.guessing==0 ) { d=rd; } } else { boolean synPredMatched5 = false; if (((LA(1)==DIGIT))) { int _m5 = mark(); synPredMatched5 = true; inputState.guessing++; try { { day(); } } catch (RecognitionException pe) { synPredMatched5 = false; } rewind(_m5); inputState.guessing--; } if ( synPredMatched5 ) { dd=day(); if ( inputState.guessing==0 ) { d=dd; } } else { boolean synPredMatched7 = false; if (((LA(1)==DIGIT))) { int _m7 = mark(); synPredMatched7 = true; inputState.guessing++; try { { rangemonth(); } } catch (RecognitionException pe) { synPredMatched7 = false; } rewind(_m7); inputState.guessing--; } if ( synPredMatched7 ) { rm=rangemonth(); if ( inputState.guessing==0 ) { d=rm; } } else { boolean synPredMatched9 = false; if (((LA(1)==DIGIT))) { int _m9 = mark(); synPredMatched9 = true; inputState.guessing++; try { { month(); } } catch (RecognitionException pe) { synPredMatched9 = false; } rewind(_m9); inputState.guessing--; } if ( synPredMatched9 ) { m=month(); if ( inputState.guessing==0 ) { d = m; } } else { boolean synPredMatched11 = false; if (((LA(1)==DIGIT))) { int _m11 = mark(); synPredMatched11 = true; inputState.guessing++; try { { rangeyear(); } } catch (RecognitionException pe) { synPredMatched11 = false; } rewind(_m11); inputState.guessing--; } if ( synPredMatched11 ) { ry=rangeyear(); if ( inputState.guessing==0 ) { d=yearToDate(ry); } } else if ((LA(1)==DIGIT)) { y=year(); if ( inputState.guessing==0 ) { d=yearToDate(y); } match(Token.EOF_TYPE); } else { throw new NoViableAltException(LT(1), getFilename()); } }}}} return d; } }
DatesParser extends antlr.LLkParser implements DatesParserTokenTypes { public final Date dates() throws RecognitionException, TokenStreamException { Date d; d=null; Date rd=null,dd=null,rm=null,m=null; int ry=0,y=0; boolean synPredMatched3 = false; if (((LA(1)==DIGIT))) { int _m3 = mark(); synPredMatched3 = true; inputState.guessing++; try { { rangeday(); } } catch (RecognitionException pe) { synPredMatched3 = false; } rewind(_m3); inputState.guessing--; } if ( synPredMatched3 ) { rd=rangeday(); if ( inputState.guessing==0 ) { d=rd; } } else { boolean synPredMatched5 = false; if (((LA(1)==DIGIT))) { int _m5 = mark(); synPredMatched5 = true; inputState.guessing++; try { { day(); } } catch (RecognitionException pe) { synPredMatched5 = false; } rewind(_m5); inputState.guessing--; } if ( synPredMatched5 ) { dd=day(); if ( inputState.guessing==0 ) { d=dd; } } else { boolean synPredMatched7 = false; if (((LA(1)==DIGIT))) { int _m7 = mark(); synPredMatched7 = true; inputState.guessing++; try { { rangemonth(); } } catch (RecognitionException pe) { synPredMatched7 = false; } rewind(_m7); inputState.guessing--; } if ( synPredMatched7 ) { rm=rangemonth(); if ( inputState.guessing==0 ) { d=rm; } } else { boolean synPredMatched9 = false; if (((LA(1)==DIGIT))) { int _m9 = mark(); synPredMatched9 = true; inputState.guessing++; try { { month(); } } catch (RecognitionException pe) { synPredMatched9 = false; } rewind(_m9); inputState.guessing--; } if ( synPredMatched9 ) { m=month(); if ( inputState.guessing==0 ) { d = m; } } else { boolean synPredMatched11 = false; if (((LA(1)==DIGIT))) { int _m11 = mark(); synPredMatched11 = true; inputState.guessing++; try { { rangeyear(); } } catch (RecognitionException pe) { synPredMatched11 = false; } rewind(_m11); inputState.guessing--; } if ( synPredMatched11 ) { ry=rangeyear(); if ( inputState.guessing==0 ) { d=yearToDate(ry); } } else if ((LA(1)==DIGIT)) { y=year(); if ( inputState.guessing==0 ) { d=yearToDate(y); } match(Token.EOF_TYPE); } else { throw new NoViableAltException(LT(1), getFilename()); } }}}} return d; } protected  DatesParser(TokenBuffer tokenBuf, int k);  DatesParser(TokenBuffer tokenBuf); protected  DatesParser(TokenStream lexer, int k);  DatesParser(TokenStream lexer);  DatesParser(ParserSharedInputState state); }
DatesParser extends antlr.LLkParser implements DatesParserTokenTypes { public final Date dates() throws RecognitionException, TokenStreamException { Date d; d=null; Date rd=null,dd=null,rm=null,m=null; int ry=0,y=0; boolean synPredMatched3 = false; if (((LA(1)==DIGIT))) { int _m3 = mark(); synPredMatched3 = true; inputState.guessing++; try { { rangeday(); } } catch (RecognitionException pe) { synPredMatched3 = false; } rewind(_m3); inputState.guessing--; } if ( synPredMatched3 ) { rd=rangeday(); if ( inputState.guessing==0 ) { d=rd; } } else { boolean synPredMatched5 = false; if (((LA(1)==DIGIT))) { int _m5 = mark(); synPredMatched5 = true; inputState.guessing++; try { { day(); } } catch (RecognitionException pe) { synPredMatched5 = false; } rewind(_m5); inputState.guessing--; } if ( synPredMatched5 ) { dd=day(); if ( inputState.guessing==0 ) { d=dd; } } else { boolean synPredMatched7 = false; if (((LA(1)==DIGIT))) { int _m7 = mark(); synPredMatched7 = true; inputState.guessing++; try { { rangemonth(); } } catch (RecognitionException pe) { synPredMatched7 = false; } rewind(_m7); inputState.guessing--; } if ( synPredMatched7 ) { rm=rangemonth(); if ( inputState.guessing==0 ) { d=rm; } } else { boolean synPredMatched9 = false; if (((LA(1)==DIGIT))) { int _m9 = mark(); synPredMatched9 = true; inputState.guessing++; try { { month(); } } catch (RecognitionException pe) { synPredMatched9 = false; } rewind(_m9); inputState.guessing--; } if ( synPredMatched9 ) { m=month(); if ( inputState.guessing==0 ) { d = m; } } else { boolean synPredMatched11 = false; if (((LA(1)==DIGIT))) { int _m11 = mark(); synPredMatched11 = true; inputState.guessing++; try { { rangeyear(); } } catch (RecognitionException pe) { synPredMatched11 = false; } rewind(_m11); inputState.guessing--; } if ( synPredMatched11 ) { ry=rangeyear(); if ( inputState.guessing==0 ) { d=yearToDate(ry); } } else if ((LA(1)==DIGIT)) { y=year(); if ( inputState.guessing==0 ) { d=yearToDate(y); } match(Token.EOF_TYPE); } else { throw new NoViableAltException(LT(1), getFilename()); } }}}} return d; } protected  DatesParser(TokenBuffer tokenBuf, int k);  DatesParser(TokenBuffer tokenBuf); protected  DatesParser(TokenStream lexer, int k);  DatesParser(TokenStream lexer);  DatesParser(ParserSharedInputState state); static Date yearToDate(int y); static Date monthToDate(int m, int y); static Date dayToDate(int d, int m, int y); static void checkMonth(int m); final Date dates(); final Date rangeday(); final Date day(); final Date rangemonth(); final Date month(); final int rangeyear(); final int year(); final int rangedaymonth(); final int daymonthpat(); }
DatesParser extends antlr.LLkParser implements DatesParserTokenTypes { public final Date dates() throws RecognitionException, TokenStreamException { Date d; d=null; Date rd=null,dd=null,rm=null,m=null; int ry=0,y=0; boolean synPredMatched3 = false; if (((LA(1)==DIGIT))) { int _m3 = mark(); synPredMatched3 = true; inputState.guessing++; try { { rangeday(); } } catch (RecognitionException pe) { synPredMatched3 = false; } rewind(_m3); inputState.guessing--; } if ( synPredMatched3 ) { rd=rangeday(); if ( inputState.guessing==0 ) { d=rd; } } else { boolean synPredMatched5 = false; if (((LA(1)==DIGIT))) { int _m5 = mark(); synPredMatched5 = true; inputState.guessing++; try { { day(); } } catch (RecognitionException pe) { synPredMatched5 = false; } rewind(_m5); inputState.guessing--; } if ( synPredMatched5 ) { dd=day(); if ( inputState.guessing==0 ) { d=dd; } } else { boolean synPredMatched7 = false; if (((LA(1)==DIGIT))) { int _m7 = mark(); synPredMatched7 = true; inputState.guessing++; try { { rangemonth(); } } catch (RecognitionException pe) { synPredMatched7 = false; } rewind(_m7); inputState.guessing--; } if ( synPredMatched7 ) { rm=rangemonth(); if ( inputState.guessing==0 ) { d=rm; } } else { boolean synPredMatched9 = false; if (((LA(1)==DIGIT))) { int _m9 = mark(); synPredMatched9 = true; inputState.guessing++; try { { month(); } } catch (RecognitionException pe) { synPredMatched9 = false; } rewind(_m9); inputState.guessing--; } if ( synPredMatched9 ) { m=month(); if ( inputState.guessing==0 ) { d = m; } } else { boolean synPredMatched11 = false; if (((LA(1)==DIGIT))) { int _m11 = mark(); synPredMatched11 = true; inputState.guessing++; try { { rangeyear(); } } catch (RecognitionException pe) { synPredMatched11 = false; } rewind(_m11); inputState.guessing--; } if ( synPredMatched11 ) { ry=rangeyear(); if ( inputState.guessing==0 ) { d=yearToDate(ry); } } else if ((LA(1)==DIGIT)) { y=year(); if ( inputState.guessing==0 ) { d=yearToDate(y); } match(Token.EOF_TYPE); } else { throw new NoViableAltException(LT(1), getFilename()); } }}}} return d; } protected  DatesParser(TokenBuffer tokenBuf, int k);  DatesParser(TokenBuffer tokenBuf); protected  DatesParser(TokenStream lexer, int k);  DatesParser(TokenStream lexer);  DatesParser(ParserSharedInputState state); static Date yearToDate(int y); static Date monthToDate(int m, int y); static Date dayToDate(int d, int m, int y); static void checkMonth(int m); final Date dates(); final Date rangeday(); final Date day(); final Date rangemonth(); final Date month(); final int rangeyear(); final int year(); final int rangedaymonth(); final int daymonthpat(); static final String[] _tokenNames; }