2011-07-01 Juan C. Montemayor <jmont@apple.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Jul 2011 19:47:05 +0000 (19:47 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Jul 2011 19:47:05 +0000 (19:47 +0000)
        Reviewed by Oliver Hunt.

        Lexer error messages are currently appalling
        https://bugs.webkit.org/show_bug.cgi?id=63340

        Updated expected test results.

        * fast/js/basic-strict-mode-expected.txt:
        * fast/js/kde/parse-expected.txt:
        * fast/js/kde/string-1-n-expected.txt:
        * fast/js/kde/string-2-n-expected.txt:
        * fast/js/numeric-escapes-in-string-literals-expected.txt:
        * fast/js/removing-Cf-characters-expected.txt:
        * fast/regex/non-pattern-characters-expected.txt:
        * http/tests/websocket/tests/bad-sub-protocol-control-chars-expected.txt:
        * loader/reload-subresource-when-type-changes-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.1_T1-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.1_T2-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.2_T1-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.2_T2-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.3-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.4-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.4_Comments/S7.4_A2_T2-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.1_T1-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.1_T2-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.2_T1-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.2_T2-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A1.1_T1-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A1.1_T2-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A1.2_T1-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A1.2_T2-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A3.1_T1-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A3.1_T2-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A3.2_T1-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A3.2_T2-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.1_T4-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T1-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T2-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T3-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T4-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T5-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T6-expected.txt:
        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.2_T1-expected.txt:
        * sputnik/Conformance/08_Types/8.4_The_String_Type/S8.4_A13_T1-expected.txt:
        * sputnik/Conformance/08_Types/8.4_The_String_Type/S8.4_A13_T2-expected.txt:
        * sputnik/Conformance/08_Types/8.4_The_String_Type/S8.4_A14_T1-expected.txt:
        * sputnik/Conformance/08_Types/8.4_The_String_Type/S8.4_A14_T2-expected.txt:
2011-07-01  Juan C. Montemayor  <jmont@apple.com>

        Reviewed by Oliver Hunt.

        Lexer error messages are currently appalling
        https://bugs.webkit.org/show_bug.cgi?id=63340

        Added error messages for the Lexer. These messages will be displayed
        instead of the lexer error messages from the parser that are currently
        shown.

        * parser/Lexer.cpp:
        (JSC::Lexer::getInvalidCharMessage):
        (JSC::Lexer::setCode):
        (JSC::Lexer::parseString):
        (JSC::Lexer::lex):
        (JSC::Lexer::clear):
        * parser/Lexer.h:
        (JSC::Lexer::getErrorMessage):
        (JSC::Lexer::setOffset):
        * parser/Parser.cpp:
        (JSC::Parser::parse):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@90265 268f45cc-cd09-0410-ab3c-d52691b4dbfc

45 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/js/basic-strict-mode-expected.txt
LayoutTests/fast/js/kde/parse-expected.txt
LayoutTests/fast/js/kde/string-1-n-expected.txt
LayoutTests/fast/js/kde/string-2-n-expected.txt
LayoutTests/fast/js/numeric-escapes-in-string-literals-expected.txt
LayoutTests/fast/js/removing-Cf-characters-expected.txt
LayoutTests/fast/regex/non-pattern-characters-expected.txt
LayoutTests/http/tests/websocket/tests/bad-sub-protocol-control-chars-expected.txt
LayoutTests/loader/reload-subresource-when-type-changes-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.1_T1-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.1_T2-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.2_T1-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.2_T2-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.3-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.4-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.4_Comments/S7.4_A2_T2-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.1_T1-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.1_T2-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.2_T1-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.2_T2-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A1.1_T1-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A1.1_T2-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A1.2_T1-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A1.2_T2-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A3.1_T1-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A3.1_T2-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A3.2_T1-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A3.2_T2-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.1_T4-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T1-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T2-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T3-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T4-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T5-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T6-expected.txt
LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.2_T1-expected.txt
LayoutTests/sputnik/Conformance/08_Types/8.4_The_String_Type/S8.4_A13_T1-expected.txt
LayoutTests/sputnik/Conformance/08_Types/8.4_The_String_Type/S8.4_A13_T2-expected.txt
LayoutTests/sputnik/Conformance/08_Types/8.4_The_String_Type/S8.4_A14_T1-expected.txt
LayoutTests/sputnik/Conformance/08_Types/8.4_The_String_Type/S8.4_A14_T2-expected.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/parser/Lexer.cpp
Source/JavaScriptCore/parser/Lexer.h
Source/JavaScriptCore/parser/Parser.cpp

index 88f43aa6819a7ce863d198aceadca7ef589f0bce..1231fea71352cf22aa372e7be5de93d9b8acd176 100644 (file)
@@ -1,3 +1,53 @@
+2011-07-01  Juan C. Montemayor  <jmont@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Lexer error messages are currently appalling
+        https://bugs.webkit.org/show_bug.cgi?id=63340
+
+        Updated expected test results.
+
+        * fast/js/basic-strict-mode-expected.txt:
+        * fast/js/kde/parse-expected.txt:
+        * fast/js/kde/string-1-n-expected.txt:
+        * fast/js/kde/string-2-n-expected.txt:
+        * fast/js/numeric-escapes-in-string-literals-expected.txt:
+        * fast/js/removing-Cf-characters-expected.txt:
+        * fast/regex/non-pattern-characters-expected.txt:
+        * http/tests/websocket/tests/bad-sub-protocol-control-chars-expected.txt:
+        * loader/reload-subresource-when-type-changes-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.1_T1-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.1_T2-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.2_T1-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.2_T2-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.3-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.4-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.4_Comments/S7.4_A2_T2-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.1_T1-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.1_T2-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.2_T1-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.3_Numeric_Literals/S7.8.3_A6.2_T2-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A1.1_T1-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A1.1_T2-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A1.2_T1-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A1.2_T2-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A3.1_T1-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A3.1_T2-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A3.2_T1-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A3.2_T2-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.1_T4-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T1-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T2-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T3-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T4-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T5-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.4_String_Literals/S7.8.4_A7.2_T6-expected.txt:
+        * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.2_T1-expected.txt:
+        * sputnik/Conformance/08_Types/8.4_The_String_Type/S8.4_A13_T1-expected.txt:
+        * sputnik/Conformance/08_Types/8.4_The_String_Type/S8.4_A13_T2-expected.txt:
+        * sputnik/Conformance/08_Types/8.4_The_String_Type/S8.4_A14_T1-expected.txt:
+        * sputnik/Conformance/08_Types/8.4_The_String_Type/S8.4_A14_T2-expected.txt:
+
 2011-07-01  Adam Roben  <aroben@apple.com>
 
         Add Leopard expected failure result for media/media-blocked-by-beforeload.html
index 49926980dc060498097846186e9c8421845e550c..fd1294052ff9b891c1c4f52ce7372eabf0774216 100644 (file)
@@ -86,12 +86,12 @@ PASS 'use strict'; for(;;)break missingLabel threw exception SyntaxError: Label
 PASS (function(){'use strict'; for(;;)break missingLabel}) threw exception SyntaxError: Label 'missingLabel' is not defined.
 PASS 'use strict'; for(;;)continue missingLabel threw exception SyntaxError: Label 'missingLabel' is not defined.
 PASS (function(){'use strict'; for(;;)continue missingLabel}) threw exception SyntaxError: Label 'missingLabel' is not defined.
-PASS 'use strict'; 007; threw exception SyntaxError: Unrecognized token '007'.
-PASS (function(){'use strict'; 007;}) threw exception SyntaxError: Unrecognized token '007'.
-PASS 'use strict'; '\007'; threw exception SyntaxError: Unrecognized token ''\0'.
-PASS (function(){'use strict'; '\007';}) threw exception SyntaxError: Unrecognized token ''\0'.
-PASS '\007'; 'use strict'; threw exception SyntaxError: Unrecognized token ''\0'.
-PASS (function(){'\007'; 'use strict';}) threw exception SyntaxError: Unrecognized token ''\0'.
+PASS 'use strict'; 007; threw exception SyntaxError: Octal escapes are forbidden in strict mode.
+PASS (function(){'use strict'; 007;}) threw exception SyntaxError: Octal escapes are forbidden in strict mode.
+PASS 'use strict'; '\007'; threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
+PASS (function(){'use strict'; '\007';}) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
+PASS '\007'; 'use strict'; threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
+PASS (function(){'\007'; 'use strict';}) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS 'use strict'; delete aDeletableProperty; threw exception SyntaxError: Cannot delete unqualified property 'aDeletableProperty' in strict mode.
 PASS (function(){'use strict'; delete aDeletableProperty;}) threw exception SyntaxError: Cannot delete unqualified property 'aDeletableProperty' in strict mode.
 PASS 'use strict'; (function (){ delete someDeclaredGlobal;}) threw exception SyntaxError: Cannot delete unqualified property 'someDeclaredGlobal' in strict mode.
@@ -175,14 +175,14 @@ PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescri
 PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f, 'caller'); return descriptor.get === descriptor.set; })() is true
 PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f, 'arguments'); return descriptor.get === descriptor.set; })() is true
 PASS 'use strict'; (function f() { for(var i in this); })(); true; is true
