mcfletch / simpleparse

SimpleParse parser generator using mxTextTools (launchpad mirror)
Other
10 stars 12 forks source link

ValueError on comments #1

Closed PanderMusubi closed 7 years ago

PanderMusubi commented 7 years ago

Version 2.2.0 in Python 2 and Python 3 gives a ValueError on comments. See the following example:

from simpleparse.parser import Parser
grammar = r'''/* Blah blah
 * blah blah
 * blah.
 */

Example ::= [a-z]'''
parser = Parser(grammar)

which results in:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/simpleparse/parser.py", line 37, in __init__
    definitionSources = definitionSources,
  File "/usr/lib/python2.7/dist-packages/simpleparse/simpleparsegrammar.py", line 483, in __init__
    Unparsed:\n%s..."""%(lineNumber, next, len(ebnf), ebnf[next:next+100])
ValueError: Unable to complete parsing of the EBNF, stopped at line 6 (0 chars of 58)
Unparsed:
/* Blah blah
 * blah blah
 * blah.
 */

Example ::= [a-z]...

A similar error occurs for:

grammar = r'''Example ::= [a-z] /* ws: explicit */'''

Is there a workaround for this or could this be fixed? Perhaps both examples require different fixes.

PanderMusubi commented 7 years ago

Ah, I see that # is the default for comments.