Default implementation of a fold over the normalized AST (using the classic fold traversal).
To modify the behavior, please extend this class and overwrite the methods of interest.
You can control the value passing (Returns generic)
by providing sensible Monoid behavior overwriting the DefaultNormalizedAstFold#concat|concat method
and supplying the empty value in the constructor.
Note
By providing entry and exit you can use this as an extension to the simpler visitAst function but without
the early termination within the visitors (for this, you can overwrite the respective fold* methods).
This one does explicitly not use the return functionality (and hence acts more as a conventional visitor).
Now let us suppose we have a normalized AST as an RNode in the variable ast
and want to check if the AST contains a number:
constresult = newMyNumberFold().fold(ast);
Please take a look at the corresponding tests or the wiki pages for more information on how to use this fold.
Default implementation of a fold over the normalized AST (using the classic fold traversal). To modify the behavior, please extend this class and overwrite the methods of interest. You can control the value passing (
Returnsgeneric) by providing sensible Monoid behavior overwriting the DefaultNormalizedAstFold#concat|concat method and supplying the empty value in the constructor.Note
By providing
entryandexityou can use this as an extension to the simpler visitAst function but without the early termination within the visitors (for this, you can overwrite the respectivefold*methods).Example: First you want to create your own fold:
This one does explicitly not use the return functionality (and hence acts more as a conventional visitor). Now let us suppose we have a normalized AST as an RNode in the variable
astand want to check if the AST contains a number:Please take a look at the corresponding tests or the wiki pages for more information on how to use this fold.