[ragel-users] Parsing PokerHand-History file (kind of log file with actions)

Jens Saathoff jensesaat at googlemail.com
Sat Jul 23 12:54:04 UTC 2011


Hi!

As i'm very new to ragel i just played around a bit and tried some examples,
modified them a bit and so on.

Before  started with Ragel i used boost::spirit to parse text. boost::spirit
is fine, speed is ok, much faster than using simple regexes, but one
problem: The compilation time of a boost::spirit-grammar is a hell. I
created a grammar for pokerhandhistory-parsing, the debug-compilation time
is about 20 minutes. A bit to long!

Here is pokerhandhistory-file: http://pastebin.com/WjDP1xmj

I'm extracting almost all information like Datetime, Limit and all player
actions and fill some structs. After parsing it's inserted to a database.

My questions:
1.Would it be easy to create such a parser with Ragel?

2.How to parse things like this: "player1 raises 1 to 2" all characters
before ' raises ' digit ' to ' digit? (a playername can contain an action
like player 1 raises raises 1 to 2)

3.How to create actions for such a line? In boost:spirit i can call a
function in this way: rule = (char_+ >> double_)[class::myfunction(_1,_2)].
_1 would be the char-array and _2 a double? Is it possible with Ragel?

4.Can i use a symbol-table in Ragel? example of a symboltable with actions:
(L"calls", 1)
(L"bets", 2)
(L"folds", 3)
(L"posts the small blind of", 4)
(L"posts a dead small blind of", 5)
(L"posts the big blind of", 6)
(L"posts", 7)
(L"antes", 8)
a rule for this is: rule = name SYMBOL::ACTION[function(_1, _2)]


So...please don't laugh ;-)

Thank you very much!!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20110723/676a7545/attachment-0001.html>
-------------- next part --------------
_______________________________________________
ragel-users mailing list
ragel-users at complang.org
http://www.complang.org/mailman/listinfo/ragel-users


More information about the ragel-users mailing list