X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/bb3b912b0a43b8b740a05ad1d15686e68f8e3f39..bfdcc3a0b273c116e01d289ce52d400f22e4da14:/src/parse-gram.y diff --git a/src/parse-gram.y b/src/parse-gram.y index 1968e310..5f77a5bd 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -20,6 +20,7 @@ #include #include "system.h" +#include "c-ctype.h" #include "complain.h" #include "conflicts.h" #include "files.h" @@ -32,6 +33,7 @@ #include "symlist.h" #include "scan-gram.h" #include "scan-code.h" +#include "xmemdup0.h" #define YYLLOC_DEFAULT(Current, Rhs, N) (Current) = lloc_default (Rhs, N) static YYLTYPE lloc_default (YYLTYPE const *, int); @@ -92,14 +94,14 @@ current_lhs(symbol *sym, location loc, named_ref *ref) %} %debug -%verbose +%define api.prefix "gram_" +%define api.pure +%define parse.lac full %defines -%locations -%pure-parser %error-verbose -%define parse.lac full -%name-prefix="gram_" %expect 0 +%locations +%verbose %initial-action { @@ -250,7 +252,7 @@ prologue_declaration: plain_code.code, @1); code_scanner_last_string_free (); } -| "%debug" { debug_flag = true; } +| "%debug" { debug = true; } | "%define" variable content.opt { muscle_percent_define_insert ($2, @2, $3, @@ -346,17 +348,27 @@ grammar_declaration: } | "%destructor" "{...}" generic_symlist { - symbol_list *list; - for (list = $3; list; list = list->next) - symbol_list_destructor_set (list, $2, @2); - symbol_list_free ($3); + code_props code; + code_props_symbol_action_init (&code, $2, @2); + code_props_translate_code (&code); + { + symbol_list *list; + for (list = $3; list; list = list->next) + symbol_list_destructor_set (list, &code); + symbol_list_free ($3); + } } | "%printer" "{...}" generic_symlist { - symbol_list *list; - for (list = $3; list; list = list->next) - symbol_list_printer_set (list, $2, @2); - symbol_list_free ($3); + code_props code; + code_props_symbol_action_init (&code, $2, @2); + code_props_translate_code (&code); + { + symbol_list *list; + for (list = $3; list; list = list->next) + symbol_list_printer_set (list, &code); + symbol_list_free ($3); + } } | "%default-prec" { @@ -723,27 +735,19 @@ add_param (char const *type, char *decl, location loc) /* Strip the surrounding '{' and '}', and any blanks just inside the braces. */ - while (*--p == ' ' || *p == '\t') - continue; + --p; + while (c_isspace ((unsigned char) *p)) + --p; p[1] = '\0'; - while (*++decl == ' ' || *decl == '\t') - continue; + ++decl; + while (c_isspace ((unsigned char) *decl)) + ++decl; if (! name_start) complain_at (loc, _("missing identifier in parameter declaration")); else { - char *name; - size_t name_len; - - for (name_len = 1; - memchr (alphanum, name_start[name_len], sizeof alphanum); - name_len++) - continue; - - name = xmalloc (name_len + 1); - memcpy (name, name_start, name_len); - name[name_len] = '\0'; + char *name = xmemdup0 (name_start, strspn (name_start, alphanum)); muscle_pair_list_grow (type, decl, name); free (name); }