diff --git a/include/cpp.h b/include/cpp.h index ad1a713..3f99f7f 100644 --- a/include/cpp.h +++ b/include/cpp.h @@ -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; diff --git a/src/cpp.c b/src/cpp.c index 50da897..f604c4f 100644 --- a/src/cpp.c +++ b/src/cpp.c @@ -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)