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

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

Issue 135803003: Translate index. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 // 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 if (identical(_oldNode, node.expression)) { 206 if (identical(_oldNode, node.expression)) {
207 return _parser.parseBitwiseOrExpression(); 207 return _parser.parseBitwiseOrExpression();
208 } else if (identical(_oldNode, node.type)) { 208 } else if (identical(_oldNode, node.type)) {
209 return _parser.parseTypeName(); 209 return _parser.parseTypeName();
210 } 210 }
211 return notAChild(node); 211 return notAChild(node);
212 } 212 }
213 213
214 ASTNode visitAssertStatement(AssertStatement node) { 214 ASTNode visitAssertStatement(AssertStatement node) {
215 if (identical(_oldNode, node.condition)) { 215 if (identical(_oldNode, node.condition)) {
216 return _parser.parseExpression2(); 216 return _parser.parseExpression3();
217 } 217 }
218 return notAChild(node); 218 return notAChild(node);
219 } 219 }
220 220
221 ASTNode visitAssignmentExpression(AssignmentExpression node) { 221 ASTNode visitAssignmentExpression(AssignmentExpression node) {
222 if (identical(_oldNode, node.leftHandSide)) { 222 if (identical(_oldNode, node.leftHandSide)) {
223 throw new InsufficientContextException(); 223 throw new InsufficientContextException();
224 } else if (identical(_oldNode, node.rightHandSide)) { 224 } else if (identical(_oldNode, node.rightHandSide)) {
225 if (isCascadeAllowed(node)) { 225 if (isCascadeAllowed(node)) {
226 return _parser.parseExpression2(); 226 return _parser.parseExpression3();
227 } 227 }
228 return _parser.parseExpressionWithoutCascade(); 228 return _parser.parseExpressionWithoutCascade();
229 } 229 }
230 return notAChild(node); 230 return notAChild(node);
231 } 231 }
232 232
233 ASTNode visitBinaryExpression(BinaryExpression node) { 233 ASTNode visitBinaryExpression(BinaryExpression node) {
234 if (identical(_oldNode, node.leftOperand)) { 234 if (identical(_oldNode, node.leftOperand)) {
235 throw new InsufficientContextException(); 235 throw new InsufficientContextException();
236 } else if (identical(_oldNode, node.rightOperand)) { 236 } else if (identical(_oldNode, node.rightOperand)) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 } else if (identical(_oldNode, node.identifier)) { 406 } else if (identical(_oldNode, node.identifier)) {
407 return _parser.parseSimpleIdentifier(); 407 return _parser.parseSimpleIdentifier();
408 } 408 }
409 return notAChild(node); 409 return notAChild(node);
410 } 410 }
411 411
412 ASTNode visitDefaultFormalParameter(DefaultFormalParameter node) { 412 ASTNode visitDefaultFormalParameter(DefaultFormalParameter node) {
413 if (identical(_oldNode, node.parameter)) { 413 if (identical(_oldNode, node.parameter)) {
414 return _parser.parseNormalFormalParameter(); 414 return _parser.parseNormalFormalParameter();
415 } else if (identical(_oldNode, node.defaultValue)) { 415 } else if (identical(_oldNode, node.defaultValue)) {
416 return _parser.parseExpression2(); 416 return _parser.parseExpression3();
417 } 417 }
418 return notAChild(node); 418 return notAChild(node);
419 } 419 }
420 420
421 ASTNode visitDoStatement(DoStatement node) { 421 ASTNode visitDoStatement(DoStatement node) {
422 if (identical(_oldNode, node.body)) { 422 if (identical(_oldNode, node.body)) {
423 return _parser.parseStatement2(); 423 return _parser.parseStatement2();
424 } else if (identical(_oldNode, node.condition)) { 424 } else if (identical(_oldNode, node.condition)) {
425 return _parser.parseExpression2(); 425 return _parser.parseExpression3();
426 } 426 }
427 return notAChild(node); 427 return notAChild(node);
428 } 428 }
429 429
430 ASTNode visitDoubleLiteral(DoubleLiteral node) => notAChild(node); 430 ASTNode visitDoubleLiteral(DoubleLiteral node) => notAChild(node);
431 431
432 ASTNode visitEmptyFunctionBody(EmptyFunctionBody node) => notAChild(node); 432 ASTNode visitEmptyFunctionBody(EmptyFunctionBody node) => notAChild(node);
433 433
434 ASTNode visitEmptyStatement(EmptyStatement node) => notAChild(node); 434 ASTNode visitEmptyStatement(EmptyStatement node) => notAChild(node);
435 435
436 ASTNode visitExportDirective(ExportDirective node) { 436 ASTNode visitExportDirective(ExportDirective node) {
437 if (identical(_oldNode, node.documentationComment)) { 437 if (identical(_oldNode, node.documentationComment)) {
438 throw new InsufficientContextException(); 438 throw new InsufficientContextException();
439 } else if (node.metadata.contains(_oldNode)) { 439 } else if (node.metadata.contains(_oldNode)) {
440 return _parser.parseAnnotation(); 440 return _parser.parseAnnotation();
441 } else if (identical(_oldNode, node.uri)) { 441 } else if (identical(_oldNode, node.uri)) {
442 return _parser.parseStringLiteral(); 442 return _parser.parseStringLiteral();
443 } else if (node.combinators.contains(_oldNode)) { 443 } else if (node.combinators.contains(_oldNode)) {
444 throw new IncrementalParseException(); 444 throw new IncrementalParseException();
445 } 445 }
446 return notAChild(node); 446 return notAChild(node);
447 } 447 }
448 448
449 ASTNode visitExpressionFunctionBody(ExpressionFunctionBody node) { 449 ASTNode visitExpressionFunctionBody(ExpressionFunctionBody node) {
450 if (identical(_oldNode, node.expression)) { 450 if (identical(_oldNode, node.expression)) {
451 return _parser.parseExpression2(); 451 return _parser.parseExpression3();
452 } 452 }
453 return notAChild(node); 453 return notAChild(node);
454 } 454 }
455 455
456 ASTNode visitExpressionStatement(ExpressionStatement node) { 456 ASTNode visitExpressionStatement(ExpressionStatement node) {
457 if (identical(_oldNode, node.expression)) { 457 if (identical(_oldNode, node.expression)) {
458 return _parser.parseExpression2(); 458 return _parser.parseExpression3();
459 } 459 }
460 return notAChild(node); 460 return notAChild(node);
461 } 461 }
462 462
463 ASTNode visitExtendsClause(ExtendsClause node) { 463 ASTNode visitExtendsClause(ExtendsClause node) {
464 if (identical(_oldNode, node.superclass)) { 464 if (identical(_oldNode, node.superclass)) {
465 return _parser.parseTypeName(); 465 return _parser.parseTypeName();
466 } 466 }
467 return notAChild(node); 467 return notAChild(node);
468 } 468 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 ASTNode visitFormalParameterList(FormalParameterList node) { 507 ASTNode visitFormalParameterList(FormalParameterList node) {
508 throw new InsufficientContextException(); 508 throw new InsufficientContextException();
509 } 509 }
510 510
511 ASTNode visitForStatement(ForStatement node) { 511 ASTNode visitForStatement(ForStatement node) {
512 if (identical(_oldNode, node.variables)) { 512 if (identical(_oldNode, node.variables)) {
513 throw new InsufficientContextException(); 513 throw new InsufficientContextException();
514 } else if (identical(_oldNode, node.initialization)) { 514 } else if (identical(_oldNode, node.initialization)) {
515 throw new InsufficientContextException(); 515 throw new InsufficientContextException();
516 } else if (identical(_oldNode, node.condition)) { 516 } else if (identical(_oldNode, node.condition)) {
517 return _parser.parseExpression2(); 517 return _parser.parseExpression3();
518 } else if (node.updaters.contains(_oldNode)) { 518 } else if (node.updaters.contains(_oldNode)) {
519 return _parser.parseExpression2(); 519 return _parser.parseExpression3();
520 } else if (identical(_oldNode, node.body)) { 520 } else if (identical(_oldNode, node.body)) {
521 return _parser.parseStatement2(); 521 return _parser.parseStatement2();
522 } 522 }
523 return notAChild(node); 523 return notAChild(node);
524 } 524 }
525 525
526 ASTNode visitFunctionDeclaration(FunctionDeclaration node) { 526 ASTNode visitFunctionDeclaration(FunctionDeclaration node) {
527 if (identical(_oldNode, node.documentationComment)) { 527 if (identical(_oldNode, node.documentationComment)) {
528 throw new InsufficientContextException(); 528 throw new InsufficientContextException();
529 } else if (node.metadata.contains(_oldNode)) { 529 } else if (node.metadata.contains(_oldNode)) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 597
598 ASTNode visitHideCombinator(HideCombinator node) { 598 ASTNode visitHideCombinator(HideCombinator node) {
599 if (node.hiddenNames.contains(_oldNode)) { 599 if (node.hiddenNames.contains(_oldNode)) {
600 return _parser.parseSimpleIdentifier(); 600 return _parser.parseSimpleIdentifier();
601 } 601 }
602 return notAChild(node); 602 return notAChild(node);
603 } 603 }
604 604
605 ASTNode visitIfStatement(IfStatement node) { 605 ASTNode visitIfStatement(IfStatement node) {
606 if (identical(_oldNode, node.condition)) { 606 if (identical(_oldNode, node.condition)) {
607 return _parser.parseExpression2(); 607 return _parser.parseExpression3();
608 } else if (identical(_oldNode, node.thenStatement)) { 608 } else if (identical(_oldNode, node.thenStatement)) {
609 return _parser.parseStatement2(); 609 return _parser.parseStatement2();
610 } else if (identical(_oldNode, node.elseStatement)) { 610 } else if (identical(_oldNode, node.elseStatement)) {
611 return _parser.parseStatement2(); 611 return _parser.parseStatement2();
612 } 612 }
613 return notAChild(node); 613 return notAChild(node);
614 } 614 }
615 615
616 ASTNode visitImplementsClause(ImplementsClause node) { 616 ASTNode visitImplementsClause(ImplementsClause node) {
617 if (node.interfaces.contains(node)) { 617 if (node.interfaces.contains(node)) {
(...skipping 14 matching lines...) Expand all
632 } else if (node.combinators.contains(_oldNode)) { 632 } else if (node.combinators.contains(_oldNode)) {
633 throw new IncrementalParseException(); 633 throw new IncrementalParseException();
634 } 634 }
635 return notAChild(node); 635 return notAChild(node);
636 } 636 }
637 637
638 ASTNode visitIndexExpression(IndexExpression node) { 638 ASTNode visitIndexExpression(IndexExpression node) {
639 if (identical(_oldNode, node.target)) { 639 if (identical(_oldNode, node.target)) {
640 throw new InsufficientContextException(); 640 throw new InsufficientContextException();
641 } else if (identical(_oldNode, node.index)) { 641 } else if (identical(_oldNode, node.index)) {
642 return _parser.parseExpression2(); 642 return _parser.parseExpression3();
643 } 643 }
644 return notAChild(node); 644 return notAChild(node);
645 } 645 }
646 646
647 ASTNode visitInstanceCreationExpression(InstanceCreationExpression node) { 647 ASTNode visitInstanceCreationExpression(InstanceCreationExpression node) {
648 if (identical(_oldNode, node.constructorName)) { 648 if (identical(_oldNode, node.constructorName)) {
649 return _parser.parseConstructorName(); 649 return _parser.parseConstructorName();
650 } else if (identical(_oldNode, node.argumentList)) { 650 } else if (identical(_oldNode, node.argumentList)) {
651 return _parser.parseArgumentList(); 651 return _parser.parseArgumentList();
652 } 652 }
653 return notAChild(node); 653 return notAChild(node);
654 } 654 }
655 655
656 ASTNode visitIntegerLiteral(IntegerLiteral node) => notAChild(node); 656 ASTNode visitIntegerLiteral(IntegerLiteral node) => notAChild(node);
657 657
658 ASTNode visitInterpolationExpression(InterpolationExpression node) { 658 ASTNode visitInterpolationExpression(InterpolationExpression node) {
659 if (identical(_oldNode, node.expression)) { 659 if (identical(_oldNode, node.expression)) {
660 if (node.leftBracket == null) { 660 if (node.leftBracket == null) {
661 throw new InsufficientContextException(); 661 throw new InsufficientContextException();
662 } 662 }
663 return _parser.parseExpression2(); 663 return _parser.parseExpression3();
664 } 664 }
665 return notAChild(node); 665 return notAChild(node);
666 } 666 }
667 667
668 ASTNode visitInterpolationString(InterpolationString node) { 668 ASTNode visitInterpolationString(InterpolationString node) {
669 throw new InsufficientContextException(); 669 throw new InsufficientContextException();
670 } 670 }
671 671
672 ASTNode visitIsExpression(IsExpression node) { 672 ASTNode visitIsExpression(IsExpression node) {
673 if (identical(_oldNode, node.expression)) { 673 if (identical(_oldNode, node.expression)) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 if (node.components.contains(_oldNode)) { 709 if (node.components.contains(_oldNode)) {
710 return _parser.parseSimpleIdentifier(); 710 return _parser.parseSimpleIdentifier();
711 } 711 }
712 return notAChild(node); 712 return notAChild(node);
713 } 713 }
714 714
715 ASTNode visitListLiteral(ListLiteral node) { 715 ASTNode visitListLiteral(ListLiteral node) {
716 if (identical(_oldNode, node.typeArguments)) { 716 if (identical(_oldNode, node.typeArguments)) {
717 return _parser.parseTypeArgumentList(); 717 return _parser.parseTypeArgumentList();
718 } else if (node.elements.contains(_oldNode)) { 718 } else if (node.elements.contains(_oldNode)) {
719 return _parser.parseExpression2(); 719 return _parser.parseExpression3();
720 } 720 }
721 return notAChild(node); 721 return notAChild(node);
722 } 722 }
723 723
724 ASTNode visitMapLiteral(MapLiteral node) { 724 ASTNode visitMapLiteral(MapLiteral node) {
725 if (identical(_oldNode, node.typeArguments)) { 725 if (identical(_oldNode, node.typeArguments)) {
726 return _parser.parseTypeArgumentList(); 726 return _parser.parseTypeArgumentList();
727 } else if (node.entries.contains(_oldNode)) { 727 } else if (node.entries.contains(_oldNode)) {
728 return _parser.parseMapLiteralEntry(); 728 return _parser.parseMapLiteralEntry();
729 } 729 }
730 return notAChild(node); 730 return notAChild(node);
731 } 731 }
732 732
733 ASTNode visitMapLiteralEntry(MapLiteralEntry node) { 733 ASTNode visitMapLiteralEntry(MapLiteralEntry node) {
734 if (identical(_oldNode, node.key)) { 734 if (identical(_oldNode, node.key)) {
735 return _parser.parseExpression2(); 735 return _parser.parseExpression3();
736 } else if (identical(_oldNode, node.value)) { 736 } else if (identical(_oldNode, node.value)) {
737 return _parser.parseExpression2(); 737 return _parser.parseExpression3();
738 } 738 }
739 return notAChild(node); 739 return notAChild(node);
740 } 740 }
741 741
742 ASTNode visitMethodDeclaration(MethodDeclaration node) { 742 ASTNode visitMethodDeclaration(MethodDeclaration node) {
743 if (identical(_oldNode, node.documentationComment)) { 743 if (identical(_oldNode, node.documentationComment)) {
744 throw new InsufficientContextException(); 744 throw new InsufficientContextException();
745 } else if (node.metadata.contains(_oldNode)) { 745 } else if (node.metadata.contains(_oldNode)) {
746 return _parser.parseAnnotation(); 746 return _parser.parseAnnotation();
747 } else if (identical(_oldNode, node.returnType)) { 747 } else if (identical(_oldNode, node.returnType)) {
(...skipping 17 matching lines...) Expand all
765 } else if (identical(_oldNode, node.argumentList)) { 765 } else if (identical(_oldNode, node.argumentList)) {
766 return _parser.parseArgumentList(); 766 return _parser.parseArgumentList();
767 } 767 }
768 return notAChild(node); 768 return notAChild(node);
769 } 769 }
770 770
771 ASTNode visitNamedExpression(NamedExpression node) { 771 ASTNode visitNamedExpression(NamedExpression node) {
772 if (identical(_oldNode, node.name)) { 772 if (identical(_oldNode, node.name)) {
773 return _parser.parseLabel(); 773 return _parser.parseLabel();
774 } else if (identical(_oldNode, node.expression)) { 774 } else if (identical(_oldNode, node.expression)) {
775 return _parser.parseExpression2(); 775 return _parser.parseExpression3();
776 } 776 }
777 return notAChild(node); 777 return notAChild(node);
778 } 778 }
779 779
780 ASTNode visitNativeClause(NativeClause node) { 780 ASTNode visitNativeClause(NativeClause node) {
781 if (identical(_oldNode, node.name)) { 781 if (identical(_oldNode, node.name)) {
782 return _parser.parseStringLiteral(); 782 return _parser.parseStringLiteral();
783 } 783 }
784 return notAChild(node); 784 return notAChild(node);
785 } 785 }
786 786
787 ASTNode visitNativeFunctionBody(NativeFunctionBody node) { 787 ASTNode visitNativeFunctionBody(NativeFunctionBody node) {
788 if (identical(_oldNode, node.stringLiteral)) { 788 if (identical(_oldNode, node.stringLiteral)) {
789 return _parser.parseStringLiteral(); 789 return _parser.parseStringLiteral();
790 } 790 }
791 return notAChild(node); 791 return notAChild(node);
792 } 792 }
793 793
794 ASTNode visitNullLiteral(NullLiteral node) => notAChild(node); 794 ASTNode visitNullLiteral(NullLiteral node) => notAChild(node);
795 795
796 ASTNode visitParenthesizedExpression(ParenthesizedExpression node) { 796 ASTNode visitParenthesizedExpression(ParenthesizedExpression node) {
797 if (identical(_oldNode, node.expression)) { 797 if (identical(_oldNode, node.expression)) {
798 return _parser.parseExpression2(); 798 return _parser.parseExpression3();
799 } 799 }
800 return notAChild(node); 800 return notAChild(node);
801 } 801 }
802 802
803 ASTNode visitPartDirective(PartDirective node) { 803 ASTNode visitPartDirective(PartDirective node) {
804 if (identical(_oldNode, node.documentationComment)) { 804 if (identical(_oldNode, node.documentationComment)) {
805 throw new InsufficientContextException(); 805 throw new InsufficientContextException();
806 } else if (node.metadata.contains(_oldNode)) { 806 } else if (node.metadata.contains(_oldNode)) {
807 return _parser.parseAnnotation(); 807 return _parser.parseAnnotation();
808 } else if (identical(_oldNode, node.uri)) { 808 } else if (identical(_oldNode, node.uri)) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 } else if (identical(_oldNode, node.argumentList)) { 860 } else if (identical(_oldNode, node.argumentList)) {
861 return _parser.parseArgumentList(); 861 return _parser.parseArgumentList();
862 } 862 }
863 return notAChild(node); 863 return notAChild(node);
864 } 864 }
865 865
866 ASTNode visitRethrowExpression(RethrowExpression node) => notAChild(node); 866 ASTNode visitRethrowExpression(RethrowExpression node) => notAChild(node);
867 867
868 ASTNode visitReturnStatement(ReturnStatement node) { 868 ASTNode visitReturnStatement(ReturnStatement node) {
869 if (identical(_oldNode, node.expression)) { 869 if (identical(_oldNode, node.expression)) {
870 return _parser.parseExpression2(); 870 return _parser.parseExpression3();
871 } 871 }
872 return notAChild(node); 872 return notAChild(node);
873 } 873 }
874 874
875 ASTNode visitScriptTag(ScriptTag node) => notAChild(node); 875 ASTNode visitScriptTag(ScriptTag node) => notAChild(node);
876 876
877 ASTNode visitShowCombinator(ShowCombinator node) { 877 ASTNode visitShowCombinator(ShowCombinator node) {
878 if (node.shownNames.contains(_oldNode)) { 878 if (node.shownNames.contains(_oldNode)) {
879 return _parser.parseSimpleIdentifier(); 879 return _parser.parseSimpleIdentifier();
880 } 880 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 } 913 }
914 return notAChild(node); 914 return notAChild(node);
915 } 915 }
916 916
917 ASTNode visitSuperExpression(SuperExpression node) => notAChild(node); 917 ASTNode visitSuperExpression(SuperExpression node) => notAChild(node);
918 918
919 ASTNode visitSwitchCase(SwitchCase node) { 919 ASTNode visitSwitchCase(SwitchCase node) {
920 if (node.labels.contains(_oldNode)) { 920 if (node.labels.contains(_oldNode)) {
921 return _parser.parseLabel(); 921 return _parser.parseLabel();
922 } else if (identical(_oldNode, node.expression)) { 922 } else if (identical(_oldNode, node.expression)) {
923 return _parser.parseExpression2(); 923 return _parser.parseExpression3();
924 } else if (node.statements.contains(_oldNode)) { 924 } else if (node.statements.contains(_oldNode)) {
925 return _parser.parseStatement2(); 925 return _parser.parseStatement2();
926 } 926 }
927 return notAChild(node); 927 return notAChild(node);
928 } 928 }
929 929
930 ASTNode visitSwitchDefault(SwitchDefault node) { 930 ASTNode visitSwitchDefault(SwitchDefault node) {
931 if (node.labels.contains(_oldNode)) { 931 if (node.labels.contains(_oldNode)) {
932 return _parser.parseLabel(); 932 return _parser.parseLabel();
933 } else if (node.statements.contains(_oldNode)) { 933 } else if (node.statements.contains(_oldNode)) {
934 return _parser.parseStatement2(); 934 return _parser.parseStatement2();
935 } 935 }
936 return notAChild(node); 936 return notAChild(node);
937 } 937 }
938 938
939 ASTNode visitSwitchStatement(SwitchStatement node) { 939 ASTNode visitSwitchStatement(SwitchStatement node) {
940 if (identical(_oldNode, node.expression)) { 940 if (identical(_oldNode, node.expression)) {
941 return _parser.parseExpression2(); 941 return _parser.parseExpression3();
942 } else if (node.members.contains(_oldNode)) { 942 } else if (node.members.contains(_oldNode)) {
943 throw new InsufficientContextException(); 943 throw new InsufficientContextException();
944 } 944 }
945 return notAChild(node); 945 return notAChild(node);
946 } 946 }
947 947
948 ASTNode visitSymbolLiteral(SymbolLiteral node) => notAChild(node); 948 ASTNode visitSymbolLiteral(SymbolLiteral node) => notAChild(node);
949 949
950 ASTNode visitThisExpression(ThisExpression node) => notAChild(node); 950 ASTNode visitThisExpression(ThisExpression node) => notAChild(node);
951 951
952 ASTNode visitThrowExpression(ThrowExpression node) { 952 ASTNode visitThrowExpression(ThrowExpression node) {
953 if (identical(_oldNode, node.expression)) { 953 if (identical(_oldNode, node.expression)) {
954 if (isCascadeAllowed2(node)) { 954 if (isCascadeAllowed2(node)) {
955 return _parser.parseExpression2(); 955 return _parser.parseExpression3();
956 } 956 }
957 return _parser.parseExpressionWithoutCascade(); 957 return _parser.parseExpressionWithoutCascade();
958 } 958 }
959 return notAChild(node); 959 return notAChild(node);
960 } 960 }
961 961
962 ASTNode visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { 962 ASTNode visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
963 if (identical(_oldNode, node.documentationComment)) { 963 if (identical(_oldNode, node.documentationComment)) {
964 throw new InsufficientContextException(); 964 throw new InsufficientContextException();
965 } else if (node.metadata.contains(_oldNode)) { 965 } else if (node.metadata.contains(_oldNode)) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 1043
1044 ASTNode visitVariableDeclarationStatement(VariableDeclarationStatement node) { 1044 ASTNode visitVariableDeclarationStatement(VariableDeclarationStatement node) {
1045 if (identical(_oldNode, node.variables)) { 1045 if (identical(_oldNode, node.variables)) {
1046 throw new InsufficientContextException(); 1046 throw new InsufficientContextException();
1047 } 1047 }
1048 return notAChild(node); 1048 return notAChild(node);
1049 } 1049 }
1050 1050
1051 ASTNode visitWhileStatement(WhileStatement node) { 1051 ASTNode visitWhileStatement(WhileStatement node) {
1052 if (identical(_oldNode, node.condition)) { 1052 if (identical(_oldNode, node.condition)) {
1053 return _parser.parseExpression2(); 1053 return _parser.parseExpression3();
1054 } else if (identical(_oldNode, node.body)) { 1054 } else if (identical(_oldNode, node.body)) {
1055 return _parser.parseStatement2(); 1055 return _parser.parseStatement2();
1056 } 1056 }
1057 return notAChild(node); 1057 return notAChild(node);
1058 } 1058 }
1059 1059
1060 ASTNode visitWithClause(WithClause node) { 1060 ASTNode visitWithClause(WithClause node) {
1061 if (node.mixinTypes.contains(node)) { 1061 if (node.mixinTypes.contains(node)) {
1062 return _parser.parseTypeName(); 1062 return _parser.parseTypeName();
1063 } 1063 }
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 * Parse an expression, starting with the given token. 1375 * Parse an expression, starting with the given token.
1376 * 1376 *
1377 * @param token the first token of the expression 1377 * @param token the first token of the expression
1378 * @return the expression that was parsed, or `null` if the tokens do not repr esent a 1378 * @return the expression that was parsed, or `null` if the tokens do not repr esent a
1379 * recognizable expression 1379 * recognizable expression
1380 */ 1380 */
1381 Expression parseExpression(Token token) { 1381 Expression parseExpression(Token token) {
1382 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.Parser.parseExpression"); 1382 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.Parser.parseExpression");
1383 try { 1383 try {
1384 _currentToken = token; 1384 _currentToken = token;
1385 return parseExpression2(); 1385 return parseExpression3();
1386 } finally { 1386 } finally {
1387 instrumentation.log(); 1387 instrumentation.log();
1388 } 1388 }
1389 } 1389 }
1390 1390
1391 /** 1391 /**
1392 * Parse a statement, starting with the given token. 1392 * Parse a statement, starting with the given token.
1393 * 1393 *
1394 * @param token the first token of the statement 1394 * @param token the first token of the statement
1395 * @return the statement that was parsed, or `null` if the tokens do not repre sent a 1395 * @return the statement that was parsed, or `null` if the tokens do not repre sent a
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 * | expression 1466 * | expression
1467 * 1467 *
1468 * namedArgument ::= 1468 * namedArgument ::=
1469 * label expression 1469 * label expression
1470 * </pre> 1470 * </pre>
1471 * 1471 *
1472 * @return the argument that was parsed 1472 * @return the argument that was parsed
1473 */ 1473 */
1474 Expression parseArgument() { 1474 Expression parseArgument() {
1475 if (matchesIdentifier() && matches4(peek(), TokenType.COLON)) { 1475 if (matchesIdentifier() && matches4(peek(), TokenType.COLON)) {
1476 return new NamedExpression(parseLabel(), parseExpression2()); 1476 return new NamedExpression(parseLabel(), parseExpression3());
1477 } else { 1477 } else {
1478 return parseExpression2(); 1478 return parseExpression3();
1479 } 1479 }
1480 } 1480 }
1481 1481
1482 /** 1482 /**
1483 * Parse a list of arguments. 1483 * Parse a list of arguments.
1484 * 1484 *
1485 * <pre> 1485 * <pre>
1486 * arguments ::= 1486 * arguments ::=
1487 * '(' argumentList? ')' 1487 * '(' argumentList? ')'
1488 * 1488 *
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1838 * 1838 *
1839 * <pre> 1839 * <pre>
1840 * expression ::= 1840 * expression ::=
1841 * assignableExpression assignmentOperator expression 1841 * assignableExpression assignmentOperator expression
1842 * | conditionalExpression cascadeSection* 1842 * | conditionalExpression cascadeSection*
1843 * | throwExpression 1843 * | throwExpression
1844 * </pre> 1844 * </pre>
1845 * 1845 *
1846 * @return the expression that was parsed 1846 * @return the expression that was parsed
1847 */ 1847 */
1848 Expression parseExpression2() { 1848 Expression parseExpression3() {
1849 if (matches(Keyword.THROW)) { 1849 if (matches(Keyword.THROW)) {
1850 return parseThrowExpression(); 1850 return parseThrowExpression();
1851 } else if (matches(Keyword.RETHROW)) { 1851 } else if (matches(Keyword.RETHROW)) {
1852 return parseRethrowExpression(); 1852 return parseRethrowExpression();
1853 } 1853 }
1854 Expression expression = parseConditionalExpression(); 1854 Expression expression = parseConditionalExpression();
1855 TokenType tokenType = _currentToken.type; 1855 TokenType tokenType = _currentToken.type;
1856 if (identical(tokenType, TokenType.PERIOD_PERIOD)) { 1856 if (identical(tokenType, TokenType.PERIOD_PERIOD)) {
1857 List<Expression> cascadeSections = new List<Expression>(); 1857 List<Expression> cascadeSections = new List<Expression>();
1858 while (identical(tokenType, TokenType.PERIOD_PERIOD)) { 1858 while (identical(tokenType, TokenType.PERIOD_PERIOD)) {
1859 Expression section = parseCascadeSection(); 1859 Expression section = parseCascadeSection();
1860 if (section != null) { 1860 if (section != null) {
1861 cascadeSections.add(section); 1861 cascadeSections.add(section);
1862 } 1862 }
1863 tokenType = _currentToken.type; 1863 tokenType = _currentToken.type;
1864 } 1864 }
1865 return new CascadeExpression(expression, cascadeSections); 1865 return new CascadeExpression(expression, cascadeSections);
1866 } else if (tokenType.isAssignmentOperator) { 1866 } else if (tokenType.isAssignmentOperator) {
1867 Token operator = andAdvance; 1867 Token operator = andAdvance;
1868 ensureAssignable(expression); 1868 ensureAssignable(expression);
1869 return new AssignmentExpression(expression, operator, parseExpression2()); 1869 return new AssignmentExpression(expression, operator, parseExpression3());
1870 } 1870 }
1871 return expression; 1871 return expression;
1872 } 1872 }
1873 1873
1874 /** 1874 /**
1875 * Parse an expression that does not contain any cascades. 1875 * Parse an expression that does not contain any cascades.
1876 * 1876 *
1877 * <pre> 1877 * <pre>
1878 * expressionWithoutCascade ::= 1878 * expressionWithoutCascade ::=
1879 * assignableExpression assignmentOperator expressionWithoutCascade 1879 * assignableExpression assignmentOperator expressionWithoutCascade
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 * Parse a map literal entry. 2145 * Parse a map literal entry.
2146 * 2146 *
2147 * <pre> 2147 * <pre>
2148 * mapLiteralEntry ::= 2148 * mapLiteralEntry ::=
2149 * expression ':' expression 2149 * expression ':' expression
2150 * </pre> 2150 * </pre>
2151 * 2151 *
2152 * @return the map literal entry that was parsed 2152 * @return the map literal entry that was parsed
2153 */ 2153 */
2154 MapLiteralEntry parseMapLiteralEntry() { 2154 MapLiteralEntry parseMapLiteralEntry() {
2155 Expression key = parseExpression2(); 2155 Expression key = parseExpression3();
2156 Token separator = expect2(TokenType.COLON); 2156 Token separator = expect2(TokenType.COLON);
2157 Expression value = parseExpression2(); 2157 Expression value = parseExpression3();
2158 return new MapLiteralEntry(key, separator, value); 2158 return new MapLiteralEntry(key, separator, value);
2159 } 2159 }
2160 2160
2161 /** 2161 /**
2162 * Parse a normal formal parameter. 2162 * Parse a normal formal parameter.
2163 * 2163 *
2164 * <pre> 2164 * <pre>
2165 * normalFormalParameter ::= 2165 * normalFormalParameter ::=
2166 * functionSignature 2166 * functionSignature
2167 * | fieldFormalParameter 2167 * | fieldFormalParameter
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
3176 * <pre> 3176 * <pre>
3177 * assertStatement ::= 3177 * assertStatement ::=
3178 * 'assert' '(' conditionalExpression ')' ';' 3178 * 'assert' '(' conditionalExpression ')' ';'
3179 * </pre> 3179 * </pre>
3180 * 3180 *
3181 * @return the assert statement 3181 * @return the assert statement
3182 */ 3182 */
3183 AssertStatement parseAssertStatement() { 3183 AssertStatement parseAssertStatement() {
3184 Token keyword = expect(Keyword.ASSERT); 3184 Token keyword = expect(Keyword.ASSERT);
3185 Token leftParen = expect2(TokenType.OPEN_PAREN); 3185 Token leftParen = expect2(TokenType.OPEN_PAREN);
3186 Expression expression = parseExpression2(); 3186 Expression expression = parseExpression3();
3187 if (expression is AssignmentExpression) { 3187 if (expression is AssignmentExpression) {
3188 reportError10(ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT, expression, []); 3188 reportError10(ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT, expression, []);
3189 } else if (expression is CascadeExpression) { 3189 } else if (expression is CascadeExpression) {
3190 reportError10(ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE, expression, [] ); 3190 reportError10(ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE, expression, [] );
3191 } else if (expression is ThrowExpression) { 3191 } else if (expression is ThrowExpression) {
3192 reportError10(ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW, expression, []); 3192 reportError10(ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW, expression, []);
3193 } else if (expression is RethrowExpression) { 3193 } else if (expression is RethrowExpression) {
3194 reportError10(ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW, expression, [] ); 3194 reportError10(ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW, expression, [] );
3195 } 3195 }
3196 Token rightParen = expect2(TokenType.CLOSE_PAREN); 3196 Token rightParen = expect2(TokenType.CLOSE_PAREN);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
3258 * | '.' identifier 3258 * | '.' identifier
3259 * </pre> 3259 * </pre>
3260 * 3260 *
3261 * @param prefix the expression preceding the selector 3261 * @param prefix the expression preceding the selector
3262 * @param optional `true` if the selector is optional 3262 * @param optional `true` if the selector is optional
3263 * @return the assignable selector that was parsed 3263 * @return the assignable selector that was parsed
3264 */ 3264 */
3265 Expression parseAssignableSelector(Expression prefix, bool optional) { 3265 Expression parseAssignableSelector(Expression prefix, bool optional) {
3266 if (matches5(TokenType.OPEN_SQUARE_BRACKET)) { 3266 if (matches5(TokenType.OPEN_SQUARE_BRACKET)) {
3267 Token leftBracket = andAdvance; 3267 Token leftBracket = andAdvance;
3268 Expression index = parseExpression2(); 3268 Expression index = parseExpression3();
3269 Token rightBracket = expect2(TokenType.CLOSE_SQUARE_BRACKET); 3269 Token rightBracket = expect2(TokenType.CLOSE_SQUARE_BRACKET);
3270 return new IndexExpression.forTarget(prefix, leftBracket, index, rightBrac ket); 3270 return new IndexExpression.forTarget(prefix, leftBracket, index, rightBrac ket);
3271 } else if (matches5(TokenType.PERIOD)) { 3271 } else if (matches5(TokenType.PERIOD)) {
3272 Token period = andAdvance; 3272 Token period = andAdvance;
3273 return new PropertyAccess(prefix, period, parseSimpleIdentifier()); 3273 return new PropertyAccess(prefix, period, parseSimpleIdentifier());
3274 } else { 3274 } else {
3275 if (!optional) { 3275 if (!optional) {
3276 reportError11(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, []); 3276 reportError11(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, []);
3277 } 3277 }
3278 return prefix; 3278 return prefix;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
3370 * @return the expression representing the cascaded method invocation 3370 * @return the expression representing the cascaded method invocation
3371 */ 3371 */
3372 Expression parseCascadeSection() { 3372 Expression parseCascadeSection() {
3373 Token period = expect2(TokenType.PERIOD_PERIOD); 3373 Token period = expect2(TokenType.PERIOD_PERIOD);
3374 Expression expression = null; 3374 Expression expression = null;
3375 SimpleIdentifier functionName = null; 3375 SimpleIdentifier functionName = null;
3376 if (matchesIdentifier()) { 3376 if (matchesIdentifier()) {
3377 functionName = parseSimpleIdentifier(); 3377 functionName = parseSimpleIdentifier();
3378 } else if (identical(_currentToken.type, TokenType.OPEN_SQUARE_BRACKET)) { 3378 } else if (identical(_currentToken.type, TokenType.OPEN_SQUARE_BRACKET)) {
3379 Token leftBracket = andAdvance; 3379 Token leftBracket = andAdvance;
3380 Expression index = parseExpression2(); 3380 Expression index = parseExpression3();
3381 Token rightBracket = expect2(TokenType.CLOSE_SQUARE_BRACKET); 3381 Token rightBracket = expect2(TokenType.CLOSE_SQUARE_BRACKET);
3382 expression = new IndexExpression.forCascade(period, leftBracket, index, ri ghtBracket); 3382 expression = new IndexExpression.forCascade(period, leftBracket, index, ri ghtBracket);
3383 period = null; 3383 period = null;
3384 } else { 3384 } else {
3385 reportError12(ParserErrorCode.MISSING_IDENTIFIER, _currentToken, [_current Token.lexeme]); 3385 reportError12(ParserErrorCode.MISSING_IDENTIFIER, _currentToken, [_current Token.lexeme]);
3386 functionName = createSyntheticIdentifier(); 3386 functionName = createSyntheticIdentifier();
3387 } 3387 }
3388 if (identical(_currentToken.type, TokenType.OPEN_PAREN)) { 3388 if (identical(_currentToken.type, TokenType.OPEN_PAREN)) {
3389 while (identical(_currentToken.type, TokenType.OPEN_PAREN)) { 3389 while (identical(_currentToken.type, TokenType.OPEN_PAREN)) {
3390 if (functionName != null) { 3390 if (functionName != null) {
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
4077 * @return the do statement that was parsed 4077 * @return the do statement that was parsed
4078 */ 4078 */
4079 Statement parseDoStatement() { 4079 Statement parseDoStatement() {
4080 bool wasInLoop = _inLoop; 4080 bool wasInLoop = _inLoop;
4081 _inLoop = true; 4081 _inLoop = true;
4082 try { 4082 try {
4083 Token doKeyword = expect(Keyword.DO); 4083 Token doKeyword = expect(Keyword.DO);
4084 Statement body = parseStatement2(); 4084 Statement body = parseStatement2();
4085 Token whileKeyword = expect(Keyword.WHILE); 4085 Token whileKeyword = expect(Keyword.WHILE);
4086 Token leftParenthesis = expect2(TokenType.OPEN_PAREN); 4086 Token leftParenthesis = expect2(TokenType.OPEN_PAREN);
4087 Expression condition = parseExpression2(); 4087 Expression condition = parseExpression3();
4088 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); 4088 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN);
4089 Token semicolon = expect2(TokenType.SEMICOLON); 4089 Token semicolon = expect2(TokenType.SEMICOLON);
4090 return new DoStatement(doKeyword, body, whileKeyword, leftParenthesis, con dition, rightParenthesis, semicolon); 4090 return new DoStatement(doKeyword, body, whileKeyword, leftParenthesis, con dition, rightParenthesis, semicolon);
4091 } finally { 4091 } finally {
4092 _inLoop = wasInLoop; 4092 _inLoop = wasInLoop;
4093 } 4093 }
4094 } 4094 }
4095 4095
4096 /** 4096 /**
4097 * Parse an empty statement. 4097 * Parse an empty statement.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
4159 * 4159 *
4160 * <pre> 4160 * <pre>
4161 * expressionList ::= 4161 * expressionList ::=
4162 * expression (',' expression)* 4162 * expression (',' expression)*
4163 * </pre> 4163 * </pre>
4164 * 4164 *
4165 * @return the expression that was parsed 4165 * @return the expression that was parsed
4166 */ 4166 */
4167 List<Expression> parseExpressionList() { 4167 List<Expression> parseExpressionList() {
4168 List<Expression> expressions = new List<Expression>(); 4168 List<Expression> expressions = new List<Expression>();
4169 expressions.add(parseExpression2()); 4169 expressions.add(parseExpression3());
4170 while (optional(TokenType.COMMA)) { 4170 while (optional(TokenType.COMMA)) {
4171 expressions.add(parseExpression2()); 4171 expressions.add(parseExpression3());
4172 } 4172 }
4173 return expressions; 4173 return expressions;
4174 } 4174 }
4175 4175
4176 /** 4176 /**
4177 * Parse the 'final', 'const', 'var' or type preceding a variable declaration. 4177 * Parse the 'final', 'const', 'var' or type preceding a variable declaration.
4178 * 4178 *
4179 * <pre> 4179 * <pre>
4180 * finalConstVarOrType ::= 4180 * finalConstVarOrType ::=
4181 * | 'final' type? 4181 * | 'final' type?
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4220 * </pre> 4220 * </pre>
4221 * 4221 *
4222 * @param kind the kind of parameter being expected based on the presence or a bsence of group 4222 * @param kind the kind of parameter being expected based on the presence or a bsence of group
4223 * delimiters 4223 * delimiters
4224 * @return the formal parameter that was parsed 4224 * @return the formal parameter that was parsed
4225 */ 4225 */
4226 FormalParameter parseFormalParameter(ParameterKind kind) { 4226 FormalParameter parseFormalParameter(ParameterKind kind) {
4227 NormalFormalParameter parameter = parseNormalFormalParameter(); 4227 NormalFormalParameter parameter = parseNormalFormalParameter();
4228 if (matches5(TokenType.EQ)) { 4228 if (matches5(TokenType.EQ)) {
4229 Token seperator = andAdvance; 4229 Token seperator = andAdvance;
4230 Expression defaultValue = parseExpression2(); 4230 Expression defaultValue = parseExpression3();
4231 if (identical(kind, ParameterKind.NAMED)) { 4231 if (identical(kind, ParameterKind.NAMED)) {
4232 reportError12(ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER, seper ator, []); 4232 reportError12(ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER, seper ator, []);
4233 } else if (identical(kind, ParameterKind.REQUIRED)) { 4233 } else if (identical(kind, ParameterKind.REQUIRED)) {
4234 reportError10(ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, parame ter, []); 4234 reportError10(ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, parame ter, []);
4235 } 4235 }
4236 return new DefaultFormalParameter(parameter, kind, seperator, defaultValue ); 4236 return new DefaultFormalParameter(parameter, kind, seperator, defaultValue );
4237 } else if (matches5(TokenType.COLON)) { 4237 } else if (matches5(TokenType.COLON)) {
4238 Token seperator = andAdvance; 4238 Token seperator = andAdvance;
4239 Expression defaultValue = parseExpression2(); 4239 Expression defaultValue = parseExpression3();
4240 if (identical(kind, ParameterKind.POSITIONAL)) { 4240 if (identical(kind, ParameterKind.POSITIONAL)) {
4241 reportError12(ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER, seperator, []); 4241 reportError12(ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER, seperator, []);
4242 } else if (identical(kind, ParameterKind.REQUIRED)) { 4242 } else if (identical(kind, ParameterKind.REQUIRED)) {
4243 reportError10(ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, parameter, []); 4243 reportError10(ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, parameter, []);
4244 } 4244 }
4245 return new DefaultFormalParameter(parameter, kind, seperator, defaultValue ); 4245 return new DefaultFormalParameter(parameter, kind, seperator, defaultValue );
4246 } else if (kind != ParameterKind.REQUIRED) { 4246 } else if (kind != ParameterKind.REQUIRED) {
4247 return new DefaultFormalParameter(parameter, kind, null, null); 4247 return new DefaultFormalParameter(parameter, kind, null, null);
4248 } 4248 }
4249 return parameter; 4249 return parameter;
(...skipping 29 matching lines...) Expand all
4279 if (!matches5(TokenType.SEMICOLON)) { 4279 if (!matches5(TokenType.SEMICOLON)) {
4280 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); 4280 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata();
4281 if (matchesIdentifier() && matches3(peek(), Keyword.IN)) { 4281 if (matchesIdentifier() && matches3(peek(), Keyword.IN)) {
4282 List<VariableDeclaration> variables = new List<VariableDeclaration>(); 4282 List<VariableDeclaration> variables = new List<VariableDeclaration>();
4283 SimpleIdentifier variableName = parseSimpleIdentifier(); 4283 SimpleIdentifier variableName = parseSimpleIdentifier();
4284 variables.add(new VariableDeclaration(null, null, variableName, null, null)); 4284 variables.add(new VariableDeclaration(null, null, variableName, null, null));
4285 variableList = new VariableDeclarationList(commentAndMetadata.comment, commentAndMetadata.metadata, null, null, variables); 4285 variableList = new VariableDeclarationList(commentAndMetadata.comment, commentAndMetadata.metadata, null, null, variables);
4286 } else if (isInitializedVariableDeclaration()) { 4286 } else if (isInitializedVariableDeclaration()) {
4287 variableList = parseVariableDeclarationList(commentAndMetadata); 4287 variableList = parseVariableDeclarationList(commentAndMetadata);
4288 } else { 4288 } else {
4289 initialization = parseExpression2(); 4289 initialization = parseExpression3();
4290 } 4290 }
4291 if (matches(Keyword.IN)) { 4291 if (matches(Keyword.IN)) {
4292 DeclaredIdentifier loopVariable = null; 4292 DeclaredIdentifier loopVariable = null;
4293 SimpleIdentifier identifier = null; 4293 SimpleIdentifier identifier = null;
4294 if (variableList == null) { 4294 if (variableList == null) {
4295 reportError11(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []); 4295 reportError11(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []);
4296 } else { 4296 } else {
4297 NodeList<VariableDeclaration> variables = variableList.variables; 4297 NodeList<VariableDeclaration> variables = variableList.variables;
4298 if (variables.length > 1) { 4298 if (variables.length > 1) {
4299 reportError11(ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, [var iables.length.toString()]); 4299 reportError11(ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, [var iables.length.toString()]);
4300 } 4300 }
4301 VariableDeclaration variable = variables[0]; 4301 VariableDeclaration variable = variables[0];
4302 if (variable.initializer != null) { 4302 if (variable.initializer != null) {
4303 reportError11(ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH, [] ); 4303 reportError11(ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH, [] );
4304 } 4304 }
4305 Token keyword = variableList.keyword; 4305 Token keyword = variableList.keyword;
4306 TypeName type = variableList.type; 4306 TypeName type = variableList.type;
4307 if (keyword != null || type != null) { 4307 if (keyword != null || type != null) {
4308 loopVariable = new DeclaredIdentifier(commentAndMetadata.comment, commentAndMetadata.metadata, keyword, type, variable.name); 4308 loopVariable = new DeclaredIdentifier(commentAndMetadata.comment, commentAndMetadata.metadata, keyword, type, variable.name);
4309 } else { 4309 } else {
4310 if (!commentAndMetadata.metadata.isEmpty) { 4310 if (!commentAndMetadata.metadata.isEmpty) {
4311 } 4311 }
4312 identifier = variable.name; 4312 identifier = variable.name;
4313 } 4313 }
4314 } 4314 }
4315 Token inKeyword = expect(Keyword.IN); 4315 Token inKeyword = expect(Keyword.IN);
4316 Expression iterator = parseExpression2(); 4316 Expression iterator = parseExpression3();
4317 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); 4317 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN);
4318 Statement body = parseStatement2(); 4318 Statement body = parseStatement2();
4319 if (loopVariable == null) { 4319 if (loopVariable == null) {
4320 return new ForEachStatement.con2(forKeyword, leftParenthesis, identi fier, inKeyword, iterator, rightParenthesis, body); 4320 return new ForEachStatement.con2(forKeyword, leftParenthesis, identi fier, inKeyword, iterator, rightParenthesis, body);
4321 } 4321 }
4322 return new ForEachStatement.con1(forKeyword, leftParenthesis, loopVari able, inKeyword, iterator, rightParenthesis, body); 4322 return new ForEachStatement.con1(forKeyword, leftParenthesis, loopVari able, inKeyword, iterator, rightParenthesis, body);
4323 } 4323 }
4324 } 4324 }
4325 Token leftSeparator = expect2(TokenType.SEMICOLON); 4325 Token leftSeparator = expect2(TokenType.SEMICOLON);
4326 Expression condition = null; 4326 Expression condition = null;
4327 if (!matches5(TokenType.SEMICOLON)) { 4327 if (!matches5(TokenType.SEMICOLON)) {
4328 condition = parseExpression2(); 4328 condition = parseExpression3();
4329 } 4329 }
4330 Token rightSeparator = expect2(TokenType.SEMICOLON); 4330 Token rightSeparator = expect2(TokenType.SEMICOLON);
4331 List<Expression> updaters = null; 4331 List<Expression> updaters = null;
4332 if (!matches5(TokenType.CLOSE_PAREN)) { 4332 if (!matches5(TokenType.CLOSE_PAREN)) {
4333 updaters = parseExpressionList(); 4333 updaters = parseExpressionList();
4334 } 4334 }
4335 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); 4335 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN);
4336 Statement body = parseStatement2(); 4336 Statement body = parseStatement2();
4337 return new ForStatement(forKeyword, leftParenthesis, variableList, initial ization, leftSeparator, condition, rightSeparator, updaters, rightParenthesis, b ody); 4337 return new ForStatement(forKeyword, leftParenthesis, variableList, initial ization, leftSeparator, condition, rightSeparator, updaters, rightParenthesis, b ody);
4338 } finally { 4338 } finally {
(...skipping 26 matching lines...) Expand all
4365 _inLoop = false; 4365 _inLoop = false;
4366 _inSwitch = false; 4366 _inSwitch = false;
4367 try { 4367 try {
4368 if (matches5(TokenType.SEMICOLON)) { 4368 if (matches5(TokenType.SEMICOLON)) {
4369 if (!mayBeEmpty) { 4369 if (!mayBeEmpty) {
4370 reportError11(emptyErrorCode, []); 4370 reportError11(emptyErrorCode, []);
4371 } 4371 }
4372 return new EmptyFunctionBody(andAdvance); 4372 return new EmptyFunctionBody(andAdvance);
4373 } else if (matches5(TokenType.FUNCTION)) { 4373 } else if (matches5(TokenType.FUNCTION)) {
4374 Token functionDefinition = andAdvance; 4374 Token functionDefinition = andAdvance;
4375 Expression expression = parseExpression2(); 4375 Expression expression = parseExpression3();
4376 Token semicolon = null; 4376 Token semicolon = null;
4377 if (!inExpression) { 4377 if (!inExpression) {
4378 semicolon = expect2(TokenType.SEMICOLON); 4378 semicolon = expect2(TokenType.SEMICOLON);
4379 } 4379 }
4380 if (!_parseFunctionBodies) { 4380 if (!_parseFunctionBodies) {
4381 return new EmptyFunctionBody(createSyntheticToken2(TokenType.SEMICOLON )); 4381 return new EmptyFunctionBody(createSyntheticToken2(TokenType.SEMICOLON ));
4382 } 4382 }
4383 return new ExpressionFunctionBody(functionDefinition, expression, semico lon); 4383 return new ExpressionFunctionBody(functionDefinition, expression, semico lon);
4384 } else if (matches5(TokenType.OPEN_CURLY_BRACKET)) { 4384 } else if (matches5(TokenType.OPEN_CURLY_BRACKET)) {
4385 if (!_parseFunctionBodies) { 4385 if (!_parseFunctionBodies) {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
4593 * <pre> 4593 * <pre>
4594 * ifStatement ::= 4594 * ifStatement ::=
4595 * 'if' '(' expression ')' statement ('else' statement)? 4595 * 'if' '(' expression ')' statement ('else' statement)?
4596 * </pre> 4596 * </pre>
4597 * 4597 *
4598 * @return the if statement that was parsed 4598 * @return the if statement that was parsed
4599 */ 4599 */
4600 Statement parseIfStatement() { 4600 Statement parseIfStatement() {
4601 Token ifKeyword = expect(Keyword.IF); 4601 Token ifKeyword = expect(Keyword.IF);
4602 Token leftParenthesis = expect2(TokenType.OPEN_PAREN); 4602 Token leftParenthesis = expect2(TokenType.OPEN_PAREN);
4603 Expression condition = parseExpression2(); 4603 Expression condition = parseExpression3();
4604 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); 4604 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN);
4605 Statement thenStatement = parseStatement2(); 4605 Statement thenStatement = parseStatement2();
4606 Token elseKeyword = null; 4606 Token elseKeyword = null;
4607 Statement elseStatement = null; 4607 Statement elseStatement = null;
4608 if (matches(Keyword.ELSE)) { 4608 if (matches(Keyword.ELSE)) {
4609 elseKeyword = andAdvance; 4609 elseKeyword = andAdvance;
4610 elseStatement = parseStatement2(); 4610 elseStatement = parseStatement2();
4611 } 4611 }
4612 return new IfStatement(ifKeyword, leftParenthesis, condition, rightParenthes is, thenStatement, elseKeyword, elseStatement); 4612 return new IfStatement(ifKeyword, leftParenthesis, condition, rightParenthes is, thenStatement, elseKeyword, elseStatement);
4613 } 4613 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
4750 leftBracket.setNext(rightBracket); 4750 leftBracket.setNext(rightBracket);
4751 _currentToken.previous.setNext(leftBracket); 4751 _currentToken.previous.setNext(leftBracket);
4752 _currentToken = _currentToken.next; 4752 _currentToken = _currentToken.next;
4753 return new ListLiteral(modifier, typeArguments, leftBracket, null, rightBr acket); 4753 return new ListLiteral(modifier, typeArguments, leftBracket, null, rightBr acket);
4754 } 4754 }
4755 Token leftBracket = expect2(TokenType.OPEN_SQUARE_BRACKET); 4755 Token leftBracket = expect2(TokenType.OPEN_SQUARE_BRACKET);
4756 if (matches5(TokenType.CLOSE_SQUARE_BRACKET)) { 4756 if (matches5(TokenType.CLOSE_SQUARE_BRACKET)) {
4757 return new ListLiteral(modifier, typeArguments, leftBracket, null, andAdva nce); 4757 return new ListLiteral(modifier, typeArguments, leftBracket, null, andAdva nce);
4758 } 4758 }
4759 List<Expression> elements = new List<Expression>(); 4759 List<Expression> elements = new List<Expression>();
4760 elements.add(parseExpression2()); 4760 elements.add(parseExpression3());
4761 while (optional(TokenType.COMMA)) { 4761 while (optional(TokenType.COMMA)) {
4762 if (matches5(TokenType.CLOSE_SQUARE_BRACKET)) { 4762 if (matches5(TokenType.CLOSE_SQUARE_BRACKET)) {
4763 return new ListLiteral(modifier, typeArguments, leftBracket, elements, a ndAdvance); 4763 return new ListLiteral(modifier, typeArguments, leftBracket, elements, a ndAdvance);
4764 } 4764 }
4765 elements.add(parseExpression2()); 4765 elements.add(parseExpression3());
4766 } 4766 }
4767 Token rightBracket = expect2(TokenType.CLOSE_SQUARE_BRACKET); 4767 Token rightBracket = expect2(TokenType.CLOSE_SQUARE_BRACKET);
4768 return new ListLiteral(modifier, typeArguments, leftBracket, elements, right Bracket); 4768 return new ListLiteral(modifier, typeArguments, leftBracket, elements, right Bracket);
4769 } 4769 }
4770 4770
4771 /** 4771 /**
4772 * Parse a list or map literal. 4772 * Parse a list or map literal.
4773 * 4773 *
4774 * <pre> 4774 * <pre>
4775 * listOrMapLiteral ::= 4775 * listOrMapLiteral ::=
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
5051 * </pre> 5051 * </pre>
5052 * 5052 *
5053 * @return the non-labeled statement that was parsed 5053 * @return the non-labeled statement that was parsed
5054 */ 5054 */
5055 Statement parseNonLabeledStatement() { 5055 Statement parseNonLabeledStatement() {
5056 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); 5056 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata();
5057 if (matches5(TokenType.OPEN_CURLY_BRACKET)) { 5057 if (matches5(TokenType.OPEN_CURLY_BRACKET)) {
5058 if (matches4(peek(), TokenType.STRING)) { 5058 if (matches4(peek(), TokenType.STRING)) {
5059 Token afterString = skipStringLiteral(_currentToken.next); 5059 Token afterString = skipStringLiteral(_currentToken.next);
5060 if (afterString != null && identical(afterString.type, TokenType.COLON)) { 5060 if (afterString != null && identical(afterString.type, TokenType.COLON)) {
5061 return new ExpressionStatement(parseExpression2(), expect2(TokenType.S EMICOLON)); 5061 return new ExpressionStatement(parseExpression3(), expect2(TokenType.S EMICOLON));
5062 } 5062 }
5063 } 5063 }
5064 return parseBlock(); 5064 return parseBlock();
5065 } else if (matches5(TokenType.KEYWORD) && !(_currentToken as KeywordToken).k eyword.isPseudoKeyword) { 5065 } else if (matches5(TokenType.KEYWORD) && !(_currentToken as KeywordToken).k eyword.isPseudoKeyword) {
5066 Keyword keyword = (_currentToken as KeywordToken).keyword; 5066 Keyword keyword = (_currentToken as KeywordToken).keyword;
5067 if (identical(keyword, Keyword.ASSERT)) { 5067 if (identical(keyword, Keyword.ASSERT)) {
5068 return parseAssertStatement(); 5068 return parseAssertStatement();
5069 } else if (identical(keyword, Keyword.BREAK)) { 5069 } else if (identical(keyword, Keyword.BREAK)) {
5070 return parseBreakStatement(); 5070 return parseBreakStatement();
5071 } else if (identical(keyword, Keyword.CONTINUE)) { 5071 } else if (identical(keyword, Keyword.CONTINUE)) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
5108 } 5108 }
5109 reportError11(ParserErrorCode.MISSING_STATEMENT, []); 5109 reportError11(ParserErrorCode.MISSING_STATEMENT, []);
5110 return new EmptyStatement(createSyntheticToken2(TokenType.SEMICOLON)); 5110 return new EmptyStatement(createSyntheticToken2(TokenType.SEMICOLON));
5111 } 5111 }
5112 } else if (identical(keyword, Keyword.CONST)) { 5112 } else if (identical(keyword, Keyword.CONST)) {
5113 if (matchesAny(peek(), [ 5113 if (matchesAny(peek(), [
5114 TokenType.LT, 5114 TokenType.LT,
5115 TokenType.OPEN_CURLY_BRACKET, 5115 TokenType.OPEN_CURLY_BRACKET,
5116 TokenType.OPEN_SQUARE_BRACKET, 5116 TokenType.OPEN_SQUARE_BRACKET,
5117 TokenType.INDEX])) { 5117 TokenType.INDEX])) {
5118 return new ExpressionStatement(parseExpression2(), expect2(TokenType.S EMICOLON)); 5118 return new ExpressionStatement(parseExpression3(), expect2(TokenType.S EMICOLON));
5119 } else if (matches4(peek(), TokenType.IDENTIFIER)) { 5119 } else if (matches4(peek(), TokenType.IDENTIFIER)) {
5120 Token afterType = skipTypeName(peek()); 5120 Token afterType = skipTypeName(peek());
5121 if (afterType != null) { 5121 if (afterType != null) {
5122 if (matches4(afterType, TokenType.OPEN_PAREN) || (matches4(afterType , TokenType.PERIOD) && matches4(afterType.next, TokenType.IDENTIFIER) && matches 4(afterType.next.next, TokenType.OPEN_PAREN))) { 5122 if (matches4(afterType, TokenType.OPEN_PAREN) || (matches4(afterType , TokenType.PERIOD) && matches4(afterType.next, TokenType.IDENTIFIER) && matches 4(afterType.next.next, TokenType.OPEN_PAREN))) {
5123 return new ExpressionStatement(parseExpression2(), expect2(TokenTy pe.SEMICOLON)); 5123 return new ExpressionStatement(parseExpression3(), expect2(TokenTy pe.SEMICOLON));
5124 } 5124 }
5125 } 5125 }
5126 } 5126 }
5127 return parseVariableDeclarationStatement(commentAndMetadata); 5127 return parseVariableDeclarationStatement(commentAndMetadata);
5128 } else if (identical(keyword, Keyword.NEW) || identical(keyword, Keyword.T RUE) || identical(keyword, Keyword.FALSE) || identical(keyword, Keyword.NULL) || identical(keyword, Keyword.SUPER) || identical(keyword, Keyword.THIS)) { 5128 } else if (identical(keyword, Keyword.NEW) || identical(keyword, Keyword.T RUE) || identical(keyword, Keyword.FALSE) || identical(keyword, Keyword.NULL) || identical(keyword, Keyword.SUPER) || identical(keyword, Keyword.THIS)) {
5129 return new ExpressionStatement(parseExpression2(), expect2(TokenType.SEM ICOLON)); 5129 return new ExpressionStatement(parseExpression3(), expect2(TokenType.SEM ICOLON));
5130 } else { 5130 } else {
5131 reportError11(ParserErrorCode.MISSING_STATEMENT, []); 5131 reportError11(ParserErrorCode.MISSING_STATEMENT, []);
5132 return new EmptyStatement(createSyntheticToken2(TokenType.SEMICOLON)); 5132 return new EmptyStatement(createSyntheticToken2(TokenType.SEMICOLON));
5133 } 5133 }
5134 } else if (matches5(TokenType.SEMICOLON)) { 5134 } else if (matches5(TokenType.SEMICOLON)) {
5135 return parseEmptyStatement(); 5135 return parseEmptyStatement();
5136 } else if (isInitializedVariableDeclaration()) { 5136 } else if (isInitializedVariableDeclaration()) {
5137 return parseVariableDeclarationStatement(commentAndMetadata); 5137 return parseVariableDeclarationStatement(commentAndMetadata);
5138 } else if (isFunctionDeclaration()) { 5138 } else if (isFunctionDeclaration()) {
5139 return parseFunctionDeclarationStatement(); 5139 return parseFunctionDeclarationStatement();
5140 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { 5140 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) {
5141 reportError11(ParserErrorCode.MISSING_STATEMENT, []); 5141 reportError11(ParserErrorCode.MISSING_STATEMENT, []);
5142 return new EmptyStatement(createSyntheticToken2(TokenType.SEMICOLON)); 5142 return new EmptyStatement(createSyntheticToken2(TokenType.SEMICOLON));
5143 } else { 5143 } else {
5144 return new ExpressionStatement(parseExpression2(), expect2(TokenType.SEMIC OLON)); 5144 return new ExpressionStatement(parseExpression3(), expect2(TokenType.SEMIC OLON));
5145 } 5145 }
5146 } 5146 }
5147 5147
5148 /** 5148 /**
5149 * Parse an operator declaration. 5149 * Parse an operator declaration.
5150 * 5150 *
5151 * <pre> 5151 * <pre>
5152 * operatorDeclaration ::= 5152 * operatorDeclaration ::=
5153 * operatorSignature (';' | functionBody) 5153 * operatorSignature (';' | functionBody)
5154 * 5154 *
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
5349 return parsePrefixedIdentifier(); 5349 return parsePrefixedIdentifier();
5350 } else if (matches(Keyword.NEW)) { 5350 } else if (matches(Keyword.NEW)) {
5351 return parseNewExpression(); 5351 return parseNewExpression();
5352 } else if (matches(Keyword.CONST)) { 5352 } else if (matches(Keyword.CONST)) {
5353 return parseConstExpression(); 5353 return parseConstExpression();
5354 } else if (matches5(TokenType.OPEN_PAREN)) { 5354 } else if (matches5(TokenType.OPEN_PAREN)) {
5355 if (isFunctionExpression(_currentToken)) { 5355 if (isFunctionExpression(_currentToken)) {
5356 return parseFunctionExpression(); 5356 return parseFunctionExpression();
5357 } 5357 }
5358 Token leftParenthesis = andAdvance; 5358 Token leftParenthesis = andAdvance;
5359 Expression expression = parseExpression2(); 5359 Expression expression = parseExpression3();
5360 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); 5360 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN);
5361 return new ParenthesizedExpression(leftParenthesis, expression, rightParen thesis); 5361 return new ParenthesizedExpression(leftParenthesis, expression, rightParen thesis);
5362 } else if (matches5(TokenType.LT)) { 5362 } else if (matches5(TokenType.LT)) {
5363 return parseListOrMapLiteral(null); 5363 return parseListOrMapLiteral(null);
5364 } else if (matches5(TokenType.QUESTION)) { 5364 } else if (matches5(TokenType.QUESTION)) {
5365 return parseArgumentDefinitionTest(); 5365 return parseArgumentDefinitionTest();
5366 } else if (matches(Keyword.VOID)) { 5366 } else if (matches(Keyword.VOID)) {
5367 reportError11(ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken.lexeme]); 5367 reportError11(ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken.lexeme]);
5368 advance(); 5368 advance();
5369 return parsePrimaryExpression(); 5369 return parsePrimaryExpression();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
5453 * 'return' expression? ';' 5453 * 'return' expression? ';'
5454 * </pre> 5454 * </pre>
5455 * 5455 *
5456 * @return the return statement that was parsed 5456 * @return the return statement that was parsed
5457 */ 5457 */
5458 Statement parseReturnStatement() { 5458 Statement parseReturnStatement() {
5459 Token returnKeyword = expect(Keyword.RETURN); 5459 Token returnKeyword = expect(Keyword.RETURN);
5460 if (matches5(TokenType.SEMICOLON)) { 5460 if (matches5(TokenType.SEMICOLON)) {
5461 return new ReturnStatement(returnKeyword, null, andAdvance); 5461 return new ReturnStatement(returnKeyword, null, andAdvance);
5462 } 5462 }
5463 Expression expression = parseExpression2(); 5463 Expression expression = parseExpression3();
5464 Token semicolon = expect2(TokenType.SEMICOLON); 5464 Token semicolon = expect2(TokenType.SEMICOLON);
5465 return new ReturnStatement(returnKeyword, expression, semicolon); 5465 return new ReturnStatement(returnKeyword, expression, semicolon);
5466 } 5466 }
5467 5467
5468 /** 5468 /**
5469 * Parse a setter. 5469 * Parse a setter.
5470 * 5470 *
5471 * <pre> 5471 * <pre>
5472 * setter ::= 5472 * setter ::=
5473 * setterSignature functionBody? 5473 * setterSignature functionBody?
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
5550 * 5550 *
5551 * @return the string literal that was parsed 5551 * @return the string literal that was parsed
5552 */ 5552 */
5553 StringInterpolation parseStringInterpolation(Token string) { 5553 StringInterpolation parseStringInterpolation(Token string) {
5554 List<InterpolationElement> elements = new List<InterpolationElement>(); 5554 List<InterpolationElement> elements = new List<InterpolationElement>();
5555 bool hasMore = matches5(TokenType.STRING_INTERPOLATION_EXPRESSION) || matche s5(TokenType.STRING_INTERPOLATION_IDENTIFIER); 5555 bool hasMore = matches5(TokenType.STRING_INTERPOLATION_EXPRESSION) || matche s5(TokenType.STRING_INTERPOLATION_IDENTIFIER);
5556 elements.add(new InterpolationString(string, computeStringValue(string.lexem e, true, !hasMore))); 5556 elements.add(new InterpolationString(string, computeStringValue(string.lexem e, true, !hasMore)));
5557 while (hasMore) { 5557 while (hasMore) {
5558 if (matches5(TokenType.STRING_INTERPOLATION_EXPRESSION)) { 5558 if (matches5(TokenType.STRING_INTERPOLATION_EXPRESSION)) {
5559 Token openToken = andAdvance; 5559 Token openToken = andAdvance;
5560 Expression expression = parseExpression2(); 5560 Expression expression = parseExpression3();
5561 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET); 5561 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET);
5562 elements.add(new InterpolationExpression(openToken, expression, rightBra cket)); 5562 elements.add(new InterpolationExpression(openToken, expression, rightBra cket));
5563 } else { 5563 } else {
5564 Token openToken = andAdvance; 5564 Token openToken = andAdvance;
5565 Expression expression = null; 5565 Expression expression = null;
5566 if (matches(Keyword.THIS)) { 5566 if (matches(Keyword.THIS)) {
5567 expression = new ThisExpression(andAdvance); 5567 expression = new ThisExpression(andAdvance);
5568 } else { 5568 } else {
5569 expression = parseSimpleIdentifier(); 5569 expression = parseSimpleIdentifier();
5570 } 5570 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
5617 * 5617 *
5618 * @return the switch statement that was parsed 5618 * @return the switch statement that was parsed
5619 */ 5619 */
5620 SwitchStatement parseSwitchStatement() { 5620 SwitchStatement parseSwitchStatement() {
5621 bool wasInSwitch = _inSwitch; 5621 bool wasInSwitch = _inSwitch;
5622 _inSwitch = true; 5622 _inSwitch = true;
5623 try { 5623 try {
5624 Set<String> definedLabels = new Set<String>(); 5624 Set<String> definedLabels = new Set<String>();
5625 Token keyword = expect(Keyword.SWITCH); 5625 Token keyword = expect(Keyword.SWITCH);
5626 Token leftParenthesis = expect2(TokenType.OPEN_PAREN); 5626 Token leftParenthesis = expect2(TokenType.OPEN_PAREN);
5627 Expression expression = parseExpression2(); 5627 Expression expression = parseExpression3();
5628 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); 5628 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN);
5629 Token leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET); 5629 Token leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET);
5630 Token defaultKeyword = null; 5630 Token defaultKeyword = null;
5631 List<SwitchMember> members = new List<SwitchMember>(); 5631 List<SwitchMember> members = new List<SwitchMember>();
5632 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET )) { 5632 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET )) {
5633 List<Label> labels = new List<Label>(); 5633 List<Label> labels = new List<Label>();
5634 while (matchesIdentifier() && matches4(peek(), TokenType.COLON)) { 5634 while (matchesIdentifier() && matches4(peek(), TokenType.COLON)) {
5635 SimpleIdentifier identifier = parseSimpleIdentifier(); 5635 SimpleIdentifier identifier = parseSimpleIdentifier();
5636 String label = identifier.token.lexeme; 5636 String label = identifier.token.lexeme;
5637 if (definedLabels.contains(label)) { 5637 if (definedLabels.contains(label)) {
5638 reportError12(ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, i dentifier.token, [label]); 5638 reportError12(ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, i dentifier.token, [label]);
5639 } else { 5639 } else {
5640 definedLabels.add(label); 5640 definedLabels.add(label);
5641 } 5641 }
5642 Token colon = expect2(TokenType.COLON); 5642 Token colon = expect2(TokenType.COLON);
5643 labels.add(new Label(identifier, colon)); 5643 labels.add(new Label(identifier, colon));
5644 } 5644 }
5645 if (matches(Keyword.CASE)) { 5645 if (matches(Keyword.CASE)) {
5646 Token caseKeyword = andAdvance; 5646 Token caseKeyword = andAdvance;
5647 Expression caseExpression = parseExpression2(); 5647 Expression caseExpression = parseExpression3();
5648 Token colon = expect2(TokenType.COLON); 5648 Token colon = expect2(TokenType.COLON);
5649 members.add(new SwitchCase(labels, caseKeyword, caseExpression, colon, parseStatements2())); 5649 members.add(new SwitchCase(labels, caseKeyword, caseExpression, colon, parseStatements2()));
5650 if (defaultKeyword != null) { 5650 if (defaultKeyword != null) {
5651 reportError12(ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE, ca seKeyword, []); 5651 reportError12(ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE, ca seKeyword, []);
5652 } 5652 }
5653 } else if (matches(Keyword.DEFAULT)) { 5653 } else if (matches(Keyword.DEFAULT)) {
5654 if (defaultKeyword != null) { 5654 if (defaultKeyword != null) {
5655 reportError12(ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES, pee k(), []); 5655 reportError12(ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES, pee k(), []);
5656 } 5656 }
5657 defaultKeyword = andAdvance; 5657 defaultKeyword = andAdvance;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
5714 * </pre> 5714 * </pre>
5715 * 5715 *
5716 * @return the throw expression that was parsed 5716 * @return the throw expression that was parsed
5717 */ 5717 */
5718 Expression parseThrowExpression() { 5718 Expression parseThrowExpression() {
5719 Token keyword = expect(Keyword.THROW); 5719 Token keyword = expect(Keyword.THROW);
5720 if (matches5(TokenType.SEMICOLON) || matches5(TokenType.CLOSE_PAREN)) { 5720 if (matches5(TokenType.SEMICOLON) || matches5(TokenType.CLOSE_PAREN)) {
5721 reportError12(ParserErrorCode.MISSING_EXPRESSION_IN_THROW, _currentToken, []); 5721 reportError12(ParserErrorCode.MISSING_EXPRESSION_IN_THROW, _currentToken, []);
5722 return new ThrowExpression(keyword, createSyntheticIdentifier()); 5722 return new ThrowExpression(keyword, createSyntheticIdentifier());
5723 } 5723 }
5724 Expression expression = parseExpression2(); 5724 Expression expression = parseExpression3();
5725 return new ThrowExpression(keyword, expression); 5725 return new ThrowExpression(keyword, expression);
5726 } 5726 }
5727 5727
5728 /** 5728 /**
5729 * Parse a throw expression. 5729 * Parse a throw expression.
5730 * 5730 *
5731 * <pre> 5731 * <pre>
5732 * throwExpressionWithoutCascade ::= 5732 * throwExpressionWithoutCascade ::=
5733 * 'throw' expressionWithoutCascade 5733 * 'throw' expressionWithoutCascade
5734 * </pre> 5734 * </pre>
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
5916 * 5916 *
5917 * @return the variable declaration that was parsed 5917 * @return the variable declaration that was parsed
5918 */ 5918 */
5919 VariableDeclaration parseVariableDeclaration() { 5919 VariableDeclaration parseVariableDeclaration() {
5920 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); 5920 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata();
5921 SimpleIdentifier name = parseSimpleIdentifier(); 5921 SimpleIdentifier name = parseSimpleIdentifier();
5922 Token equals = null; 5922 Token equals = null;
5923 Expression initializer = null; 5923 Expression initializer = null;
5924 if (matches5(TokenType.EQ)) { 5924 if (matches5(TokenType.EQ)) {
5925 equals = andAdvance; 5925 equals = andAdvance;
5926 initializer = parseExpression2(); 5926 initializer = parseExpression3();
5927 } 5927 }
5928 return new VariableDeclaration(commentAndMetadata.comment, commentAndMetadat a.metadata, name, equals, initializer); 5928 return new VariableDeclaration(commentAndMetadata.comment, commentAndMetadat a.metadata, name, equals, initializer);
5929 } 5929 }
5930 5930
5931 /** 5931 /**
5932 * Parse a variable declaration list. 5932 * Parse a variable declaration list.
5933 * 5933 *
5934 * <pre> 5934 * <pre>
5935 * variableDeclarationList ::= 5935 * variableDeclarationList ::=
5936 * finalConstVarOrType variableDeclaration (',' variableDeclaration)* 5936 * finalConstVarOrType variableDeclaration (',' variableDeclaration)*
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
6020 * </pre> 6020 * </pre>
6021 * 6021 *
6022 * @return the while statement that was parsed 6022 * @return the while statement that was parsed
6023 */ 6023 */
6024 Statement parseWhileStatement() { 6024 Statement parseWhileStatement() {
6025 bool wasInLoop = _inLoop; 6025 bool wasInLoop = _inLoop;
6026 _inLoop = true; 6026 _inLoop = true;
6027 try { 6027 try {
6028 Token keyword = expect(Keyword.WHILE); 6028 Token keyword = expect(Keyword.WHILE);
6029 Token leftParenthesis = expect2(TokenType.OPEN_PAREN); 6029 Token leftParenthesis = expect2(TokenType.OPEN_PAREN);
6030 Expression condition = parseExpression2(); 6030 Expression condition = parseExpression3();
6031 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); 6031 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN);
6032 Statement body = parseStatement2(); 6032 Statement body = parseStatement2();
6033 return new WhileStatement(keyword, leftParenthesis, condition, rightParent hesis, body); 6033 return new WhileStatement(keyword, leftParenthesis, condition, rightParent hesis, body);
6034 } finally { 6034 } finally {
6035 _inLoop = wasInLoop; 6035 _inLoop = wasInLoop;
6036 } 6036 }
6037 } 6037 }
6038 6038
6039 /** 6039 /**
6040 * Return the token that is immediately after the current token. This is equiv alent to 6040 * Return the token that is immediately after the current token. This is equiv alent to
(...skipping 3255 matching lines...) Expand 10 before | Expand all | Expand 10 after
9296 if ("\n" == separator) { 9296 if ("\n" == separator) {
9297 _writer.print("\n"); 9297 _writer.print("\n");
9298 indent(); 9298 indent();
9299 } else if (i > 0) { 9299 } else if (i > 0) {
9300 _writer.print(separator); 9300 _writer.print(separator);
9301 } 9301 }
9302 _writer.print(tokens[i].lexeme); 9302 _writer.print(tokens[i].lexeme);
9303 } 9303 }
9304 } 9304 }
9305 } 9305 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698