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

Fix problems with expressions #2

Merged
merged 3 commits into from
Nov 5, 2018
Merged

Fix problems with expressions #2

merged 3 commits into from
Nov 5, 2018

Conversation

segeljakt
Copy link
Member

@segeljakt segeljakt commented Nov 5, 2018

This PR corrects the grammar so that it is no longer possible to write things like:
!let x = 3; x or for([1,2,3], appender[i32], 5)
The previous expression definition:

expr : letExpr | lambdaExpr | operatorExpr;

Has been changed to:

valueExpr : letExpr | operatorExpr;
expr : lambdaExpr | valueExpr;

This helps rules distinguish lambda expressions from expressions which evaluate to a value. As an example, for-expressions were before defined as:

annotations? TFor '(' iterator ',' builder=expr ',' body=expr ')' # For

and are now:

annotations? TFor '(' iterator ',' builder=valueExpr ',' body=lambdaExpr ')' # For

@segeljakt segeljakt requested a review from Bathtor November 5, 2018 17:21
Copy link
Contributor

@Bathtor Bathtor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks :)

@Bathtor Bathtor merged commit 0b0b63c into master Nov 5, 2018
@segeljakt segeljakt deleted the klass/fix-expr branch November 5, 2018 19:18
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

Successfully merging this pull request may close these issues.

2 participants