QmlJS: Sync parser with Qt 5.10

Change-Id: I87c64edc1235bab10b9f32abeab4386b5cc7390b
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Orgad Shaneh
2018-04-05 11:13:53 +03:00
committed by Orgad Shaneh
parent dba102ff61
commit 3a52a2c3f1
4 changed files with 42 additions and 38 deletions

View File

@@ -582,7 +582,7 @@ again:
if (end - begin != chars.size() - 1) {
_errorCode = IllegalExponentIndicator;
_errorMessage = QCoreApplication::translate("QmlParser", "Illegal syntax for exponential number.");
_errorMessage = QCoreApplication::translate("QmlParser", "Illegal syntax for exponential number");
return T_ERROR;
}
@@ -675,7 +675,7 @@ again:
if (qmlMode())
break;
_errorCode = IllegalCharacter;
_errorMessage = QCoreApplication::translate("QmlParser", "Stray newline in string literal.");
_errorMessage = QCoreApplication::translate("QmlParser", "Stray newline in string literal");
return T_ERROR;
} else if (_char == QLatin1Char('\\')) {
break;
@@ -713,7 +713,7 @@ again:
scanChar();
if (_codePtr > _endPtr) {
_errorCode = IllegalEscapeSequence;
_errorMessage = QCoreApplication::translate("QmlParser", "End of file reached at escape sequence.");
_errorMessage = QCoreApplication::translate("QmlParser", "End of file reached at escape sequence");
return T_ERROR;
}
@@ -726,7 +726,7 @@ again:
u = decodeUnicodeEscapeCharacter(&ok);
if (! ok) {
_errorCode = IllegalUnicodeEscapeSequence;
_errorMessage = QCoreApplication::translate("QmlParser", "Illegal unicode escape sequence.");
_errorMessage = QCoreApplication::translate("QmlParser", "Illegal unicode escape sequence");
return T_ERROR;
}
} break;
@@ -737,7 +737,7 @@ again:
u = decodeHexEscapeCharacter(&ok);
if (!ok) {
_errorCode = IllegalHexadecimalEscapeSequence;
_errorMessage = QCoreApplication::translate("QmlParser", "Illegal hexadecimal escape sequence.");
_errorMessage = QCoreApplication::translate("QmlParser", "Illegal hexadecimal escape sequence");
return T_ERROR;
}
} break;
@@ -759,7 +759,7 @@ again:
u = QLatin1Char('\0');
break;
}
Q_FALLTHROUGH();
// fall through
case '1':
case '2':
case '3':
@@ -770,7 +770,7 @@ again:
case '8':
case '9':
_errorCode = IllegalEscapeSequence;
_errorMessage = QCoreApplication::translate("QmlParser", "Octal escape sequences are not allowed.");
_errorMessage = QCoreApplication::translate("QmlParser", "Octal escape sequences are not allowed");
return T_ERROR;
case '\r':
@@ -794,7 +794,7 @@ again:
}
_errorCode = UnclosedStringLiteral;
_errorMessage = QCoreApplication::translate("QmlParser", "Unclosed string at end of line.");
_errorMessage = QCoreApplication::translate("QmlParser", "Unclosed string at end of line");
return T_ERROR;
}
case '0':
@@ -818,7 +818,7 @@ again:
c = decodeUnicodeEscapeCharacter(&ok);
if (! ok) {
_errorCode = IllegalUnicodeEscapeSequence;
_errorMessage = QCoreApplication::translate("QmlParser", "Illegal unicode escape sequence.");
_errorMessage = QCoreApplication::translate("QmlParser", "Illegal unicode escape sequence");
return T_ERROR;
}
}
@@ -843,7 +843,7 @@ again:
c = decodeUnicodeEscapeCharacter(&ok);
if (! ok) {
_errorCode = IllegalUnicodeEscapeSequence;
_errorMessage = QCoreApplication::translate("QmlParser", "Illegal unicode escape sequence.");
_errorMessage = QCoreApplication::translate("QmlParser", "Illegal unicode escape sequence");
return T_ERROR;
}
if (isIdentifierPart(c))
@@ -906,7 +906,7 @@ int Lexer::scanNumber(QChar ch)
}
} else if (_char.isDigit() && !qmlMode()) {
_errorCode = IllegalCharacter;
_errorMessage = QCoreApplication::translate("QmlParser", "Decimal numbers can't start with \"0\".");
_errorMessage = QCoreApplication::translate("QmlParser", "Decimal numbers can't start with '0'");
return T_ERROR;
}
@@ -927,7 +927,7 @@ int Lexer::scanNumber(QChar ch)
if (chars.size() < 3) {
_errorCode = IllegalHexNumber;
_errorMessage = QCoreApplication::translate("QmlParser", "At least one hexadecimal digit is required after \"0%1\".").arg(ch);
_errorMessage = QCoreApplication::translate("QmlParser", "At least one hexadecimal digit is required after '0%1'").arg(ch);
return T_ERROR;
}
@@ -1003,7 +1003,7 @@ int Lexer::scanNumber(QChar ch)
if (end - begin != chars.size() - 1) {
_errorCode = IllegalExponentIndicator;
_errorMessage = QCoreApplication::translate("QmlParser", "Illegal syntax for exponential number.");
_errorMessage = QCoreApplication::translate("QmlParser", "Illegal syntax for exponential number");
return T_ERROR;
}
@@ -1029,7 +1029,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
while (isIdentLetter(_char)) {
int flag = regExpFlagFromChar(_char);
if (flag == 0 || _patternFlags & flag) {
_errorMessage = QCoreApplication::translate("QmlParser", "Invalid regular expression flag \"%0\".")
_errorMessage = QCoreApplication::translate("QmlParser", "Invalid regular expression flag '%0'")
.arg(QChar(_char));
return false;
}
@@ -1046,7 +1046,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
scanChar();
if (_codePtr > _endPtr || isLineTerminator()) {
_errorMessage = QCoreApplication::translate("QmlParser", "Unterminated regular expression backslash sequence.");
_errorMessage = QCoreApplication::translate("QmlParser", "Unterminated regular expression backslash sequence");
return false;
}
@@ -1068,7 +1068,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
scanChar();
if (_codePtr > _endPtr || isLineTerminator()) {
_errorMessage = QCoreApplication::translate("QmlParser", "Unterminated regular expression backslash sequence.");
_errorMessage = QCoreApplication::translate("QmlParser", "Unterminated regular expression backslash sequence");
return false;
}
@@ -1081,7 +1081,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
}
if (_char != QLatin1Char(']')) {
_errorMessage = QCoreApplication::translate("QmlParser", "Unterminated regular expression class.");
_errorMessage = QCoreApplication::translate("QmlParser", "Unterminated regular expression class");
return false;
}
@@ -1091,7 +1091,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
default:
if (_codePtr > _endPtr || isLineTerminator()) {
_errorMessage = QCoreApplication::translate("QmlParser", "Unterminated regular expression literal.");
_errorMessage = QCoreApplication::translate("QmlParser", "Unterminated regular expression literal");
return false;
} else {
_tokenText += _char;
@@ -1295,7 +1295,7 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
if (! (directiveName == QLatin1String("pragma") ||
directiveName == QLatin1String("import"))) {
error->message = QCoreApplication::translate("QmlParser", "Syntax error.");
error->message = QCoreApplication::translate("QmlParser", "Syntax error");
error->loc.startLine = tokenStartLine();
error->loc.startColumn = tokenStartColumn();
return false; // not a valid directive name
@@ -1305,7 +1305,7 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
if (directiveName == QLatin1String("pragma")) {
// .pragma library
if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("library"))) {
error->message = QCoreApplication::translate("QmlParser", "Syntax error.");
error->message = QCoreApplication::translate("QmlParser", "Syntax error");
error->loc.startLine = tokenStartLine();
error->loc.startColumn = tokenStartColumn();
return false; // expected `library
@@ -1329,7 +1329,7 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
pathOrUri = tokenText();
if (!pathOrUri.endsWith(QLatin1String("js"))) {
error->message = QCoreApplication::translate("QmlParser","Imported file must be a script.");
error->message = QCoreApplication::translate("QmlParser","Imported file must be a script");
error->loc.startLine = tokenStartLine();
error->loc.startColumn = tokenStartColumn();
return false;
@@ -1340,7 +1340,7 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
while (true) {
if (!isUriToken(_tokenKind)) {
error->message = QCoreApplication::translate("QmlParser","Invalid module URI.");
error->message = QCoreApplication::translate("QmlParser","Invalid module URI");
error->loc.startLine = tokenStartLine();
error->loc.startColumn = tokenStartColumn();
return false;
@@ -1350,7 +1350,7 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
lex();
if (tokenStartLine() != lineNumber) {
error->message = QCoreApplication::translate("QmlParser","Invalid module URI.");
error->message = QCoreApplication::translate("QmlParser","Invalid module URI");
error->loc.startLine = tokenStartLine();
error->loc.startColumn = tokenStartColumn();
return false;
@@ -1362,7 +1362,7 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
lex();
if (tokenStartLine() != lineNumber) {
error->message = QCoreApplication::translate("QmlParser","Invalid module URI.");
error->message = QCoreApplication::translate("QmlParser","Invalid module URI");
error->loc.startLine = tokenStartLine();
error->loc.startColumn = tokenStartColumn();
return false;
@@ -1370,7 +1370,7 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
}
if (_tokenKind != T_NUMERIC_LITERAL) {
error->message = QCoreApplication::translate("QmlParser","Module import requires a version.");
error->message = QCoreApplication::translate("QmlParser","Module import requires a version");
error->loc.startLine = tokenStartLine();
error->loc.startColumn = tokenStartColumn();
return false; // expected the module version number
@@ -1384,9 +1384,9 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
//
if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("as") && tokenStartLine() == lineNumber)) {
if (fileImport)
error->message = QCoreApplication::translate("QmlParser", "File import requires a qualifier.");
error->message = QCoreApplication::translate("QmlParser", "File import requires a qualifier");
else
error->message = QCoreApplication::translate("QmlParser", "Module import requires a qualifier.");
error->message = QCoreApplication::translate("QmlParser", "Module import requires a qualifier");
if (tokenStartLine() != lineNumber) {
error->loc.startLine = lineNumber;
error->loc.startColumn = column;
@@ -1399,9 +1399,9 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
if (lex() != T_IDENTIFIER || tokenStartLine() != lineNumber) {
if (fileImport)
error->message = QCoreApplication::translate("QmlParser", "File import requires a qualifier.");
error->message = QCoreApplication::translate("QmlParser", "File import requires a qualifier");
else
error->message = QCoreApplication::translate("QmlParser", "Module import requires a qualifier.");
error->message = QCoreApplication::translate("QmlParser", "Module import requires a qualifier");
error->loc.startLine = tokenStartLine();
error->loc.startColumn = tokenStartColumn();
return false; // expected module name
@@ -1409,7 +1409,7 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
const QString module = tokenText();
if (!module.at(0).isUpper()) {
error->message = QCoreApplication::translate("QmlParser","Invalid import qualifier.");
error->message = QCoreApplication::translate("QmlParser","Invalid import qualifier");
error->loc.startLine = tokenStartLine();
error->loc.startColumn = tokenStartColumn();
return false;
@@ -1422,7 +1422,7 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
}
if (tokenStartLine() != lineNumber) {
error->message = QCoreApplication::translate("QmlParser", "Syntax error.");
error->message = QCoreApplication::translate("QmlParser", "Syntax error");
error->loc.startLine = tokenStartLine();
error->loc.startColumn = tokenStartColumn();
return false; // the directives cannot span over multiple lines