Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(689)

Side by Side Diff: src/preparser.h

Issue 861173005: Version 4.1.0.11 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.1
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/version.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2857 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 next = peek(); 2877 next = peek();
2878 if (!next) { 2878 if (next == Token::EOS) {
2879 ReportMessageAt(Scanner::Location(start, peek_position()), 2879 ReportMessageAt(Scanner::Location(start, peek_position()),
2880 "unterminated_template"); 2880 "unterminated_template");
2881 *ok = false; 2881 *ok = false;
2882 return Traits::EmptyExpression(); 2882 return Traits::EmptyExpression();
2883 } else if (next == Token::ILLEGAL) {
2884 Traits::ReportMessageAt(
2885 Scanner::Location(position() + 1, peek_position()),
2886 "unexpected_token", "ILLEGAL", false);
2887 *ok = false;
2888 return Traits::EmptyExpression();
2883 } 2889 }
2884 2890
2885 int expr_pos = peek_position(); 2891 int expr_pos = peek_position();
2886 ExpressionT expression = this->ParseExpression(true, CHECK_OK); 2892 ExpressionT expression = this->ParseExpression(true, CHECK_OK);
2887 Traits::AddTemplateExpression(&ts, expression); 2893 Traits::AddTemplateExpression(&ts, expression);
2888 2894
2889 if (peek() != Token::RBRACE) { 2895 if (peek() != Token::RBRACE) {
2890 ReportMessageAt(Scanner::Location(expr_pos, peek_position()), 2896 ReportMessageAt(Scanner::Location(expr_pos, peek_position()),
2891 "unterminated_template_expr"); 2897 "unterminated_template_expr");
2892 *ok = false; 2898 *ok = false;
2893 return Traits::EmptyExpression(); 2899 return Traits::EmptyExpression();
2894 } 2900 }
2895 2901
2896 // If we didn't die parsing that expression, our next token should be a 2902 // If we didn't die parsing that expression, our next token should be a
2897 // TEMPLATE_SPAN or TEMPLATE_TAIL. 2903 // TEMPLATE_SPAN or TEMPLATE_TAIL.
2898 next = scanner()->ScanTemplateContinuation(); 2904 next = scanner()->ScanTemplateContinuation();
2899 Next(); 2905 Next();
2900 2906
2901 if (!next) { 2907 if (next == Token::EOS) {
2902 ReportMessageAt(Scanner::Location(start, position()), 2908 ReportMessageAt(Scanner::Location(start, position()),
2903 "unterminated_template"); 2909 "unterminated_template");
2904 *ok = false; 2910 *ok = false;
2905 return Traits::EmptyExpression(); 2911 return Traits::EmptyExpression();
2912 } else if (next == Token::ILLEGAL) {
2913 Traits::ReportMessageAt(
2914 Scanner::Location(position() + 1, peek_position()),
2915 "unexpected_token", "ILLEGAL", false);
2916 *ok = false;
2917 return Traits::EmptyExpression();
2906 } 2918 }
2907 2919
2908 Traits::AddTemplateSpan(&ts, next == Token::TEMPLATE_TAIL); 2920 Traits::AddTemplateSpan(&ts, next == Token::TEMPLATE_TAIL);
2909 } while (next == Token::TEMPLATE_SPAN); 2921 } while (next == Token::TEMPLATE_SPAN);
2910 2922
2911 DCHECK_EQ(next, Token::TEMPLATE_TAIL); 2923 DCHECK_EQ(next, Token::TEMPLATE_TAIL);
2912 CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK); 2924 CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK);
2913 // Once we've reached a TEMPLATE_TAIL, we can close the TemplateLiteral. 2925 // Once we've reached a TEMPLATE_TAIL, we can close the TemplateLiteral.
2914 return Traits::CloseTemplateLiteral(&ts, start, tag); 2926 return Traits::CloseTemplateLiteral(&ts, start, tag);
2915 } 2927 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2967 DCHECK(IsAccessorAccessorConflict(old_type, type)); 2979 DCHECK(IsAccessorAccessorConflict(old_type, type));
2968 // Both accessors of the same type. 2980 // Both accessors of the same type.
2969 parser()->ReportMessage("accessor_get_set"); 2981 parser()->ReportMessage("accessor_get_set");
2970 } 2982 }
2971 *ok = false; 2983 *ok = false;
2972 } 2984 }
2973 } 2985 }
2974 } } // v8::internal 2986 } } // v8::internal
2975 2987
2976 #endif // V8_PREPARSER_H 2988 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « no previous file | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698