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 /** | 5 /** |
6 * An event generating parser of Dart programs. This parser expects | 6 * An event generating parser of Dart programs. This parser expects |
7 * all tokens in a linked list (aka a token stream). | 7 * all tokens in a linked list (aka a token stream). |
8 * | 8 * |
9 * The class [Scanner] is used to generate a token stream. See the | 9 * The class [Scanner] is used to generate a token stream. See the |
10 * file scanner.dart. | 10 * file scanner.dart. |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 } | 566 } |
567 handleNoStuff(token); | 567 handleNoStuff(token); |
568 return token; | 568 return token; |
569 } | 569 } |
570 | 570 |
571 Token parseTopLevelMember(Token token) { | 571 Token parseTopLevelMember(Token token) { |
572 Token start = token; | 572 Token start = token; |
573 listener.beginTopLevelMember(token); | 573 listener.beginTopLevelMember(token); |
574 | 574 |
575 Link<Token> identifiers = findMemberName(token); | 575 Link<Token> identifiers = findMemberName(token); |
576 if (identifiers.isEmpty()) { | 576 if (identifiers.isEmpty) { |
577 return listener.unexpected(start); | 577 return listener.unexpected(start); |
578 } | 578 } |
579 Token name = identifiers.head; | 579 Token name = identifiers.head; |
580 identifiers = identifiers.tail; | 580 identifiers = identifiers.tail; |
581 Token getOrSet; | 581 Token getOrSet; |
582 if (!identifiers.isEmpty()) { | 582 if (!identifiers.isEmpty) { |
583 String value = identifiers.head.stringValue; | 583 String value = identifiers.head.stringValue; |
584 if ((identical(value, 'get')) || (identical(value, 'set'))) { | 584 if ((identical(value, 'get')) || (identical(value, 'set'))) { |
585 getOrSet = identifiers.head; | 585 getOrSet = identifiers.head; |
586 identifiers = identifiers.tail; | 586 identifiers = identifiers.tail; |
587 } | 587 } |
588 } | 588 } |
589 Token type; | 589 Token type; |
590 if (!identifiers.isEmpty()) { | 590 if (!identifiers.isEmpty) { |
591 if (isValidTypeReference(identifiers.head)) { | 591 if (isValidTypeReference(identifiers.head)) { |
592 type = identifiers.head; | 592 type = identifiers.head; |
593 identifiers = identifiers.tail; | 593 identifiers = identifiers.tail; |
594 } | 594 } |
595 } | 595 } |
596 parseModifierList(identifiers.reverse()); | 596 parseModifierList(identifiers.reverse()); |
597 if (type == null) { | 597 if (type == null) { |
598 listener.handleNoType(token); | 598 listener.handleNoType(token); |
599 } else { | 599 } else { |
600 parseReturnTypeOpt(type); | 600 parseReturnTypeOpt(type); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 } | 764 } |
765 | 765 |
766 Token parseModifier(Token token) { | 766 Token parseModifier(Token token) { |
767 assert(isModifier(token)); | 767 assert(isModifier(token)); |
768 listener.handleModifier(token); | 768 listener.handleModifier(token); |
769 return token.next; | 769 return token.next; |
770 } | 770 } |
771 | 771 |
772 void parseModifierList(Link<Token> tokens) { | 772 void parseModifierList(Link<Token> tokens) { |
773 int count = 0; | 773 int count = 0; |
774 for (; !tokens.isEmpty(); tokens = tokens.tail) { | 774 for (; !tokens.isEmpty; tokens = tokens.tail) { |
775 Token token = tokens.head; | 775 Token token = tokens.head; |
776 if (isModifier(token)) { | 776 if (isModifier(token)) { |
777 parseModifier(token); | 777 parseModifier(token); |
778 } else { | 778 } else { |
779 listener.unexpected(token); | 779 listener.unexpected(token); |
780 } | 780 } |
781 count++; | 781 count++; |
782 } | 782 } |
783 listener.handleModifiers(count); | 783 listener.handleModifiers(count); |
784 } | 784 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 Token parseMember(Token token) { | 860 Token parseMember(Token token) { |
861 token = parseMetadataStar(token); | 861 token = parseMetadataStar(token); |
862 String value = token.stringValue; | 862 String value = token.stringValue; |
863 if (isFactoryDeclaration(token)) { | 863 if (isFactoryDeclaration(token)) { |
864 return parseFactoryMethod(token); | 864 return parseFactoryMethod(token); |
865 } | 865 } |
866 Token start = token; | 866 Token start = token; |
867 listener.beginMember(token); | 867 listener.beginMember(token); |
868 | 868 |
869 Link<Token> identifiers = findMemberName(token); | 869 Link<Token> identifiers = findMemberName(token); |
870 if (identifiers.isEmpty()) { | 870 if (identifiers.isEmpty) { |
871 return listener.unexpected(start); | 871 return listener.unexpected(start); |
872 } | 872 } |
873 Token name = identifiers.head; | 873 Token name = identifiers.head; |
874 identifiers = identifiers.tail; | 874 identifiers = identifiers.tail; |
875 if (!identifiers.isEmpty()) { | 875 if (!identifiers.isEmpty) { |
876 if (optional('operator', identifiers.head)) { | 876 if (optional('operator', identifiers.head)) { |
877 name = identifiers.head; | 877 name = identifiers.head; |
878 identifiers = identifiers.tail; | 878 identifiers = identifiers.tail; |
879 } | 879 } |
880 } | 880 } |
881 Token getOrSet; | 881 Token getOrSet; |
882 if (!identifiers.isEmpty()) { | 882 if (!identifiers.isEmpty) { |
883 if (isGetOrSet(identifiers.head)) { | 883 if (isGetOrSet(identifiers.head)) { |
884 getOrSet = identifiers.head; | 884 getOrSet = identifiers.head; |
885 identifiers = identifiers.tail; | 885 identifiers = identifiers.tail; |
886 } | 886 } |
887 } | 887 } |
888 Token type; | 888 Token type; |
889 if (!identifiers.isEmpty()) { | 889 if (!identifiers.isEmpty) { |
890 if (isValidTypeReference(identifiers.head)) { | 890 if (isValidTypeReference(identifiers.head)) { |
891 type = identifiers.head; | 891 type = identifiers.head; |
892 identifiers = identifiers.tail; | 892 identifiers = identifiers.tail; |
893 } | 893 } |
894 } | 894 } |
895 parseModifierList(identifiers.reverse()); | 895 parseModifierList(identifiers.reverse()); |
896 if (type == null) { | 896 if (type == null) { |
897 listener.handleNoType(token); | 897 listener.handleNoType(token); |
898 } else { | 898 } else { |
899 parseReturnTypeOpt(type); | 899 parseReturnTypeOpt(type); |
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2160 } | 2160 } |
2161 listener.handleContinueStatement(hasTarget, continueKeyword, token); | 2161 listener.handleContinueStatement(hasTarget, continueKeyword, token); |
2162 return expectSemicolon(token); | 2162 return expectSemicolon(token); |
2163 } | 2163 } |
2164 | 2164 |
2165 Token parseEmptyStatement(Token token) { | 2165 Token parseEmptyStatement(Token token) { |
2166 listener.handleEmptyStatement(token); | 2166 listener.handleEmptyStatement(token); |
2167 return expectSemicolon(token); | 2167 return expectSemicolon(token); |
2168 } | 2168 } |
2169 } | 2169 } |
OLD | NEW |