aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Vanhauwaert <bart.vanhauwaert@grafitroniks.fr>2016-11-22 10:19:40 +0100
committerBart Vanhauwaert <bart.vanhauwaert@grafitroniks.fr>2016-11-23 11:40:19 +0100
commit07b0807cc47b41e3ce44b29fa31989849311c640 (patch)
tree363ee0be34174a0ed9fad358364a00d94166648b
parentAdd QFileDevice for closing QFiles (diff)
downloadqtscriptgenerator-07b0807cc47b41e3ce44b29fa31989849311c640.tar.xz
qtscriptgenerator-07b0807cc47b41e3ce44b29fa31989849311c640.zip
Parse new Q_ENUM Qt macro introduced with Qt 5.5.
We do the same thing as moc and just treat it as a Q_ENUMS(...) macro since Q_ENUM's syntactic use should be a strict subset of Q_ENUMS'
-rw-r--r--generator/parser/lexer.cpp12
-rw-r--r--generator/parser/parser.cpp3
-rw-r--r--generator/parser/tokens.cpp3
-rw-r--r--generator/parser/tokens.h1
4 files changed, 17 insertions, 2 deletions
diff --git a/generator/parser/lexer.cpp b/generator/parser/lexer.cpp
index 575c55d..b1a16f3 100644
--- a/generator/parser/lexer.cpp
+++ b/generator/parser/lexer.cpp
@@ -1406,6 +1406,18 @@ void Lexer::scanKeyword6()
}
break;
+ case 'Q':
+ if (*(cursor + 1) == '_' &&
+ *(cursor + 2) == 'E' &&
+ *(cursor + 3) == 'N' &&
+ *(cursor + 4) == 'U' &&
+ *(cursor + 5) == 'M')
+ {
+ token_stream[(int) index++].kind = Token_Q_ENUM;
+ return;
+ }
+ break;
+
}
token_stream[(int) index++].kind = Token_identifier;
}
diff --git a/generator/parser/parser.cpp b/generator/parser/parser.cpp
index 15edc7b..a8692e9 100644
--- a/generator/parser/parser.cpp
+++ b/generator/parser/parser.cpp
@@ -460,6 +460,7 @@ bool Parser::parseDeclaration(DeclarationAST *&node)
case Token_asm:
return parseAsmDefinition(node);
+ case Token_Q_ENUM:
case Token_Q_ENUMS:
return parseQ_ENUMS(node);
@@ -4375,7 +4376,7 @@ bool Parser::parseThrowExpression(ExpressionAST *&node)
bool Parser::parseQ_ENUMS(DeclarationAST *&node)
{
- if (token_stream.lookAhead() != Token_Q_ENUMS)
+ if (token_stream.lookAhead() != Token_Q_ENUMS && token_stream.lookAhead() != Token_Q_ENUM)
return false;
if (token_stream.lookAhead(1) != '(')
diff --git a/generator/parser/tokens.cpp b/generator/parser/tokens.cpp
index 79c87c5..07cc10a 100644
--- a/generator/parser/tokens.cpp
+++ b/generator/parser/tokens.cpp
@@ -148,7 +148,8 @@ static char const * const _S_token_names[] = {
"whitespaces",
"xor",
"xor_eq",
- "Q_ENUMS"
+ "Q_ENUMS",
+ "Q_ENUM"
};
static char _S_printable[][2] = {
diff --git a/generator/parser/tokens.h b/generator/parser/tokens.h
index c2b5bc9..6bb944a 100644
--- a/generator/parser/tokens.h
+++ b/generator/parser/tokens.h
@@ -151,6 +151,7 @@ enum TOKEN_KIND
Token_xor,
Token_xor_eq,
Token_Q_ENUMS,
+ Token_Q_ENUM,
Token_Q_INVOKABLE,
TOKEN_KIND_COUNT