summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkim Demaille <akim@lrde.epita.fr>2013-02-21 15:58:05 +0100
committerAkim Demaille <akim@lrde.epita.fr>2013-04-09 14:07:51 +0200
commitcb8d8bb9b6aec5b873e93d0bab91f0a4ab29d9b0 (patch)
tree4e6dfd3eaa159d57f60cc2cf991adc9eac462619 /src
parente52ddf820b9c9c123e4f3c3799fc1fb9b0a54c09 (diff)
downloadbison-cb8d8bb9b6aec5b873e93d0bab91f0a4ab29d9b0.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/scan-code.l8
-rw-r--r--src/scan-gram.l2
2 files changed, 6 insertions, 4 deletions
diff --git a/src/scan-code.l b/src/scan-code.l
index bff3280a..cced97bf 100644
--- a/src/scan-code.l
+++ b/src/scan-code.l
@@ -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
diff --git a/src/scan-gram.l b/src/scan-gram.l
index 58f6590b..cf8b220d 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -572,7 +572,7 @@ eqopt ([[:space:]]*=)?
STRING_GROW;
}
- [^<>]+ STRING_GROW;
+ ([^<>]|->)+ STRING_GROW;
"<"+ STRING_GROW; nesting += yyleng;
<<EOF>> unexpected_eof (token_start, ">");