X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/db89d400f26fe44997c601d783800849e96fb0c9..0049ec8628e5a320d055a0cea8676a58cec60986:/src/parse-gram.y diff --git a/src/parse-gram.y b/src/parse-gram.y index 18eb1ac3..86c1dece 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -286,7 +286,30 @@ prologue_declaration: | "%push-parser" { push_parser = true; pull_parser = false; } | "%push-pull-parser" { push_parser = true; pull_parser = true; } | "%require" STRING { version_check (&@2, $2); } -| "%skeleton" STRING { skeleton_arg ($2, 1, &@1); } +| "%skeleton" STRING + { + char const *skeleton_user = $2; + if (strchr (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, 1, &@1); + } | "%token-table" { token_table_flag = true; } | "%verbose" { report_flag = report_states; } | "%yacc" { yacc_flag = true; } @@ -324,7 +347,7 @@ grammar_declaration: } | "%code" braceless { - muscle_code_grow ("percent_code_unqualified", $2, @2); + muscle_code_grow ("percent_code()", $2, @2); code_scanner_last_string_free (); } | "%code" ID braceless @@ -528,12 +551,11 @@ variable: | STRING { $$ = uniqstr_new ($1); } /* deprecated and not M4-friendly */ ; -/* Some content or "1" by default. */ +/* Some content or empty by default. */ content.opt: /* Nothing. */ { - static char one[] = "1"; - $$ = one; + $$ = ""; } | STRING ;