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

Use operator precedence parser for infix expressions and add prefix/postfix expressions #16

Merged
merged 13 commits into from Feb 21, 2023

Conversation

fwcd
Copy link
Collaborator

@fwcd fwcd commented Feb 20, 2023

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 as PostfixExpr of Expression::Ident and PostfixOp::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.

@fwcd fwcd force-pushed the operator-precedence-parsing branch from 399e6b7 to 2ef79b8 Compare February 21, 2023 21:07
@fwcd 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
@fwcd fwcd marked this pull request as ready for review February 21, 2023 23:33
@H1ghBre4k3r H1ghBre4k3r self-assigned this Feb 21, 2023
@H1ghBre4k3r H1ghBre4k3r merged commit 48fcec9 into main Feb 21, 2023
@H1ghBre4k3r H1ghBre4k3r deleted the operator-precedence-parsing branch February 21, 2023 23:56
@H1ghBre4k3r H1ghBre4k3r added this to the V0.1.0 milestone Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants