Open
Description
I came across a bug that was rooted in what seems to be a curious feature of Parsley: changing from single to double quotes leads to a parsing error:
import sys
print(sys.version_info)
# sys.version_info(major=3, minor=5, micro=1, releaselevel='final', serial=0)
import parsley
print(parsley.__version__)
#1.3
grammar = parsley.makeGrammar("""
add = <digit+>:left sp "+" sp add:right -> ('add', left, right)
| <digit+>:child -> child
sp = ' '*
""", {})
grammar('4 + 3').add()
# ('add', '4', '3')
But if we change sp = ' '*
to sp = " "*
and keep everything else constant, we get an error:
grammar = parsley.makeGrammar("""
add = <digit+>:left sp "+" sp add:right -> ('add', left, right)
| <digit+>:child -> child
sp = " "*
""", {})
grammar('4 + 3').add()
---------------------------------------------------------------------------
ParseError Traceback (most recent call last)
<ipython-input-20-5d4b7ce9eeba> in <module>()
6 """, {})
7
----> 8 grammar('4 + 3').add()
/Users/jakevdp/anaconda/envs/python3.5/lib/python3.5/site-packages/parsley.py in invokeRule(*args, **kwargs)
96 err = ParseError(err.input, err.position + 1,
97 [["message", "expected EOF"]], err.trail)
---> 98 raise err
99 return invokeRule
100
ParseError:
4 + 3
^
Parse error at line 2, column 0: expected EOF. trail: []
Is the semantic difference between " "
and ' '
intended? I couldn't find any discussion of this in the documentation. Thank you!
Metadata
Metadata
Assignees
Labels
No labels
Activity