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

Side by Side Diff: compiler/java/com/google/dart/compiler/parser/DartParser.java

Issue 8774024: Parse method names that include type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Feedback from mmedendez Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java » ('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 (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 package com.google.dart.compiler.parser; 5 package com.google.dart.compiler.parser;
6 6
7 import com.google.common.annotations.VisibleForTesting; 7 import com.google.common.annotations.VisibleForTesting;
8 import com.google.common.io.CharStreams; 8 import com.google.common.io.CharStreams;
9 import com.google.dart.compiler.DartCompilationError; 9 import com.google.dart.compiler.DartCompilationError;
10 import com.google.dart.compiler.DartCompilerListener; 10 import com.google.dart.compiler.DartCompilerListener;
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 // Simple checks 954 // Simple checks
955 if (peekPseudoKeyword(0, GETTER_KEYWORD) 955 if (peekPseudoKeyword(0, GETTER_KEYWORD)
956 || peekPseudoKeyword(0, SETTER_KEYWORD) 956 || peekPseudoKeyword(0, SETTER_KEYWORD)
957 || peekPseudoKeyword(0, OPERATOR_KEYWORD)) { 957 || peekPseudoKeyword(0, OPERATOR_KEYWORD)) {
958 return true; 958 return true;
959 } 959 }
960 960
961 consume(Token.IDENTIFIER); 961 consume(Token.IDENTIFIER);
962 962
963 if (peek(0).equals(Token.PERIOD) && peek(1).equals(Token.IDENTIFIER)) { 963 if (peek(0).equals(Token.PERIOD) && peek(1).equals(Token.IDENTIFIER)) {
964 // Case 1 a constructor of the form class.id
965 if (peek(0).equals(Token.LPAREN)) {
966 return true;
967 }
968
969 // Case 2, a constructor of the form library.class.<typearguments?>.id 964 // Case 2, a constructor of the form library.class.<typearguments?>.id
codefu 2011/12/02 13:51:21 There's no more case 1 prior to this comment.
970 consume(Token.PERIOD); 965 consume(Token.PERIOD);
971 consume(Token.IDENTIFIER); 966 consume(Token.IDENTIFIER);
972 parseTypeArgumentsOpt(); 967 parseTypeArgumentsOpt();
codefu 2011/12/02 13:51:21 ws
973 if (peek(0).equals(Token.PERIOD) && peek(1).equals(Token.IDENTIFIER) && peek(2).equals(Token.LPAREN)) { 968 if (peek(0).equals(Token.PERIOD) && peek(1).equals(Token.IDENTIFIER)
969 && peek(2).equals(Token.LPAREN)) {
974 return true; 970 return true;
975 } 971 }
972 } else {
973 // Case 1 class.id<typearguments>
974 // Case 3, id<typearguments?>
975 parseTypeArgumentsOpt();
976 } 976 }
977 977
978 // Case 1 class.id<typearguments>
979 // Case 3, id<typearguments?>
980 parseTypeArgumentsOpt();
981
982 if (peek(0).equals(Token.PERIOD) && peek(1).equals(Token.IDENTIFIER)) { 978 if (peek(0).equals(Token.PERIOD) && peek(1).equals(Token.IDENTIFIER)) {
983 // Case 1, a constructor of the form class<typearguments>.id 979 // Case 1, a constructor of the form class<typearguments>.id
984 consume(Token.PERIOD); 980 consume(Token.PERIOD);
985 consume(Token.IDENTIFIER); 981 consume(Token.IDENTIFIER);
986 } 982 }
987 983
988 // next token should be LPAREN 984 // next token should be LPAREN
989 return (peek(0).equals(Token.LPAREN)); 985 return (peek(0).equals(Token.LPAREN));
990 } finally { 986 } finally {
991 rollback(); 987 rollback();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 name = parseIdentifier(); 1078 name = parseIdentifier();
1083 modifiers = modifiers.makeGetter(); 1079 modifiers = modifiers.makeGetter();
1084 arity = 0; 1080 arity = 0;
1085 } else if (optionalPseudoKeyword(SETTER_KEYWORD)) { 1081 } else if (optionalPseudoKeyword(SETTER_KEYWORD)) {
1086 name = parseIdentifier(); 1082 name = parseIdentifier();
1087 modifiers = modifiers.makeSetter(); 1083 modifiers = modifiers.makeSetter();
1088 arity = 1; 1084 arity = 1;
1089 } else { 1085 } else {
1090 // Normal method or property. 1086 // Normal method or property.
1091 name = parseIdentifier(); 1087 name = parseIdentifier();
1092
1093 // TODO(zundel): something constructive with the type arguments 1088 // TODO(zundel): something constructive with the type arguments
1094 parseTypeArgumentsOpt(); 1089 parseTypeArgumentsOpt();
1095 } 1090 }
1096 1091
1097 // Check for named constructor. 1092 // Check for named constructor.
1098 if (optional(Token.PERIOD)) { 1093 if (optional(Token.PERIOD)) {
1099 name = doneWithoutConsuming(new DartPropertyAccess(name, parseIdentifier ())); 1094 name = doneWithoutConsuming(new DartPropertyAccess(name, parseIdentifier ()));
1100 1095
1101 if (optional(Token.PERIOD)) { 1096 if (optional(Token.PERIOD)) {
1102 name = doneWithoutConsuming(new DartPropertyAccess(name, parseIdentifi er())); 1097 name = doneWithoutConsuming(new DartPropertyAccess(name, parseIdentifi er()));
1103 } 1098 }
1104 } 1099 }
(...skipping 2615 matching lines...) Expand 10 before | Expand all | Expand 10 after
3720 } else { 3715 } else {
3721 ctx.error(dartError); 3716 ctx.error(dartError);
3722 errorHistory.add(dartError.hashCode()); 3717 errorHistory.add(dartError.hashCode());
3723 } 3718 }
3724 } 3719 }
3725 3720
3726 private void reportError(DartNode node, ErrorCode errorCode, Object... argumen ts) { 3721 private void reportError(DartNode node, ErrorCode errorCode, Object... argumen ts) {
3727 reportError(new DartCompilationError(node, errorCode, arguments)); 3722 reportError(new DartCompilationError(node, errorCode, arguments));
3728 } 3723 }
3729 } 3724 }
OLDNEW
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698