Collection attribute keywords 'with' and 'root' can be misspelled without consequence
JastAdd 2.1.13
The declaration syntax for a collection attribute looks like this:
coll Collection<B> A.set() [new HashSet<B>()] with add root A;
Currently JastAdd does not care what the spelling of the words with
or root
is. For example the following compiles identically to the above:
coll Collection<B> A.set() [new HashSet<B>()] without add not_root A;
This bug has the troublesome consequence that the order of 'with' and 'root' does not matter, only the order of their arguments. For example, the following declaration is also identical to the first one:
coll Collection<B> A.set() [new HashSet<B>()] root add with A;
The origin of this bug is the parser rule for collection attribute declarations, which only requires an identifier in place of root
and with
. These should have been keywords, but making root
and with
keywords might cause old code to break.
Comments (3)
-
-
reporter A better solution is probably to use lexical states. The
coll
keyword is a useful disambiguator. -
reporter - changed status to resolved
Treat 'with' and 'root' as keywords for coll decl
Added lexical state for collection attribute declarations in the aspect parser to make 'with' and 'root' be treated like regular keywords in that context.
fixes
#237(bitbucket)→ <<cset 0e1c85d687b7>>
- Log in to comment
It makes sense to not have "root" and "with" as keywords. Instead this error can be reported as a semantic error.