#include "reader.h"
#include "conflicts.h"
-/* Produce verbose parse errors. */
+/* Produce verbose syntax errors. */
#define YYERROR_VERBOSE 1
#define YYLLOC_DEFAULT(Current, Rhs, N) \
do { \
correctly typed access to it. */
#define yycontrol ((gram_control_t *) gram_control)
-/* Request detailed parse error messages, and pass them to GRAM_ERROR.
+/* Request detailed syntax error messages, and pass them to GRAM_ERROR.
FIXME: depends on the undocumented availability of YYLLOC.t */
#undef yyerror
#define yyerror(Msg) \
static void yyprint (FILE *file, int type, const yystype *value);
symbol_class current_class = unknown_sym;
-char *current_type = 0;
+struniq_t current_type = 0;
symbol_t *current_lhs;
location_t current_lhs_location;
assoc_t current_assoc;
int integer;
char *string;
assoc_t assoc;
+ struniq_t struniq;
};
/* Define the tokens together with their human representation. */
%token BRACED_CODE "{...}"
-%type <string> TYPE STRING string_content
- BRACED_CODE PROLOGUE EPILOGUE epilogue.opt action
+%type <string> STRING string_content
+ BRACED_CODE code_content action
+ PROLOGUE EPILOGUE
+%type <struniq> TYPE
%type <integer> INT
%type <symbol> ID symbol string_as_id
%type <assoc> precedence_declarator
declarations "%%" grammar epilogue.opt
{
yycontrol->errcode = 0;
- epilogue_set ($4, @4);
}
;
| "%expect" INT { expected_conflicts = $2; }
| "%file-prefix" "=" string_content { spec_file_prefix = $3; }
| "%glr-parser" { glr_parser = 1; }
-| "%lex-param" string_content "," string_content
- { muscle_pair_list_grow ("lex_param", $2, $4); }
+| "%lex-param" code_content "," code_content
+ {
+ muscle_pair_list_grow ("lex_param", $2, $4);
+ scanner_last_string_free ();
+ }
| "%locations" { locations_flag = 1; }
| "%name-prefix" "=" string_content { spec_name_prefix = $3; }
| "%no-lines" { no_lines_flag = 1; }
| "%output" "=" string_content { spec_outfile = $3; }
-| "%parse-param" string_content "," string_content
- { muscle_pair_list_grow ("parse_param", $2, $4); }
+| "%parse-param" code_content "," code_content
+ {
+ muscle_pair_list_grow ("parse_param", $2, $4);
+ scanner_last_string_free ();
+ }
| "%pure-parser" { pure_parser = 1; }
| "%skeleton" string_content { skeleton = $2; }
| "%token-table" { token_table_flag = 1; }
};
+/* A BRACED_CODE used for its contents. Strip the braces. */
+code_content:
+ BRACED_CODE
+ {
+ $$ = $1 + 1;
+ $$[strlen ($$) - 1] = '\0';
+ };
+
+
epilogue.opt:
/* Nothing. */
- {
- $$ = xstrdup ("");
- }
| "%%" EPILOGUE
{
- $$ = $2;
+ epilogue_augment ($2, @2);
+ scanner_last_string_free ();
}
;
break;
case TYPE:
- fprintf (file, " = <%s>", value->string);
+ fprintf (file, " = <%s>", value->struniq);
break;
case BRACED_CODE:
case EPILOGUE:
fprintf (file, " = {{ %s }}", value->string);
break;
+
+ default:
+ fprintf (file, "unknown token type");
+ break;
}
}