2012-01-13 66 views
3

我正在構建一些需要解析撲克手歷史的iOS軟件。由於我對解析沒有太多瞭解,所以我希望有人能指出我正確的方向,指向我一些教程,...Objective-C解析器撲克手歷史

我已經開始分解撲克牌手了,然後我開始用字符串函數處理每一行。但是現在我已經看到有可用的解析工具,我可以編寫一個BNF語法。所以如果我想實現業績,這可能是正確的路要走,對吧?但是,我對BNF語法一無所知,以及如何使用它們......任何人都可以爲我的初學者指點一些教程嗎?

哎呦,一手牌的歷史看起來是這樣的:

PokerStars Game #73611647630: Hold'em No Limit ($0.01/$0.02 USD) - 2012/01/10 17:15:42 CET [2012/01/10 11:15:42 ET] 
Table 'Joella VIII' 6-max Seat #1 is the button 
Seat 1: [email protected] ($0.85 in chips) 
Seat 2: Pet21 ($1.96 in chips) 
Seat 3: derphurp ($2.79 in chips) 
Seat 4: -M-A-R-K-qaz ($0.90 in chips) 
Seat 5: Rolle55 ($2.47 in chips) 
Seat 6: SanderDecler ($2 in chips) 
Pet21: posts small blind $0.01 
derphurp: posts big blind $0.02 
*** HOLE CARDS *** 
Dealt to SanderDecler [Jc 2s] 
-M-A-R-K-qaz: folds 
Rolle55: calls $0.02 
SanderDecler: folds 
[email protected]: folds 
Pet21: folds 
derphurp: checks 
*** FLOP *** [2h 3s As] 
derphurp: checks 
Rolle55: checks 
*** TURN *** [2h 3s As] [Kh] 
derphurp: bets $0.02 
Rolle55: calls $0.02 
*** RIVER *** [2h 3s As Kh] [5d] 
derphurp: bets $0.02 
Rolle55: raises $0.02 to $0.04 
derphurp: raises $0.16 to $0.20 
Rolle55: raises $0.16 to $0.36 
derphurp: folds 
Uncalled bet ($0.16) returned to Rolle55 
Rolle55 collected $0.47 from pot 
*** SUMMARY *** 
Total pot $0.49 | Rake $0.02 
Board [2h 3s As Kh 5d] 
Seat 1: [email protected] (button) folded before Flop (didn't bet) 
Seat 2: Pet21 (small blind) folded before Flop 
Seat 3: derphurp (big blind) folded on the River 
Seat 4: -M-A-R-K-qaz folded before Flop (didn't bet) 
Seat 5: Rolle55 collected ($0.47) 
Seat 6: SanderDecler folded before Flop (didn't bet) 

回答

2

一個BNF是做這個的理想方式......但是如果你時間有限,不想學太多,我可以建議一個快速和骯髒的解決方案。使用正則表達式並根據哪一個匹配進行切換。