Apparently handling enumerations a bit better

This commit is contained in:
Pierre Pronchery 2008-06-12 05:40:15 +00:00
parent 29b5cb4e51
commit c44c0e4bd6
3 changed files with 11 additions and 6 deletions

View File

@ -399,6 +399,7 @@ int code_context_set_identifier(Code * code, char const * identifier)
"declaration parameters",
"declaration start",
"enumeration constant",
"enumeration name",
"enumeration value",
"function",
"function call",

View File

@ -38,6 +38,7 @@ typedef enum _CodeContext
CODE_CONTEXT_DECLARATION_PARAMETERS,
CODE_CONTEXT_DECLARATION_START,
CODE_CONTEXT_ENUMERATION_CONSTANT,
CODE_CONTEXT_ENUMERATION_NAME,
CODE_CONTEXT_ENUMERATION_VALUE,
CODE_CONTEXT_FUNCTION,
CODE_CONTEXT_FUNCTION_CALL,

View File

@ -580,18 +580,24 @@ static int _struct_declarator(C99 * c99)
/* enum-specifier
* PRE the first token starts an enum-specifier */
static int _enum_specifier(C99 * c99)
/* enum [ identifier ] "{" enumerator { "," enumerator } [ ","] "}"
* enum identifier */
/* "enum" [ identifier ] "{" enumerator { "," enumerator } [ ","] "}"
* "enum" identifier */
{
int ret;
CodeContext context;
DEBUG_GRAMMAR();
context = code_context_get(c99->code);
ret = scan(c99);
if(_parse_is_code(c99, C99_CODE_IDENTIFIER))
{
code_context_set(c99->code, CODE_CONTEXT_ENUMERATION_NAME);
ret |= _identifier(c99);
if(!_parse_is_code(c99, C99_CODE_OPERATOR_LBRACE))
{
code_context_set(c99->code, context);
return ret;
}
}
ret |= _parse_check(c99, C99_CODE_OPERATOR_LBRACE);
ret |= _parse_check_set(c99, c99set_enumerator, "enumerator",
@ -606,6 +612,7 @@ static int _enum_specifier(C99 * c99)
break;
}
ret |= _parse_check(c99, C99_CODE_OPERATOR_RBRACE);
code_context_set(c99->code, context);
return ret;
}
@ -908,9 +915,7 @@ static int _direct_abstract_declarator(C99 * c99)
{
ret = scan(c99);
ret |= _abstract_declarator(c99);
fprintf(stderr, "DEBUG: before 2\n");
ret |= _parse_check(c99, C99_CODE_OPERATOR_RPAREN);
fprintf(stderr, "DEBUG: after 2\n");
}
else if(code == C99_CODE_OPERATOR_LBRACKET)
{
@ -925,9 +930,7 @@ static int _direct_abstract_declarator(C99 * c99)
ret |= scan(c99);
if(_parse_in_set(c99, c99set_parameter_type_list))
ret |= _parameter_type_list(c99);
fprintf(stderr, "DEBUG: before\n");
ret |= _parse_check(c99, C99_CODE_OPERATOR_RPAREN);
fprintf(stderr, "DEBUG: after\n");
}
else if(code == C99_CODE_OPERATOR_LBRACKET)
{