Type definitions for parameterized rules are inconsistent with behavior
LoganWalls opened this issue · comments
Hi!
Thank you for maintaining this project! It is proving very useful for me.
If I define a parameterized rule like so:
Test{
AThen<B>
= A B
A
= "A"+
AX
= AThen<"X">
}
The ActionDict
type hints generated by ohm generateBundles --withTypes
show AX
as taking a single parameter (matches for "X"
):
// ...
export interface TestActionDict<T> extends ActionDict<T> {
AThen?: (this: NonterminalNode, arg0: NonterminalNode, arg1: Node) => T;
A?: (this: NonterminalNode, arg0: IterationNode) => T;
AX?: (this: NonterminalNode, arg0: NonterminalNode) => T;
}
// ...
But in practice, when the AX
rule is triggered ohm will pass two parameters (matches for "A"+
and matches for "X"
).
Is this intended behavior? What I expected was what ohm is actually doing (actions for the AX
rule should receive the matches for both "A"+
and "X"
).
Thanks!
Please disregard. There was a non-obvious mismatch between my actual environment and this minimal example. Everything in ohm is working as expected. (Although I will note for future readers: AX will receive its own match as just one argument. To get the separate matches for A and X you need to look at arg0.children
.
My apologies, and thanks again for maintaining the library!