-PASS 'use strict'̻ threw exception SyntaxError: Unrecognized token ''.
-PASS (function(){'use strict'̻}) threw exception SyntaxError: Unrecognized token ''.
-PASS 'use strict'5.f threw exception SyntaxError: Unrecognized token '5.'.
-PASS (function(){'use strict'5.f}) threw exception SyntaxError: Unrecognized token '5.'.
-PASS 'use strict';̻ threw exception SyntaxError: Unrecognized token ''.
-PASS (function(){'use strict';̻}) threw exception SyntaxError: Unrecognized token ''.
-PASS 'use strict';5.f threw exception SyntaxError: Unrecognized token '5.'.
-PASS (function(){'use strict';5.f}) threw exception SyntaxError: Unrecognized token '5.'.
+PASS 'use strict'̻ threw exception SyntaxError: Invalid character '\u0827'.
+PASS (function(){'use strict'̻}) threw exception SyntaxError: Invalid character '\u0827'.
+PASS 'use strict'5.f threw exception SyntaxError: At least one digit must occur after a decimal point.
+PASS (function(){'use strict'5.f}) threw exception SyntaxError: At least one digit must occur after a decimal point.
+PASS 'use strict';̻ threw exception SyntaxError: Invalid character '\u0827'.
+PASS (function(){'use strict';̻}) threw exception SyntaxError: Invalid character '\u0827'.
+PASS 'use strict';5.f threw exception SyntaxError: At least one digit must occur after a decimal point.
+PASS (function(){'use strict';5.f}) threw exception SyntaxError: At least one digit must occur after a decimal point.
 PASS 'use strict';1-(eval=1); threw exception SyntaxError: 'eval' cannot be modified in strict mode.
 PASS (function(){'use strict';1-(eval=1);}) threw exception SyntaxError: 'eval' cannot be modified in strict mode.
 PASS 'use strict';arguments=1; threw exception SyntaxError: 'arguments' cannot be modified in strict mode.
