/* lookup the type to get the type descriptor */
type.setSuperType(lookupType(subtype, CREATE_MISSING));
+ } else if (pn.getChild("subclass") != null) {
+ // has a subtype, lets try to resolve it
+ String subclass = pn.getChild("subclass").getTerminal();
+
+ if (subclass.equals(typename)) {
+ // Semantic Error: cyclic inheritance
+ er.report(pn, "Cyclic inheritance prohibited");
+ ok = false;
+ }
+
+ /* lookup the type to get the type descriptor */
+ type.setSuperType(lookupType(subclass, CREATE_MISSING));
+ type.setSubClass(true);
}
// set the current type so that the recursive parses on the labels
<YYINITIAL> byte { return tok(Sym.BYTE, yytext()); }
<YYINITIAL> subtype { return tok(Sym.SUBTYPE, yytext()); }
+<YYINITIAL> subclass { return tok(Sym.SUBCLASS, yytext()); }
<YYINITIAL> of { return tok(Sym.OF, yytext()); }
<YYINITIAL> ";" { return tok(Sym.SEMICOLON, yytext()); }
terminal LABEL;
terminal INT;
terminal SUBTYPE;
+ terminal SUBCLASS;
terminal OF;
terminal SEMICOLON;
;
optsubtype ::=
-
+ /* subtype */
SUBTYPE OF ID:type
{:
debugMessage(PRODSTRING);
subtype.addChild(type);
RESULT = subtype;
:}
+
+ | /* subclass */
+
+ SUBCLASS OF ID:type
+ {:
+ debugMessage(PRODSTRING);
+ ParseNode subtype = new ParseNode("subclass", parser.curLine(3));
+ subtype.addChild(type);
+ RESULT = subtype;
+ :}
| /* nothing */
{: