string_stack = reinterpret_cast<QStringRef*> (qRealloc(string_stack, stack_size * sizeof(QStringRef)));
}
-inline static bool automatic(Engine *driver, int token)
-{
- return token == $table::T_RBRACE
- || token == 0
- || driver->lexer()->prevTerminator();
-}
-
-
Parser::Parser(Engine *engine):
driver(engine),
pool(engine->pool()),
const int errorState = state_stack[tos];
// automatic insertion of `;'
- if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && automatic(driver, yytoken)) {
+ if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) {
SavedToken &tk = token_buffer[0];
tk.token = yytoken;
tk.dval = yylval;
, _prohibitAutomaticSemicolon(false)
, _restrictedKeyword(false)
, _terminator(false)
+ , _followsClosingBrace(false)
, _delimited(false)
, _qmlMode(true)
{
_prohibitAutomaticSemicolon = false;
_restrictedKeyword = false;
_terminator = false;
+ _followsClosingBrace = false;
_delimited = false;
}
int Lexer::lex()
{
+ const int previousTokenKind = _tokenKind;
+
_tokenSpell = QStringRef();
_tokenKind = scanToken();
_tokenLength = _codePtr - _tokenStartPtr - 1;
_delimited = false;
_restrictedKeyword = false;
+ _followsClosingBrace = (previousTokenKind == T_RBRACE);
// update the flags
switch (_tokenKind) {
return _terminator;
}
+bool Lexer::followsClosingBrace() const
+{
+ return _followsClosingBrace;
+}
+
+bool Lexer::canInsertAutomaticSemicolon(int token) const
+{
+ return token == T_RBRACE
+ || token == EOF_SYMBOL
+ || _terminator
+ || _followsClosingBrace;
+}
+
#include "qdeclarativejskeywords_p.h"
QString errorMessage() const;
bool prevTerminator() const;
+ bool followsClosingBrace() const;
+ bool canInsertAutomaticSemicolon(int token) const;
enum ParenthesesState {
IgnoreParentheses,
bool _prohibitAutomaticSemicolon;
bool _restrictedKeyword;
bool _terminator;
+ bool _followsClosingBrace;
bool _delimited;
bool _qmlMode;
};
string_stack = reinterpret_cast<QStringRef*> (qRealloc(string_stack, stack_size * sizeof(QStringRef)));
}
-inline static bool automatic(Engine *driver, int token)
-{
- return token == QDeclarativeJSGrammar::T_RBRACE
- || token == 0
- || driver->lexer()->prevTerminator();
-}
-
-
Parser::Parser(Engine *engine):
driver(engine),
pool(engine->pool()),
const int errorState = state_stack[tos];
// automatic insertion of `;'
- if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && automatic(driver, yytoken)) {
+ if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) {
SavedToken &tk = token_buffer[0];
tk.token = yytoken;
tk.dval = yylval;
--- /dev/null
+
+import QtQuick 2.0
+
+QtObject {
+ function code() {
+ if (1) {
+ var a;
+ function f1(){}a=1;
+ }
+ }
+}
void revisionErrors();
void revision();
+ void automaticSemicolon();
+
private:
QDeclarativeEngine engine;
};
QString::fromLatin1("string:Hello World false:0 true:1 uint32:100 int32:-100 double:3.14159 date:2011-02-11 05::30:50!"));
}
+void tst_qdeclarativeecmascript::automaticSemicolon()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("automaticSemicolon.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
QTEST_MAIN(tst_qdeclarativeecmascript)
#include "tst_qdeclarativeecmascript.moc"