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

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

Issue 8774024: Parse method names that include type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
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.dart.compiler.DartCompilationError; 7 import com.google.dart.compiler.DartCompilationError;
8 import com.google.dart.compiler.DartCompilerListener; 8 import com.google.dart.compiler.DartCompilerListener;
9 import com.google.dart.compiler.Source; 9 import com.google.dart.compiler.Source;
10 import com.google.dart.compiler.ast.DartUnit; 10 import com.google.dart.compiler.ast.DartUnit;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 scanner.getLineCount(), scanner.getNonCommentLineCount()); 79 scanner.getLineCount(), scanner.getNonCommentLineCount());
80 } 80 }
81 } 81 }
82 82
83 // want next begin() call to seek to the next token and skip whitespace afte r previous done() 83 // want next begin() call to seek to the next token and skip whitespace afte r previous done()
84 return result; 84 return result;
85 } 85 }
86 86
87 /** 87 /**
88 * Set the source position on a result, if it is a {@link HasSourceInfo}. 88 * Set the source position on a result, if it is a {@link HasSourceInfo}.
89 * 89 *
90 * @param <T> result type 90 * @param <T> result type
91 * @param result 91 * @param result
92 * @param startPos 92 * @param startPos
93 */ 93 */
94 private <T> void setSourcePosition(T result, DartScanner.Position startPos) { 94 private <T> void setSourcePosition(T result, DartScanner.Position startPos) {
95 if (result instanceof HasSourceInfo) { 95 if (result instanceof HasSourceInfo) {
96 HasSourceInfo node = (HasSourceInfo) result; 96 HasSourceInfo node = (HasSourceInfo) result;
97 int start = startPos.getPos(); 97 int start = startPos.getPos();
98 int end = getEndLocation().getPos(); 98 int end = getEndLocation().getPos();
99 if (start != -1 && end < start) { 99 if (start != -1 && end < start) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 138
139 @Override 139 @Override
140 public void rollback() { 140 public void rollback() {
141 // undo changes made to scanner tokens 141 // undo changes made to scanner tokens
142 DartScanner.State oldState = stateStack.pop(); 142 DartScanner.State oldState = stateStack.pop();
143 scanner.restoreState(oldState); 143 scanner.restoreState(oldState);
144 144
145 // Restore the replaced tokens to their state. 145 // Restore the replaced tokens to their state.
146 if (oldState.rollbackTokens != null) { 146 if (oldState.rollbackTokens != null) {
147 for (State.RollbackToken token : oldState.rollbackTokens) { 147 while (!oldState.rollbackTokens.isEmpty()) {
148 State.RollbackToken token = oldState.rollbackTokens.pop();
zundel 2011/12/01 23:45:54 Found a bug in this logic when rolling back >>> pa
codefu 2011/12/02 13:51:21 Thanks for catching this!
148 scanner.setAbsolutePeek(token.absoluteOffset, token.replacedToken); 149 scanner.setAbsolutePeek(token.absoluteOffset, token.replacedToken);
149 } 150 }
150 } 151 }
151 positionStack.pop(); 152 positionStack.pop();
152 } 153 }
153 154
154 @Override 155 @Override
155 public String getTokenString() { 156 public String getTokenString() {
156 return scanner.getTokenValue(); 157 return scanner.getTokenValue();
157 } 158 }
(...skipping 22 matching lines...) Expand all
180 181
181 protected DartScanner createScanner(String sourceCode) { 182 protected DartScanner createScanner(String sourceCode) {
182 return new DartScanner(sourceCode); 183 return new DartScanner(sourceCode);
183 } 184 }
184 185
185 @Override 186 @Override
186 public Source getSource() { 187 public Source getSource() {
187 return source; 188 return source;
188 } 189 }
189 } 190 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698