#include <config.h>
#include "system.h"
+#include <strverscmp.h>
+
#include "complain.h"
#include "conflicts.h"
#include "files.h"
#include "symlist.h"
#include "scan-gram.h"
#include "scan-code.h"
-#include "strverscmp.h"
#define YYLLOC_DEFAULT(Current, Rhs, N) (Current) = lloc_default (Rhs, N)
static YYLTYPE lloc_default (YYLTYPE const *, int);
static location current_lhs_location;
static int current_prec = 0;
-#ifdef UINT_FAST8_MAX
-# define YYTYPE_UINT8 uint_fast8_t
-#endif
-#ifdef INT_FAST8_MAX
-# define YYTYPE_INT8 int_fast8_t
-#endif
-#ifdef UINT_FAST16_MAX
-# define YYTYPE_UINT16 uint_fast16_t
-#endif
-#ifdef INT_FAST16_MAX
-# define YYTYPE_INT16 int_fast16_t
-#endif
+#define YYTYPE_INT16 int_fast16_t
+#define YYTYPE_INT8 int_fast8_t
+#define YYTYPE_UINT16 uint_fast16_t
+#define YYTYPE_UINT8 uint_fast8_t
%}
%debug
{
/* Bison's grammar can initial empty locations, hence a default
location is needed. */
- boundary_set (&@$.start, current_file, 1, 0);
- boundary_set (&@$.end, current_file, 1, 0);
+ boundary_set (&@$.start, current_file, 1, 1);
+ boundary_set (&@$.end, current_file, 1, 1);
}
/* Only NUMBERS have a value. */
`----------------------*/
%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"
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"
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
{
}
| "%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; }
| "%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; }
| 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