X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/b2ed6e5826e772162719db595446b2c58e4ac5d6..927c15577418c9c18feea508854a3f49bb03aa9f:/src/gram.h diff --git a/src/gram.h b/src/gram.h index 66031cc3..e26582fe 100644 --- a/src/gram.h +++ b/src/gram.h @@ -50,6 +50,17 @@ RULE_TABLE[R].rhs -- the index in RITEM of the beginning of the portion for rule R. + RULE_TABLE[R].prec -- the precedence level of R. + + RULE_TABLE[R].precsym -- the symbol-number of the symbol in %prec + for R (if any). + + RULE_TABLE[R].assoc -- the associativity of R. + + RULE_TABLE[R].line -- the line where R was defined. + + RULE_TABLE[R].useful -- TRUE iff the rule is used. + The right hand side is stored as symbol numbers in a portion of RITEM. @@ -67,10 +78,7 @@ Item numbers are used in the finite state machine to represent places that parsing can get to. - Precedence levels are recorded in the vectors sprec and rprec. - sprec records the precedence level of each symbol, rprec the - precedence level of each rule. rprecsym is the symbol-number of - the symbol in %prec for this rule (if any). + SPREC 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 @@ -91,23 +99,11 @@ extern int nvars; extern short *ritem; -extern short *rprec; -extern short *rprecsym; extern short *sprec; -extern short *rassoc; extern short *sassoc; -extern short *rline; /* Source line number of each rule */ extern int start_symbol; -typedef struct rule_s -{ - short lhs; - short rhs; -} rule_t; - -extern struct rule_s *rule_table; - /* associativity values in elements of rassoc, sassoc. */ typedef enum { @@ -117,6 +113,19 @@ typedef enum } associativity; +typedef struct rule_s +{ + short lhs; + short rhs; + short prec; + short precsym; + short assoc; + short line; + bool useful; +} rule_t; + +extern struct rule_s *rule_table; + /* token translation table: indexed by a token number as returned by the user's yylex routine, it yields the internal token number used by the parser and throughout bison. */ @@ -138,4 +147,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_ */