index c732b316694a55bd3f5b402381c3ce9a7ffec830..15e9c3956e9590a5f071fbbbcddd908351792589 100644 (file)
@@ -16,7 +16,7 @@ PASS function test() { return 0 } lab: 1 is 1
 PASS function test() { while(0) break lab } lab: 1 threw exception SyntaxError: Label 'lab' is not defined.
 PASS function test() { while(0) continue lab } lab: 1 threw exception SyntaxError: Label 'lab' is not defined.
 PASS var éĀʯΈᢨ = 101; éĀʯΈᢨ; is 101
-PASS var f÷; threw exception SyntaxError: Unrecognized token ''.
+PASS var f÷; threw exception SyntaxError: Invalid character '\u0247'.
 PASS var \u0061 = 102; a is 102
 PASS var f\u0030 = 103; f0 is 103
 PASS var \u00E9\u0100\u02AF\u0388\u18A8 = 104; \u00E9\u0100\u02AF\u0388\u18A8; is 104
index 17fea1e2c2c29a21277888b9b5a57be32f8460d2..02e51cf3b2e749d0f40472801b36357cf1defb7d 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1: SyntaxError: Unrecognized token '"unterminated string'
+CONSOLE MESSAGE: line 1: SyntaxError: Unexpected EOF
 KDE JS Test
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
index c0dec209fc43d925d3b9909e1b0fd753ade01771..02e51cf3b2e749d0f40472801b36357cf1defb7d 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1: SyntaxError: Unrecognized token '"broken'
+CONSOLE MESSAGE: line 1: SyntaxError: Unexpected EOF
 KDE JS Test
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
index 4fde2ac430439c843af223a315402224b365bae7..95777ad6d986d91e323237fb7d5e9840a6fbd14f 100644 (file)
@@ -6,39 +6,39 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 PASS eval(stringLiteral) is nonStrictResult
 PASS eval(stringLiteral) is strictResult
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\1'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\7'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\8'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\9'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\0'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\0'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\0'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\0'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\0'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\0'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\1'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\1'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\1'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\1'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\1'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\1'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS eval(stringLiteral) is nonStrictResult
-PASS eval(stringLiteral) threw exception SyntaxError: Unrecognized token '"\9'.
+PASS eval(stringLiteral) threw exception SyntaxError: The only valid numeric escape in strict mode is '\0'.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index dd2b64f4232a2465a1d4bae758b6b8b57e0b3658..bd461915ba746b5386471439c7374afc3528df0f 100644 (file)
@@ -9,7 +9,7 @@ PASS 1 is 1
 PASS eval('""').length is 1
 PASS eval('""').charCodeAt(0) is 0xFEFF
 PASS ++1 /* BOM between the +'s */ is 1
-PASS var ZWJ_I‍nside; threw exception SyntaxError: Unrecognized token ''.
+PASS var ZWJ_I‍nside; threw exception SyntaxError: Invalid character '\u8205'.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index c3ba340b4c206f682e1d295227ff3062ac4991eb..dce63f9aa1a870c7fb6f7002b5eb8291890770f4 100644 (file)
@@ -51,7 +51,7 @@ PASS regexp.test('aaba') is true
 PASS regexp.lastIndex is 2
 
 Testing regexp: [invalid * variations]
-PASS /*/ threw exception SyntaxError: Unrecognized token '/*/'.
+PASS /*/ threw exception SyntaxError: Multiline comment was not closed properly.
 PASS /^*/ threw exception SyntaxError: Invalid regular expression: nothing to repeat.
 
 Testing regexp: /a+/gm
index 6de9e8d5158b5aebb1ecb030a6b5a0354a921dc4..215280c9f369fd059d4fc7db213ad5c2fe97697e 100644 (file)
@@ -8,9 +8,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 PASS new WebSocket("ws://127.0.0.1:8880/simple", "\0") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS new WebSocket("ws://127.0.0.1:8880/simple", "     ") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS new WebSocket("ws://127.0.0.1:8880/simple", "
-") threw exception SyntaxError: Unrecognized token '"'.
+") threw exception SyntaxError: Unexpected EOF.
 PASS new WebSocket("ws://127.0.0.1:8880/simple", "
-") threw exception SyntaxError: Unrecognized token '"'.
+") threw exception SyntaxError: Unexpected EOF.
 PASS new WebSocket("ws://127.0.0.1:8880/simple", "\e") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS successfullyParsed is true
 
index 263acc817266b50b65bd7f23ecd90878e1730246..10b9dbd9592386e31f1e6f945c81a66bf47278f3 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1: SyntaxError: Unrecognized token ''
+CONSOLE MESSAGE: line 1: SyntaxError: Invalid character '\u8240'
 PASS 1 of 3
 PASS 2 of 3
 PASS 3 of 3
index 1ebff5dcb698828158792ba5b318cd544dafe38b..4784d7fab6e8d03028e86f8cbe4c0e3990256a35 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '"'
+CONSOLE MESSAGE: line 77: SyntaxError: Unexpected EOF
 S7.3_A2.1_T2
 
 PASS Expected parsing failure
index ed1cc3de12b5875794b0c683fd9bffea4bd2d73a..9881a67cfadab64796bbb4e514214fa533b34558 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '"'
+CONSOLE MESSAGE: line 77: SyntaxError: Unexpected EOF
 S7.3_A2.2_T2
 
 PASS Expected parsing failure
index a12cadcb0caacd4ce71cadbe1e709bef09b2df4a..d16df9b5bbda29f2fec2a0480faccaeae62ee295 100644 (file)
@@ -1,11 +1,4 @@
-CONSOLE MESSAGE: line 83: SyntaxError: Unrecognized token '/*CHECK#1/
-
-} catch (ex) {
-    sputnikException = ex;
-}
-
-var successfullyParsed = true;
-'
+CONSOLE MESSAGE: line 83: SyntaxError: Multiline comment was not closed properly
 S7.4_A2_T2
 
 PASS Expected parsing failure
index 4456f310c3594c10a8180cfc2f60682f73262a12..e859d4bea7e3983cf1cea5204d20469189238c23 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '0'
+CONSOLE MESSAGE: line 77: SyntaxError: At least one digit must occur after a decimal point
 S7.8.3_A6.1_T1
 
 PASS Expected parsing failure
index 2ad088cbb1efcc5f168e8c386aeec77b22e404de..0db6796e76e0ca260bd4f2905c298c9c46ff0ec4 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '0'
+CONSOLE MESSAGE: line 77: SyntaxError: At least one digit must occur after a decimal point
 S7.8.3_A6.1_T2
 
 PASS Expected parsing failure
index c14136c15c690ad0779041f4d4649f539e2feedc..30173dd29aaf063ab24227d15ca5e57488e0a640 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '0'
+CONSOLE MESSAGE: line 77: SyntaxError: At least one digit must occur after a decimal point
 S7.8.3_A6.2_T1
 
 PASS Expected parsing failure
index 8c96af3a12a46dbb600da4a8083d57e408aef12a..c95a0dd4d5a9db82010facd0431e1f16041f9b51 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '0'
+CONSOLE MESSAGE: line 77: SyntaxError: At least one digit must occur after a decimal point
 S7.8.3_A6.2_T2
 
 PASS Expected parsing failure
index c98da89949fa9d461e25ea67df945230a0994ccd..d021bd1b2fe3436e6d559a0737f9f44b01c3e679 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '"'
+CONSOLE MESSAGE: line 77: SyntaxError: Unexpected EOF
 S7.8.4_A1.1_T1
 
 PASS Expected parsing failure
index de0bc13595c3b1385ebc57d25e5cb2af427b81e7..f081263d0a06bbbca8bdf7a738a9581cfc61d229 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '"'
+CONSOLE MESSAGE: line 77: SyntaxError: Unexpected EOF
 S7.8.4_A1.1_T2
 
 PASS Expected parsing failure
index 546fe5d8d067deda7205ffd2b98e76f81d58d5e4..2c2f1c40345ee70adc472a3a40a042a0dfdc9f54 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '''
+CONSOLE MESSAGE: line 77: SyntaxError: Unexpected EOF
 S7.8.4_A1.2_T1
 
 PASS Expected parsing failure
index 02864b441fd3e63a50ff370210bd3cade44c2864..917a8a08486f2877b048a4c1ff669262c11b8342 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '''
+CONSOLE MESSAGE: line 77: SyntaxError: Unexpected EOF
 S7.8.4_A1.2_T2
 
 PASS Expected parsing failure
index 6d4d50251d2ddad00fff0ad54ca8b959d8d547f7..e35235dca58d03f153243f5e137b2b2e08c2ada5 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '"\"'
+CONSOLE MESSAGE: line 77: SyntaxError: Unexpected EOF
 S7.8.4_A3.1_T1
 
 PASS Expected parsing failure
index c20685b17027d45a684390fc0d989b121db1dc12..c645de2413d4bbefd7b4247dd70918d9d01eb2ed 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token ''\''
+CONSOLE MESSAGE: line 77: SyntaxError: Unexpected EOF
 S7.8.4_A3.1_T2
 
 PASS Expected parsing failure
index be830857b378ae6832d39341a89be8bef1e7986e..7ce39b24b3e23b5b57c3110457d82395b5f2238b 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '"\\\"'
+CONSOLE MESSAGE: line 77: SyntaxError: Unexpected EOF
 S7.8.4_A3.2_T1
 
 PASS Expected parsing failure
index c0138fec7672f1635391f06c7931fa348dc4d5a2..372a0e151f6308c5cd562ef748668902f3532aa5 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token ''\\\''
+CONSOLE MESSAGE: line 77: SyntaxError: Unexpected EOF
 S7.8.4_A3.2_T2
 
 PASS Expected parsing failure
index 81cdc6b913610d932cb9412faef53a90715305fe..e7aa66cd85817ffd0fe11cc6d597ebe3bb285c66 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '"\u'
+CONSOLE MESSAGE: line 77: SyntaxError: \u can only be followed by a Unicode character sequence
 S7.8.4_A7.1_T4
 
 PASS Expected parsing failure
index d8fbfd2382d83cffba3bb9850c81ccd2aa2edb74..f1afdfb4aeece9f78fd5632e975af3c417f9dc39 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '"\u'
+CONSOLE MESSAGE: line 77: SyntaxError: \u can only be followed by a Unicode character sequence
 S7.8.4_A7.2_T1
 
 PASS Expected parsing failure
index 17d867fa73d028299e98c5d5d9c741dd02b6f3bd..301cec6bf93a9721f3397093b2abf8c5975460c2 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '"\u'
+CONSOLE MESSAGE: line 77: SyntaxError: \u can only be followed by a Unicode character sequence
 S7.8.4_A7.2_T2
 
 PASS Expected parsing failure
index 61f0ea0cf2065589b59af29ee92dd7fe5c1f1bc8..9d7b476c51f21f98662c7037ad300b6cd328dafb 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '"\u'
+CONSOLE MESSAGE: line 77: SyntaxError: \u can only be followed by a Unicode character sequence
 S7.8.4_A7.2_T3
 
 PASS Expected parsing failure
index 3d30508cb36589961497b7a9ba0ee81501be7908..06573acac8eeb19f3adbd06b2631e68a7bb480db 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '"\u'
+CONSOLE MESSAGE: line 77: SyntaxError: \u can only be followed by a Unicode character sequence
 S7.8.4_A7.2_T4
 
 PASS Expected parsing failure
index 594378bb819e6d2bafbf3aba61ab936a2d002bdb..0dd61cb95d7730e47ef3ccc94a61c6dee979d26d 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '"\u'
+CONSOLE MESSAGE: line 77: SyntaxError: \u can only be followed by a Unicode character sequence
 S7.8.4_A7.2_T5
 
 PASS Expected parsing failure
index e4849df0b41de664215e362152616cfd64936881..ec846b606c637c55f1ff4aced00cdc0bfbf31f27 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 77: SyntaxError: Unrecognized token '"\u'
+CONSOLE MESSAGE: line 77: SyntaxError: \u can only be followed by a Unicode character sequence
 S7.8.4_A7.2_T6
 
 PASS Expected parsing failure
index e1a54350b3e4c7198842a0f212cd90c0b3178efd..9f86288cc5d23240e1f4467554957c27d78f09dd 100644 (file)
@@ -1,11 +1,4 @@
-CONSOLE MESSAGE: line 84: SyntaxError: Unrecognized token '/*/
-
-} catch (ex) {
-    sputnikException = ex;
-}
-
-var successfullyParsed = true;
-'
+CONSOLE MESSAGE: line 84: SyntaxError: Multiline comment was not closed properly
 S7.8.5_A1.2_T1
 
 PASS Expected parsing failure
