Fix automatic insertion of semicolons.
authorRoberto Raggi <roberto.raggi@nokia.com>
Thu, 15 Sep 2011 15:08:22 +0000 (17:08 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 19 Sep 2011 10:07:46 +0000 (12:07 +0200)
Use Lexer::canInsertAutomaticSemicolon() when recovering from errors
generated by missing T_SEMICOLON tokens.

Change-Id: Ie4011d8d3e02b02a7dccd0a09ffa28b1ec9e654d
Reviewed-on: http://codereview.qt-project.org/5017
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
tools/qmlmin/main.cpp

index 61223ad..7a5b8f9 100644 (file)
@@ -122,11 +122,6 @@ public:
     }
 
 protected:
-    bool automatic(int token) const
-    {
-        return token == T_RBRACE || token == 0 || prevTerminator();
-    }
-
     virtual bool parse(int startToken) = 0;
 
     static QString quote(const QString &string)
@@ -346,7 +341,7 @@ bool Minify::parse(int startToken)
     const int yyerrorstate = _stateStack[yytos];
 
     // automatic insertion of `;'
-    if (yytoken != -1 && t_action(yyerrorstate, T_AUTOMATIC_SEMICOLON) && automatic(yytoken)) {
+    if (yytoken != -1 && t_action(yyerrorstate, T_AUTOMATIC_SEMICOLON) && canInsertAutomaticSemicolon(yytoken)) {
         _tokens.prepend(yytoken);
         _tokenStrings.prepend(yytokentext);
         yyaction = yyerrorstate;
@@ -461,7 +456,7 @@ bool Tokenize::parse(int startToken)
     const int yyerrorstate = _stateStack[yytos];
 
     // automatic insertion of `;'
-    if (yytoken != -1 && t_action(yyerrorstate, T_AUTOMATIC_SEMICOLON) && automatic(yytoken)) {
+    if (yytoken != -1 && t_action(yyerrorstate, T_AUTOMATIC_SEMICOLON) && canInsertAutomaticSemicolon(yytoken)) {
         _tokens.prepend(yytoken);
         _tokenStrings.prepend(yytokentext);
         yyaction = yyerrorstate;