OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 // The PreParser checks that the syntax follows the grammar for JavaScript, | 50 // The PreParser checks that the syntax follows the grammar for JavaScript, |
51 // and collects some information about the program along the way. | 51 // and collects some information about the program along the way. |
52 // The grammar check is only performed in order to understand the program | 52 // The grammar check is only performed in order to understand the program |
53 // sufficiently to deduce some information about it, that can be used | 53 // sufficiently to deduce some information about it, that can be used |
54 // to speed up later parsing. Finding errors is not the goal of pre-parsing, | 54 // to speed up later parsing. Finding errors is not the goal of pre-parsing, |
55 // rather it is to speed up properly written and correct programs. | 55 // rather it is to speed up properly written and correct programs. |
56 // That means that contextual checks (like a label being declared where | 56 // That means that contextual checks (like a label being declared where |
57 // it is used) are generally omitted. | 57 // it is used) are generally omitted. |
58 | 58 |
59 namespace i = ::v8::internal; | |
60 | |
61 void PreParser::ReportUnexpectedToken(i::Token::Value token) { | 59 void PreParser::ReportUnexpectedToken(i::Token::Value token) { |
62 // We don't report stack overflows here, to avoid increasing the | 60 // We don't report stack overflows here, to avoid increasing the |
63 // stack depth even further. Instead we report it after parsing is | 61 // stack depth even further. Instead we report it after parsing is |
64 // over, in ParseProgram. | 62 // over, in ParseProgram. |
65 if (token == i::Token::ILLEGAL && stack_overflow_) { | 63 if (token == i::Token::ILLEGAL && stack_overflow_) { |
66 return; | 64 return; |
67 } | 65 } |
68 i::JavaScriptScanner::Location source_location = scanner_->location(); | 66 i::JavaScriptScanner::Location source_location = scanner_->location(); |
69 | 67 |
70 // Four of the tokens are treated specially | 68 // Four of the tokens are treated specially |
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 return result; | 1454 return result; |
1457 } | 1455 } |
1458 | 1456 |
1459 bool PreParser::peek_any_identifier() { | 1457 bool PreParser::peek_any_identifier() { |
1460 i::Token::Value next = peek(); | 1458 i::Token::Value next = peek(); |
1461 return next == i::Token::IDENTIFIER || | 1459 return next == i::Token::IDENTIFIER || |
1462 next == i::Token::FUTURE_RESERVED_WORD || | 1460 next == i::Token::FUTURE_RESERVED_WORD || |
1463 next == i::Token::FUTURE_STRICT_RESERVED_WORD; | 1461 next == i::Token::FUTURE_STRICT_RESERVED_WORD; |
1464 } | 1462 } |
1465 } } // v8::preparser | 1463 } } // v8::preparser |
OLD | NEW |