summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org.ua>2011-10-09 18:38:21 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-10-09 19:03:58 (GMT)
commita43d8894bc5bed439265dd3984898c22c8df857b (patch) (side-by-side diff)
tree39256849547ae47a95107c8e9aa5856ec9578c07 /src
parent1fdfe0ec055c5e8c080dd1427d98730885ac8bd4 (diff)
downloadcflow-a43d8894bc5bed439265dd3984898c22c8df857b.tar.gz
cflow-a43d8894bc5bed439265dd3984898c22c8df857b.tar.bz2
Accept qualifiers before declarations.
* src/c.l: Handle "inline" keyword. * src/main.c (symbol_optype): Add "qualifier". * src/parser.c (print_token): Correctly handle PARM_WRAPPER and STRING. (save_token): Handle QUALIFIER. In verbose mode, warn about unexpected symbols. (yyparse): Handle QUALIFIER and PARM_WRAPPER. * src/parser.h (QUALIFIER): New define.
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/c.l1
-rw-r--r--src/main.c1
-rw-r--r--src/parser.c28
-rw-r--r--src/parser.h1
4 files changed, 28 insertions, 3 deletions
diff --git a/src/c.l b/src/c.l
index bb38d17..205a297 100644
--- a/src/c.l
+++ b/src/c.l
@@ -75,6 +75,7 @@ auto /* ignored */;
extern return EXTERN;
static return STATIC;
typedef return TYPEDEF;
+inline {yylval.str = "inline"; return QUALIFIER; }
struct {yylval.str = "struct"; return STRUCT;}
union {yylval.str = "union"; return STRUCT;}
enum {yylval.str = "enum"; return STRUCT;}
diff --git a/src/main.c b/src/main.c
index 12ef6b7..dff6788 100644
--- a/src/main.c
+++ b/src/main.c
@@ -246,6 +246,7 @@ static struct option_type symbol_optype[] = {
{ "identifier", 1, IDENTIFIER },
{ "type", 1, TYPE },
{ "wrapper", 1, PARM_WRAPPER },
+ { "qualifier", 1, QUALIFIER },
{ 0 },
};
diff --git a/src/parser.c b/src/parser.c
index af0d0ab..0b524fc 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -84,6 +84,7 @@ print_token(TOKSTK *tokptr)
case WORD:
case MODIFIER:
case STRUCT:
+ case PARM_WRAPPER:
fprintf(stderr, "`%s'", tokptr->token);
break;
case LBRACE0:
@@ -106,6 +107,9 @@ print_token(TOKSTK *tokptr)
case OP:
fprintf(stderr, "OP"); /* ouch!!! */
break;
+ case STRING:
+ fprintf(stderr, "\"%s\"", tokptr->token);
+ break;
default:
fprintf(stderr, "`%c'", tokptr->type);
}
@@ -214,6 +218,7 @@ save_token(TOKSTK *tokptr)
case STRUCT:
case PARM_WRAPPER:
case WORD:
+ case QUALIFIER:
if (need_space)
obstack_1grow(&text_stk, ' ');
len = strlen(tokptr->token);
@@ -233,13 +238,23 @@ save_token(TOKSTK *tokptr)
case EXTERN: /* storage class specifiers are already taken care of */
case STATIC:
break;
+ case ',':
+ obstack_1grow(&text_stk, ',');
+ need_space = 1;
+ break;
case '(':
if (need_space)
obstack_1grow(&text_stk, ' ');
- /*FALLTHRU*/
- default:
obstack_1grow(&text_stk, tokptr->type);
need_space = 0;
+ break;
+ case ')':
+ obstack_1grow(&text_stk, tokptr->type);
+ need_space = 1;
+ break;
+ default:
+ if (verbose)
+ file_error(_("unrecognized definition"), 1);
}
}
@@ -339,6 +354,8 @@ yyparse()
switch (tok.type) {
case 0:
return 0;
+ case QUALIFIER:
+ continue;
case TYPEDEF:
parse_typedef();
break;
@@ -477,6 +494,12 @@ parse_function_declaration(Ident *ident, int parm)
}
goto restart;
+
+ case PARM_WRAPPER:
+ if (skip_balanced('(', ')', 0) == -1)
+ file_error(_("unexpected end of file in wrapper"), 0);
+ goto restart;
+
case ';':
case ',':
break;
@@ -842,7 +865,6 @@ maybe_parm_list(int *parm_cnt_return)
case IDENTIFIER:
case STRUCT:
case UNION:
- case ENUM:
case TYPE:
parmcnt++;
ident.storage = AutoStorage;
diff --git a/src/parser.h b/src/parser.h
index fd423ae..49c8b45 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -35,6 +35,7 @@
#define TYPE 270
#define STRING 271
#define PARM_WRAPPER 272
+#define QUALIFIER 273
typedef struct {
char *str;

Return to:

Send suggestions and report system problems to the System administrator.