]> git.saurik.com Git - bison.git/blobdiff - src/parse-gram.y
Fix code formatting.
[bison.git] / src / parse-gram.y
index 9933ecdad7e3574c13f9b1688c9a5f09d893e39b..ae9eb535682e889ea203d8697f5c083cf5fa500e 100644 (file)
@@ -130,10 +130,13 @@ static int current_prec = 0;
 `----------------------*/
 
 %token
+  PERCENT_AFTER_HEADER    "%after-header"
+  PERCENT_BEFORE_HEADER   "%before-header"
   PERCENT_DEBUG           "%debug"
   PERCENT_DEFAULT_PREC    "%default-prec"
   PERCENT_DEFINE          "%define"
   PERCENT_DEFINES         "%defines"
+  PERCENT_END_HEADER      "%end-header"
   PERCENT_ERROR_VERBOSE   "%error-verbose"
   PERCENT_EXPECT          "%expect"
   PERCENT_EXPECT_RR      "%expect-rr"
@@ -153,6 +156,7 @@ static int current_prec = 0;
   PERCENT_REQUIRE        "%require"
   PERCENT_SKELETON        "%skeleton"
   PERCENT_START           "%start"
+  PERCENT_START_HEADER    "%start-header"
   PERCENT_TOKEN_TABLE     "%token-table"
   PERCENT_VERBOSE         "%verbose"
   PERCENT_YACC            "%yacc"
@@ -210,8 +214,22 @@ declarations:
 
 declaration:
   grammar_declaration
-| PROLOGUE                         { prologue_augment (translate_code ($1, @1),
-                                                      @1); }
+| PROLOGUE
+    {
+      prologue_augment (translate_code ($1, @1), @1, typed);
+    }
+| "%after-header" "{...}"
+    {
+      /* Remove the '{', and replace the '}' with '\n'.  */
+      $2[strlen ($2) - 1] = '\n';
+      prologue_augment (translate_code ($2+1, @2), @2, true);
+    }
+| "%before-header" "{...}"
+    {
+      /* Remove the '{', and replace the '}' with '\n'.  */
+      $2[strlen ($2) - 1] = '\n';
+      prologue_augment (translate_code ($2+1, @2), @2, false);
+    }
 | "%debug"                                 { debug_flag = true; }
 | "%define" string_content
     {
@@ -220,6 +238,12 @@ declaration:
     }
 | "%define" string_content string_content  { muscle_insert ($2, $3); }
 | "%defines"                               { defines_flag = true; }
+| "%end-header" "{...}"
+    {
+      /* Remove the '{', and replace the '}' with '\n'.  */
+      $2[strlen ($2) - 1] = '\n';
+      muscle_code_grow ("end_header", translate_code ($2+1, @2), @2);
+    }
 | "%error-verbose"                         { error_verbose = true; }
 | "%expect" INT                            { expected_sr_conflicts = $2; }
 | "%expect-rr" INT                        { expected_rr_conflicts = $2; }
@@ -243,6 +267,12 @@ declaration:
 | "%pure-parser"                           { pure_parser = true; }
 | "%require" string_content                { version_check (&@2, $2); }
 | "%skeleton" string_content               { skeleton = $2; }
+| "%start-header" "{...}"
+    {
+      /* Remove the '{', and replace the '}' with '\n'.  */
+      $2[strlen ($2) - 1] = '\n';
+      muscle_code_grow ("start_header", translate_code ($2+1, @2), @2);
+    }
 | "%token-table"                           { token_table_flag = true; }
 | "%verbose"                               { report_flag = report_states; }
 | "%yacc"                                  { yacc_flag = true; }
@@ -443,8 +473,7 @@ rhs:
 | rhs symbol
     { grammar_current_rule_symbol_append ($2, @2); }
 | rhs "{...}"
-    { grammar_current_rule_action_append (gram_last_string,
-                                         gram_last_braced_code_loc); }
+    { grammar_current_rule_action_append ($2, @2); }
 | rhs "%prec" symbol
     { grammar_current_rule_prec_set ($3, @3); }
 | rhs "%dprec" INT