/[bison]/bison/src/parse-gram.y
ViewVC logotype

Diff of /bison/src/parse-gram.y

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by akim, Fri Jun 14 17:38:14 2002 UTC revision 1.6 by akim, Sat Jun 15 18:21:11 2002 UTC
# Line 40  Line 40 
40    
41  /* Produce verbose parse errors.  */  /* Produce verbose parse errors.  */
42  #define YYERROR_VERBOSE 1  #define YYERROR_VERBOSE 1
43    #define YYLLOC_DEFAULT(Current, Rhs, N)                 \
44    do {                                                    \
45      if (N)                                                \
46      {                                                     \
47        Current.first_column  = Rhs[1].first_column;        \
48        Current.first_line    = Rhs[1].first_line;          \
49        Current.last_column   = Rhs[N].last_column;         \
50        Current.last_line     = Rhs[N].last_line;           \
51      }                                                     \
52      else                                                  \
53      {                                                     \
54        Current = Rhs[0];                                   \
55      }                                                     \
56    } while (0)
57    
58  /* Pass the control structure to YYPARSE and YYLEX. */  /* Pass the control structure to YYPARSE and YYLEX. */
59  #define YYPARSE_PARAM gram_control  #define YYPARSE_PARAM gram_control
# Line 64  static void yyprint (FILE *file, const l Line 78  static void yyprint (FILE *file, const l
78  symbol_class current_class = unknown_sym;  symbol_class current_class = unknown_sym;
79  char *current_type = 0;  char *current_type = 0;
80  symbol_t *current_lhs;  symbol_t *current_lhs;
81    location_t current_lhs_location;
82  associativity current_assoc;  associativity current_assoc;
83  int current_prec = 0;  int current_prec = 0;
84  %}  %}
# Line 128  int current_prec = 0; Line 143  int current_prec = 0;
143    
144  %%  %%
145    
146  input: { LOCATION_RESET (yylloc); }  input:
147    declarations "%%" grammar epilogue.opt    declarations "%%" grammar epilogue.opt
148      {      {
149        yycontrol->errcode = 0;        yycontrol->errcode = 0;
150        epilogue_set ($5, @5);        epilogue_set ($4, @4);
151      }      }
152  ;  ;
153    
# Line 171  grammar_declaration: Line 186  grammar_declaration:
186  | symbol_declaration  | symbol_declaration
187  | "%start" symbol  | "%start" symbol
188      {      {
189        grammar_start_symbol_set ($2);        grammar_start_symbol_set ($2, @2);
190      }      }
191  | "%union" BRACED_CODE  | "%union" BRACED_CODE
192      {      {
# Line 298  rules_or_grammar_declaration: Line 313  rules_or_grammar_declaration:
313  ;  ;
314    
315  rules:  rules:
316    ID ":" { current_lhs = $1; } rhses.1 ";"    ID ":" { current_lhs = $1; current_lhs_location = @1; } rhses.1 ";"
317      {;}      {;}
318  ;  ;
319    
320  rhses.1:  rhses.1:
321    rhs                { grammar_rule_end (); }    rhs                { grammar_rule_end (@1); }
322  | rhses.1 "|" rhs    { grammar_rule_end (); }  | rhses.1 "|" rhs    { grammar_rule_end (@3); }
323  ;  ;
324    
325  rhs:  rhs:
326    /* Nothing.  */    /* Nothing.  */
327      { grammar_rule_begin (current_lhs); }      { grammar_rule_begin (current_lhs, current_lhs_location); }
328  | rhs symbol  | rhs symbol
329      { grammar_current_rule_symbol_append ($2); }      { grammar_current_rule_symbol_append ($2, @2); }
330  | rhs action  | rhs action
331      { grammar_current_rule_action_append ($2, @2.first_line); }      { grammar_current_rule_action_append ($2, @2); }
332  | rhs "%prec" symbol  | rhs "%prec" symbol
333      { grammar_current_rule_prec_set ($3); }      { grammar_current_rule_prec_set ($3); }
334  ;  ;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26