[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Invalid element names


I am getting the following error when compiling a grammar that refers to the
element 'class' in one of its productions:
"java.lang.RuntimeException: [<row>,<col>] class is an invalid element

So it seems like 'class' is a reserved element name in SableCC.
I checked the java example grammars, and, surely, they don't use class as
element names either. But they also show a convenient way to get around the
problem: append a different element name to the 'class' element.

Now that explains why defining a 'class' token or production is permitted,
although using it as an element name is not.

Wow! I was going to ask why such a limitation but it just him me in the
face: all Java classes inherit the getClass() method from the Object root
class, and having a 'class' element would require a getClass() method, a
I wonder if Etienne didn't come upon this one when writing translating the
java grammar... ;-)

I guess I already answered all the questions I wanted to ask while writing
this message. A last one though: anymore like these in SableCC?