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 "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 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 if (!this_seen && (CurrentToken() == Token::kTHIS)) { | 886 if (!this_seen && (CurrentToken() == Token::kTHIS)) { |
887 ConsumeToken(); | 887 ConsumeToken(); |
888 ExpectToken(Token::kPERIOD); | 888 ExpectToken(Token::kPERIOD); |
889 this_seen = true; | 889 this_seen = true; |
890 parameter.is_field_initializer = true; | 890 parameter.is_field_initializer = true; |
891 } | 891 } |
892 | 892 |
893 // At this point, we must see an identifier for the parameter name. | 893 // At this point, we must see an identifier for the parameter name. |
894 parameter.name_pos = token_index_; | 894 parameter.name_pos = token_index_; |
895 parameter.name = ExpectIdentifier("parameter name expected"); | 895 parameter.name = ExpectIdentifier("parameter name expected"); |
896 if (params->has_named_optional_parameters && | |
897 (parameter.name->CharAt(0) == '_')) { | |
898 ErrorMsg(parameter.name_pos, | |
899 "named optional parameters may not start with '_'\n"); | |
900 } | |
901 | 896 |
902 if (parameter.is_field_initializer) { | 897 if (parameter.is_field_initializer) { |
903 params->has_field_initializer = true; | 898 params->has_field_initializer = true; |
904 } | 899 } |
905 | 900 |
906 if (CurrentToken() == Token::kLPAREN) { | 901 if (CurrentToken() == Token::kLPAREN) { |
907 // This parameter is probably a closure. If we saw the keyword 'var' | 902 // This parameter is probably a closure. If we saw the keyword 'var' |
908 // or 'final', a closure is not legal here and we ignore the | 903 // or 'final', a closure is not legal here and we ignore the |
909 // opening parens. | 904 // opening parens. |
910 if (!var_seen && !parameter.is_final) { | 905 if (!var_seen && !parameter.is_final) { |
(...skipping 7301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8212 void Parser::SkipQualIdent() { | 8207 void Parser::SkipQualIdent() { |
8213 ASSERT(IsIdentifier()); | 8208 ASSERT(IsIdentifier()); |
8214 ConsumeToken(); | 8209 ConsumeToken(); |
8215 if (CurrentToken() == Token::kPERIOD) { | 8210 if (CurrentToken() == Token::kPERIOD) { |
8216 ConsumeToken(); // Consume the kPERIOD token. | 8211 ConsumeToken(); // Consume the kPERIOD token. |
8217 ExpectIdentifier("identifier expected after '.'"); | 8212 ExpectIdentifier("identifier expected after '.'"); |
8218 } | 8213 } |
8219 } | 8214 } |
8220 | 8215 |
8221 } // namespace dart | 8216 } // namespace dart |
OLD | NEW |