index 439fbb9e02046df1f04de3befacd83916b6d6533..98e8d9ef522eb0dae5661f85e9ab179e992a8744 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 76: SyntaxError: Unrecognized token '';'
+CONSOLE MESSAGE: line 76: SyntaxError: Unexpected EOF
 S8.4_A13_T1
 
 PASS Expected parsing failure
index 860be2f53c8d2362b38dbd4740d3f2fec41c6115..a4092de1ba727c995e41294a11cc59226bde24f1 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 76: SyntaxError: Unrecognized token '';'
+CONSOLE MESSAGE: line 76: SyntaxError: Unexpected EOF
 S8.4_A13_T2
 
 PASS Expected parsing failure
index 06db2046d7f87649d0266c530ec6aec47e170324..1ada740ce13b6a3501637d8387ee3379961076d5 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 76: SyntaxError: Unrecognized token '";'
+CONSOLE MESSAGE: line 76: SyntaxError: Unexpected EOF
 S8.4_A14_T1
 
 PASS Expected parsing failure
index 0369ea04749e2d6214ae4b7c2be172fc663c4249..23462048db97f64a7f4c460b0d08d54a7a643977 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 76: SyntaxError: Unrecognized token '";'
+CONSOLE MESSAGE: line 76: SyntaxError: Unexpected EOF
 S8.4_A14_T2
 
 PASS Expected parsing failure
