diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-09-19 10:27:23 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-09-19 10:27:23 +0200 |
commit | 0603db21d2622588ab35389d3ddcaac7410c9f11 (patch) | |
tree | 4f97b4445fe53d17005550b9f5a1c2dd7cd80952 /odb/cxx-lexer.cxx | |
parent | c9ff2aaaf3cadcd1a80455cba426ffb12e62ce7b (diff) |
Recognize C++ keywords when parsing C++ expressions in pragmas
Diffstat (limited to 'odb/cxx-lexer.cxx')
-rw-r--r-- | odb/cxx-lexer.cxx | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/odb/cxx-lexer.cxx b/odb/cxx-lexer.cxx index 7076e8b..6124855 100644 --- a/odb/cxx-lexer.cxx +++ b/odb/cxx-lexer.cxx @@ -79,39 +79,37 @@ start (tree& token, cpp_ttype& type) cpp_ttype cxx_pragma_lexer:: next (string& token) { - *type_ = pragma_lex (token_); + next (*token_); token = translate (); return *type_; } +cpp_ttype cxx_pragma_lexer:: +next (tree& token) +{ + *type_ = pragma_lex (token_); + + // See if this is a keyword using the C++ parser machinery and + // the current C++ dialect. + // + if (*type_ == CPP_NAME && C_IS_RESERVED_WORD (*token_)) + *type_ = CPP_KEYWORD; + + if (&token != token_) + token = *token_; + + return *type_; +} + string cxx_pragma_lexer:: translate () { string r; - switch (*type_) - { - case CPP_NAME: - { - r = IDENTIFIER_POINTER (*token_); - - // See if this is a keyword using the C++ parser machinery and - // the current C++ dialect. - // - tree id (get_identifier (r.c_str ())); - - if (C_IS_RESERVED_WORD (id)) - *type_ = CPP_KEYWORD; - break; - } - case CPP_STRING: - { - r = TREE_STRING_POINTER (*token_); - break; - } - default: - break; - } + if (*type_ == CPP_NAME || *type_ == CPP_KEYWORD) + r = IDENTIFIER_POINTER (*token_); + else if (*type_ == CPP_STRING) + r = TREE_STRING_POINTER (*token_); return r; } |