Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule arguments are wrapped in tuples #77

Open
jshprentz opened this issue Mar 17, 2019 · 0 comments
Open

Rule arguments are wrapped in tuples #77

jshprentz opened this issue Mar 17, 2019 · 0 comments

Comments

@jshprentz
Copy link

When a rule has multiple arguments and passes those arguments to another rule, all but the last argument are wrapped in single-valued tuples. This is a concern because the tuples are unexpected and the multiple arguments are not handled consistently.

Code example:

from parsley import makeGrammar

GRAMMAR = """
    a :x :y :z = b(x, y, z) -> print("a: x={} y={} z={}".format(x, y, z))
    b :x :y :z = c(x, y, z) -> print("b: x={} y={} z={}".format(x, y, z))
    c :x :y :z =            -> print("c: x={} y={} z={}".format(x, y, z))
"""

ParserClass = makeGrammar(GRAMMAR, {})
parser = ParserClass('')
parser.a(1, 2, 3)

Output from Python 3.5.3:

c: x=((1,),) y=((2,),) z=3
b: x=(1,) y=(2,) z=3
a: x=1 y=2 z=3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant