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

HCL fix compound expression grammar #5854

Merged

Conversation

lkishalmi
Copy link
Contributor

It seems there is a bug in the HCL Grammar spec: hashicorp/hcl#553

According to the spec an operation only can happen between ExprTerm-s not Expression-s making the following assignment invalid:

value = 1 + 2 + 3

This change moves the operations to the expression level, as ANTLR4 cannot handle indirect recursions, I had to move the operation rules to the expression level. I do not know if I took the left/right association directives right. That would only affect the ParserTree then the AST build up, though at the moment we do not use those that deep.

@lkishalmi lkishalmi added the HCL label Apr 20, 2023
@lkishalmi lkishalmi added this to the NB18 milestone Apr 20, 2023
Copy link
Contributor

@vieiro vieiro left a comment

Choose a reason for hiding this comment

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

Looks good to me. You may consider having different lines for different operator precedences. At your consideration.

@lkishalmi
Copy link
Contributor Author

Might be not the final expression Grammar, but seems to be good enough.

@vieiro
Copy link
Contributor

vieiro commented Apr 21, 2023

Might be not the final expression Grammar, but seems to be good enough.

Great job. Changes look great to me.

@neilcsmith-net neilcsmith-net merged commit 5666dc2 into apache:delivery Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants