written. Actions and guards are accessed via the rule number.
The rules themselves are described by several arrays: amongst which
- RITEM, and RULE_TABLE.
+ RITEM, and RULES.
- RULE_TABLE is an array of struct rule_s, which members are:
+ RULES is an array of struct rule_s, which members are:
- RULE_TABLE[R].lhs -- the symbol number of the left hand side of
+ RULES[R].lhs -- the symbol number of the left hand side of
rule R. If -1, the rule has been thrown out by reduce.c and should
be ignored.
- RULE_TABLE[R].rhs -- the index in RITEM of the beginning of the
+ RULES[R].rhs -- the index in RITEM of the beginning of the
portion for rule R.
- RULE_TABLE[R].prec -- the precedence level of R.
+ RULES[R].prec -- the precedence level of R.
- RULE_TABLE[R].precsym -- the symbol-number of the symbol in %prec
+ RULES[R].precsym -- the symbol-number of the symbol in %prec
for R (if any).
- RULE_TABLE[R].assoc -- the associativity of R.
+ RULES[R].assoc -- the associativity of R.
- RULE_TABLE[R].line -- the line where R was defined.
+ RULES[R].line -- the line where R was defined.
- RULE_TABLE[R].useful -- TRUE iff the rule is used.
+ RULES[R].useful -- TRUE iff the rule is used.
The right hand side is stored as symbol numbers in a portion of
RITEM.
Item numbers are used in the finite state machine to represent
places that parsing can get to.
- SPREC records the precedence level of each symbol.
+ SYMBOLS[I]->PREC records the precedence level of each symbol.
Precedence levels are assigned in increasing order starting with 1
so that numerically higher precedence values mean tighter binding
extern int nvars;
extern short *ritem;
-
-extern short *sprec;
-extern short *sassoc;
+extern int nritems;
extern int start_symbol;
short assoc;
short line;
bool useful;
+
+ const char *action;
+ short action_line;
+
+ const char *guard;
+ short guard_line;
} rule_t;
-extern struct rule_s *rule_table;
+extern struct rule_s *rules;
+
+/* Table of the symbols, indexed by the symbol number. */
+extern struct bucket **symbols;
/* token translation table: indexed by a token number as returned by
the user's yylex routine, it yields the internal token number used
/* ERROR_TOKEN_NUMBER is the token number of the error token. */
extern int error_token_number;
+
+
+/* Dump RITEM for traces. */
+void ritem_print PARAMS ((FILE *out));
+
+/* Return the size of the longest rule RHS. */
+size_t ritem_longest_rhs PARAMS ((void));
+
#endif /* !GRAM_H_ */