mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 13:23:04 +00:00
value type: accept "->" in type tags
Provide a means to dereference pointers when defining tags. One
example could be:
%code requires
{
typedef struct ListElementType
{
union value
{
int intVal;
float floatVal;
char* charptrVal;
} value;
struct ListElementType* next;
} ListElementType;
}
%union
{
ListElementType* list;
}
%token <list->value.charptrVal> STRING
%token <list->value.intVal> INTEGER
%token <list->value.floatVal> REAL
%type <list> ElementList LiteralType
* src/scan-code.l, src/scan-gram.l: Accept "->" in tags.
* tests/types.at: Add more test cases to cover this case.
This commit is contained in:
@@ -78,8 +78,9 @@ static bool untyped_var_seen;
|
||||
|
||||
/* POSIX says that a tag must be both an id and a C union member, but
|
||||
historically almost any character is allowed in a tag. We disallow
|
||||
NUL and newline, as this simplifies our implementation. */
|
||||
tag [^\0\n>]+
|
||||
NUL and newline, as this simplifies our implementation. We allow
|
||||
"->" as a means to dereference a pointer. */
|
||||
tag ([^\0\n>]|->)+
|
||||
|
||||
/* Zero or more instances of backslash-newline. Following GCC, allow
|
||||
white space between the backslash and the newline. */
|
||||
@@ -595,7 +596,8 @@ fetch_type_name (char *cp, char const **type_name,
|
||||
if (*cp == '<')
|
||||
{
|
||||
*type_name = ++cp;
|
||||
while (*cp != '>')
|
||||
/* Series of non-'>' or "->". */
|
||||
while (*cp != '>' || cp[-1] == '-')
|
||||
++cp;
|
||||
|
||||
/* The '>' symbol will be later replaced by '\0'. Original
|
||||
|
||||
Reference in New Issue
Block a user