Merge remote-tracking branch 'origin/maint'

* origin/maint: (29 commits)
  regen
  synclines: remove spurious empty line
  also support $<foo>$ in the %initial-action
  skeletons: b4_dollar_pushdef and popdef to simpify complex definitions
  regen
  printer/destructor: translate only once
  factor the handling of m4 escaping
  news: schedule the removal of the ";" hack
  style changes in the scanners
  regen
  support $<tag>$ in printers and destructors
  scan-code: factor the handling of the type in $<TYPE>$
  muscles: fix another occurrence of unescaped type name
  glr.cc: fix the handling of yydebug
  gnulib: update
  formatting changes
  tests: fix an assertion
  tests: adjust to GCC 4.8, which displays caret errors
  be sure to properly escape type names
  obstack_quote: escape and quote for M4
  muscles: shuffle responsabilities
  muscles: make private functions static
  muscles: rename private functions/macros
  obstack_escape: escape M4 characters
  remove dead macro
  maint: style changes
  doc: avoid problems with case insensitive file systems
  configure: fix botched quoting
  news: fix typo.

Conflicts:
	NEWS
	data/c.m4
	data/glr.cc
	data/lalr1.cc
	examples/rpcalc/local.mk
	src/muscle-tab.h
	src/output.c
	src/parse-gram.c
	src/parse-gram.h
	src/parse-gram.y
	src/scan-code.l
	src/symlist.c
	src/symlist.h
	src/symtab.h
	tests/calc.at
This commit is contained in:
Akim Demaille
2012-07-27 16:22:45 +02:00
32 changed files with 669 additions and 294 deletions

View File

@@ -177,10 +177,10 @@ static void
muscle_syncline_grow (char const *key, location loc)
{
char *extension = NULL;
obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, [[", loc.start.line);
MUSCLE_OBSTACK_SGROW (&muscle_obstack,
quotearg_style (c_quoting_style, loc.start.file));
obstack_sgrow (&muscle_obstack, "]])[");
obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, ", loc.start.line);
obstack_quote (&muscle_obstack,
quotearg_style (c_quoting_style, loc.start.file));
obstack_sgrow (&muscle_obstack, ")[");
obstack_1grow (&muscle_obstack, 0);
extension = obstack_finish (&muscle_obstack);
muscle_grow (key, extension, "");
@@ -205,11 +205,11 @@ void muscle_pair_list_grow (const char *muscle,
const char *a1, const char *a2)
{
char *pair;
obstack_sgrow (&muscle_obstack, "[[[");
MUSCLE_OBSTACK_SGROW (&muscle_obstack, a1);
obstack_sgrow (&muscle_obstack, "]], [[");
MUSCLE_OBSTACK_SGROW (&muscle_obstack, a2);
obstack_sgrow (&muscle_obstack, "]]]");
obstack_sgrow (&muscle_obstack, "[");
obstack_quote (&muscle_obstack, a1);
obstack_sgrow (&muscle_obstack, ", ");
obstack_quote (&muscle_obstack, a2);
obstack_sgrow (&muscle_obstack, "]");
obstack_1grow (&muscle_obstack, 0);
pair = obstack_finish (&muscle_obstack);
muscle_grow (muscle, pair, ",\n");
@@ -259,53 +259,61 @@ muscle_find (char const *key)
}
void
/* In the format `file_name:line.column', append BOUND to MUSCLE. Use
digraphs for special characters in the file name. */
static void
muscle_boundary_grow (char const *key, boundary bound)
{
char *extension;
MUSCLE_OBSTACK_SGROW (&muscle_obstack, bound.file);
obstack_sgrow (&muscle_obstack, "[[");
obstack_escape (&muscle_obstack, bound.file);
obstack_1grow (&muscle_obstack, ':');
obstack_fgrow1 (&muscle_obstack, "%d", bound.line);
obstack_1grow (&muscle_obstack, '.');
obstack_fgrow1 (&muscle_obstack, "%d", bound.column);
obstack_sgrow (&muscle_obstack, "]]");
obstack_1grow (&muscle_obstack, '\0');
extension = obstack_finish (&muscle_obstack);
muscle_grow (key, extension, "");
obstack_free (&muscle_obstack, extension);
}
void
/* In the format `[[file_name:line.column]], [[file_name:line.column]]',
append LOC to MUSCLE. Use digraphs for special characters in each
file name. */
static void
muscle_location_grow (char const *key, location loc)
{
muscle_grow (key, "[[", "");
muscle_boundary_grow (key, loc.start);
muscle_grow (key, "]], [[", "");
muscle_grow (key, "", ", ");
muscle_boundary_grow (key, loc.end);
muscle_grow (key, "]]", "");
}
#define MUSCLE_COMMON_DECODE(Value) \
case '$': \
aver (*++(Value) == ']'); \
aver (*++(Value) == '['); \
obstack_sgrow (&muscle_obstack, "$"); \
break; \
case '@': \
switch (*++(Value)) \
{ \
case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \
case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \
case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \
default: aver (false); break; \
} \
break; \
default: \
obstack_1grow (&muscle_obstack, *(Value)); \
#define COMMON_DECODE(Value) \
case '$': \
aver (*++(Value) == ']'); \
aver (*++(Value) == '['); \
obstack_sgrow (&muscle_obstack, "$"); \
break; \
case '@': \
switch (*++(Value)) \
{ \
case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \
case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \
case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \
default: aver (false); break; \
} \
break; \
default: \
obstack_1grow (&muscle_obstack, *(Value)); \
break;
/* Reverse of MUSCLE_OBSTACK_SGROW. */
/* Reverse of obstack_escape. */
static char *
muscle_string_decode (char const *key)
string_decode (char const *key)
{
char const *value;
char *value_decoded;
@@ -317,7 +325,7 @@ muscle_string_decode (char const *key)
do {
switch (*value)
{
MUSCLE_COMMON_DECODE (value)
COMMON_DECODE (value)
case '[':
case ']':
aver (false);
@@ -332,7 +340,7 @@ muscle_string_decode (char const *key)
/* Reverse of muscle_location_grow. */
static location
muscle_location_decode (char const *key)
location_decode (char const *key)
{
location loc;
char const *value = muscle_find_const (key);
@@ -342,7 +350,7 @@ muscle_location_decode (char const *key)
while (*++value)
switch (*value)
{
MUSCLE_COMMON_DECODE (value)
COMMON_DECODE (value)
case '[':
aver (false);
break;
@@ -491,7 +499,7 @@ muscle_percent_define_get (char const *variable)
variable, ")");
muscle_insert (usage_name, "");
value = muscle_string_decode (name);
value = string_decode (name);
if (!value)
value = xstrdup ("");
return value;
@@ -505,7 +513,7 @@ muscle_percent_define_get_loc (char const *variable)
if (!muscle_find_const (loc_name))
complain (fatal, _("%s: undefined %%define variable %s"),
"muscle_percent_define_get_loc", quote (variable));
return muscle_location_decode (loc_name);
return location_decode (loc_name);
}
char const *
@@ -610,7 +618,7 @@ muscle_percent_define_check_values (char const * const *values)
name = UNIQSTR_CONCAT ("percent_define(", *variablep, ")");
value = muscle_string_decode (name);
value = string_decode (name);
if (value)
{
for (++values; *values; ++values)

View File

@@ -35,63 +35,48 @@ void muscle_free (void);
extern struct obstack muscle_obstack;
#define MUSCLE_INSERT_BOOL(Key, Value) \
do { \
int v__ = Value; \
MUSCLE_INSERT_INT (Key, v__); \
} while(0)
do { \
int v__ = Value; \
MUSCLE_INSERT_INT (Key, v__); \
} while (0)
#define MUSCLE_INSERT_INT(Key, Value) \
do { \
obstack_fgrow1 (&muscle_obstack, "%d", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
do { \
obstack_fgrow1 (&muscle_obstack, "%d", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while (0)
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
do { \
obstack_fgrow1 (&muscle_obstack, "%ld", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
do { \
obstack_fgrow1 (&muscle_obstack, "%ld", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while (0)
/* Key -> Value, but don't apply escaping to Value. */
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
do { \
obstack_sgrow (&muscle_obstack, Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
do { \
obstack_sgrow (&muscle_obstack, Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while (0)
/* Key -> Value, applying M4 escaping to Value. */
#define MUSCLE_INSERT_STRING(Key, Value) \
do { \
MUSCLE_OBSTACK_SGROW (&muscle_obstack, Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \
do { \
char const *p__; \
for (p__ = Value; *p__; p__++) \
switch (*p__) \
{ \
case '$': obstack_sgrow (Obstack, "$]["); break; \
case '@': obstack_sgrow (Obstack, "@@" ); break; \
case '[': obstack_sgrow (Obstack, "@{" ); break; \
case ']': obstack_sgrow (Obstack, "@}" ); break; \
default: obstack_1grow (Obstack, *p__); break; \
} \
} while(0)
do { \
obstack_escape (&muscle_obstack, Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while (0)
#define MUSCLE_INSERT_C_STRING(Key, Value) \
do { \
MUSCLE_OBSTACK_SGROW (&muscle_obstack, \
quotearg_style (c_quoting_style, \
Value)); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
do { \
obstack_escape (&muscle_obstack, \
quotearg_style (c_quoting_style, Value)); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while (0)
/* Append VALUE to the current value of KEY. If KEY did not already
exist, create it. Use MUSCLE_OBSTACK. De-allocate the previously
@@ -113,14 +98,6 @@ void muscle_code_grow (const char *key, const char *value, location loc);
void muscle_pair_list_grow (const char *muscle,
const char *a1, const char *a2);
/* In the format `[[file_name:line.column]], [[file_name:line.column]]', append
LOC to MUSCLE. Use digraphs for special characters in each file name. */
void muscle_location_grow (char const *key, location loc);
/* In the format `file_name:line.column', append BOUND to MUSCLE. Use digraphs
for special characters in the file name. */
void muscle_boundary_grow (char const *key, boundary bound);
/* Grow KEY for the occurrence of the name USER_NAME at LOC appropriately for
use with b4_check_user_names in ../data/bison.m4. USER_NAME is not escaped
with digraphs, so it must not contain `[' or `]'. */

View File

@@ -108,29 +108,39 @@ GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_symbol_number_table, symbol_number)
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_state_number_table, state_number)
/*--------------------------------------------------------------------.
| Print to OUT a representation of STRING escaped both for C and M4. |
`--------------------------------------------------------------------*/
/*----------------------------------------------------------------.
| Print to OUT a representation of CP quoted and escaped for M4. |
`----------------------------------------------------------------*/
static void
escaped_output (FILE *out, char const *string)
quoted_output (FILE *out, char const *cp)
{
char const *p;
fprintf (out, "[[");
for (p = quotearg_style (c_quoting_style, string); *p; p++)
switch (*p)
for (; *cp; cp++)
switch (*cp)
{
case '$': fputs ("$][", out); break;
case '@': fputs ("@@", out); break;
case '[': fputs ("@{", out); break;
case ']': fputs ("@}", out); break;
default: fputc (*p, out); break;
default: fputc (*cp, out); break;
}
fprintf (out, "]]");
}
/*----------------------------------------------------------------.
| Print to OUT a representation of STRING quoted and escaped both |
| for C and M4. |
`----------------------------------------------------------------*/
static void
string_output (FILE *out, char const *string)
{
quoted_output (out, quotearg_style (c_quoting_style, string));
}
/*------------------------------------------------------------------.
| Prepare the muscles related to the symbols: translate, tname, and |
@@ -174,7 +184,7 @@ prepare_symbols (void)
if (i)
obstack_1grow (&format_obstack, ' ');
MUSCLE_OBSTACK_SGROW (&format_obstack, cp);
obstack_escape (&format_obstack, cp);
free (cp);
obstack_1grow (&format_obstack, ',');
j += width;
@@ -355,7 +365,7 @@ user_actions_output (FILE *out)
fprintf (out, "b4_%scase(%d, [b4_syncline(%d, ",
rules[r].is_predicate ? "predicate_" : "",
r + 1, rules[r].action_location.start.line);
escaped_output (out, rules[r].action_location.start.file);
string_output (out, rules[r].action_location.start.file);
fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
}
fputs ("])\n\n", out);

View File

@@ -389,10 +389,15 @@ grammar_declaration:
}
| code_props_type "{...}" generic_symlist
{
symbol_list *list;
for (list = $3; list; list = list->next)
symbol_list_code_props_set (list, $1, @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_code_props_set (list, $1, &code);
symbol_list_free ($3);
}
}
| "%default-prec"
{

View File

@@ -45,7 +45,10 @@ typedef struct code_props {
CODE_PROPS_SYMBOL_ACTION, CODE_PROPS_RULE_ACTION
} kind;
/** \c NULL iff \c code_props::kind is \c CODE_PROPS_NONE. */
/**
* \c NULL iff \c code_props::kind is \c CODE_PROPS_NONE.
* Memory is allocated in an obstack freed elsewhere.
*/
char const *code;
/** Undefined iff \c code_props::code is \c NULL. */
location location;

View File

@@ -47,6 +47,9 @@ YY_DECL;
#define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng);
static char *fetch_type_name (char *cp, char const **type_name,
location dollar_loc);
static void handle_action_dollar (symbol_list *rule, char *cp,
location dollar_loc);
static void handle_action_at (symbol_list *rule, char *cp, location at_loc);
@@ -96,11 +99,15 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
int braces_level = 0;
/* Whether a semicolon is probably needed.
The heuristic is that a semicolon is not needed after '{', '}', ';',
or a C preprocessor directive, and that whitespaces and comments
do not affect this flag.
Note that '{' does not need a semicolon because of '{}'.
A semicolon may be needed before a cpp direcive, but don't bother. */
The heuristic is that a semicolon is not needed after '{', '}',
';', or a C preprocessor directive, and that whitespaces and
comments do not affect this flag. Note that '{' does not need a
semicolon because of '{}'. A semicolon may be needed before a
cpp directive, but don't bother.
While it is maintained in several start-conditions (factoring
opportunities), it is meaningful only for SC_RULE_ACTION. */
bool need_semicolon = false;
/* Whether in a C preprocessor directive. Don't use a start condition
@@ -158,7 +165,8 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
}
<SC_RULE_ACTION,SC_SYMBOL_ACTION>{
<SC_RULE_ACTION,SC_SYMBOL_ACTION>
{
"'" {
STRING_GROW;
BEGIN SC_CHARACTER;
@@ -177,42 +185,31 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
STRING_GROW;
BEGIN SC_LINE_COMMENT;
}
[$@] {
complain_at (*loc, Wother, _("stray '%s'"), yytext);
obstack_escape (&obstack_for_string, yytext);
need_semicolon = true;
}
[\[\]] {
obstack_escape (&obstack_for_string, yytext);
need_semicolon = true;
}
}
<SC_RULE_ACTION>
{
"$"("<"{tag}">")?{ref} {
ref_tail_fields = 0;
ref_tail_fields = NULL;
handle_action_dollar (self->rule, yytext, *loc);
if (ref_tail_fields) {
if (ref_tail_fields)
obstack_sgrow (&obstack_for_string, ref_tail_fields);
}
need_semicolon = true;
}
"@"{ref} {
ref_tail_fields = 0;
ref_tail_fields = NULL;
handle_action_at (self->rule, yytext, *loc);
if (ref_tail_fields) {
if (ref_tail_fields)
obstack_sgrow (&obstack_for_string, ref_tail_fields);
}
need_semicolon = true;
}
"$" {
complain_at (*loc, Wother, _("stray '$'"));
obstack_sgrow (&obstack_for_string, "$][");
need_semicolon = true;
}
"@" {
complain_at (*loc, Wother, _("stray '@'"));
obstack_sgrow (&obstack_for_string, "@@");
need_semicolon = true;
}
"[" {
obstack_sgrow (&obstack_for_string, "@{");
need_semicolon = true;
}
"]" {
obstack_sgrow (&obstack_for_string, "@}");
need_semicolon = true;
}
@@ -253,8 +250,12 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
<SC_SYMBOL_ACTION>
{
"$$" {
obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar[");
"$"("<"{tag}">")?"$" {
const char *type_name = NULL;
fetch_type_name (yytext + 1, &type_name, *loc)[-1] = 0;
obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar(");
obstack_quote (&obstack_for_string, type_name);
obstack_sgrow (&obstack_for_string, ")[");
self->is_value_used = true;
}
"@$" {
@@ -264,29 +265,17 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
}
/*-----------------------------------------.
| Escape M4 quoting characters in C code. |
`-----------------------------------------*/
<*>
{
\$ obstack_sgrow (&obstack_for_string, "$][");
\@ obstack_sgrow (&obstack_for_string, "@@");
\[ obstack_sgrow (&obstack_for_string, "@{");
\] obstack_sgrow (&obstack_for_string, "@}");
}
/* Escape M4 quoting characters in C code. */
[$@\[\]] obstack_escape (&obstack_for_string, yytext);
/*-----------------------------------------------------.
| By default, grow the string obstack with the input. |
`-----------------------------------------------------*/
<*>.|\n STRING_GROW;
/* By default, grow the string obstack with the input. */
.|\n STRING_GROW;
/* End of processing. */
<*><<EOF>> {
STRING_FINISH;
return last_string;
}
<<EOF>> STRING_FINISH; return last_string;
}
%%
@@ -335,7 +324,7 @@ typedef struct
not visible from current midrule. */
#define VARIANT_NOT_VISIBLE_FROM_MIDRULE (1 << 2)
static variant *variant_table = 0;
static variant *variant_table = NULL;
static unsigned variant_table_size = 0;
static unsigned variant_count = 0;
@@ -357,7 +346,7 @@ static void
variant_table_free (void)
{
free (variant_table);
variant_table = 0;
variant_table = NULL;
variant_table_size = variant_count = 0;
}
@@ -681,6 +670,32 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
int max_left_semantic_context = 0;
/* If CP points to a typename (i.e., <.*?>), set TYPE_NAME to its
beginning (i.e., after the opening "<", and return the pointer
immediately after it. */
static
char *
fetch_type_name (char *cp, char const **type_name,
location dollar_loc)
{
if (*cp == '<')
{
*type_name = ++cp;
while (*cp != '>')
++cp;
/* The '>' symbol will be later replaced by '\0'. Original
'text' is needed for error messages. */
++cp;
if (untyped_var_seen)
complain_at (dollar_loc, complaint,
_("explicit type given in untyped grammar"));
tag_seen = true;
}
return cp;
}
/*------------------------------------------------------------------.
| TEXT is pointing to a wannabee semantic value (i.e., a '$'). |
| |
@@ -694,7 +709,6 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
{
char const *type_name = NULL;
char *cp = text + 1;
char *gt_ptr = 0;
symbol_list *effective_rule;
int effective_rule_length;
int n;
@@ -711,27 +725,14 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
}
/* Get the type name if explicit. */
if (*cp == '<')
{
type_name = ++cp;
while (*cp != '>')
++cp;
/* The '>' symbol will be later replaced by '\0'. Original
'text' is needed for error messages. */
gt_ptr = cp;
++cp;
if (untyped_var_seen)
complain_at (dollar_loc, complaint,
_("explicit type given in untyped grammar"));
tag_seen = true;
}
cp = fetch_type_name (cp, &type_name, dollar_loc);
n = parse_ref (cp, effective_rule, effective_rule_length,
rule->midrule_parent_rhs_index, text, dollar_loc, '$');
if (gt_ptr)
*gt_ptr = '\0';
/* End type_name. */
if (type_name)
cp[-1] = '\0';
switch (n)
{
@@ -759,11 +760,11 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
}
else
untyped_var_seen = true;
type_name = "";
}
obstack_fgrow1 (&obstack_for_string,
"]b4_lhs_value([%s])[", type_name);
obstack_sgrow (&obstack_for_string, "]b4_lhs_value(");
obstack_quote (&obstack_for_string, type_name);
obstack_sgrow (&obstack_for_string, ")[");
rule->action_props.is_value_used = true;
break;
@@ -781,12 +782,12 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
quote (effective_rule->content.sym->tag));
else
untyped_var_seen = true;
type_name = "";
}
obstack_fgrow3 (&obstack_for_string,
"]b4_rhs_value(%d, %d, [%s])[",
effective_rule_length, n, type_name);
obstack_fgrow2 (&obstack_for_string,
"]b4_rhs_value(%d, %d, ", effective_rule_length, n);
obstack_quote (&obstack_for_string, type_name);
obstack_sgrow (&obstack_for_string, ")[");
if (n > 0)
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
true;

View File

@@ -72,8 +72,8 @@ static void fail_for_invalid_at (char const *at);
"@@" fputc ('@', yyout);
"@{" fputc ('[', yyout);
"@}" fputc (']', yyout);
"@`" /* Empty. Used by b4_cat in ../data/bison.m4. */
@\n /* Likewise. */
"@`" continue; /* Used by b4_cat in ../data/bison.m4. */
@\n continue;
"@oline@" fprintf (yyout, "%d", out_lineno + 1);
"@ofile@" QPUTS (outname);
@@ -91,7 +91,7 @@ static void fail_for_invalid_at (char const *at);
\n out_lineno++; ECHO;
[^@\n]+ ECHO;
<INITIAL><<EOF>> {
<<EOF>> {
if (outname)
{
free (outname);
@@ -100,15 +100,15 @@ static void fail_for_invalid_at (char const *at);
return EOF;
}
<SC_AT_DIRECTIVE_ARGS>{
[^@]+ { STRING_GROW; }
<SC_AT_DIRECTIVE_ARGS>
{
[^@]+ STRING_GROW;
"@@" { obstack_1grow (&obstack_for_string, '@'); }
"@{" { obstack_1grow (&obstack_for_string, '['); }
"@}" { obstack_1grow (&obstack_for_string, ']'); }
"@`" /* Empty. Useful for starting an argument
that begins with whitespace. */
@\n /* Empty. */
"@@" obstack_1grow (&obstack_for_string, '@');
"@{" obstack_1grow (&obstack_for_string, '[');
"@}" obstack_1grow (&obstack_for_string, ']');
"@`" continue; /* For starting an argument that begins with whitespace. */
@\n continue;
@[,)] {
if (at_directive_argc >= AT_DIRECTIVE_ARGC_MAX)
@@ -131,15 +131,17 @@ static void fail_for_invalid_at (char const *at);
}
}
@.? { fail_for_invalid_at (yytext); }
@.? fail_for_invalid_at (yytext);
}
<SC_AT_DIRECTIVE_SKIP_WS>{
[ \t\r\n]
<SC_AT_DIRECTIVE_SKIP_WS>
{
[ \t\r\n] continue;
. { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; }
}
<SC_AT_DIRECTIVE_ARGS,SC_AT_DIRECTIVE_SKIP_WS>{
<SC_AT_DIRECTIVE_ARGS,SC_AT_DIRECTIVE_SKIP_WS>
{
<<EOF>> {
complain (fatal, _("unclosed %s directive in skeleton"),
at_directive_argv[0]);

View File

@@ -191,15 +191,12 @@ symbol_list_null (symbol_list *node)
void
symbol_list_code_props_set (symbol_list *node, code_props_type kind,
location loc, char const *code)
code_props const *cprops)
{
code_props cprops;
code_props_symbol_action_init (&cprops, code, loc);
code_props_translate_code (&cprops);
switch (node->content_type)
{
case SYMLIST_SYMBOL:
symbol_code_props_set (node->content.sym, kind, &cprops);
symbol_code_props_set (node->content.sym, kind, cprops);
if (node->content.sym->status == undeclared)
node->content.sym->status = used;
break;
@@ -207,7 +204,7 @@ symbol_list_code_props_set (symbol_list *node, code_props_type kind,
semantic_type_code_props_set
(semantic_type_get (node->content.sem_type->tag,
&node->content.sem_type->location),
kind, &cprops);
kind, cprops);
if (node->content.sem_type->status == undeclared)
node->content.sem_type->status = used;
break;

View File

@@ -113,9 +113,8 @@ uniqstr symbol_list_n_type_name_get (symbol_list *l, location loc, int n);
/* Check whether the node is a border element of a rule. */
bool symbol_list_null (symbol_list *node);
/** Set the \c \%destructor or \c \%printer for \c node as \c code at
\c loc. */
/** Set the \c \%destructor or \c \%printer for \c node as \c cprops. */
void symbol_list_code_props_set (symbol_list *node, code_props_type kind,
location loc, char const *code);
code_props const *cprops);
#endif /* !SYMLIST_H_ */

View File

@@ -92,8 +92,14 @@ struct symbol
/** The location of its first occurrence. */
location location;
/** Its \c \%type. */
/** Its \c \%type.
Beware that this is the type_name as was entered by the user,
including silly things such as "]" if she entered "%token <]> t".
Therefore, when outputting type_name to M4, be sure to escape it
into "@}". See quoted_output for instance. */
uniqstr type_name;
/** Its \c \%type's location. */
location type_location;
@@ -101,9 +107,9 @@ struct symbol
symbol.
Access this field only through <tt>symbol</tt>'s interface functions. For
Example, if <tt>symbol::destructor = NULL</tt> (resp. <tt>symbol::printer
example, if <tt>symbol::destructor = NULL</tt> (resp. <tt>symbol::printer
= NULL</tt>), a default \c \%destructor (resp. \%printer) or a per-type
\c symbol_destructor_printer_get will compute the corect one. */
\c symbol_destructor_printer_get will compute the correct one. */
code_props props[CODE_PROPS_SIZE];
symbol_number number;

View File

@@ -177,32 +177,75 @@ typedef size_t uintptr_t;
obstack_grow (Obs, Str, strlen (Str))
#define obstack_fgrow1(Obs, Format, Arg1) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
#define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
#define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2, Arg3); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2, Arg3); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
#define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
/* Output Str escaped for our postprocessing (i.e., escape M4 special
characters).
For instance "[foo]" -> "@{foo@}", "$$" -> "$][$][". */
# define obstack_escape(Obs, Str) \
do { \
char const *p__; \
for (p__ = Str; *p__; p__++) \
switch (*p__) \
{ \
case '$': obstack_sgrow (Obs, "$]["); break; \
case '@': obstack_sgrow (Obs, "@@" ); break; \
case '[': obstack_sgrow (Obs, "@{" ); break; \
case ']': obstack_sgrow (Obs, "@}" ); break; \
default: obstack_1grow (Obs, *p__ ); break; \
} \
} while (0)
/* Output Str both quoted for M4 (i.e., embed in [[...]]), and escaped
for our postprocessing (i.e., escape M4 special characters). If
Str is empty (or NULL), output "[]" instead of "[[]]" as it make M4
programming easier (m4_ifval can be used).
For instance "[foo]" -> "[[@{foo@}]]", "$$" -> "[[$][$][]]". */
# define obstack_quote(Obs, Str) \
do { \
char const* obstack_quote_p = Str; \
if (obstack_quote_p && obstack_quote_p[0]) \
{ \
obstack_sgrow (Obs, "[["); \
obstack_escape (Obs, obstack_quote_p); \
obstack_sgrow (Obs, "]]"); \
} \
else \
obstack_sgrow (Obs, "[]"); \
} while (0)
@@ -218,10 +261,6 @@ do { \
# define TAB_EXT ".tab"
#endif
#ifndef DEFAULT_TMPDIR
# define DEFAULT_TMPDIR "/tmp"
#endif
/*---------------------.