Closed GoogleCodeExporter closed 8 years ago
Given that this grammar has 15 shift/reduce conflicts, this problem is very
likely a problem with the grammar
and not a problem with PLY. It's not going to be easy to track down, but
your task at this point is to
investigate those shift reduce conflicts and to rewrite parts of the grammar to
try and eliminate them.
Note: I've written a C++ header parser for the SWIG project and happen to know
that it's notoriously difficult
to do so. That grammar has still has 5 shift/reduce conflicts.
The only way I'd classify this as a PLY bug is if the *exact same* grammar used
here works with another
LALR(1) parser generator (yacc, bison, etc.).
Original comment by dbeaz...@gmail.com
on 16 Sep 2008 at 10:56
I've finished fixing the bugs in my parser. As Dave noted, the shift-reduce
issues
were the source of the bug in my grammar.
However, the reason I submitted this issue was not because my grammar was
failing,
but because I was having difficulty tracking down the issue. My issue with the
state
machine generated by Ply is that it can have states that look 'good', but which
generate parse errors.
Perhaps this is a well-known issue with LALR parsers, but I was unsuccessful
googling
for dicussions of this issue. Thus, this may be a 'usability' issue for Ply???
Original comment by whart222
on 22 Sep 2008 at 5:44
The difficulty of tracking down parsing problems, especially shift-reduce
conflicts, is a well-known problem with
LALR(1) parsers and is a "feature" PLY shares with yacc, bison, and other LALR
parser generators. PLY provides
the same diagnostic information as those tools and parser.out contains all of
the information that went into
constructing the state tables. So, I'm not exactly sure what I would add in
addition to that.
Of course, people are usually willing to put up with LALR magic because the
resulting parsers usually run really
fast have other nice properties.
Original comment by dbeaz...@gmail.com
on 22 Sep 2008 at 11:20
Original issue reported on code.google.com by
whart222
on 16 Sep 2008 at 7:00Attachments: