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

Exp ordering #12

Closed
SirSeim opened this issue Apr 20, 2016 · 1 comment
Closed

Exp ordering #12

SirSeim opened this issue Apr 20, 2016 · 1 comment
Assignees

Comments

@SirSeim
Copy link
Owner

SirSeim commented Apr 20, 2016

As it stands right now, this is our order of Exp:

Exp0           ::=  Exp1 ('if' Exp1 ('else' Exp1)?)?
Exp1           ::=  Exp2 ('or' Exp2)*
Exp2           ::=  Exp3 ('and' Exp3)*
Exp3           ::=  Exp4 (relop Exp4)?
Exp4           ::=  Exp5 (('thru'|'till') Exp5 ('by' Exp5)?)?
Exp5           ::=  Exp6 (addop Exp6)*
Exp6           ::=  Exp7 (mulop Exp7)*
Exp7           ::=  prefixop? Exp8
Exp8           ::=  Exp9 ('**' Exp5)?
Exp9           ::=  Exp10 ('.' Exp10 | '[' Exp4 ']' | Args)*
Exp10          ::=  boollit | intlit | floatlit | id | '(' Exp ')' | stringlit
                 | DictLit | ListLit

My question pertains to the ordering of the math operations and their interior Exp references.
For a piece of code like 3 ** 4 + 5 this ordering of Grammar means the result is (** 3 (+ 4 5)). Would it make more sense for it to be (+ (** 3 4) 5) so if you wanted (** 3 (+ 4 5)) you'd have to do 3 ** (4 + 5). If the later is the case, does that mean that instead of putting Exp8 above Exp5 we should instead replace the Exp5 reference within Exp8 to Exp9, aka make Exp8:

Exp8           ::=  Exp9 ('**' Exp9)?

I'm also wondering if Exp7 should be placed below Exp8. Under the current ordering, -3 ** -4 creates (UnaryOp - (BinaryOp ** 3 (UnaryOp - 4))) Switching as suggested would hopefully create (BinaryOp ** (UnaryOp - 3) (UnaryOp - 4)).

Any comments on these subjects?

@rtoal
Copy link
Collaborator

rtoal commented Apr 20, 2016

Yes on the first one, 8 -> 9 9

Probably no on the second, to stay in line with Python.

@rtoal rtoal closed this as completed Apr 20, 2016
SirSeim added a commit that referenced this issue Apr 20, 2016
We want `3 ** 4 + 5` to be `(+ (** 3 4) 5)`
Also updated some out of date Exp references
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

2 participants