Productions
program = cls*;
cls = clsdef name openbrace clsdata closingbrace;
clsdata = (clsfield|clsmethod)*;
clsfield = [variabletype]:name [variablename]:name semi;
clsmethod = [returntype]:name [methodname]:name openmethodbrace closingmethodbrace openbrace closingbrace;
The problem resides in
clsdata = (clsfield|clsmethod)*;
If I set clsdata
to
clsdata = clsfield*;
or to
clsdata = clsmethod*;
it works fine, though, as you can imagine, it doesn't mean the same thing as what I intended it to. I want a class to allow for both methods and fields (in no specific order!).
So my question is in how should I define clsdata
so that I don't get errors. I can think of recursive alternatives, but I'd like to keep this as clean as possible!
Thanks