X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/68f1e3edc304e03b249b64791e4b7d981938bef4..1a2b5d37e1d44b47cd51220945f4ba29c228a419:/src/gram.h diff --git a/src/gram.h b/src/gram.h index ca55d007..9e16c031 100644 --- a/src/gram.h +++ b/src/gram.h @@ -39,27 +39,27 @@ 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. @@ -78,7 +78,7 @@ 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 @@ -98,9 +98,7 @@ extern int ntokens; extern int nvars; extern short *ritem; - -extern short *sprec; -extern short *sassoc; +extern int nritems; extern int start_symbol; @@ -122,9 +120,18 @@ typedef struct rule_s 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 @@ -147,4 +154,12 @@ extern int pure_parser; /* 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_ */