Parsing commas

This commit is contained in:
Pierre Pronchery 2008-02-26 23:55:30 +00:00
parent 1a4b51f3ac
commit fa744b9884
2 changed files with 21 additions and 3 deletions

View File

@ -30,7 +30,8 @@ typedef enum _CppFilter { CPP_FILTER_TRIGRAPH = 1 } CppFilter;
typedef enum _CppCode
{
CPP_CODE_DQUOTE = 0,
CPP_CODE_COMMA = 0,
CPP_CODE_DQUOTE,
CPP_CODE_OPERATOR_AEQUALS,
CPP_CODE_OPERATOR_AMPERSAND,
CPP_CODE_OPERATOR_BAR,
@ -71,7 +72,6 @@ typedef enum _CppCode
CPP_CODE_SQUOTE,
CPP_CODE_WHITESPACE,
CPP_CODE_WORD, /* FIXME numbers and keywords? */
/* FIXME comma? */
CPP_CODE_UNKNOWN
} CppCode;

View File

@ -114,6 +114,8 @@ static int _cpp_callback_whitespace(Parser * parser, Token * token, int c,
/* FIXME handle directives */
static int _cpp_callback_comment(Parser * parser, Token * token, int c,
void * data);
static int _cpp_callback_comma(Parser * parser, Token * token, int c,
void * data);
static int _cpp_callback_operator(Parser * parser, Token * token, int c,
void * data);
static int _cpp_callback_quote(Parser * parser, Token * token, int c,
@ -324,7 +326,7 @@ static int _cpp_callback_comment(Parser * parser, Token * token, int c,
if(c != '/')
return 1;
#ifdef DEBUG
fprintf(stderr, "DEBUG: cpp_callback_comment()\n");
fprintf(stderr, "%s", "DEBUG: cpp_callback_comment()\n");
#endif
if((c = parser_scan_filter(parser)) != '*')
{
@ -351,6 +353,22 @@ static int _cpp_callback_comment(Parser * parser, Token * token, int c,
}
/* cpp_callback_comma */
static int _cpp_callback_comma(Parser * parser, Token * token, int c,
void * data)
{
if(c != ',')
return 1;
#ifdef DEBUG
fprintf(stderr, "%s", "DEBUG: cpp_callback_comma()\n");
#endif
token_set_code(token, CPP_CODE_COMMA);
token_set_string(token, ",");
parser_scan_filter(parser);
return 0;
}
/* cpp_callback_operator */
static int _cpp_callback_operator(Parser * parser, Token * token, int c,
void * data)