Skip to content

Support infix rules - #134

Merged
msujew merged 8 commits into
mainfrom
msujew/infix-operator
Aug 31, 2026
Merged

Support infix rules#134
msujew merged 8 commits into
mainfrom
msujew/infix-operator

Conversation

@msujew

@msujew msujew commented Jul 27, 2026

Copy link
Copy Markdown
Member

Closes #115 (as a side effect).

Adds infix rule support, similar to how Langium did it (but a bit simpler, since we don't need CST support).

Implements the support by rewriting infix rules into parser rules of the shape Expr (op Expr)*.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: 6c2d06c Previous: d803417 Ratio
BenchmarkWorkspaceCycle (typefox.dev/fastbelt/examples/statemachine) - MB/s 22 MB/s 5.21 MB/s 4.22
BenchmarkParser (typefox.dev/fastbelt/examples/statemachine) - MB/s 90.81 MB/s 37.68 MB/s 2.41
BenchmarkLexer (typefox.dev/fastbelt/examples/statemachine) - MB/s 119.62 MB/s 64.67 MB/s 1.85
BenchmarkLexerAndParser (typefox.dev/fastbelt/examples/statemachine) - MB/s 50.43 MB/s 23.82 MB/s 2.12
BenchmarkLocalLinking (typefox.dev/fastbelt/examples/statemachine) - MB/s 25.57 MB/s 16.69 MB/s 1.53

This comment was automatically generated by workflow using github-action-benchmark.

@ssmifi ssmifi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks well-designed and -tested. There are one design and some minor questions left.

Comment thread internal/grammar/grammar.fb Outdated
Comment thread internal/grammar/validator.go
Comment thread internal/generator/parser_generator.go
Comment thread internal/generator/infix_generator.go
Comment thread parser/infix.go Outdated
Comment thread cmd/fastbelt/generate.go
@msujew
msujew force-pushed the msujew/infix-operator branch from fe3f042 to b6735dc Compare August 10, 2026 16:31
@msujew
msujew force-pushed the msujew/infix-operator branch from 6c2d06c to efe4301 Compare August 12, 2026 08:46
Comment thread examples/arithmetics/arithmetics.fb Outdated
Comment thread examples/arithmetics/infix_test.go
Comment thread grammar/doc.go Outdated
Comment thread grammar/doc.go
Comment thread internal/grammar/infix.go
Comment thread internal/grammar/infix.go
Comment thread parser/infix_test.go
Comment thread internal/grammar/infix_validator_test.go

@sailingKieler sailingKieler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @msujew for this additional feature.

I've just minor remarks, mainly doc and a few nitpicks, see below.
Otherwise it's good to go.

For curiosity: Does the infix operator have measurable performance benefits?

Comment thread cmd/fastbelt/generate.go
Comment thread internal/grammar/infix_validator_test.go Outdated
Comment thread grammar/doc.go Outdated
Comment thread grammar/doc.go
Comment thread grammar/doc.go Outdated
Comment thread grammar/doc.go Outdated

@ssmifi ssmifi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

From me as well. Thanks for the answers and the algo. :)

@msujew

msujew commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

For curiosity: Does the infix operator have measurable performance benefits?

Minor only. Before #142, it was more. Now it's a 10% performance improvement for the arithmetics parser benchmark.

@msujew
msujew merged commit 5a686be into main Aug 31, 2026
5 checks passed
@msujew
msujew deleted the msujew/infix-operator branch August 31, 2026 13:33
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.

Arithmetics example: Exponentiation not right-associative yet

4 participants