Support infix rules - #134
Conversation
There was a problem hiding this comment.
⚠️ 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
left a comment
There was a problem hiding this comment.
Looks well-designed and -tested. There are one design and some minor questions left.
fe3f042 to
b6735dc
Compare
6c2d06c to
efe4301
Compare
sailingKieler
left a comment
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Why the renaming here? Will cause merge conflict with changes of #130.
| ` + commonTokens) | ||
| diag := doc.ExpectDiagnostic("1") | ||
| diag.WithSeverity(core.SeverityError) | ||
| diag.WithCode(ValidateInfixReturnType) |
There was a problem hiding this comment.
is diag used anywhere? otherwise, please make consistent with other tests.
| // | Expression "*" Expression | ||
| // | PrimaryExpression | ||
| // | ||
| // In this example, the "*" operator binds tighter than "+", so "a + b * c" parses |
There was a problem hiding this comment.
You meant this, right?
| // In this example, the "*" operator binds tighter than "+", so "a + b * c" parses | |
| // In this example, the "*" operator is supposed to bind tighter than "+", so "a + b * c" parses |
| // | ||
| // Expression: Addition | ||
| // Addition: Multiplication ("+" Multiplication)* | ||
| // Multiplication: PrimaryExpression ("*" PrimaryExpression)* |
There was a problem hiding this comment.
Please add a dummy definition of PrimaryExpression for completeness.
| // > "+" | "-" | ||
| // | ||
| // The rule name must resolve to an interface declaring the fields Left, | ||
| // Right (of an interface type both the rule's return type and node type are |
There was a problem hiding this comment.
What is node referring to?
Did you mean this? Then reorder the subsequent sentences, please.
| // Right (of an interface type both the rule's return type and node type are | |
| // Right (of an interface type both the rule's return type and operand rule's type are |
| // > "+" | "-" | ||
| // | ||
| // The return type of an infix rule defaults to the operand rule's return | ||
| // type; "returns" overrides it. A lone operand is returned unchanged - no |
There was a problem hiding this comment.
| // type; "returns" overrides it. A lone operand is returned unchanged - no | |
| // type; an additional "returns" clause overrides it. A lone operand is returned unchanged - no |
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)*.