diff options
author | Bart Vanhauwaert <bart.vanhauwaert@grafitroniks.fr> | 2016-11-22 10:19:40 +0100 |
---|---|---|
committer | Bart Vanhauwaert <bart.vanhauwaert@grafitroniks.fr> | 2016-11-23 11:40:19 +0100 |
commit | 07b0807cc47b41e3ce44b29fa31989849311c640 (patch) | |
tree | 363ee0be34174a0ed9fad358364a00d94166648b | |
parent | Add QFileDevice for closing QFiles (diff) | |
download | qtscriptgenerator-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.cpp | 12 | ||||
-rw-r--r-- | generator/parser/parser.cpp | 3 | ||||
-rw-r--r-- | generator/parser/tokens.cpp | 3 | ||||
-rw-r--r-- | generator/parser/tokens.h | 1 |
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 |