I am customizing the Lua AST I generate with type-specific nodes, but I can't figure out whether one of my productions needs a custom tree constructor node class. A simplified form of the production without all the labels, error handling, etc. is:
functionCallOrAssignmentList.Production = ((@openParenthesis + expression["expr"] + @closeParenthesis) | @identifier["ident"] | @luaFunction["luaFunc"]) + (
identifierAndArguments.OneOrMore().SetLabel("identAndArgs")
| (@comma + variable).ZeroOrMore() + @assignment + expressionList);
If the production matches for a function call by ending in identifierAndArguments.OneOrMore(), I want to create a FunctionCall AST node and set its string name property as appropriate.
There are two complicating factors: I don't know which of the three possible starting matches (expression, identifier, or luaFunction) will be hit, and the presence of multiple identifierAndArguments would indicate nested, consecutive calls (e.g. functionReturningFunction(arg1, arg2)(x)) that I'd want to append to the name as well.
I don't see how to manage all that with the built-in constructors; am I correct that it could be handled with a custom tree constructor node class that runs logic examining the presence, counts, and labels of the matches passed in?
If so, would I want to subclass TreeConstructionNodeBase or ParentTreeConstructionNodeBase? I'm unclear on the difference between them.