index c40cfbc57a2d9af0b19bf0a74fb9ebcd75aae27f..70e6f01c075c4274c2cdbf371ca5a9ee7f81c051 100644 (file)
@@ -1,3 +1,26 @@
+2011-07-01  Juan C. Montemayor  <jmont@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Lexer error messages are currently appalling
+        https://bugs.webkit.org/show_bug.cgi?id=63340
+
+        Added error messages for the Lexer. These messages will be displayed
+        instead of the lexer error messages from the parser that are currently
+        shown.
+
+        * parser/Lexer.cpp:
+        (JSC::Lexer::getInvalidCharMessage):
+        (JSC::Lexer::setCode):
+        (JSC::Lexer::parseString):
+        (JSC::Lexer::lex):
+        (JSC::Lexer::clear):
+        * parser/Lexer.h:
+        (JSC::Lexer::getErrorMessage):
+        (JSC::Lexer::setOffset):
+        * parser/Parser.cpp:
+        (JSC::Parser::parse):
+
 2011-07-01  Jungshik Shin  <jshin@chromium.org>
 
         Reviewed by Alexey Proskuryakov.
index 7d77b77d0112795806e049ae623225f8e1dc2462..1ef8b5f419c7a2a0269349df76fac36e13fb8361 100644 (file)
@@ -233,6 +233,28 @@ Lexer::~Lexer()
 {
     m_keywordTable.deleteTable();
 }
