OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/parser.h" | 5 #include "vm/parser.h" |
6 | 6 |
7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/ast_transformer.h" | 9 #include "vm/ast_transformer.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
(...skipping 8859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8870 | 8870 |
8871 | 8871 |
8872 AstNode* Parser::ParseExpr(bool require_compiletime_const, | 8872 AstNode* Parser::ParseExpr(bool require_compiletime_const, |
8873 bool consume_cascades) { | 8873 bool consume_cascades) { |
8874 TRACE_PARSER("ParseExpr"); | 8874 TRACE_PARSER("ParseExpr"); |
8875 String* expr_ident = | 8875 String* expr_ident = |
8876 Token::IsIdentifier(CurrentToken()) ? CurrentLiteral() : NULL; | 8876 Token::IsIdentifier(CurrentToken()) ? CurrentLiteral() : NULL; |
8877 const intptr_t expr_pos = TokenPos(); | 8877 const intptr_t expr_pos = TokenPos(); |
8878 | 8878 |
8879 if (CurrentToken() == Token::kTHROW) { | 8879 if (CurrentToken() == Token::kTHROW) { |
| 8880 if (require_compiletime_const) { |
| 8881 ReportError("'throw expr' is not a valid compile-time constant"); |
| 8882 } |
8880 ConsumeToken(); | 8883 ConsumeToken(); |
8881 if (CurrentToken() == Token::kSEMICOLON) { | 8884 if (CurrentToken() == Token::kSEMICOLON) { |
8882 ReportError("expression expected after throw"); | 8885 ReportError("expression expected after throw"); |
8883 } | 8886 } |
8884 AstNode* expr = ParseExpr(require_compiletime_const, consume_cascades); | 8887 AstNode* expr = ParseExpr(require_compiletime_const, consume_cascades); |
8885 return new(I) ThrowNode(expr_pos, expr, NULL); | 8888 return new(I) ThrowNode(expr_pos, expr, NULL); |
8886 } | 8889 } |
8887 AstNode* expr = ParseConditionalExpr(); | 8890 AstNode* expr = ParseConditionalExpr(); |
8888 if (!Token::IsAssignmentOperator(CurrentToken())) { | 8891 if (!Token::IsAssignmentOperator(CurrentToken())) { |
8889 if ((CurrentToken() == Token::kCASCADE) && consume_cascades) { | 8892 if ((CurrentToken() == Token::kCASCADE) && consume_cascades) { |
(...skipping 2893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11783 void Parser::SkipQualIdent() { | 11786 void Parser::SkipQualIdent() { |
11784 ASSERT(IsIdentifier()); | 11787 ASSERT(IsIdentifier()); |
11785 ConsumeToken(); | 11788 ConsumeToken(); |
11786 if (CurrentToken() == Token::kPERIOD) { | 11789 if (CurrentToken() == Token::kPERIOD) { |
11787 ConsumeToken(); // Consume the kPERIOD token. | 11790 ConsumeToken(); // Consume the kPERIOD token. |
11788 ExpectIdentifier("identifier expected after '.'"); | 11791 ExpectIdentifier("identifier expected after '.'"); |
11789 } | 11792 } |
11790 } | 11793 } |
11791 | 11794 |
11792 } // namespace dart | 11795 } // namespace dart |
OLD | NEW |