-2

I have to parse some pokerhandhistory-files, log files.

The content is like this:

Theplayername bets $100

All i need is the name, the action(as token) and the amount.

The problem is that the name can also contain an action and spaces.

Example: theplayer bets bets $100

I tried to get it working with GoldParser and ANTLR. Can't get it...

With Boost::spirit there's no problem, it works. The only bad thing is that the compilation time for my whole poker-grammar is awesome, takes 20 minutes.

I saw that ANTLR (C-Api) and GoldParser are a bit better in compilation times.

Would be nice if someone could post a tip on how to grab the information with Goldparser.

Thank you very much!!!!

extreme001
  • 303
  • 1
  • 5
  • 16

2 Answers2

2

They can both be used (ANTLR or Goldparser). But if the format is so simple (USERNAME ACTION ... AMOUNT), then I see no need for a full-blown parser: mind as well process the file line by line and split on white spaces.

Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
2

You could go like this:

  1. Find the last $ sign
  2. Look for the beginning of the "bets " substring that should be before that
  3. The player name is the substring before that position.

No need to get into some complicated parser, do it by hand if the format is just that.

Vincent Mimoun-Prat
  • 28,208
  • 16
  • 81
  • 124
  • And next thing...there are other formats of this file...like "Playyername: bets $100". The whole content can contain other things as well. So i think it's more comfortable to use a parser. – extreme001 Jul 20 '11 at 21:55
  • Thanks for your answer! It's really important to do it with a parser. I want to learn GoldParser or ANTLR. And another point...the $-Sign is not always there. I could be another currency or just no currency for playmoney. Please, if someone knows how to do it with GoldParser or ANTLR, please answer! Please no answers with "You don't need a parser" Thanks! – extreme001 Jul 22 '11 at 07:58