OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_PREPARSER_H | 5 #ifndef V8_PREPARSER_H |
6 #define V8_PREPARSER_H | 6 #define V8_PREPARSER_H |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 2856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2867 int pos = position(); | 2867 int pos = position(); |
2868 typename Traits::TemplateLiteralState ts = Traits::OpenTemplateLiteral(pos); | 2868 typename Traits::TemplateLiteralState ts = Traits::OpenTemplateLiteral(pos); |
2869 Traits::AddTemplateSpan(&ts, false); | 2869 Traits::AddTemplateSpan(&ts, false); |
2870 Token::Value next; | 2870 Token::Value next; |
2871 | 2871 |
2872 // If we open with a TEMPLATE_SPAN, we must scan the subsequent expression, | 2872 // If we open with a TEMPLATE_SPAN, we must scan the subsequent expression, |
2873 // and repeat if the following token is a TEMPLATE_SPAN as well (in this | 2873 // and repeat if the following token is a TEMPLATE_SPAN as well (in this |
2874 // case, representing a TemplateMiddle). | 2874 // case, representing a TemplateMiddle). |
2875 | 2875 |
2876 do { | 2876 do { |
| 2877 CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK); |
2877 next = peek(); | 2878 next = peek(); |
2878 if (!next) { | 2879 if (!next) { |
2879 ReportMessageAt(Scanner::Location(start, peek_position()), | 2880 ReportMessageAt(Scanner::Location(start, peek_position()), |
2880 "unterminated_template"); | 2881 "unterminated_template"); |
2881 *ok = false; | 2882 *ok = false; |
2882 return Traits::EmptyExpression(); | 2883 return Traits::EmptyExpression(); |
2883 } | 2884 } |
2884 | 2885 |
2885 int expr_pos = peek_position(); | 2886 int expr_pos = peek_position(); |
2886 ExpressionT expression = this->ParseExpression(true, CHECK_OK); | 2887 ExpressionT expression = this->ParseExpression(true, CHECK_OK); |
2887 Traits::AddTemplateExpression(&ts, expression); | 2888 Traits::AddTemplateExpression(&ts, expression); |
2888 | 2889 |
2889 if (peek() != Token::RBRACE) { | 2890 if (peek() != Token::RBRACE) { |
2890 ReportMessageAt(Scanner::Location(expr_pos, peek_position()), | 2891 ReportMessageAt(Scanner::Location(expr_pos, peek_position()), |
2891 "unterminated_template_expr"); | 2892 "unterminated_template_expr"); |
2892 *ok = false; | 2893 *ok = false; |
2893 return Traits::EmptyExpression(); | 2894 return Traits::EmptyExpression(); |
2894 } | 2895 } |
2895 | 2896 |
2896 // If we didn't die parsing that expression, our next token should be a | 2897 // If we didn't die parsing that expression, our next token should be a |
2897 // TEMPLATE_SPAN or TEMPLATE_TAIL. | 2898 // TEMPLATE_SPAN or TEMPLATE_TAIL. |
2898 next = scanner()->ScanTemplateContinuation(); | 2899 next = scanner()->ScanTemplateContinuation(); |
2899 Next(); | 2900 Next(); |
| 2901 pos = position(); |
2900 | 2902 |
2901 if (!next) { | 2903 if (!next) { |
2902 ReportMessageAt(Scanner::Location(start, position()), | 2904 ReportMessageAt(Scanner::Location(start, pos), "unterminated_template"); |
2903 "unterminated_template"); | |
2904 *ok = false; | 2905 *ok = false; |
2905 return Traits::EmptyExpression(); | 2906 return Traits::EmptyExpression(); |
2906 } | 2907 } |
2907 | 2908 |
2908 Traits::AddTemplateSpan(&ts, next == Token::TEMPLATE_TAIL); | 2909 Traits::AddTemplateSpan(&ts, next == Token::TEMPLATE_TAIL); |
2909 } while (next == Token::TEMPLATE_SPAN); | 2910 } while (next == Token::TEMPLATE_SPAN); |
2910 | 2911 |
2911 DCHECK_EQ(next, Token::TEMPLATE_TAIL); | 2912 DCHECK_EQ(next, Token::TEMPLATE_TAIL); |
2912 CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK); | 2913 CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK); |
2913 // Once we've reached a TEMPLATE_TAIL, we can close the TemplateLiteral. | 2914 // Once we've reached a TEMPLATE_TAIL, we can close the TemplateLiteral. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2967 DCHECK(IsAccessorAccessorConflict(old_type, type)); | 2968 DCHECK(IsAccessorAccessorConflict(old_type, type)); |
2968 // Both accessors of the same type. | 2969 // Both accessors of the same type. |
2969 parser()->ReportMessage("accessor_get_set"); | 2970 parser()->ReportMessage("accessor_get_set"); |
2970 } | 2971 } |
2971 *ok = false; | 2972 *ok = false; |
2972 } | 2973 } |
2973 } | 2974 } |
2974 } } // v8::internal | 2975 } } // v8::internal |
2975 | 2976 |
2976 #endif // V8_PREPARSER_H | 2977 #endif // V8_PREPARSER_H |
OLD | NEW |