+    
+UString Lexer::getInvalidCharMessage()
+{
+    switch (m_current) {
+    case 0:
+        return "Invalid character: '\\0'";
+    case 10:
+        return "Invalid character: '\\n'";
+    case 11:
+        return "Invalid character: '\\v'";
+    case 13:
+        return "Invalid character: '\\r'";
+    case 35:
+        return "Invalid character: '#'";
+    case 64:
+        return "Invalid character: '@'";
+    case 96:
+        return "Invalid character: '`'";
+    default:
+        return String::format("Invalid character '\\u%04u'", m_current).impl();
+    }
+}
 
 ALWAYS_INLINE const UChar* Lexer::currentCharacter() const
 {
@@ -261,6 +283,7 @@ void Lexer::setCode(const SourceCode& source, ParserArena& arena)
     m_codeEnd = data + source.endOffset();
     m_error = false;
     m_atLineStart = true;
+    m_lexErrorMessage = UString();
 
     m_buffer8.reserveInitialCapacity(initialReadBufferCapacity);
     m_buffer16.reserveInitialCapacity((m_codeEnd - m_code) / 2);
@@ -527,14 +550,18 @@ template <bool shouldBuildStrings> ALWAYS_INLINE bool Lexer::parseString(JSToken
                 } else if (m_current == stringQuoteCharacter) {
                     if (shouldBuildStrings)
                         record16('u');
-                } else // Only stringQuoteCharacter allowed after \u
+                } else {
+                    m_lexErrorMessage = "\\u can only be followed by a Unicode character sequence";
                     return false;
+                }
             } else if (strictMode && isASCIIDigit(m_current)) {
                 // The only valid numeric escape in strict mode is '\0', and this must not be followed by a decimal digit.
                 int character1 = m_current;
                 shift();
-                if (character1 != '0' || isASCIIDigit(m_current))
+                if (character1 != '0' || isASCIIDigit(m_current)) {
+                    m_lexErrorMessage = "The only valid numeric escape in strict mode is '\\0'";
                     return false;
+                }
                 if (shouldBuildStrings)
                     record16(0);
             } else if (!strictMode && isASCIIOctalDigit(m_current)) {
@@ -561,8 +588,10 @@ template <bool shouldBuildStrings> ALWAYS_INLINE bool Lexer::parseString(JSToken
                 if (shouldBuildStrings)
                     record16(m_current);
                 shift();
-            } else
+            } else {
+                m_lexErrorMessage = "Unterminated string constant";
                 return false;
+            }
 
             stringStart = currentCharacter();
             continue;
