| 764 | | * expressions beginning and ending with reserved words |
| 765 | | * Expr ::= DelimitedExpr |
| 766 | | */ |
| 767 | | abstract DelimitedExpr(); |
| 768 | | /** |
| 769 | | * sequence of block elements implicitly enclosed by do/end |
| 770 | | * BlockElems ::= BlockElem+ |
| 771 | | * e.g.) y = x |
| 772 | | * z = 2x |
| 773 | | * y + z |
| 774 | | */ |
| 775 | | Block(List<Expr> exprs); |
| 776 | | /** |
| 777 | | * case expression or extremum expression |
| 778 | | * DelimitedExpr ::= case Expr Op? of CaseClauses CaseElse? end |
| 779 | | * | case most Op of CaseClauses end |
| 780 | | * CaseElse ::= else => BlockElems |
| 781 | | * e.g.) case most > of |
| 782 | | * 1 mile => "miles are larger" |
| 783 | | * 1 kilometer => "we were wrong again" |
| 784 | | * end |
| 785 | | * eqOp and inOp are to help with disambiguation |
| 786 | | */ |
| 787 | | CaseExpr(Option<Expr> param, |
| 788 | | Option<OpRef> compare = Option.<OpRef>none(), |
| 789 | | OpRef equalsOp = ExprFactory.makeInfixEq(), |
| 790 | | OpRef inOp= ExprFactory.makeInfixIn(), |
| 791 | | List<CaseClause> clauses, |
| 792 | | Option<Block> elseClause = Option.<Block>none()); |
| 793 | | /** |
| 794 | | * do expression |
| 795 | | * Do ::= (DoFront also)* DoFront end |
| 796 | | * e.g.) do |
| 797 | | * accum += treeSum(t.left) |
| 798 | | * also do |
| 799 | | * accum += treeSum(t.right) |
| 800 | | * also do |
| 801 | | * accum += t.datum |
| 802 | | * end |
| 803 | | */ |
| 804 | | Do(List<DoFront> fronts); |
| 805 | | /** |
| 806 | | * for expression |
| 807 | | * DelimitedExpr ::= for GeneratorClauseList DoFront end |
| 808 | | * e.g.) for i <- sequential(1:5) do |
| 809 | | * print (i " ") |
| 810 | | * end |
| 811 | | */ |
| 812 | | For(List<GeneratorClause> gens, DoFront body); |
| 813 | | /** |
| 814 | | * if expression |
| 815 | | * DelimitedExpr ::= if CondExpr then BlockElems Elifs? Else? end |
| 816 | | * | ( if CondExpr then BlockElems Elifs? Else end? ) |
| 817 | | * Elif ::= elif CondExpr then BlockElems |
| 818 | | * Else ::= else BlockElems |
| 819 | | * CondExpr ::= BindId <- Expr |
| 820 | | * | Expr |
| 821 | | * e.g.) if x IN {0, 1, 2} then 0 |
| 822 | | * elif x IN {3, 4, 5} then 3 |
| 823 | | * else 6 end |
| 824 | | */ |
| 825 | | If(List<IfClause> clauses, |
| 826 | | Option<Block> elseClause = Option.<Block>none()); |
| 827 | | /** |
| 828 | | * label expression |
| 829 | | * Names must be unqualified. |
| 830 | | * DelimitedExpr ::= label Id BlockElems end Id |
| 831 | | * e.g.) label I_95 |
| 832 | | * if goingTo(Sun) |
| 833 | | * then exit I_95 with x32B |
| 834 | | * else x32A |
| 835 | | * end |
| 836 | | * end I_95 |
| 837 | | */ |
| 838 | | Label(Id name, Block body); |
| | 764 | * sequence of block elements implicitly enclosed by do/end |
| | 765 | * BlockElems ::= BlockElem+ |
| | 766 | * e.g.) y = x |
| | 767 | * z = 2x |
| | 768 | * y + z |
| | 769 | */ |
| | 770 | Block(List<Expr> exprs); |
| | 771 | /** |
| | 772 | * case expression or extremum expression |
| | 773 | * DelimitedExpr ::= case Expr Op? of CaseClauses CaseElse? end |
| | 774 | * | case most Op of CaseClauses end |
| | 775 | * CaseElse ::= else => BlockElems |
| | 776 | * e.g.) case most > of |
| | 777 | * 1 mile => "miles are larger" |
| | 778 | * 1 kilometer => "we were wrong again" |
| | 779 | * end |
| | 780 | * eqOp and inOp are to help with disambiguation |
| | 781 | */ |
| | 782 | CaseExpr(Option<Expr> param, |
| | 783 | Option<OpRef> compare = Option.<OpRef>none(), |
| | 784 | OpRef equalsOp = ExprFactory.makeInfixEq(), |
| | 785 | OpRef inOp= ExprFactory.makeInfixIn(), |
| | 786 | List<CaseClause> clauses, |
| | 787 | Option<Block> elseClause = Option.<Block>none()); |
| | 788 | /** |
| | 789 | * do expression |
| | 790 | * Do ::= (DoFront also)* DoFront end |
| | 791 | * e.g.) do |
| | 792 | * accum += treeSum(t.left) |
| | 793 | * also do |
| | 794 | * accum += treeSum(t.right) |
| | 795 | * also do |
| | 796 | * accum += t.datum |
| | 797 | * end |
| | 798 | */ |
| | 799 | Do(List<DoFront> fronts); |
| | 800 | /** |
| | 801 | * for expression |
| | 802 | * DelimitedExpr ::= for GeneratorClauseList DoFront end |
| | 803 | * e.g.) for i <- sequential(1:5) do |
| | 804 | * print (i " ") |
| | 805 | * end |
| | 806 | */ |
| | 807 | For(List<GeneratorClause> gens, DoFront body); |
| | 808 | /** |
| | 809 | * if expression |
| | 810 | * DelimitedExpr ::= if CondExpr then BlockElems Elifs? Else? end |
| | 811 | * | ( if CondExpr then BlockElems Elifs? Else end? ) |
| | 812 | * Elif ::= elif CondExpr then BlockElems |
| | 813 | * Else ::= else BlockElems |
| | 814 | * CondExpr ::= BindId <- Expr |
| | 815 | * | Expr |
| | 816 | * e.g.) if x IN {0, 1, 2} then 0 |
| | 817 | * elif x IN {3, 4, 5} then 3 |
| | 818 | * else 6 end |
| | 819 | */ |
| | 820 | If(List<IfClause> clauses, |
| | 821 | Option<Block> elseClause = Option.<Block>none()); |
| | 822 | /** |
| | 823 | * label expression |
| | 824 | * Names must be unqualified. |
| | 825 | * DelimitedExpr ::= label Id BlockElems end Id |
| | 826 | * e.g.) label I_95 |
| | 827 | * if goingTo(Sun) |
| | 828 | * then exit I_95 with x32B |
| | 829 | * else x32A |
| | 830 | * end |
| | 831 | * end I_95 |
| | 832 | */ |
| | 833 | Label(Id name, Block body); |
| | 834 | /** |
| | 835 | * object expression |
| | 836 | */ |
| | 837 | abstract AbstractObjectExpr(List<TraitTypeWhere> extendsClause |
| | 838 | = Collections.<TraitTypeWhere>emptyList(), |
| | 839 | List<Decl> decls); |
| 841 | | */ |
| 842 | | abstract AbstractObjectExpr(List<TraitTypeWhere> extendsClause |
| 843 | | = Collections.<TraitTypeWhere>emptyList(), |
| 844 | | List<Decl> decls); |
| 845 | | /** |
| 846 | | * object expression |
| 847 | | * DelimitedExpr ::= object ExtendsWhere? GoInAnObject? end |
| 848 | | * e.g.) object extends {List} |
| 849 | | * cons(x) = Cons(x, self) |
| 850 | | * append (xs) = xs |
| 851 | | * end |
| 852 | | */ |
| 853 | | ObjectExpr(); |
| 854 | | /** |
| 855 | | * object expression rewritten by interpreter.rewrite.Disambiguate |
| 856 | | */ |
| 857 | | _RewriteObjectExpr(Map<String, StaticParam> implicitTypeParameters, |
| 858 | | String genSymName, |
| 859 | | List<StaticParam> staticParams, |
| 860 | | List<StaticArg> staticArgs, |
| 861 | | Option<List<Param>> params) |
| 862 | | implements GenericWithParams; |
| 863 | | /** |
| 864 | | * try expression |
| 865 | | * DelimitedExpr ::= try BlockElems Catch? (forbid TraitTypes)? |
| 866 | | * (finally BlockElems)? end |
| 867 | | * e.g.) try |
| 868 | | * inp = read (file) |
| 869 | | * write (inp, newFile) |
| 870 | | * forbid IOException |
| 871 | | * end |
| 872 | | */ |
| 873 | | Try(Block body, Option<Catch> catchClause = Option.<Catch>none(), |
| 874 | | List<BaseType> forbid = Collections.<BaseType>emptyList(), |
| 875 | | Option<Block> finallyClause = Option.<Block>none()); |
| 876 | | /** |
| 877 | | * labeled expression: tuple expression or argument expression |
| 878 | | */ |
| 879 | | abstract AbstractTupleExpr(List<Expr> exprs); |
| 880 | | /** |
| 881 | | * tuple expression |
| 882 | | * TupleExpr ::= ( (Expr,)+ Expr ) |
| 883 | | * e.g.) (1, 2, 5) |
| 884 | | */ |
| 885 | | TupleExpr(); |
| 886 | | /** |
| 887 | | * argument expression |
| 888 | | * ArgExpr ::= ( (Expr,)* (Expr...,)? KeywordExpr(, KeywordExpr)* ) |
| 889 | | * | ( (Expr,)* Expr... ) |
| 890 | | * | TupleExpr |
| 891 | | * e.g.) (1, 2, [3 4]..., x = 5) |
| 892 | | */ |
| 893 | | ArgExpr(Option<VarargsExpr> varargs |
| 894 | | = Option.<VarargsExpr>none(), |
| 895 | | List<KeywordExpr> keywords |
| 896 | | = Collections.<KeywordExpr>emptyList(), |
| 897 | | boolean inApp = false); |
| 898 | | /** |
| 899 | | * typecase expression |
| 900 | | * DelimitedExpr ::= typecase TypecaseBindings of TypecaseClauses |
| 901 | | * CaseElse? end |
| 902 | | * TypecaseBindings ::= TypecaseVars (= Expr)? |
| 903 | | * TypecaseVars ::= BindId |
| 904 | | * | ( BindId(, BindId)+ ) |
| 905 | | * e.g.) typecase x = myLoser .myField of |
| 906 | | * String => x.append("foo") |
| 907 | | * Number => x + 3 |
| 908 | | * Object => yogiBerraAutograph |
| 909 | | * end |
| 910 | | * Names in bind must be unqualified. |
| 911 | | */ |
| 912 | | Typecase(List<Id> bindIds, Option<Expr> bindExpr, |
| 913 | | List<TypecaseClause> clauses, |
| 914 | | Option<Block> elseClause = Option.<Block>none()); |
| 915 | | /** |
| 916 | | * while expression |
| 917 | | * DelimitedExpr ::= while GeneratorClause Do |
| 918 | | * e.g.) while x < 10 do print x; x += 1 end |
| 919 | | */ |
| 920 | | While(GeneratorClause test, Do body); |
| 921 | | /** |
| 922 | | * control flow expression |
| 923 | | * Expr ::= FlowExpr |
| 924 | | */ |
| 925 | | abstract FlowExpr(); |
| 926 | | /** |
| 927 | | * comprehension or accumulator |
| 928 | | */ |
| 929 | | abstract BigOpApp(List<StaticArg> staticArgs |
| 930 | | = Collections.<StaticArg>emptyList()); |
| 931 | | /** |
| 932 | | * summation and other reduction expression |
| 933 | | * FlowExpr ::= Accumulator StaticArgs? |
| 934 | | * ([ GeneratorClauseList ])? Expr |
| 935 | | * Accumulator ::= SUM | PROD | Big Op |
| 936 | | * e.g.) PROD[i <- 1:n] i |
| 937 | | */ |
| 938 | | Accumulator(OpName opr, List<GeneratorClause> gens, Expr body); |
| 939 | | /** |
| 940 | | * array comprehension |
| 941 | | * Comprehension ::= BIG? [ StaticArgs? ArrayComprehensionClause+ |
| 942 | | * ] |
| 943 | | * e.g.) [(x, y, 1) |-> 0.0 | x <- 1:xSize, y <- 1:ySize ] |
| 944 | | */ |
| 945 | | ArrayComprehension(List<ArrayComprehensionClause> clauses); |
| 946 | | /** |
| 947 | | * atomic expression |
| 948 | | * FlowExpr ::= atomic AtomicBack |
| 949 | | * AtomicBack ::= AssignExpr |
| 950 | | * | OpExpr |
| 951 | | * | DelimitedExpr |
| 952 | | * e.g.) atomic sum += a[i] |
| 953 | | */ |
| 954 | | AtomicExpr(Expr expr); |
| 955 | | /** |
| 956 | | * exiting labeled expressions |
| 957 | | * FlowExpr ::= exit Id? (with Expr)? |
| 958 | | * e.g.) exit I_95 with x32B |
| 959 | | * Targets must be unqualified. |
| 960 | | */ |
| 961 | | Exit(Option<Id> target = Option.<Id>none(), |
| 962 | | Option<Expr> returnExpr = Option.<Expr>none()); |
| 963 | | /** |
| 964 | | * spawn expression |
| 965 | | * FlowExpr ::= spawn Expr |
| 966 | | * e.g.) spawn mm(lefttop, right, resulttop) |
| 967 | | */ |
| 968 | | Spawn(Expr body); |
| 969 | | /** |
| 970 | | * throw expression |
| 971 | | * FlowExpr ::= throw Expr |
| 972 | | * e.g.) throw Error |
| 973 | | */ |
| 974 | | Throw(Expr expr); |
| 975 | | /** |
| 976 | | * tryatomic expression |
| 977 | | * FlowExpr ::= tryatomic AtomicBack |
| 978 | | * e.g.) tryatomic sum += a[i] |
| 979 | | */ |
| 980 | | TryAtomicExpr(Expr expr); |
| | 842 | * DelimitedExpr ::= object ExtendsWhere? GoInAnObject? end |
| | 843 | * e.g.) object extends {List} |
| | 844 | * cons(x) = Cons(x, self) |
| | 845 | * append (xs) = xs |
| | 846 | * end |
| | 847 | */ |
| | 848 | ObjectExpr(); |
| | 849 | /** |
| | 850 | * object expression rewritten by interpreter.rewrite.Disambiguate |
| | 851 | */ |
| | 852 | _RewriteObjectExpr(Map<String, StaticParam> implicitTypeParameters, |
| | 853 | String genSymName, |
| | 854 | List<StaticParam> staticParams, |
| | 855 | List<StaticArg> staticArgs, |
| | 856 | Option<List<Param>> params) |
| | 857 | implements GenericWithParams; |
| | 858 | /** |
| | 859 | * try expression |
| | 860 | * DelimitedExpr ::= try BlockElems Catch? (forbid TraitTypes)? |
| | 861 | * (finally BlockElems)? end |
| | 862 | * e.g.) try |
| | 863 | * inp = read (file) |
| | 864 | * write (inp, newFile) |
| | 865 | * forbid IOException |
| | 866 | * end |
| | 867 | */ |
| | 868 | Try(Block body, Option<Catch> catchClause = Option.<Catch>none(), |
| | 869 | List<BaseType> forbid = Collections.<BaseType>emptyList(), |
| | 870 | Option<Block> finallyClause = Option.<Block>none()); |
| | 871 | /** |
| | 872 | * labeled expression: tuple expression or argument expression |
| | 873 | */ |
| | 874 | abstract AbstractTupleExpr(List<Expr> exprs); |
| | 875 | /** |
| | 876 | * tuple expression |
| | 877 | * TupleExpr ::= ( (Expr,)+ Expr ) |
| | 878 | * e.g.) (1, 2, 5) |
| | 879 | */ |
| | 880 | TupleExpr(); |
| | 881 | /** |
| | 882 | * argument expression |
| | 883 | * ArgExpr ::= ( (Expr,)* (Expr...,)? KeywordExpr(, KeywordExpr)* ) |
| | 884 | * | ( (Expr,)* Expr... ) |
| | 885 | * | TupleExpr |
| | 886 | * e.g.) (1, 2, [3 4]..., x = 5) |
| | 887 | */ |
| | 888 | ArgExpr(Option<VarargsExpr> varargs |
| | 889 | = Option.<VarargsExpr>none(), |
| | 890 | List<KeywordExpr> keywords |
| | 891 | = Collections.<KeywordExpr>emptyList(), |
| | 892 | boolean inApp = false); |
| | 893 | /** |
| | 894 | * typecase expression |
| | 895 | * DelimitedExpr ::= typecase TypecaseBindings of TypecaseClauses |
| | 896 | * CaseElse? end |
| | 897 | * TypecaseBindings ::= TypecaseVars (= Expr)? |
| | 898 | * TypecaseVars ::= BindId |
| | 899 | * | ( BindId(, BindId)+ ) |
| | 900 | * e.g.) typecase x = myLoser .myField of |
| | 901 | * String => x.append("foo") |
| | 902 | * Number => x + 3 |
| | 903 | * Object => yogiBerraAutograph |
| | 904 | * end |
| | 905 | * Names in bind must be unqualified. |
| | 906 | */ |
| | 907 | Typecase(List<Id> bindIds, Option<Expr> bindExpr, |
| | 908 | List<TypecaseClause> clauses, |
| | 909 | Option<Block> elseClause = Option.<Block>none()); |
| | 910 | /** |
| | 911 | * while expression |
| | 912 | * DelimitedExpr ::= while GeneratorClause Do |
| | 913 | * e.g.) while x < 10 do print x; x += 1 end |
| | 914 | */ |
| | 915 | While(GeneratorClause test, Do body); |
| | 916 | /** |
| | 917 | * comprehension or accumulator |
| | 918 | */ |
| | 919 | abstract BigOpApp(List<StaticArg> staticArgs |
| | 920 | = Collections.<StaticArg>emptyList()); |
| | 921 | /** |
| | 922 | * summation and other reduction expression |
| | 923 | * FlowExpr ::= Accumulator StaticArgs? |
| | 924 | * ([ GeneratorClauseList ])? Expr |
| | 925 | * Accumulator ::= SUM | PROD | Big Op |
| | 926 | * e.g.) PROD[i <- 1:n] i |
| | 927 | */ |
| | 928 | Accumulator(OpName opr, List<GeneratorClause> gens, Expr body); |
| | 929 | /** |
| | 930 | * array comprehension |
| | 931 | * Comprehension ::= BIG? [ StaticArgs? ArrayComprehensionClause+ |
| | 932 | * ] |
| | 933 | * e.g.) [(x, y, 1) |-> 0.0 | x <- 1:xSize, y <- 1:ySize ] |
| | 934 | */ |
| | 935 | ArrayComprehension(List<ArrayComprehensionClause> clauses); |
| | 936 | /** |
| | 937 | * atomic expression |
| | 938 | * FlowExpr ::= atomic AtomicBack |
| | 939 | * AtomicBack ::= AssignExpr |
| | 940 | * | OpExpr |
| | 941 | * | DelimitedExpr |
| | 942 | * e.g.) atomic sum += a[i] |
| | 943 | */ |
| | 944 | AtomicExpr(Expr expr); |
| | 945 | /** |
| | 946 | * exiting labeled expressions |
| | 947 | * FlowExpr ::= exit Id? (with Expr)? |
| | 948 | * e.g.) exit I_95 with x32B |
| | 949 | * Targets must be unqualified. |
| | 950 | */ |
| | 951 | Exit(Option<Id> target = Option.<Id>none(), |
| | 952 | Option<Expr> returnExpr = Option.<Expr>none()); |
| | 953 | /** |
| | 954 | * spawn expression |
| | 955 | * FlowExpr ::= spawn Expr |
| | 956 | * e.g.) spawn mm(lefttop, right, resulttop) |
| | 957 | */ |
| | 958 | Spawn(Expr body); |
| | 959 | /** |
| | 960 | * throw expression |
| | 961 | * FlowExpr ::= throw Expr |
| | 962 | * e.g.) throw Error |
| | 963 | */ |
| | 964 | Throw(Expr expr); |
| | 965 | /** |
| | 966 | * tryatomic expression |
| | 967 | * FlowExpr ::= tryatomic AtomicBack |
| | 968 | * e.g.) tryatomic sum += a[i] |
| | 969 | */ |
| | 970 | TryAtomicExpr(Expr expr); |