cleanup builtin handling and put it into an own file. Also implement a bunch of entit...
[cparser] / lexer.c
diff --git a/lexer.c b/lexer.c
index 7cc61aa..247083c 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -1766,6 +1766,16 @@ static void parse_preprocessor_directive(void)
                                        lexer_token.type = set_type;           \
                                        return;
 
+/* must use this as last thing */
+#define MAYBE_MODE(ch, set_type, mode)                     \
+                               case ch:                                   \
+                                       if (c_mode & mode) {                   \
+                                               next_char();                       \
+                                               lexer_token.type = set_type;       \
+                                               return;                            \
+                                       }                                      \
+                                       /* fallthrough */
+
 #define ELSE_CODE(code)                                    \
                                default:                                   \
                                        code                                   \
@@ -1796,12 +1806,10 @@ void lexer_next_preprocessing_token(void)
                SYMBOL_CHARS
                        parse_symbol();
                        /* might be a wide string ( L"string" ) */
-                       if(lexer_token.type == T_IDENTIFIER &&
-                           lexer_token.v.symbol == symbol_L) {
-                           if(c == '"') {
-                                       parse_wide_string_literal();
-                               } else if(c == '\'') {
-                                       parse_wide_character_constant();
+                       if (lexer_token.v.symbol == symbol_L) {
+                               switch (c) {
+                                       case '"':  parse_wide_string_literal();     break;
+                                       case '\'': parse_wide_character_constant(); break;
                                }
                        }
                        return;
@@ -1921,6 +1929,7 @@ void lexer_next_preprocessing_token(void)
                case ':':
                        MAYBE_PROLOG
                        MAYBE('>', ']')
+                       MAYBE_MODE(':', T_COLONCOLON, _CXX)
                        ELSE(':')
                case '=':
                        MAYBE_PROLOG