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 typedef enum _CppCode
{ {
CPP_CODE_DQUOTE = 0, CPP_CODE_COMMA = 0,
CPP_CODE_DQUOTE,
CPP_CODE_OPERATOR_AEQUALS, CPP_CODE_OPERATOR_AEQUALS,
CPP_CODE_OPERATOR_AMPERSAND, CPP_CODE_OPERATOR_AMPERSAND,
CPP_CODE_OPERATOR_BAR, CPP_CODE_OPERATOR_BAR,
@ -71,7 +72,6 @@ typedef enum _CppCode
CPP_CODE_SQUOTE, CPP_CODE_SQUOTE,
CPP_CODE_WHITESPACE, CPP_CODE_WHITESPACE,
CPP_CODE_WORD, /* FIXME numbers and keywords? */ CPP_CODE_WORD, /* FIXME numbers and keywords? */
/* FIXME comma? */
CPP_CODE_UNKNOWN CPP_CODE_UNKNOWN
} CppCode; } CppCode;

View File

@ -114,6 +114,8 @@ static int _cpp_callback_whitespace(Parser * parser, Token * token, int c,
/* FIXME handle directives */ /* FIXME handle directives */
static int _cpp_callback_comment(Parser * parser, Token * token, int c, static int _cpp_callback_comment(Parser * parser, Token * token, int c,
void * data); 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, static int _cpp_callback_operator(Parser * parser, Token * token, int c,
void * data); void * data);
static int _cpp_callback_quote(Parser * parser, Token * token, int c, 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 != '/') if(c != '/')
return 1; return 1;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: cpp_callback_comment()\n"); fprintf(stderr, "%s", "DEBUG: cpp_callback_comment()\n");
#endif #endif
if((c = parser_scan_filter(parser)) != '*') 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 */ /* cpp_callback_operator */
static int _cpp_callback_operator(Parser * parser, Token * token, int c, static int _cpp_callback_operator(Parser * parser, Token * token, int c,
void * data) void * data)