The BindAST template requires that AST classes have default constructors
and a construct method for post-construction initialization. This is fine
for some use cases, but it precludes effective patterns like
immutable fields and factory methods.
The precise details of how a language's AST nodes are constructed are
highly variable, so rather than adding more variants of BindAST to
Pegmatite itself, this commit makes ASTParserDelegate::set_parse_proc
and bind_parse_proc visible to subclasses of ASTParserDelegate.
That way, a language's parser delegate can implement its own binding logic.
Looks fine to me. Please rebase / apply to head. There are a few things that could be a lot nicer in AST construction (e.g. default classes for constructing strings, numbers and so on).
The
BindAST
template requires that AST classes have default constructors and aconstruct
method for post-construction initialization. This is fine for some use cases, but it precludes effective patterns like immutable fields and factory methods.The precise details of how a language's AST nodes are constructed are highly variable, so rather than adding more variants of
BindAST
to Pegmatite itself, this commit makesASTParserDelegate::set_parse_proc
andbind_parse_proc
visible to subclasses ofASTParserDelegate
. That way, a language's parser delegate can implement its own binding logic.