help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Parsing a strange list


From: Joris Esch
Subject: Parsing a strange list
Date: Tue, 14 Aug 2001 11:16:22 -0700 (PDT)

Hello all:

I have a problem writing a parser for a list.

The list contains the token
name and the literal character '-'
Whenever a '-' is seen, the two names should be
combined.
E.g.
a b c d - e f g h - k l

should return something like

a
b
c - d (combination of c and d)
e
f
g - h
k
l

(The actual example is a little more complicated...)

The following does not work (assume a, b and c are
valid 'name_token's)
name_list: name 
{ /* do something */
        | name_list name 
        { /* do something */ }
name:     name_token
{ /* do something */ }
        | name_token name_token -
{ /* do something */ }

When I try this on input a b c:

Error: parse error, expecting `'-''

Any help or suggestions to documentation are greatly
appreciated. I tried it with precedence trickery, but
I couldn't get it to work.

Thanks

joris esch



__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]