summaryrefslogtreecommitdiff
path: root/shared/cplusplus/Lexer.cpp
diff options
context:
space:
mode:
authorRoberto Raggi <qtc-committer@nokia.com>2009-01-08 11:08:40 +0100
committerRoberto Raggi <qtc-committer@nokia.com>2009-01-08 11:29:05 +0100
commit57c10b601a3126f2f0eb9b19a44075fa8dc50986 (patch)
tree70e746ec08fb75462d905972429b33f8b5d8c0dd /shared/cplusplus/Lexer.cpp
parent2d8af0709dd98925ab1a5886abfde8073d82b8c4 (diff)
downloadqt-creator-57c10b601a3126f2f0eb9b19a44075fa8dc50986.tar.gz
Recognize Objective C @tokens.
Diffstat (limited to 'shared/cplusplus/Lexer.cpp')
-rw-r--r--shared/cplusplus/Lexer.cpp53
1 files changed, 52 insertions, 1 deletions
diff --git a/shared/cplusplus/Lexer.cpp b/shared/cplusplus/Lexer.cpp
index 56098d39f2..fcc17313b4 100644
--- a/shared/cplusplus/Lexer.cpp
+++ b/shared/cplusplus/Lexer.cpp
@@ -122,6 +122,12 @@ bool Lexer::qtMocRunEnabled() const
void Lexer::setQtMocRunEnabled(bool onoff)
{ _qtMocRunEnabled = onoff; }
+bool Lexer::objcEnabled() const
+{ return _objcEnabled; }
+
+void Lexer::setObjcEnabled(bool onoff)
+{ _objcEnabled = onoff; }
+
bool Lexer::isIncremental() const
{ return _isIncremental; }
@@ -548,8 +554,53 @@ void Lexer::scan_helper(Token *tok)
break;
default: {
+ if (_objcEnabled) {
+ if (ch == '@' && _yychar >= 'a' && _yychar <= 'z') {
+ const char *yytext = _currentChar;
+
+ do {
+ yyinp();
+ if (! isalnum(_yychar))
+ break;
+ } while (_yychar);
+
+ const int yylen = _currentChar - yytext;
+ tok->kind = classifyObjCAtKeyword(yytext, yylen);
+ break;
+ } else if (ch == '@' && _yychar == '"') {
+ // objc @string literals
+ ch = _yychar;
+ yyinp();
+ tok->kind = T_AT_STRING_LITERAL;
+
+ const char *yytext = _currentChar;
+
+ while (_yychar && _yychar != '"') {
+ if (_yychar != '\\')
+ yyinp();
+ else {
+ yyinp(); // skip `\\'
+
+ if (_yychar)
+ yyinp();
+ }
+ }
+ // assert(_yychar == '"');
+
+ int yylen = _currentChar - yytext;
+
+ if (_yychar == '"')
+ yyinp();
+
+ if (control())
+ tok->string = control()->findOrInsertStringLiteral(yytext, yylen);
+
+ break;
+ }
+ }
+
if (ch == 'L' && (_yychar == '"' || _yychar == '\'')) {
- // wide char literals
+ // wide char/string literals
ch = _yychar;
yyinp();