mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 08:43:03 +00:00
Inform m4 whether a tag is a valid id.
* src/output.c (is_identifier): New. (symbol_definitions_output): Use it to define tag_is_id. But maybe this should be done at m4 level?
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
2008-11-11 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
|
Inform m4 whether a tag is a valid id.
|
||||||
|
* src/output.c (is_identifier): New.
|
||||||
|
(symbol_definitions_output): Use it to define tag_is_id.
|
||||||
|
But maybe this should be done at m4 level?
|
||||||
|
|
||||||
2008-11-11 Akim Demaille <demaille@gostai.com>
|
2008-11-11 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
Test 214 was failing: it greps with a pattern containing [ ]*
|
Test 214 was failing: it greps with a pattern containing [ ]*
|
||||||
|
|||||||
25
src/output.c
25
src/output.c
@@ -396,6 +396,26 @@ merger_output (FILE *out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------.
|
||||||
|
| Whether S is a valid identifier. |
|
||||||
|
`----------------------------------*/
|
||||||
|
|
||||||
|
static bool
|
||||||
|
is_identifier (uniqstr s)
|
||||||
|
{
|
||||||
|
static char const alphanum[26 + 26 + 1 + 10] =
|
||||||
|
"abcdefghijklmnopqrstuvwxyz"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
"_"
|
||||||
|
"0123456789";
|
||||||
|
if (!s || ! memchr (alphanum, *s, sizeof alphanum - 10))
|
||||||
|
return false;
|
||||||
|
for (++s; *s; ++s)
|
||||||
|
if (! memchr (alphanum, *s, sizeof alphanum))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------.
|
/*---------------------------------------.
|
||||||
| Output the symbol definitions to OUT. |
|
| Output the symbol definitions to OUT. |
|
||||||
`---------------------------------------*/
|
`---------------------------------------*/
|
||||||
@@ -414,6 +434,11 @@ symbol_definitions_output (FILE *out)
|
|||||||
obstack_1grow (&format_obstack, 0); \
|
obstack_1grow (&format_obstack, 0); \
|
||||||
key = obstack_finish (&format_obstack);
|
key = obstack_finish (&format_obstack);
|
||||||
|
|
||||||
|
// Whether the tag is a valid identifier.
|
||||||
|
SET_KEY("tag_is_id");
|
||||||
|
MUSCLE_INSERT_INT (key, is_identifier(sym->tag));
|
||||||
|
|
||||||
|
// The inner tag.
|
||||||
SET_KEY("tag");
|
SET_KEY("tag");
|
||||||
MUSCLE_INSERT_STRING (key, sym->tag);
|
MUSCLE_INSERT_STRING (key, sym->tag);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user