terminal SUB;
terminal MULT;
terminal DIV;
+ terminal SUM;
terminal NOT;
terminal LT;
terminal LABEL;
terminal INT;
terminal SUBTYPE;
+ terminal SUBCLASS;
terminal OF;
terminal SEMICOLON;
nonterminal ParseNode field;
nonterminal ParseNode optptr;
nonterminal ParseNode type;
+nonterminal ParseNode primtype;
nonterminal ParseNode optindex;
nonterminal ParseNode expr;
nonterminal ParseNode simple_expr;
{:
debugMessage(PRODSTRING);
ParseNode global = new ParseNode("global", parser.curLine(4));
+ global.addChild("ptr");
global.addChild("type").addChild(type);
global.addChild("name").addChild(name);
RESULT = global;
:}
+
+ | primtype:type ID:name SEMICOLON
+ {:
+ debugMessage(PRODSTRING);
+ ParseNode global = new ParseNode("global", parser.curLine(4));
+ global.addChild(type);
+ global.addChild("name").addChild(name);
+ RESULT = global;
+ :}
;
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 */
{:
RESULT = expr;
:}
- | LITERAL OPENPAREN literal:literal CLOSEPAREN
+ | literal:literal
{:
debugMessage(PRODSTRING);
ParseNode expr = new ParseNode("expr", parser.curLine(4));
debugMessage(PRODSTRING);
RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("decimal").addChild(dec).getRoot();
:}
+
+ | SUB DECIMAL:dec
+ {:
+ debugMessage(PRODSTRING);
+ RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("decimal").addChild("-"+dec).getRoot();
+ :}
| STRING:str
{:
RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("char").addChild(chr).getRoot();
:}
- | ID:literal
+ | LITERAL OPENPAREN ID:literal CLOSEPAREN
{:
debugMessage(PRODSTRING);
RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("token").addChild(literal).getRoot();
RESULT = type;
:}
;
+
+primtype ::=
+
+ BIT
+ {:
+ debugMessage(PRODSTRING);
+ ParseNode type = new ParseNode("type", parser.curLine(1));
+ type.addChild("bit");
+ RESULT = type;
+ :}
+
+ | BYTE
+ {:
+ debugMessage(PRODSTRING);
+ ParseNode type = new ParseNode("type", parser.curLine(1));
+ type.addChild("byte");
+ RESULT = type;
+ :}
+
+ | SHORT
+ {:
+ debugMessage(PRODSTRING);
+ ParseNode type = new ParseNode("type", parser.curLine(1));
+ type.addChild("short");
+ RESULT = type;
+ :}
+
+ | INT
+ {:
+ debugMessage(PRODSTRING);
+ ParseNode type = new ParseNode("type", parser.curLine(1));
+ type.addChild("int");
+ RESULT = type;
+ :}
+;
\ No newline at end of file