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

Side by Side Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 103233003: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 3
4 library engine.parser; 4 library engine.parser;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'java_core.dart'; 7 import 'java_core.dart';
8 import 'instrumentation.dart'; 8 import 'instrumentation.dart';
9 import 'error.dart'; 9 import 'error.dart';
10 import 'source.dart'; 10 import 'source.dart';
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 * @param errorListener the error listener that will be informed of any errors that are found 1156 * @param errorListener the error listener that will be informed of any errors that are found
1157 * during the parse 1157 * during the parse
1158 */ 1158 */
1159 IncrementalParser(Source source, TokenMap tokenMap, AnalysisErrorListener erro rListener) { 1159 IncrementalParser(Source source, TokenMap tokenMap, AnalysisErrorListener erro rListener) {
1160 this._source = source; 1160 this._source = source;
1161 this._tokenMap = tokenMap; 1161 this._tokenMap = tokenMap;
1162 this._errorListener = errorListener; 1162 this._errorListener = errorListener;
1163 } 1163 }
1164 1164
1165 /** 1165 /**
1166 * Given a range of tokens that were re-scanned, re-parse the minimimum number of tokens to 1166 * Given a range of tokens that were re-scanned, re-parse the minimum number o f tokens to produce
1167 * produce a consistent AST structure. The range is represented by the first a nd last tokens in 1167 * a consistent AST structure. The range is represented by the first and last tokens in the range.
1168 * the range. The tokens are assumed to be contained in the same token stream. 1168 * The tokens are assumed to be contained in the same token stream.
1169 * 1169 *
1170 * @param firstToken the first token in the range of tokens that were re-scann ed or `null` 1170 * @param leftToken the token in the new token stream immediately to the left of the range of
1171 * if no new tokens were inserted 1171 * tokens that were inserted
1172 * @param lastToken the last token in the range of tokens that were re-scanned or `null` if 1172 * @param rightToken the token in the new token stream immediately to the righ t of the range of
1173 * no new tokens were inserted 1173 * tokens that were inserted
1174 * @param originalStart the offset in the original source of the first charact er that was modified 1174 * @param originalStart the offset in the original source of the first charact er that was modified
1175 * @param originalEnd the offset in the original source of the last character that was modified 1175 * @param originalEnd the offset in the original source of the last character that was modified
1176 */ 1176 */
1177 ASTNode reparse(ASTNode originalStructure, Token firstToken, Token lastToken, int originalStart, int originalEnd) { 1177 ASTNode reparse(ASTNode originalStructure, Token leftToken, Token rightToken, int originalStart, int originalEnd) {
1178 ASTNode oldNode = null; 1178 ASTNode oldNode = null;
1179 ASTNode newNode = null; 1179 ASTNode newNode = null;
1180 if (firstToken != null) { 1180 Token firstToken = leftToken.next;
1181 if (originalEnd < originalStart) { 1181 if (identical(firstToken, rightToken)) {
1182 oldNode = new NodeLocator.con1(originalStart).searchWithin(originalStruc ture); 1182 firstToken = leftToken;
1183 } else { 1183 }
1184 oldNode = new NodeLocator.con2(originalStart, originalEnd).searchWithin( originalStructure); 1184 if (originalEnd < originalStart) {
1185 oldNode = new NodeLocator.con1(originalStart).searchWithin(originalStructu re);
1186 } else {
1187 oldNode = new NodeLocator.con2(originalStart, originalEnd).searchWithin(or iginalStructure);
1188 }
1189 int originalOffset = oldNode.offset;
1190 Token parseToken = findTokenAt(firstToken, originalOffset);
1191 if (parseToken == null) {
1192 return null;
1193 }
1194 Parser parser = new Parser(_source, _errorListener);
1195 parser.currentToken = parseToken;
1196 while (newNode == null) {
1197 ASTNode parent = oldNode.parent;
1198 if (parent == null) {
1199 parseToken = findFirstToken(parseToken);
1200 parser.currentToken = parseToken;
1201 return parser.parseCompilationUnit2() as ASTNode;
1185 } 1202 }
1186 int originalOffset = oldNode.offset; 1203 bool advanceToParent = false;
1187 Token parseToken = findTokenAt(firstToken, originalOffset); 1204 try {
1188 if (parseToken == null) { 1205 IncrementalParseDispatcher dispatcher = new IncrementalParseDispatcher(p arser, oldNode);
1206 newNode = parent.accept(dispatcher);
1207 Token mappedToken = _tokenMap.get(oldNode.endToken.next);
1208 if (mappedToken == null || mappedToken.offset != newNode.endToken.next.o ffset || newNode.offset != oldNode.offset) {
1209 advanceToParent = true;
1210 }
1211 } on InsufficientContextException catch (exception) {
1212 advanceToParent = true;
1213 } on JavaException catch (exception) {
1189 return null; 1214 return null;
1190 } 1215 }
1191 Parser parser = new Parser(_source, _errorListener); 1216 if (advanceToParent) {
1192 parser.currentToken = parseToken; 1217 newNode = null;
1193 while (newNode == null) { 1218 oldNode = parent;
1194 ASTNode parent = oldNode.parent; 1219 originalOffset = oldNode.offset;
1195 if (parent == null) { 1220 parseToken = findTokenAt(parseToken, originalOffset);
1196 parseToken = findFirstToken(parseToken); 1221 parser.currentToken = parseToken;
1197 parser.currentToken = parseToken;
1198 return parser.parseCompilationUnit2() as ASTNode;
1199 }
1200 try {
1201 IncrementalParseDispatcher dispatcher = new IncrementalParseDispatcher (parser, oldNode);
1202 newNode = parent.accept(dispatcher);
1203 } on InsufficientContextException catch (exception) {
1204 oldNode = parent;
1205 originalOffset = oldNode.offset;
1206 parseToken = findTokenAt(parseToken, originalOffset);
1207 parser.currentToken = parseToken;
1208 } on JavaException catch (exception) {
1209 return null;
1210 }
1211 } 1222 }
1212 if (newNode.offset != originalOffset) { 1223 }
1213 return null; 1224 if (identical(oldNode, originalStructure)) {
1214 }
1215 if (identical(oldNode, originalStructure)) {
1216 return newNode as ASTNode;
1217 }
1218 ResolutionCopier.copyResolutionData(oldNode, newNode); 1225 ResolutionCopier.copyResolutionData(oldNode, newNode);
1226 return newNode as ASTNode;
1219 } 1227 }
1228 ResolutionCopier.copyResolutionData(oldNode, newNode);
1220 IncrementalASTCloner cloner = new IncrementalASTCloner(oldNode, newNode, _to kenMap); 1229 IncrementalASTCloner cloner = new IncrementalASTCloner(oldNode, newNode, _to kenMap);
1221 return originalStructure.accept(cloner) as ASTNode; 1230 return originalStructure.accept(cloner) as ASTNode;
1222 } 1231 }
1223 1232
1224 /** 1233 /**
1225 * Return the first (non-EOF) token in the token stream containing the given t oken. 1234 * Return the first (non-EOF) token in the token stream containing the given t oken.
1226 * 1235 *
1227 * @param firstToken the token from which the search is to begin 1236 * @param firstToken the token from which the search is to begin
1228 * @return the first token in the token stream containing the given token 1237 * @return the first token in the token stream containing the given token
1229 */ 1238 */
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 /** 1344 /**
1336 * Parse a compilation unit, starting with the given token. 1345 * Parse a compilation unit, starting with the given token.
1337 * 1346 *
1338 * @param token the first token of the compilation unit 1347 * @param token the first token of the compilation unit
1339 * @return the compilation unit that was parsed 1348 * @return the compilation unit that was parsed
1340 */ 1349 */
1341 CompilationUnit parseCompilationUnit(Token token) { 1350 CompilationUnit parseCompilationUnit(Token token) {
1342 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.Parser.parseCompilationUnit"); 1351 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.Parser.parseCompilationUnit");
1343 try { 1352 try {
1344 _currentToken = token; 1353 _currentToken = token;
1345 CompilationUnit compilationUnit = parseCompilationUnit2(); 1354 return parseCompilationUnit2();
1346 gatherTodoComments(token);
1347 return compilationUnit;
1348 } finally { 1355 } finally {
1349 instrumentation.log2(2); 1356 instrumentation.log2(2);
1350 } 1357 }
1351 } 1358 }
1352 1359
1353 /** 1360 /**
1354 * Parse an expression, starting with the given token. 1361 * Parse an expression, starting with the given token.
1355 * 1362 *
1356 * @param token the first token of the expression 1363 * @param token the first token of the expression
1357 * @return the expression that was parsed, or `null` if the tokens do not repr esent a 1364 * @return the expression that was parsed, or `null` if the tokens do not repr esent a
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 if (directive is ExportDirective) { 1722 if (directive is ExportDirective) {
1716 reportError10(ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, (directive as NamespaceDirective).keyword, []); 1723 reportError10(ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, (directive as NamespaceDirective).keyword, []);
1717 } else if (directive is ImportDirective) { 1724 } else if (directive is ImportDirective) {
1718 reportError10(ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, (directive as NamespaceDirective).keyword, []); 1725 reportError10(ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, (directive as NamespaceDirective).keyword, []);
1719 } 1726 }
1720 } 1727 }
1721 if (directive is PartOfDirective) { 1728 if (directive is PartOfDirective) {
1722 if (partOfDirectiveFound) { 1729 if (partOfDirectiveFound) {
1723 reportError9(ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES, []); 1730 reportError9(ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES, []);
1724 } else { 1731 } else {
1725 for (Directive precedingDirective in directives) { 1732 int directiveCount = directives.length;
1726 reportError10(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, prece dingDirective.keyword, []); 1733 for (int i = 0; i < directiveCount; i++) {
1734 reportError10(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, direc tives[i].keyword, []);
1727 } 1735 }
1728 partOfDirectiveFound = true; 1736 partOfDirectiveFound = true;
1729 } 1737 }
1730 } else { 1738 } else {
1731 if (partOfDirectiveFound) { 1739 if (partOfDirectiveFound) {
1732 reportError10(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, directi ve.keyword, []); 1740 reportError10(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, directi ve.keyword, []);
1733 } 1741 }
1734 } 1742 }
1735 directives.add(directive); 1743 directives.add(directive);
1736 } else if (matches5(TokenType.SEMICOLON)) { 1744 } else if (matches5(TokenType.SEMICOLON)) {
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
2522 } 2530 }
2523 } 2531 }
2524 return false; 2532 return false;
2525 } 2533 }
2526 2534
2527 /** 2535 /**
2528 * Create a synthetic identifier. 2536 * Create a synthetic identifier.
2529 * 2537 *
2530 * @return the synthetic identifier that was created 2538 * @return the synthetic identifier that was created
2531 */ 2539 */
2532 SimpleIdentifier createSyntheticIdentifier() => new SimpleIdentifier.full(crea teSyntheticToken2(TokenType.IDENTIFIER)); 2540 SimpleIdentifier createSyntheticIdentifier() {
2541 Token syntheticToken;
2542 if (identical(_currentToken.type, TokenType.KEYWORD)) {
2543 syntheticToken = injectToken(new SyntheticStringToken(TokenType.IDENTIFIER , _currentToken.lexeme, _currentToken.offset));
2544 } else {
2545 syntheticToken = createSyntheticToken2(TokenType.IDENTIFIER);
2546 }
2547 return new SimpleIdentifier.full(syntheticToken);
2548 }
2533 2549
2534 /** 2550 /**
2535 * Create a synthetic string literal. 2551 * Create a synthetic string literal.
2536 * 2552 *
2537 * @return the synthetic string literal that was created 2553 * @return the synthetic string literal that was created
2538 */ 2554 */
2539 SimpleStringLiteral createSyntheticStringLiteral() => new SimpleStringLiteral. full(createSyntheticToken2(TokenType.STRING), ""); 2555 SimpleStringLiteral createSyntheticStringLiteral() => new SimpleStringLiteral. full(createSyntheticToken2(TokenType.STRING), "");
2540 2556
2541 /** 2557 /**
2542 * Create a synthetic token representing the given keyword. 2558 * Create a synthetic token representing the given keyword.
2543 * 2559 *
2544 * @return the synthetic token that was created 2560 * @return the synthetic token that was created
2545 */ 2561 */
2546 Token createSyntheticToken(Keyword keyword) => new Parser_SyntheticKeywordToke n(keyword, _currentToken.offset); 2562 Token createSyntheticToken(Keyword keyword) => injectToken(new Parser_Syntheti cKeywordToken(keyword, _currentToken.offset));
2547 2563
2548 /** 2564 /**
2549 * Create a synthetic token with the given type. 2565 * Create a synthetic token with the given type.
2550 * 2566 *
2551 * @return the synthetic token that was created 2567 * @return the synthetic token that was created
2552 */ 2568 */
2553 Token createSyntheticToken2(TokenType type) => new StringToken(type, "", _curr entToken.offset); 2569 Token createSyntheticToken2(TokenType type) => injectToken(new StringToken(typ e, "", _currentToken.offset));
2554 2570
2555 /** 2571 /**
2556 * Check that the given expression is assignable and report an error if it isn 't. 2572 * Check that the given expression is assignable and report an error if it isn 't.
2557 * 2573 *
2558 * <pre> 2574 * <pre>
2559 * assignableExpression ::= 2575 * assignableExpression ::=
2560 * primary (arguments* assignableSelector)+ 2576 * primary (arguments* assignableSelector)+
2561 * | 'super' assignableSelector 2577 * | 'super' assignableSelector
2562 * | identifier 2578 * | identifier
2563 * 2579 *
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2610 2626
2611 /** 2627 /**
2612 * Search the given list of ranges for a range that contains the given index. Return the range 2628 * Search the given list of ranges for a range that contains the given index. Return the range
2613 * that was found, or `null` if none of the ranges contain the index. 2629 * that was found, or `null` if none of the ranges contain the index.
2614 * 2630 *
2615 * @param ranges the ranges to be searched 2631 * @param ranges the ranges to be searched
2616 * @param index the index contained in the returned range 2632 * @param index the index contained in the returned range
2617 * @return the range that was found 2633 * @return the range that was found
2618 */ 2634 */
2619 List<int> findRange(List<List<int>> ranges, int index) { 2635 List<int> findRange(List<List<int>> ranges, int index) {
2620 for (List<int> range in ranges) { 2636 int rangeCount = ranges.length;
2637 for (int i = 0; i < rangeCount; i++) {
2638 List<int> range = ranges[i];
2621 if (range[0] <= index && index <= range[1]) { 2639 if (range[0] <= index && index <= range[1]) {
2622 return range; 2640 return range;
2623 } else if (index < range[0]) { 2641 } else if (index < range[0]) {
2624 return null; 2642 return null;
2625 } 2643 }
2626 } 2644 }
2627 return null; 2645 return null;
2628 } 2646 }
2629 2647
2630 void gatherTodoComments(Token token) {
2631 while (token != null && token.type != TokenType.EOF) {
2632 Token commentToken = token.precedingComments;
2633 while (commentToken != null) {
2634 if (identical(commentToken.type, TokenType.SINGLE_LINE_COMMENT) || ident ical(commentToken.type, TokenType.MULTI_LINE_COMMENT)) {
2635 scrapeTodoComment(commentToken);
2636 }
2637 commentToken = commentToken.next;
2638 }
2639 token = token.next;
2640 }
2641 }
2642
2643 /** 2648 /**
2644 * Advance to the next token in the token stream, making it the new current to ken. 2649 * Advance to the next token in the token stream, making it the new current to ken.
2645 * 2650 *
2646 * @return the token that was current before this method was invoked 2651 * @return the token that was current before this method was invoked
2647 */ 2652 */
2648 Token get andAdvance { 2653 Token get andAdvance {
2649 Token token = _currentToken; 2654 Token token = _currentToken;
2650 advance(); 2655 advance();
2651 return token; 2656 return token;
2652 } 2657 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2719 */ 2724 */
2720 bool hasReturnTypeInTypeAlias() { 2725 bool hasReturnTypeInTypeAlias() {
2721 Token next = skipReturnType(_currentToken); 2726 Token next = skipReturnType(_currentToken);
2722 if (next == null) { 2727 if (next == null) {
2723 return false; 2728 return false;
2724 } 2729 }
2725 return matchesIdentifier2(next); 2730 return matchesIdentifier2(next);
2726 } 2731 }
2727 2732
2728 /** 2733 /**
2734 * Inject the given token into the token stream immediately before the current token.
2735 *
2736 * @param token the token to be added to the token stream
2737 * @return the token that was just added to the token stream
2738 */
2739 Token injectToken(Token token) {
2740 Token previous = _currentToken.previous;
2741 token.setNext(_currentToken);
2742 previous.setNext(token);
2743 return token;
2744 }
2745
2746 /**
2729 * Return `true` if the current token appears to be the beginning of a functio n declaration. 2747 * Return `true` if the current token appears to be the beginning of a functio n declaration.
2730 * 2748 *
2731 * @return `true` if the current token appears to be the beginning of a functi on declaration 2749 * @return `true` if the current token appears to be the beginning of a functi on declaration
2732 */ 2750 */
2733 bool isFunctionDeclaration() { 2751 bool isFunctionDeclaration() {
2734 if (matches(Keyword.VOID)) { 2752 if (matches(Keyword.VOID)) {
2735 return true; 2753 return true;
2736 } 2754 }
2737 Token afterReturnType = skipTypeName(_currentToken); 2755 Token afterReturnType = skipTypeName(_currentToken);
2738 if (afterReturnType == null) { 2756 if (afterReturnType == null) {
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
3616 * @param referenceSource the source occurring between the square brackets wit hin a documentation 3634 * @param referenceSource the source occurring between the square brackets wit hin a documentation
3617 * comment 3635 * comment
3618 * @param sourceOffset the offset of the first character of the reference sour ce 3636 * @param sourceOffset the offset of the first character of the reference sour ce
3619 * @return the comment reference that was parsed, or `null` if no reference co uld be found 3637 * @return the comment reference that was parsed, or `null` if no reference co uld be found
3620 */ 3638 */
3621 CommentReference parseCommentReference(String referenceSource, int sourceOffse t) { 3639 CommentReference parseCommentReference(String referenceSource, int sourceOffse t) {
3622 if (referenceSource.length == 0) { 3640 if (referenceSource.length == 0) {
3623 return null; 3641 return null;
3624 } 3642 }
3625 try { 3643 try {
3626 List<bool> errorFound = [false]; 3644 BooleanErrorListener listener = new BooleanErrorListener();
3627 AnalysisErrorListener listener = new AnalysisErrorListener_16(errorFound);
3628 Scanner scanner = new Scanner(null, new SubSequenceReader(new CharSequence (referenceSource), sourceOffset), listener); 3645 Scanner scanner = new Scanner(null, new SubSequenceReader(new CharSequence (referenceSource), sourceOffset), listener);
3629 scanner.setSourceStart(1, 1); 3646 scanner.setSourceStart(1, 1);
3630 Token firstToken = scanner.tokenize(); 3647 Token firstToken = scanner.tokenize();
3631 if (errorFound[0]) { 3648 if (listener.errorReported) {
3632 return null; 3649 return null;
3633 } 3650 }
3634 Token newKeyword = null; 3651 Token newKeyword = null;
3635 if (matches3(firstToken, Keyword.NEW)) { 3652 if (matches3(firstToken, Keyword.NEW)) {
3636 newKeyword = firstToken; 3653 newKeyword = firstToken;
3637 firstToken = firstToken.next; 3654 firstToken = firstToken.next;
3638 } 3655 }
3639 if (matchesIdentifier2(firstToken)) { 3656 if (matchesIdentifier2(firstToken)) {
3640 Token secondToken = firstToken.next; 3657 Token secondToken = firstToken.next;
3641 Token thirdToken = secondToken.next; 3658 Token thirdToken = secondToken.next;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
3862 FunctionBody body; 3879 FunctionBody body;
3863 if (matches5(TokenType.EQ)) { 3880 if (matches5(TokenType.EQ)) {
3864 separator = andAdvance; 3881 separator = andAdvance;
3865 redirectedConstructor = parseConstructorName(); 3882 redirectedConstructor = parseConstructorName();
3866 body = new EmptyFunctionBody.full(expect2(TokenType.SEMICOLON)); 3883 body = new EmptyFunctionBody.full(expect2(TokenType.SEMICOLON));
3867 if (factoryKeyword == null) { 3884 if (factoryKeyword == null) {
3868 reportError(ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR, redi rectedConstructor, []); 3885 reportError(ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR, redi rectedConstructor, []);
3869 } 3886 }
3870 } else { 3887 } else {
3871 body = parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION_BODY, fals e); 3888 body = parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION_BODY, fals e);
3872 if (constKeyword != null && factoryKeyword != null) { 3889 if (constKeyword != null && factoryKeyword != null && externalKeyword == n ull) {
3873 reportError10(ParserErrorCode.CONST_FACTORY, factoryKeyword, []); 3890 reportError10(ParserErrorCode.CONST_FACTORY, factoryKeyword, []);
3874 } else if (body is EmptyFunctionBody) { 3891 } else if (body is EmptyFunctionBody) {
3875 if (factoryKeyword != null && externalKeyword == null) { 3892 if (factoryKeyword != null && externalKeyword == null) {
3876 reportError10(ParserErrorCode.FACTORY_WITHOUT_BODY, factoryKeyword, [] ); 3893 reportError10(ParserErrorCode.FACTORY_WITHOUT_BODY, factoryKeyword, [] );
3877 } 3894 }
3878 } else { 3895 } else {
3879 if (constKeyword != null) { 3896 if (constKeyword != null) {
3880 reportError(ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY, body, []); 3897 reportError(ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY, body, []);
3881 } else if (!bodyAllowed) { 3898 } else if (!bodyAllowed) {
3882 reportError(ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, body, []); 3899 reportError(ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, body, []);
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after
5570 Token defaultKeyword = null; 5587 Token defaultKeyword = null;
5571 List<SwitchMember> members = new List<SwitchMember>(); 5588 List<SwitchMember> members = new List<SwitchMember>();
5572 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET )) { 5589 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET )) {
5573 List<Label> labels = new List<Label>(); 5590 List<Label> labels = new List<Label>();
5574 while (matchesIdentifier() && matches4(peek(), TokenType.COLON)) { 5591 while (matchesIdentifier() && matches4(peek(), TokenType.COLON)) {
5575 SimpleIdentifier identifier = parseSimpleIdentifier(); 5592 SimpleIdentifier identifier = parseSimpleIdentifier();
5576 String label = identifier.token.lexeme; 5593 String label = identifier.token.lexeme;
5577 if (definedLabels.contains(label)) { 5594 if (definedLabels.contains(label)) {
5578 reportError10(ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, i dentifier.token, [label]); 5595 reportError10(ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, i dentifier.token, [label]);
5579 } else { 5596 } else {
5580 javaSetAdd(definedLabels, label); 5597 definedLabels.add(label);
5581 } 5598 }
5582 Token colon = expect2(TokenType.COLON); 5599 Token colon = expect2(TokenType.COLON);
5583 labels.add(new Label.full(identifier, colon)); 5600 labels.add(new Label.full(identifier, colon));
5584 } 5601 }
5585 if (matches(Keyword.CASE)) { 5602 if (matches(Keyword.CASE)) {
5586 Token caseKeyword = andAdvance; 5603 Token caseKeyword = andAdvance;
5587 Expression caseExpression = parseExpression2(); 5604 Expression caseExpression = parseExpression2();
5588 Token colon = expect2(TokenType.COLON); 5605 Token colon = expect2(TokenType.COLON);
5589 members.add(new SwitchCase.full(labels, caseKeyword, caseExpression, c olon, parseStatements2())); 5606 members.add(new SwitchCase.full(labels, caseKeyword, caseExpression, c olon, parseStatements2()));
5590 if (defaultKeyword != null) { 5607 if (defaultKeyword != null) {
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
6025 * 6042 *
6026 * @param errorCode the error code of the error to be reported 6043 * @param errorCode the error code of the error to be reported
6027 * @param token the token specifying the location of the error 6044 * @param token the token specifying the location of the error
6028 * @param arguments the arguments to the error, used to compose the error mess age 6045 * @param arguments the arguments to the error, used to compose the error mess age
6029 */ 6046 */
6030 void reportError10(ParserErrorCode errorCode, Token token, List<Object> argume nts) { 6047 void reportError10(ParserErrorCode errorCode, Token token, List<Object> argume nts) {
6031 _errorListener.onError(new AnalysisError.con2(_source, token.offset, token.l ength, errorCode, arguments)); 6048 _errorListener.onError(new AnalysisError.con2(_source, token.offset, token.l ength, errorCode, arguments));
6032 } 6049 }
6033 6050
6034 /** 6051 /**
6035 * Look for user defined tasks in comments and convert them into info level an alysis issues.
6036 *
6037 * @param commentToken the comment token to analyze
6038 */
6039 void scrapeTodoComment(Token commentToken) {
6040 JavaPatternMatcher matcher = new JavaPatternMatcher(TodoCode.TODO_REGEX, com mentToken.lexeme);
6041 if (matcher.find()) {
6042 int offset = commentToken.offset + matcher.start() + matcher.group(1).leng th;
6043 int length = matcher.group(2).length;
6044 // _errorListener.onError(new AnalysisError.con2(_source, offset, length, TodoCode.TODO, [matcher.group(2)]));
6045 }
6046 }
6047
6048 /**
6049 * Parse the 'final', 'const', 'var' or type preceding a variable declaration, starting at the 6052 * Parse the 'final', 'const', 'var' or type preceding a variable declaration, starting at the
6050 * given token, without actually creating a type or changing the current token . Return the token 6053 * given token, without actually creating a type or changing the current token . Return the token
6051 * following the type that was parsed, or `null` if the given token is not the first token 6054 * following the type that was parsed, or `null` if the given token is not the first token
6052 * in a valid type. 6055 * in a valid type.
6053 * 6056 *
6054 * <pre> 6057 * <pre>
6055 * finalConstVarOrType ::= 6058 * finalConstVarOrType ::=
6056 * | 'final' type? 6059 * | 'final' type?
6057 * | 'const' type? 6060 * | 'const' type?
6058 * | 'var' 6061 * | 'var'
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
6836 * @param keyword the keyword being represented by this token 6839 * @param keyword the keyword being represented by this token
6837 * @param offset the offset from the beginning of the file to the first charac ter in the token 6840 * @param offset the offset from the beginning of the file to the first charac ter in the token
6838 */ 6841 */
6839 Parser_SyntheticKeywordToken(Keyword keyword, int offset) : super(keyword, off set); 6842 Parser_SyntheticKeywordToken(Keyword keyword, int offset) : super(keyword, off set);
6840 6843
6841 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); 6844 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset);
6842 6845
6843 int get length => 0; 6846 int get length => 0;
6844 } 6847 }
6845 6848
6846 class AnalysisErrorListener_16 implements AnalysisErrorListener {
6847 List<bool> errorFound;
6848
6849 AnalysisErrorListener_16(this.errorFound);
6850
6851 void onError(AnalysisError error) {
6852 errorFound[0] = true;
6853 }
6854 }
6855
6856 /** 6849 /**
6857 * The enumeration `ParserErrorCode` defines the error codes used for errors det ected by the 6850 * The enumeration `ParserErrorCode` defines the error codes used for errors det ected by the
6858 * parser. The convention for this class is for the name of the error code to in dicate the problem 6851 * parser. The convention for this class is for the name of the error code to in dicate the problem
6859 * that caused the error to be generated and for the error message to explain wh at is wrong and, 6852 * that caused the error to be generated and for the error message to explain wh at is wrong and,
6860 * when appropriate, how the problem can be corrected. 6853 * when appropriate, how the problem can be corrected.
6861 * 6854 *
6862 * @coverage dart.engine.parser 6855 * @coverage dart.engine.parser
6863 */ 6856 */
6864 class ParserErrorCode extends Enum<ParserErrorCode> implements ErrorCode { 6857 class ParserErrorCode extends Enum<ParserErrorCode> implements ErrorCode {
6865 static final ParserErrorCode ABSTRACT_CLASS_MEMBER = new ParserErrorCode.con3( 'ABSTRACT_CLASS_MEMBER', 0, "Members of classes cannot be declared to be 'abstra ct'"); 6858 static final ParserErrorCode ABSTRACT_CLASS_MEMBER = new ParserErrorCode.con3( 'ABSTRACT_CLASS_MEMBER', 0, "Members of classes cannot be declared to be 'abstra ct'");
(...skipping 2364 matching lines...) Expand 10 before | Expand all | Expand 10 after
9230 if ("\n" == separator) { 9223 if ("\n" == separator) {
9231 _writer.print("\n"); 9224 _writer.print("\n");
9232 indent(); 9225 indent();
9233 } else if (i > 0) { 9226 } else if (i > 0) {
9234 _writer.print(separator); 9227 _writer.print(separator);
9235 } 9228 }
9236 _writer.print(tokens[i].lexeme); 9229 _writer.print(tokens[i].lexeme);
9237 } 9230 }
9238 } 9231 }
9239 } 9232 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/java_core.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698