@@ -572,8 +601,10 @@ template <bool shouldBuildStrings> ALWAYS_INLINE bool Lexer::parseString(JSToken
         // as possible, and lets through all common ASCII characters.
         if (UNLIKELY(((static_cast<unsigned>(m_current) - 0xE) & 0x2000))) {
             // New-line or end of input is not allowed
-            if (UNLIKELY(isLineTerminator(m_current)) || UNLIKELY(m_current == -1))
+            if (UNLIKELY(isLineTerminator(m_current)) || UNLIKELY(m_current == -1)) {
+                m_lexErrorMessage = "Unexpected EOF";
                 return false;
+            }
             // Anything else is just a normal character
         }
         shift();
@@ -923,6 +954,7 @@ start:
             shift();
             if (parseMultilineComment())
                 goto start;
+            m_lexErrorMessage = "Multiline comment was not closed properly";
             goto returnError;
         }
         if (m_current == '=') {
@@ -1042,8 +1074,10 @@ start:
             record8('0');
             if (isASCIIOctalDigit(m_current)) {
                 if (parseOctal(tokenData->doubleValue)) {
-                    if (strictMode)
+                    if (strictMode) {
+                        m_lexErrorMessage = "Octal escapes are forbidden in strict mode";
                         goto returnError;
+                    }
                     token = NUMBER;
                 }
             }
@@ -1058,8 +1092,10 @@ inNumberAfterDecimalPoint:
                     parseNumberAfterDecimalPoint();
                 }
                 if ((m_current | 0x20) == 'e')
-                    if (!parseNumberAfterExponentIndicator())
+                    if (!parseNumberAfterExponentIndicator()) {
+                        m_lexErrorMessage = "Non-number found after exponent indicator";
                         goto returnError;
+                    }
                 // Null-terminate string for strtod.
                 m_buffer8.append('\0');
                 tokenData->doubleValue = WTF::strtod(m_buffer8.data(), 0);
@@ -1068,8 +1104,10 @@ inNumberAfterDecimalPoint:
         }
 
         // No identifiers allowed directly after numeric literal, e.g. "3in" is bad.
-        if (UNLIKELY(isIdentStart(m_current)))
+        if (UNLIKELY(isIdentStart(m_current))) {
+            m_lexErrorMessage = "At least one digit must occur after a decimal point";
             goto returnError;
+        }
         m_buffer8.resize(0);
         m_delimited = false;
         break;
@@ -1101,9 +1139,11 @@ inNumberAfterDecimalPoint:
         m_terminator = true;
         goto start;
     case CharacterInvalid:
+        m_lexErrorMessage = getInvalidCharMessage();
         goto returnError;
     default:
         ASSERT_NOT_REACHED();
+        m_lexErrorMessage = "Internal Error";
         goto returnError;
     }
 
index 6dfd52e315b71cc572fd6afe2c91788d5f108dce..1ec4773829a604fe4155b0a56642b33851026a8b 100644 (file)
@@ -69,11 +69,13 @@ namespace JSC {
 
         // Functions for use after parsing.
         bool sawError() const { return m_error; }
+        UString getErrorMessage() const { return m_lexErrorMessage; }
         void clear();
         int currentOffset() { return m_code - m_codeStart; }
         void setOffset(int offset)
         {
             m_error = 0;
+            m_lexErrorMessage = UString();
             m_code = m_codeStart + offset;
             m_buffer8.resize(0);
             m_buffer16.resize(0);
@@ -110,6 +112,7 @@ namespace JSC {
         int getUnicodeCharacter();
         void shiftLineTerminator();
 
+        UString getInvalidCharMessage();
         ALWAYS_INLINE const UChar* currentCharacter() const;
         ALWAYS_INLINE int currentOffset() const;
 
@@ -147,6 +150,7 @@ namespace JSC {
         bool m_isReparsing;
         bool m_atLineStart;
         bool m_error;
+        UString m_lexErrorMessage;
 
         // current and following unicode characters (int to allow for -1 for end-of-file marker)
         int m_current;
index 95f1fa1aa1931f25a238b9759b269436e62f627d..bc8e66d1eab4ee6fe5a3bba141b4302a1dbccf80 100644 (file)
@@ -51,11 +51,13 @@ void Parser::parse(JSGlobalData* globalData, FunctionParameters* parameters, JSP
     UString parseError = jsParse(globalData, parameters, strictness, mode, m_source);
     int lineNumber = lexer.lineNumber();
     bool lexError = lexer.sawError();
+    UString lexErrorMessage = lexError ? lexer.getErrorMessage() : UString();
+    ASSERT(lexErrorMessage.isNull() != lexError);
     lexer.clear();
 
     if (!parseError.isNull() || lexError) {
         *errLine = lineNumber;
-        *errMsg = !parseError.isNull() ? parseError : "Parse error";
+        *errMsg = !lexErrorMessage.isNull() ? lexErrorMessage : parseError;
         m_sourceElements = 0;
     }
 }