/[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.3 by akim, Fri Jun 14 17:35:45 2002 UTC revision 1.4 by akim, Fri Jun 14 17:36:44 2002 UTC
# Line 85  int current_prec = 0; Line 85  int current_prec = 0;
85    
86  %token PERCENT_TOKEN "%token"  %token PERCENT_TOKEN "%token"
87  %token PERCENT_NTERM "%nterm"  %token PERCENT_NTERM "%nterm"
88  %token PERCENT_TYPE "%type"  %token PERCENT_TYPE  "%type"
89  %token PERCENT_UNION "%union"  %token PERCENT_UNION "%union"
90  %token PERCENT_EXPECT "%expect"  %token PERCENT_EXPECT "%expect"
91  %token PERCENT_START "%start"  %token PERCENT_START "%start"
92  %token PERCENT_LEFT "%left"  %token PERCENT_LEFT  "%left"
93  %token PERCENT_RIGHT "%right"  %token PERCENT_RIGHT "%right"
94  %token PERCENT_NONASSOC "%nonassoc"  %token PERCENT_NONASSOC "%nonassoc"
95  %token PERCENT_PREC     "%prec"  %token PERCENT_PREC     "%prec"
# Line 123  int current_prec = 0; Line 123  int current_prec = 0;
123  %token PROLOGUE EPILOGUE  %token PROLOGUE EPILOGUE
124  %token BRACED_CODE  %token BRACED_CODE
125    
126  %type <string> CHARACTER TYPE  STRING string_content  %type <string> CHARACTER TYPE STRING string_content
127                 BRACED_CODE PROLOGUE EPILOGUE epilogue.opt action                 BRACED_CODE PROLOGUE EPILOGUE epilogue.opt action
128  %type <integer> INT  %type <integer> INT
129  %type <symbol> ID symbol string_as_id  %type <symbol> ID symbol string_as_id
130  %type <assoc> precedence_directive  %type <assoc> precedence_declarator
131    
132  %%  %%
133    
134  input: { LOCATION_RESET (yylloc); }  input: { LOCATION_RESET (yylloc); }
135    directives "%%" gram epilogue.opt    declarations "%%" grammar epilogue.opt
136      {      {
137        yycontrol->errcode = 0;        yycontrol->errcode = 0;
138        epilogue_set ($5, @5);        epilogue_set ($5, @5);
139      }      }
140  ;  ;
141    
142  directives:  
143            /*------------------------------------.
144            | Declarations: before the first %%.  |
145            `------------------------------------*/
146    
147    declarations:
148    /* Nothing */    /* Nothing */
149  | directives directive  | declarations declaration
150  ;  ;
151    
152  directive:  declaration:
153    grammar_directives    grammar_declaration
154  | PROLOGUE  | PROLOGUE                                 { prologue_augment ($1, @1); }
    {  
      prologue_augment ($1, @1);  
    }  
155  | "%debug"                                 { debug_flag = 1; }  | "%debug"                                 { debug_flag = 1; }
156  | "%define" string_content string_content  { muscle_insert ($2, $3); }  | "%define" string_content string_content  { muscle_insert ($2, $3); }
157  | "%defines"                               { defines_flag = 1; }  | "%defines"                               { defines_flag = 1; }
# Line 165  directive: Line 169  directive:
169  | "%yacc"                                  { yacc_flag = 1; }  | "%yacc"                                  { yacc_flag = 1; }
170  ;  ;
171    
172  grammar_directives:  grammar_declaration:
173    precedence_directives    precedence_declaration
174  | "%nterm" { current_class = nterm_sym; } symbol_defs.1  | symbol_declaration
     {  
       current_class = unknown_sym;  
       current_type = NULL;  
     }  
175  | "%start" symbol  | "%start" symbol
176      {      {
177        grammar_start_symbol_set ($2);        grammar_start_symbol_set ($2);
178      }      }
179  | "%token" { current_class = token_sym; } symbol_defs.1  | "%union" BRACED_CODE semi_colon_opt
180        {
181          typed = 1;
182          MUSCLE_INSERT_INT ("stype_line", @2.first_line);
183          muscle_insert ("stype", $2);
184        }
185    ;
186    
187    symbol_declaration:
188      "%nterm" { current_class = nterm_sym; } symbol_defs.1
189      {      {
190        current_class = unknown_sym;        current_class = unknown_sym;
191        current_type = NULL;        current_type = NULL;
192      }      }
193  | "%type" TYPE {current_type = $2; } nterms_to_type.1  | "%token" { current_class = token_sym; } symbol_defs.1
194      {      {
195          current_class = unknown_sym;
196        current_type = NULL;        current_type = NULL;
197      }      }
198  | "%union" BRACED_CODE semi_colon_opt  | "%type" TYPE {current_type = $2; } nterms_to_type.1
199      {      {
200        typed = 1;        current_type = NULL;
       MUSCLE_INSERT_INT ("stype_line", @2.first_line);  
       muscle_insert ("stype", $2);  
201      }      }
202  ;  ;
203    
204  precedence_directives:  precedence_declaration:
205    precedence_directive type.opt    precedence_declarator type.opt
206      { current_assoc = $1; ++current_prec; }      { current_assoc = $1; ++current_prec; }
207    terms_to_prec.1    terms_to_prec.1
208      { current_assoc = non_assoc; current_type = NULL; }      { current_assoc = non_assoc; current_type = NULL; }
209  ;  ;
210    
211  precedence_directive:  precedence_declarator:
212    "%left"     { $$ = left_assoc; }    "%left"     { $$ = left_assoc; }
213  | "%right"    { $$ = right_assoc; }  | "%right"    { $$ = right_assoc; }
214  | "%nonassoc" { $$ = non_assoc; }  | "%nonassoc" { $$ = non_assoc; }
# Line 231  terms_to_prec.1: Line 239  terms_to_prec.1:
239      }      }
240  ;  ;
241    
   
242  /* One token definition.  */  /* One token definition.  */
243  symbol_def:  symbol_def:
244    TYPE    TYPE
# Line 272  symbol_defs.1: Line 279  symbol_defs.1:
279      {;}      {;}
280  ;  ;
281    
282  gram:  
283            /*------------------------------------------.
284            | The grammar section: between the two %%.  |
285            `------------------------------------------*/
286    
287    grammar:
288    rules    rules
289  | gram rules  | grammar rules
290  ;  ;
291    
292  rules:  rules:

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

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