1

I have a large grammar written for DParser format and using the Python binding. When I parse a code using this grammar, I get the following exception but with different symbols depending on what code I pass to it. But the ambiguous symbols are always the same non_terminal. How do I find out what the ambiguity is?

Traceback (most recent call last):
  File "parser.py", line 2030, in ambiguity
    raise dparser.AmbiguityException("\n\nUnresolved ambiguity!  Symbols:\n  " + '\n'.join([node.symbol for node in nodes]))
dparser.AmbiguityException:

Unresolved ambiguity!  Symbols:
  non_terminal
  non_terminal

Any hints or ideas would be appreciated.

Amal
  • 243
  • 1
  • 3
  • 8
  • According to the DParser manual, "If the verbose_level flag is set, the default ambiguity handler will print out parenthesized versions of the ambiguous parse trees. This may be of some assistence in disambiguating a grammar." I'd suggest you try that. – rici Aug 07 '13 at 04:03
  • I saw that in the documentation, but I cannot really find where to set that variable specifically in Python version. – Amal Aug 07 '13 at 15:20
  • looks like you'll have to dig through the swig files to figure out how. I'd say that this, and the other issue you mention in your other question, are basically code rot. But I'm not an expert on DParse; your best bet is probably to file bug reports or email the author. – rici Aug 08 '13 at 03:27
  • I converted my grammar to using the C version of the DParser. That way, I could set the d_verbose_level set. This prints out the ambiguous parse trees, but the problem is that it is difficult to find what non_terminals really matched with each parse tree. There is some guess work involved. Not sure if there is a way to print out the parse tree with the matched grammar rules. – Amal Aug 12 '13 at 15:00

0 Answers0