Hi,
I try to implement a logfile parser. Content of the logfile is a
sequense of games like this:
PokerStars Game #35139121861: Hold'em No Limit ($0.05/$0.10 USD) -
2009/11/09 16:48:09 ET
...
PokerStars Game #35139121865: Hold'em No Limit ($0.05/$0.10 USD) -
2009/11/09 16:48:45 ET
...
If there is an syntax error within a game, I would like to skip the
whole game and start parsing the next. To do this I disabled the
default recovery by overriding recoverFromMismatchedToken with:
protected Object recoverFromMismatchedToken(IntStream input, int
ttype, BitSet follow)
throws RecognitionException
{
throw new MismatchedTokenException(ttype, input);
}
I also changed the default rule catch clause with this one:
@rulecatch {
catch (RecognitionException e) {
reportError(e);
throw e;
}
}
For the parser rule "game" I have my own catch clause wich in case of
an error will consume Until the Token SITE, "PokerStars" for the above
example. Here are the relevant parts of the grammar:
handhistory
: ( game )*
;
game
: game_info
table
hand
summary
;
catch [RecognitionException re] {
reportError(re);
consumeUntil(input, SITE);
}
game_info
: site
primarykey
COLON (cash | tournament)
MINUS datetime
;
site
: SITE
;
...
Unfortunately it don't works as expected. In case of an invalid game
the parser goes into the game catch clause, but don't continue
parsing. To debug I also have override the consumeUntil Method:
public void consumeUntil(IntStream input, int tokenType) {
super.consumeUntil(input, tokenType);
System.out.println("### NEXT Token ### " + getCurrentInputSymbol(input));
}
The output of the parser is:
line 61:59 [handhistory, game, game_info, tournament, buyin, rake,
recoverFromMismatchedToken] mismatched input
[...@699,1923:1923='$',<98>,61:59] expecting RAKE
### GAME CATCH ###
### NEXT Token ### [...@1350,3688:3702='PokerStars',<4>,123:0]
I am wondering why the parser stops parsing here. As you could see in
the output the next Token is as expectet "PokerStars". I would be very
happy for each hint.
best regards, Christian
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.