| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 | 923 |
| 924 void Parser::ParseFormalParameterList(bool allow_explicit_default_values, | 924 void Parser::ParseFormalParameterList(bool allow_explicit_default_values, |
| 925 ParamList* params) { | 925 ParamList* params) { |
| 926 TRACE_PARSER("ParseFormalParameterList"); | 926 TRACE_PARSER("ParseFormalParameterList"); |
| 927 ASSERT(CurrentToken() == Token::kLPAREN); | 927 ASSERT(CurrentToken() == Token::kLPAREN); |
| 928 | 928 |
| 929 if (LookaheadToken(1) != Token::kRPAREN) { | 929 if (LookaheadToken(1) != Token::kRPAREN) { |
| 930 // Parse positional parameters. | 930 // Parse positional parameters. |
| 931 ParseFormalParameters(allow_explicit_default_values, | 931 ParseFormalParameters(allow_explicit_default_values, |
| 932 params); | 932 params); |
| 933 if (CurrentToken() == Token::kLBRACK) { | 933 if (params->has_named_optional_parameters) { |
| 934 ASSERT(!params->has_named_optional_parameters); | |
| 935 params->has_named_optional_parameters = true; | |
| 936 // Parse named optional parameters. | 934 // Parse named optional parameters. |
| 937 ParseFormalParameters(allow_explicit_default_values, | 935 ParseFormalParameters(allow_explicit_default_values, |
| 938 params); | 936 params); |
| 939 if (CurrentToken() != Token::kRBRACK) { | 937 if (CurrentToken() != Token::kRBRACK) { |
| 940 ErrorMsg("',' or ']' expected"); | 938 ErrorMsg("',' or ']' expected"); |
| 941 } | 939 } |
| 942 ExpectToken(Token::kRBRACK); | 940 ExpectToken(Token::kRBRACK); |
| 943 } | 941 } |
| 944 if ((CurrentToken() != Token::kRPAREN) && | 942 if ((CurrentToken() != Token::kRPAREN) && |
| 945 !params->has_named_optional_parameters) { | 943 !params->has_named_optional_parameters) { |
| 946 ErrorMsg("',' or ')' expected"); | 944 ErrorMsg("',' or ')' expected"); |
| 947 } | 945 } |
| 948 } else { | 946 } else { |
| 949 ConsumeToken(); | 947 ConsumeToken(); |
| 950 } | 948 } |
| 951 ExpectToken(Token::kRPAREN); | 949 ExpectToken(Token::kRPAREN); |
| 952 } | 950 } |
| 953 | 951 |
| 954 | 952 |
| 955 // Parses a sequence of normal or named formal parameters. | 953 // Parses a sequence of normal or named formal parameters. |
| 956 void Parser::ParseFormalParameters(bool allow_explicit_default_values, | 954 void Parser::ParseFormalParameters(bool allow_explicit_default_values, |
| 957 ParamList* params) { | 955 ParamList* params) { |
| 958 TRACE_PARSER("ParseFormalParameters"); | 956 TRACE_PARSER("ParseFormalParameters"); |
| 959 do { | 957 do { |
| 960 ConsumeToken(); | 958 ConsumeToken(); |
| 961 if (!params->has_named_optional_parameters && | 959 if (!params->has_named_optional_parameters && |
| 962 (CurrentToken() == Token::kLBRACK)) { | 960 (CurrentToken() == Token::kLBRACK)) { |
| 963 // End of normal parameters, start of named parameters. | 961 // End of normal parameters, start of named parameters. |
| 962 params->has_named_optional_parameters = true; |
| 964 return; | 963 return; |
| 965 } | 964 } |
| 966 ParseFormalParameter(allow_explicit_default_values, params); | 965 ParseFormalParameter(allow_explicit_default_values, params); |
| 967 } while (CurrentToken() == Token::kCOMMA); | 966 } while (CurrentToken() == Token::kCOMMA); |
| 968 } | 967 } |
| 969 | 968 |
| 970 | 969 |
| 971 String& Parser::ParseNativeDeclaration() { | 970 String& Parser::ParseNativeDeclaration() { |
| 972 TRACE_PARSER("ParseNativeDeclaration"); | 971 TRACE_PARSER("ParseNativeDeclaration"); |
| 973 ASSERT(IsLiteral("native")); | 972 ASSERT(IsLiteral("native")); |
| (...skipping 6045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7019 } | 7018 } |
| 7020 | 7019 |
| 7021 | 7020 |
| 7022 void Parser::SkipNestedExpr() { | 7021 void Parser::SkipNestedExpr() { |
| 7023 const bool saved_mode = SetAllowFunctionLiterals(true); | 7022 const bool saved_mode = SetAllowFunctionLiterals(true); |
| 7024 SkipExpr(); | 7023 SkipExpr(); |
| 7025 SetAllowFunctionLiterals(saved_mode); | 7024 SetAllowFunctionLiterals(saved_mode); |
| 7026 } | 7025 } |
| 7027 | 7026 |
| 7028 } // namespace dart | 7027 } // namespace dart |
| OLD | NEW |