Add a "union" keyword to replace funcenum.

This commit is contained in:
David Anderson
2014-08-28 14:02:08 -07:00
parent 89f5d6ecfb
commit a1b7c32b29
9 changed files with 68 additions and 41 deletions
+1
View File
@@ -432,6 +432,7 @@ enum TokenKind {
tTAGOF,
tTHEN,
tTYPEDEF,
tUNION,
tVOID,
tWHILE,
/* compiler directives */
+25
View File
@@ -144,6 +144,7 @@ static void dolabel(void);
static void doreturn(void);
static void dofuncenum(int listmode);
static void dotypedef();
static void dounion();
static void domethodmap(LayoutSpec spec);
static void dobreak(void);
static void docont(void);
@@ -1535,6 +1536,9 @@ static void parse(void)
case tTYPEDEF:
dotypedef();
break;
case tUNION:
dounion();
break;
case tSTRUCT:
declstruct();
break;
@@ -4247,6 +4251,27 @@ static void dotypedef()
functags_add(def, &type);
}
// Unsafe union - only supports function types. This is a transition hack for SP2.
static void dounion()
{
token_ident_t ident;
if (!needsymbol(&ident))
return;
int prev_tag = pc_findtag(ident.name);
if (prev_tag != -1 && !(prev_tag & FUNCTAG))
error(94);
funcenum_t *def = funcenums_add(ident.name);
needtoken('{');
while (!matchtoken('}')) {
functag_t type;
parse_function_type(&type);
functags_add(def, &type);
}
require_newline(TRUE);
}
/**
* dofuncenum - declare function enumerations
+1
View File
@@ -1963,6 +1963,7 @@ const char *sc_tokens[] = {
"return",
"sizeof", "sleep", "static", "stock", "struct", "switch",
"tagof", "*then", "typedef",
"union",
"void",
"while",
"#assert", "#define", "#else", "#elseif", "#emit", "#endif", "#endinput",