• oliver@apple.com's avatar
    JS Lexer and Parser should be more informative when they encounter errors · 568b48ca
    oliver@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=114924
    
    Reviewed by Filip Pizlo.
    
    Source/JavaScriptCore:
    
    Add new tokens to represent the various ways that parsing and lexing have failed.
    This gives us the ability to produce better error messages in some cases,
    and to indicate whether or not the failure was due to invalid source, or simply
    early termination.
    
    The jsc prompt now makes use of this so that you can write functions that
    are more than one line long.
    
    * bytecompiler/BytecodeGenerator.cpp:
    (JSC::BytecodeGenerator::generate):
    * jsc.cpp:
    (stringFromUTF):
    (jscSource):
    (runInteractive):
    * parser/Lexer.cpp:
    (JSC::::parseFourDigitUnicodeHex):
    (JSC::::parseIdentifierSlowCase):
    (JSC::::parseString):
    (JSC::::parseStringSlowCase):
    (JSC::::lex):
    * parser/Lexer.h:
    (UnicodeHexValue):
    (JSC::Lexer::UnicodeHexValue::UnicodeHexValue):
    (JSC::Lexer::UnicodeHexValue::valueType):
    (JSC::Lexer::UnicodeHexValue::isValid):
    (JSC::Lexer::UnicodeHexValue::value):
    (Lexer):
    * parser/Parser.h:
    (JSC::Parser::getTokenName):
    (JSC::Parser::updateErrorMessageSpecialCase):
    (JSC::::parse):
    * parser/ParserError.h:
    (ParserError):
    (JSC::ParserError::ParserError):
    * parser/ParserTokens.h:
    * runtime/Completion.cpp:
    (JSC):
    (JSC::checkSyntax):
    * runtime/Completion.h:
    (JSC):
    
    LayoutTests:
    
    Update test results to cover improved error messages.
    
    * fast/js/kde/parse-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.2_White_Space/S7.2_A5_T1-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.2_White_Space/S7.2_A5_T2-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.2_White_Space/S7.2_A5_T3-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.2_White_Space/S7.2_A5_T4-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.2_White_Space/S7.2_A5_T5-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A6_T1-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A6_T2-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A6_T3-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A6_T4-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.7_Punctuators/S7.7_A2_T1-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.7_Punctuators/S7.7_A2_T10-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.7_Punctuators/S7.7_A2_T2-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.7_Punctuators/S7.7_A2_T3-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.7_Punctuators/S7.7_A2_T4-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.7_Punctuators/S7.7_A2_T5-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.7_Punctuators/S7.7_A2_T6-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.7_Punctuators/S7.7_A2_T7-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.7_Punctuators/S7.7_A2_T8-expected.txt:
    * sputnik/Conformance/07_Lexical_Conventions/7.7_Punctuators/S7.7_A2_T9-expected.txt:
    * sputnik/Conformance/13_Function_Definition/S13_A7_T3-expected.txt:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148849 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    568b48ca
Completion.h 1.46 KB