- {
- nondeterministic_parser = true;
- glr_parser = true;
- }
-| "%initial-action {...}"
- {
- muscle_code_grow ("initial_action", $1, @1);
- }
-| "%lex-param {...}" { add_param ("lex_param", $1, @1); }
-| "%locations" { locations_flag = true; }
-| "%name-prefix" "=" string_content { spec_name_prefix = $3; }
-| "%no-lines" { no_lines_flag = true; }
-| "%nondeterministic-parser" { nondeterministic_parser = true; }
-| "%output" "=" string_content { spec_outfile = $3; }
-| "%parse-param {...}" { add_param ("parse_param", $1, @1); }
-| "%pure-parser" { pure_parser = true; }
-| "%skeleton" string_content { skeleton = $2; }
-| "%token-table" { token_table_flag = true; }
-| "%verbose" { report_flag = report_states; }
-| "%yacc" { yacc_flag = true; }
+ {
+ nondeterministic_parser = true;
+ glr_parser = true;
+ }
+| "%initial-action" "{...}"
+ {
+ code_props action;
+ code_props_symbol_action_init (&action, $2, @2);
+ code_props_translate_code (&action);
+ gram_scanner_last_string_free ();
+ muscle_code_grow ("initial_action", action.code, @2);
+ code_scanner_last_string_free ();
+ }
+| "%language" STRING { language_argmatch ($2, grammar_prio, @1); }
+| "%lex-param" "{...}" { add_param ("lex_param", $2, @2); }
+| "%locations" { locations_flag = true; }
+| "%name-prefix" STRING { spec_name_prefix = $2; }
+| "%name-prefix" "=" STRING { spec_name_prefix = $3; } /* deprecated */
+| "%no-lines" { no_lines_flag = true; }
+| "%nondeterministic-parser" { nondeterministic_parser = true; }
+| "%output" STRING { spec_outfile = $2; }
+| "%output" "=" STRING { spec_outfile = $3; } /* deprecated */
+| "%parse-param" "{...}" { add_param ("parse_param", $2, @2); }
+| "%pure-parser"
+ {
+ /* %pure-parser is deprecated in favor of `%define api.pure', so use
+ `%define api.pure' in a backward-compatible manner here. First, don't
+ complain if %pure-parser is specified multiple times. */
+ if (!muscle_find_const ("percent_define(api.pure)"))
+ muscle_percent_define_insert ("api.pure", @1, "",
+ MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
+ /* In all cases, use api.pure now so that the backend doesn't complain if
+ the skeleton ignores api.pure, but do warn now if there's a previous
+ conflicting definition from an actual %define. */
+ if (!muscle_percent_define_flag_if ("api.pure"))
+ muscle_percent_define_insert ("api.pure", @1, "",
+ MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
+ }
+| "%require" STRING { version_check (&@2, $2); }
+| "%skeleton" STRING
+ {
+ char const *skeleton_user = $2;
+ if (mbschr (skeleton_user, '/'))
+ {
+ size_t dir_length = strlen (current_file);
+ char *skeleton_build;
+ while (dir_length && current_file[dir_length - 1] != '/')
+ --dir_length;
+ while (dir_length && current_file[dir_length - 1] == '/')
+ --dir_length;
+ skeleton_build =
+ xmalloc (dir_length + 1 + strlen (skeleton_user) + 1);
+ if (dir_length > 0)
+ {
+ strncpy (skeleton_build, current_file, dir_length);
+ skeleton_build[dir_length++] = '/';
+ }
+ strcpy (skeleton_build + dir_length, skeleton_user);
+ skeleton_user = uniqstr_new (skeleton_build);
+ free (skeleton_build);
+ }
+ skeleton_arg (skeleton_user, grammar_prio, @1);
+ }
+| "%token-table" { token_table_flag = true; }
+| "%verbose" { report_flag |= report_states; }
+| "%yacc" { yacc_flag = true; }