]> git.saurik.com Git - bison.git/blobdiff - src/gram.h
Initial check-in introducing experimental GLR parsing. See entry in
[bison.git] / src / gram.h
index a5079e379042718345766ec8d3652d75b7b0e420..3254678ffedb24adc5b4a06b460e1508eb149116 100644 (file)
 
    RULES[R].assoc -- the associativity of R.
 
+   RULES[R].dprec -- the dynamic precedence level of R (for GLR parsing).
+
+   RULES[R].merger -- index of merging function for R (for GLR parsing).
+
    RULES[R].line -- the line where R was defined.
 
    RULES[R].useful -- TRUE iff the rule is used (i.e., FALSE if thrown
 
    Associativities are recorded similarly in SYMBOLS[I]->assoc.  */
 
-#include "symtab.h"
+# include "location.h"
+# include "symtab.h"
 
-#define        ISTOKEN(s)      ((s) < ntokens)
-#define        ISVAR(s)        ((s) >= ntokens)
+# define ISTOKEN(s)    ((s) < ntokens)
+# define ISVAR(s)      ((s) >= ntokens)
 
 extern int nrules;
 extern int nsyms;
 extern int ntokens;
 extern int nvars;
 
-#define ITEM_NUMBER_MAX INT_MAX
+# define ITEM_NUMBER_MAX INT_MAX
 typedef int item_number_t;
 extern item_number_t *ritem;
 extern unsigned int nritems;
@@ -118,8 +123,8 @@ extern unsigned int nritems;
 
    Therefore, an symbol_number_t must be a valid item_number_t, and we
    sometimes have to perform the converse transformation.  */
-#define symbol_number_as_item_number(Tok) ((item_number_t) (Tok))
-#define item_number_as_symbol_number(Ite) ((symbol_number_t) (Ite))
+# define symbol_number_as_item_number(Tok) ((item_number_t) (Tok))
+# define item_number_as_symbol_number(Ite) ((symbol_number_t) (Ite))
 
 extern symbol_number_t start_symbol;
 
@@ -140,14 +145,17 @@ typedef struct rule_s
   /* This symbol provides both the associativity, and the precedence. */
   symbol_t *prec;
 
+  short dprec;
+  short merger;
+
   /* This symbol was attached to the rule via %prec. */
   symbol_t *precsym;
 
-  int line;
+  location_t location;
   bool useful;
 
   const char *action;
-  int action_line;
+  location_t action_location;
 } rule_t;
 
 extern struct rule_s *rules;
@@ -162,20 +170,40 @@ extern symbol_number_t *token_translations;
 extern int max_user_token_number;
 
 
+/* GLR_PARSER is nonzero if the input file says to use the GLR
+   (Generalized LR) parser, and to output some additional
+   information used by the GLR algorithm. */
+
+extern int glr_parser;
+
 /* PURE_PARSER is nonzero if should generate a parser that is all pure
    and reentrant.  */
 
 extern int pure_parser;
 
-/* Report the length of the RHS. */
+/* Return the length of the RHS.  */
 int rule_rhs_length PARAMS ((rule_t *rule));
 
+/* Print this RULE's RHS on OUT.  */
+void rule_rhs_print PARAMS ((rule_t *rule, FILE *out));
+
+/* Print this RULE on OUT.  */
+void rule_print PARAMS ((rule_t *rule, FILE *out));
+
 /* 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));
 
+/* Print the grammar's rules numbers from BEGIN (inclusive) to END
+   (exclusive) on OUT under TITLE.  */
+void grammar_rules_partial_print PARAMS ((FILE *out, const char *title,
+                                         int begin, int end));
+
+/* Print the grammar's rules on OUT.  */
+void grammar_rules_print PARAMS ((FILE *out));
+
 /* Dump the grammar. */
 void grammar_dump PARAMS ((FILE *out, const char *title));