|HELP needed with this s/r error email@example.com (Seet Chern Hway) (1997-02-16)|
|Re: HELP needed with this s/r error firstname.lastname@example.org (1997-02-27)|
|From:||Seet Chern Hway <email@example.com>|
|Date:||16 Feb 1997 23:15:57 -0500|
|Organization:||Information Technology Institute|
|Keywords:||yacc, parse, question, comment|
I hope somebody can help me overcome an s/r error in the grammar I have
constructed to parse a language. The language has the following
INDEX name [segment]
[ , INDEX name [segment] ]...
where segment refers to the fragment
SEGMENT item [ , item ]...
The s/r error can be reproduced by the simplified YACC productions shown
below. The problem is caused by the occurrence of the ',' separator
used in both the list_index and list_item productions.
Could somebody help me rewrite the grammar to avoid the s/r error
Seet Chern Hway
Information Technology Institute
------------- start of grammar ------------
%token INDEX name SEGMENT item ','
| list_index ',' index
: INDEX name SEGMENT list_item
| INDEX name
| list_item ',' item
-------------- end of grammar -------------
[Looks to me like this is LR(2) -- when it sees a comma it has to reduce one
rule or the other but it can't because it needs to look ahead and see if
there is an INDEX following. -John]
Return to the
Search the comp.compilers archives again.