Empty must provide a sensible default whenever you want to have Returns
as non-void
(e.g., whenever you want your visitors to be able to return a value).
Optional
enter: EntryExitVisitor<Info>Optional
exit: EntryExitVisitor<Info>Protected
Readonly
emptyProtected
Readonly
enterProtected
Readonly
exitProtected
Readonly
foldsProtected
concatMonoid::concat
Protected
concatProtected
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 (
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
andexit
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 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
ast
and 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.