Remove the error: "multiple tree roots to search for contributions"
Issue #294
resolved
The proposal is to remove the error: "multiple tree roots to search for contributions" and instead let the root in the tree you calling the collection attribute on be the root for the collecting.
This is useful when writing reusable collection attributes and you do not know the roots of the abstract grammar.
Comments (3)
-
-
- changed status to resolved
Generalize handling of implicit collection roots
Allow implicit root type for collection attributes when the grammar has multiple root types.
If there are multiple roots in the grammar, the collection root type is set to ASTNode.
Factored out root finding in collection attribute templates.
fixes
#294(bitbucket)→ <<cset 83593f2315c8>>
-
- changed component to attribute checking
- Log in to comment
This error only occurs when using an implicit collection root, i.e. when you omit the
root X
part of the collection attribute declaration.Intuitively one would think that the actual root node of the current tree could be used as the collection root. The only problem is that the generated code for finding the root node searches for a specific root type. Here is the relevant template code:
If the collection root is implicit, then we could instead set
#rootType
toASTNode
and use this:However having
rootType = ASTNode
would not be good for cache memory usage as there are a couple fields generated on the root type for memoizing the collection attribute survey phase.The root type could be the grammar root type if there is one and otherwise ASTNode.