]> git.saurik.com Git - bison.git/blobdiff - src/gram.h
* tests/regression.at, tests/torture.at, tests/calc.at: Adjust to
[bison.git] / src / gram.h
index 66031cc38e67220f55ad241d7c82088208170e02..e26582fe145017ca187b2c1d07591fc254f69af7 100644 (file)
    RULE_TABLE[R].rhs -- the index in RITEM of the beginning of the
    portion for rule R.
 
    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.
 
    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.
 
    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
 
    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 *ritem;
 
-extern short *rprec;
-extern short *rprecsym;
 extern short *sprec;
 extern short *sprec;
-extern short *rassoc;
 extern short *sassoc;
 extern short *sassoc;
-extern short *rline;           /* Source line number of each rule */
 
 extern int start_symbol;
 
 
 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
 {
 /* associativity values in elements of rassoc, sassoc.  */
 typedef enum
 {
@@ -117,6 +113,19 @@ typedef enum
 } associativity;
 
 
 } 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.  */
 /* 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;
 /* 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_ */
 #endif /* !GRAM_H_ */