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_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
7 | 7 |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 5137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5148 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseIfStatement( | 5148 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseIfStatement( |
5149 ZoneList<const AstRawString*>* labels, bool* ok) { | 5149 ZoneList<const AstRawString*>* labels, bool* ok) { |
5150 // IfStatement :: | 5150 // IfStatement :: |
5151 // 'if' '(' Expression ')' Statement ('else' Statement)? | 5151 // 'if' '(' Expression ')' Statement ('else' Statement)? |
5152 | 5152 |
5153 int pos = peek_position(); | 5153 int pos = peek_position(); |
5154 Expect(Token::IF, CHECK_OK); | 5154 Expect(Token::IF, CHECK_OK); |
5155 Expect(Token::LPAREN, CHECK_OK); | 5155 Expect(Token::LPAREN, CHECK_OK); |
5156 ExpressionT condition = ParseExpression(true, CHECK_OK); | 5156 ExpressionT condition = ParseExpression(true, CHECK_OK); |
5157 Expect(Token::RPAREN, CHECK_OK); | 5157 Expect(Token::RPAREN, CHECK_OK); |
| 5158 |
| 5159 SourceRange then_range, else_range; |
| 5160 then_range.from = peek_position(); |
5158 StatementT then_statement = ParseScopedStatement(labels, CHECK_OK); | 5161 StatementT then_statement = ParseScopedStatement(labels, CHECK_OK); |
| 5162 then_range.to = position(); |
| 5163 |
5159 StatementT else_statement = impl()->NullStatement(); | 5164 StatementT else_statement = impl()->NullStatement(); |
5160 if (Check(Token::ELSE)) { | 5165 if (Check(Token::ELSE)) { |
| 5166 else_range.from = peek_position(); |
5161 else_statement = ParseScopedStatement(labels, CHECK_OK); | 5167 else_statement = ParseScopedStatement(labels, CHECK_OK); |
| 5168 else_range.to = position(); |
5162 } else { | 5169 } else { |
5163 else_statement = factory()->NewEmptyStatement(kNoSourcePosition); | 5170 else_statement = factory()->NewEmptyStatement(kNoSourcePosition); |
5164 } | 5171 } |
5165 return factory()->NewIfStatement(condition, then_statement, else_statement, | 5172 return factory()->NewIfStatement(condition, then_statement, else_statement, |
5166 pos); | 5173 pos, then_range, else_range); |
5167 } | 5174 } |
5168 | 5175 |
5169 template <typename Impl> | 5176 template <typename Impl> |
5170 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseContinueStatement( | 5177 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseContinueStatement( |
5171 bool* ok) { | 5178 bool* ok) { |
5172 // ContinueStatement :: | 5179 // ContinueStatement :: |
5173 // 'continue' Identifier? ';' | 5180 // 'continue' Identifier? ';' |
5174 | 5181 |
5175 int pos = peek_position(); | 5182 int pos = peek_position(); |
5176 Expect(Token::CONTINUE, CHECK_OK); | 5183 Expect(Token::CONTINUE, CHECK_OK); |
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6022 } | 6029 } |
6023 | 6030 |
6024 #undef CHECK_OK | 6031 #undef CHECK_OK |
6025 #undef CHECK_OK_CUSTOM | 6032 #undef CHECK_OK_CUSTOM |
6026 #undef CHECK_OK_VOID | 6033 #undef CHECK_OK_VOID |
6027 | 6034 |
6028 } // namespace internal | 6035 } // namespace internal |
6029 } // namespace v8 | 6036 } // namespace v8 |
6030 | 6037 |
6031 #endif // V8_PARSING_PARSER_BASE_H | 6038 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |