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

Side by Side Diff: lib/compiler/implementation/scanner/listener.dart

Issue 11238035: Make isEmpty a getter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status file with co19 issue number. Created 8 years, 2 months 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) 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 const bool VERBOSE = false; 5 const bool VERBOSE = false;
6 6
7 /** 7 /**
8 * A parser event listener that does nothing except throw exceptions 8 * A parser event listener that does nothing except throw exceptions
9 * on parser errors. 9 * on parser errors.
10 */ 10 */
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 node: node); 647 node: node);
648 return null; 648 return null;
649 } 649 }
650 return node; 650 return node;
651 } 651 }
652 652
653 bool allowLibraryTags() { 653 bool allowLibraryTags() {
654 // Library tags are only allowed in the library file itself, not 654 // Library tags are only allowed in the library file itself, not
655 // in sourced files. 655 // in sourced files.
656 LibraryElement library = compilationUnitElement.getLibrary(); 656 LibraryElement library = compilationUnitElement.getLibrary();
657 return compilationUnitElement.localMembers.isEmpty() 657 return compilationUnitElement.localMembers.isEmpty
658 && library.entryCompilationUnit == compilationUnitElement; 658 && library.entryCompilationUnit == compilationUnitElement;
659 } 659 }
660 660
661 void endLibraryName(Token libraryKeyword, Token semicolon) { 661 void endLibraryName(Token libraryKeyword, Token semicolon) {
662 Expression name = popNode(); 662 Expression name = popNode();
663 addLibraryTag(new LibraryName(libraryKeyword, name)); 663 addLibraryTag(new LibraryName(libraryKeyword, name));
664 } 664 }
665 665
666 void endImport(Token importKeyword, Token asKeyword, Token semicolon) { 666 void endImport(Token importKeyword, Token asKeyword, Token semicolon) {
667 NodeList combinators = popNode(); 667 NodeList combinators = popNode();
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 NodeList variables, 835 NodeList variables,
836 ContainerElement enclosingElement, 836 ContainerElement enclosingElement,
837 void buildFieldElement(SourceString name, 837 void buildFieldElement(SourceString name,
838 Element fields), 838 Element fields),
839 Token beginToken, Token endToken) { 839 Token beginToken, Token endToken) {
840 Element fields = new PartialFieldListElement(beginToken, 840 Element fields = new PartialFieldListElement(beginToken,
841 endToken, 841 endToken,
842 modifiers, 842 modifiers,
843 enclosingElement); 843 enclosingElement);
844 for (Link<Node> variableNodes = variables.nodes; 844 for (Link<Node> variableNodes = variables.nodes;
845 !variableNodes.isEmpty(); 845 !variableNodes.isEmpty;
846 variableNodes = variableNodes.tail) { 846 variableNodes = variableNodes.tail) {
847 Expression initializedIdentifier = variableNodes.head; 847 Expression initializedIdentifier = variableNodes.head;
848 Identifier identifier = initializedIdentifier.asIdentifier(); 848 Identifier identifier = initializedIdentifier.asIdentifier();
849 if (identifier == null) { 849 if (identifier == null) {
850 identifier = initializedIdentifier.asSendSet().selector.asIdentifier(); 850 identifier = initializedIdentifier.asSendSet().selector.asIdentifier();
851 } 851 }
852 SourceString name = identifier.source; 852 SourceString name = identifier.source;
853 buildFieldElement(name, fields); 853 buildFieldElement(name, fields);
854 } 854 }
855 } 855 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 Token unmatched(Token token) { 983 Token unmatched(Token token) {
984 listener.cancel("unmatched '${token.slowToString()}'", token: token); 984 listener.cancel("unmatched '${token.slowToString()}'", token: token);
985 return skipToEof(token); 985 return skipToEof(token);
986 } 986 }
987 987
988 void recoverableError(String message, {Token token, Node node}) { 988 void recoverableError(String message, {Token token, Node node}) {
989 listener.cancel(message, token: token, node: node); 989 listener.cancel(message, token: token, node: node);
990 } 990 }
991 991
992 void pushElement(Element element) { 992 void pushElement(Element element) {
993 for (Link link = metadata; !link.isEmpty(); link = link.tail) { 993 for (Link link = metadata; !link.isEmpty; link = link.tail) {
994 element.addMetadata(link.head); 994 element.addMetadata(link.head);
995 } 995 }
996 metadata = const Link<MetadataAnnotation>(); 996 metadata = const Link<MetadataAnnotation>();
997 compilationUnitElement.addMember(element, listener); 997 compilationUnitElement.addMember(element, listener);
998 } 998 }
999 999
1000 void pushMetadata(MetadataAnnotation annotation) { 1000 void pushMetadata(MetadataAnnotation annotation) {
1001 metadata = metadata.prepend(annotation); 1001 metadata = metadata.prepend(annotation);
1002 } 1002 }
1003 1003
1004 void addScriptTag(ScriptTag tag) { 1004 void addScriptTag(ScriptTag tag) {
1005 // TODO(ahe): Remove this method. 1005 // TODO(ahe): Remove this method.
1006 addLibraryTag(tag.toLibraryTag()); 1006 addLibraryTag(tag.toLibraryTag());
1007 } 1007 }
1008 1008
1009 void addLibraryTag(LibraryTag tag) { 1009 void addLibraryTag(LibraryTag tag) {
1010 if (!allowLibraryTags()) { 1010 if (!allowLibraryTags()) {
1011 recoverableError('library tags not allowed here', node: tag); 1011 recoverableError('library tags not allowed here', node: tag);
1012 } 1012 }
1013 compilationUnitElement.getImplementationLibrary().addTag(tag, listener); 1013 compilationUnitElement.getImplementationLibrary().addTag(tag, listener);
1014 } 1014 }
1015 1015
1016 void pushNode(Node node) { 1016 void pushNode(Node node) {
1017 nodes = nodes.prepend(node); 1017 nodes = nodes.prepend(node);
1018 if (VERBOSE) log("push $nodes"); 1018 if (VERBOSE) log("push $nodes");
1019 } 1019 }
1020 1020
1021 Node popNode() { 1021 Node popNode() {
1022 assert(!nodes.isEmpty()); 1022 assert(!nodes.isEmpty);
1023 Node node = nodes.head; 1023 Node node = nodes.head;
1024 nodes = nodes.tail; 1024 nodes = nodes.tail;
1025 if (VERBOSE) log("pop $nodes"); 1025 if (VERBOSE) log("pop $nodes");
1026 return node; 1026 return node;
1027 } 1027 }
1028 1028
1029 Node peekNode() { 1029 Node peekNode() {
1030 assert(!nodes.isEmpty()); 1030 assert(!nodes.isEmpty);
1031 Node node = nodes.head; 1031 Node node = nodes.head;
1032 if (VERBOSE) log("peek $node"); 1032 if (VERBOSE) log("peek $node");
1033 return node; 1033 return node;
1034 } 1034 }
1035 1035
1036 void log(message) { 1036 void log(message) {
1037 print(message); 1037 print(message);
1038 } 1038 }
1039 1039
1040 NodeList makeNodeList(int count, Token beginToken, Token endToken, 1040 NodeList makeNodeList(int count, Token beginToken, Token endToken,
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 return cachedNode; 1906 return cachedNode;
1907 } 1907 }
1908 } 1908 }
1909 1909
1910 Node parse(DiagnosticListener diagnosticListener, 1910 Node parse(DiagnosticListener diagnosticListener,
1911 CompilationUnitElement element, 1911 CompilationUnitElement element,
1912 doParse(Parser parser)) { 1912 doParse(Parser parser)) {
1913 NodeListener listener = new NodeListener(diagnosticListener, element); 1913 NodeListener listener = new NodeListener(diagnosticListener, element);
1914 doParse(new Parser(listener)); 1914 doParse(new Parser(listener));
1915 Node node = listener.popNode(); 1915 Node node = listener.popNode();
1916 assert(listener.nodes.isEmpty()); 1916 assert(listener.nodes.isEmpty);
1917 return node; 1917 return node;
1918 } 1918 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/scanner/keyword.dart ('k') | lib/compiler/implementation/scanner/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698