X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/091e20bbee87fc6e5b1e9e2938767c6e89b19035..3cd5bcdd19537bafd3ae7d0851cda452a3422e98:/src/output.c?ds=sidebyside diff --git a/src/output.c b/src/output.c index 60b79790..34d6b06a 100644 --- a/src/output.c +++ b/src/output.c @@ -1075,7 +1075,8 @@ output_master_parser (void) #define MUSCLE_INSERT_PREFIX(Key, Value) \ { \ - obstack_fgrow2 (&muscle_obstack, "%s%s", spec_name_prefix, Value); \ + obstack_fgrow2 (&muscle_obstack, "%s%s", \ + spec_name_prefix ? spec_name_prefix : "yy", Value); \ obstack_1grow (&muscle_obstack, 0); \ muscle_insert (Key, obstack_finish (&muscle_obstack)); \ } @@ -1091,7 +1092,7 @@ prepare (void) MUSCLE_INSERT_INT ("final", final_state); MUSCLE_INSERT_INT ("maxtok", max_user_token_number); MUSCLE_INSERT_INT ("error-verbose", error_verbose); - MUSCLE_INSERT_STRING ("prefix", spec_name_prefix); + MUSCLE_INSERT_STRING ("prefix", spec_name_prefix ? spec_name_prefix : "yy"); MUSCLE_INSERT_INT ("nnts", nvars); MUSCLE_INSERT_INT ("nrules", nrules); @@ -1127,7 +1128,27 @@ yystype;\n\ if (!pure_parser) fprintf (out, "\nextern YYSTYPE %slval;\n", - spec_name_prefix); + spec_name_prefix ? spec_name_prefix : "yy"); + + if (locations_flag) + { + fputs ("\n\n", out); + fprintf (out, "\ +#ifndef YYLTYPE\n\ +typedef struct yyltype\n\ +{\n\ + int first_line;\n\ + int first_column;\n\ + int last_line;\n\ + int last_column;\n\ +} yyltype;\n\ +# define YYLTYPE yyltype\n\ +#endif\n"); + if (!pure_parser) + fprintf (out, "\nextern YYLTYPE %slloc;\n", + spec_name_prefix ? spec_name_prefix : "yy"); + } + if (semantic_parser) { int i;