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
Use operator precedence parser for infix expressions and add prefix/postfix expressions #16
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fwcd
force-pushed
the
operator-precedence-parsing
branch
from
February 21, 2023 19:37
e9b9766
to
399e6b7
Compare
...since expr is already included in stmt.
fwcd
force-pushed
the
operator-precedence-parsing
branch
from
February 21, 2023 21:07
399e6b7
to
2ef79b8
Compare
fwcd
changed the title
Use operator precedence parser for infix expressions
Use operator precedence parser for infix expressions and add prefix/postfix expressions
Feb 21, 2023
H1ghBre4k3r
approved these changes
Feb 21, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch contains some preliminary experiments for parsing all infix (and prefix and postfix) expressions in a unified way using a
PrattParser
with proper handling of precedence and associativity.The prefix/postfix expressions are currently handled in a very ad-hoc way, notably in the interpreter and compiler, to be retrofitted into the existing architecture without rewriting most of the previous
FnCall
infrastructure (these are now represented asPostfixExpr
ofExpression::Ident
andPostfixOp::Call
). These implementations ({run, compile, check}_{prefix, postfix}_expression
et al.) deserve a refactor, but this isn't feasible without significantly changing the way function name resolution works currently and so might be better suited for a future PR.