Skip to content

Operator priority: binary ops vs. 'if' expressions #1643

Answered by ospencer
dermagen asked this question in Help
Discussion options

You must be logged in to vote

Hey @dermagen. You can find Grain's general operator precedence here: https://github.com/grain-lang/grain/blob/main/docs/contributor/operator_precedence.md

There'll be a page about this on the website as well, but it hasn't made it there just yet. It doesn't contain any information about how this interacts with if expressions, though.

else attempts to parse as much as it can as an expression, so it captures the entire expression 4 + 5. You can look at this in Grain's grammar if you'd like: https://github.com/grain-lang/grain/blob/main/compiler/src/parsing/parser.mly#L502

I'm not sure what you mean when you say traditional operator grammars. In most languages, if is a statement rather than…

Replies: 2 comments 3 replies

This comment has been hidden.

@dermagen

This comment has been hidden.

Comment options

You must be logged in to vote
2 replies
@dermagen
Comment options

@dermagen
Comment options

Answer selected by phated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants