[antlr-interest] Parsing names

alan brown listbrownie at gmail.com
Mon Mar 17 21:06:43 PDT 2008


(Austin.  Sorry for replying to personally.  Here's my reply done to the
group as intended!)


Happy to provide example text...

The following is a hand being played with "Pretty Pam 10".  My lexer creates
tokens that are mostly words and numbers and my parser is being forced to do
major look ahead to work out what each line is trying to convey (because
things like 'PeggySue has 15 seconds to act'  or 'johnvfardella is feeling
happy' (among others) can appear almost anywhere).

How would I implement a symbol table dynamically.  Can you point me to an
example or some documentation?  I don't see it in the book.  I haven't
created a symbol table before.

In the example below I'd like to make the 10 players names first class
citizens (ie single tokens).

alan

Game #5678328259: Table Play Chip 798 - 10/20 - Limit Hold'em - 22:09:21 ET
- 2008/03/17
Seat 1: miannie (949)
Seat 2: LATUK (320)
Seat 3: stigs2 (1,110)
Seat 4: PeggySue07 (1,080)
Seat 5: tishlidji (300)
Seat 6: brownalan (200)
Seat 7: Pretty Pam 10 (3,355)
Seat 8: larrydj (31,142)
Seat 9: johnvfardella (200)
stigs2 posts the small blind of 5
PeggySue07 posts the big blind of 10
brownalan posts 10
johnvfardella posts 10
larrydj posts a dead small blind of 5
larrydj posts 10
The button is in seat #2
*** HOLE CARDS ***
Dealt to brownalan [Qh Qd]
tishlidji calls 10
brownalan raises to 20
Pretty Pam 10 calls 20
larrydj calls 10
johnvfardella calls 10
miannie has 8 seconds left to act
johnvfardella is feeling happy
miannie calls 20
LATUK calls 20
stigs2 calls 15
PeggySue07 calls 10
tishlidji calls 10
*** FLOP *** [Kc 5d 2s]
stigs2 has 8 seconds left to act
stigs2 checks
PeggySue07 checks
tishlidji checks
brownalan checks
Pretty Pam 10 checks
larrydj checks
johnvfardella: Hi Pam
johnvfardella checks
miannie checks
LATUK checks
*** TURN *** [Kc 5d 2s] [2c]
stigs2 has 8 seconds left to act
stigs2 bets 20
PeggySue07 calls 20
tishlidji calls 20
johnvfardella: looking good
brownalan raises to 40
Pretty Pam 10 folds
larrydj calls 40
johnvfardella calls 40
miannie folds
LATUK folds
stigs2 raises to 60
PeggySue07 calls 40
tishlidji calls 40
brownalan calls 20
larrydj calls 20
johnvfardella calls 20
*** RIVER *** [Kc 5d 2s 2c] [7s]
Pretty Pam 10: hello
stigs2 has 8 seconds left to act
stigs2 bets 20
PeggySue07 calls 20
tishlidji raises to 40
brownalan has 8 seconds left to act
brownalan folds
larrydj folds
johnvfardella calls 40
stigs2 raises to 60
PeggySue07 folds
tishlidji raises to 80
johnvfardella folds
stigs2 calls 20
*** SHOW DOWN ***
tishlidji shows [7h 2h] a full house, Twos full of Sevens
stigs2 shows [Ks 2d] a full house, Twos full of Kings
stigs2 wins the pot (765) with a full house, Twos full of Kings
*** SUMMARY ***
Total pot 765 | Rake 0
Board: [Kc 5d 2s 2c 7s]
Seat 1: miannie folded on the Turn
Seat 2: LATUK (button) folded on the Turn
Seat 3: stigs2 (small blind) showed [Ks 2d] and won (765) with a full house,
Twos full of Kings
Seat 4: PeggySue07 (big blind) folded on the River
Seat 5: tishlidji showed [7h 2h] and lost with a full house, Twos full of
Sevens
Seat 6: brownalan folded on the River
Seat 7: Pretty Pam 10 folded on the Turn
Seat 8: larrydj folded on the River
Seat 9: johnvfardella folded on the River


On Mon, Mar 17, 2008 at 8:54 PM, Austin Hastings <Austin_Hastings at yahoo.com>
wrote:

> Alan,
>
> 1. How about giving us some example text?
>
> 2. Create a symbol table. This is a "higher level" solution, but
> probably right.
>
> 3. It may be that your text is more amenable to parsing with a "lower
> level" approach. Possibly more use of regular expressions is needed.
>
> Before you make any permanent decisions, see #1.
>
> =Austin
>
>  alan brown wrote:
> > I'm having a problem with my lexer/parser design.  I'm trying to parse
> > a poker hand history file and extract the relevant information.  I got
> > a working solution but it's quite brittle.  My problem is that my
> > lexer is creating tokens of the words and my parser is reading those
> > words to work out player names and bets and so on.  My issue is that
> > the player names (among other things) is causing me grief.  A player
> > name can be "alan 10 folds" which as you might imagine, can cause some
> > confusion.
> >
> > What I'd like to do is to parse the file to create the tokens that the
> > lexer would look for so when my parser runs over the tokens all the
> > names are single tokens.
> >
> > How do I dynamically define the tokens for the lexer to parse?
> >
> > alan
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080317/d53f2321/attachment.html 


More information about the antlr-interest mailing list