Changeset 3097

Show
Ignore:
Timestamp:
11/24/08 23:20:43 (12 months ago)
Author:
sukyoungryu
Message:

[ast refactoring] Made Decl a superclass rather than an interface.

Location:
trunk/ProjectFortress
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/ProjectFortress/astgen/Fortress.ast

    r3096 r3097  
    7373 */ 
    7474interface Node(ignoreForEquals Span span) extends HasAt; 
    75     /** 
    76      * declaration in components or APIs 
    77      */ 
    78     interface Decl(); 
    7975    /** 
    8076     * left-hand-side of assignments, local variable declarations, or 
     
    9490     */ 
    9591    interface Generic(List<StaticParam> staticParams); 
     92        interface GenericWithParams() extends HasParams; 
     93        interface GenericDecl(); 
     94            interface GenericDeclWithParams() extends GenericWithParams; 
     95 
    9696    /** 
    9797     * with value parameters 
     
    124124 
    125125    /** 
    126      * intersections of interface types 
    127      */ 
    128     interface GenericWithParams() extends Generic, HasParams; 
    129     interface GenericDecl() extends Generic, Decl; 
    130         interface GenericDeclWithParams() extends GenericWithParams; 
    131  
    132     /** 
    133126     * type or the domain of an arrow type 
    134127     */ 
     
    217210                       Option<Id> alias = Option.<Id>none()); 
    218211        /** 
    219          * trait or object declaration in components or APIs 
    220          * Name must be unqualified. 
    221          */ 
    222         abstract TraitObjectDecl(List<Modifier> mods 
    223                                      = Collections.<Modifier>emptyList(), 
    224                                  Id name, 
    225                                  List<StaticParam> staticParams 
    226                                      = Collections.<StaticParam>emptyList(), 
    227                                  List<TraitTypeWhere> extendsClause 
    228                                      = Collections.<TraitTypeWhere>emptyList(), 
    229                                  Option<WhereClause> where 
    230                                      = Option.<WhereClause>none(), 
    231                                  List<Decl> decls) 
    232                                  implements HasWhere, GenericDecl; 
    233             /** 
    234              * trait declaration in components or APIs 
     212         * declaration in components or APIs 
     213         */ 
     214        abstract Decl(); 
     215            /** 
     216             * trait or object declaration in components or APIs 
     217             * Name must be unqualified. 
     218             */ 
     219            abstract TraitObjectDecl(List<Modifier> mods 
     220                                         = Collections.<Modifier>emptyList(), 
     221                                     Id name, 
     222                                     List<StaticParam> staticParams 
     223                                         = Collections.<StaticParam>emptyList(), 
     224                                     List<TraitTypeWhere> extendsClause 
     225                                         = Collections.<TraitTypeWhere>emptyList(), 
     226                                     Option<WhereClause> where 
     227                                         = Option.<WhereClause>none(), 
     228                                     List<Decl> decls) 
     229                                     implements HasWhere, GenericDecl; 
     230                /** 
     231                 * trait declaration in components or APIs 
     232                 * 
     233                 * trait declaration in APIs 
     234                 * AbsTraitDecl ::= AbsTraitMods? TraitHeaderFront AbsTraitClauses 
     235                 *                  AbsGoInATrait? end 
     236                 * TraitHeaderFront ::= trait Id StaticParams? ExtendsWhere? 
     237                 * ExtendsWhere ::= extends TraitTypeWheres 
     238                 * AbsTraitClause ::= Excludes | AbsComprises | Where 
     239                 * Excludes ::= excludes TraitTypes 
     240                 * AbsComprises ::= comprises ComprisingTypes 
     241                 * ComprisingTypes ::= TraitType | { ComprisingTypeList } 
     242                 * ComprisingTypeList ::= ... 
     243                 *                      | TraitType(, TraitType)*(, ...)? 
     244                 * AbsGoInATrait ::= AbsCoercions? AbsGoFrontInATrait AbsGoBackInATrait? 
     245                 *                 | AbsCoercions? AbsGoBackInATrait 
     246                 *                 | AbsCoercions 
     247                 * AbsGoesFrontInATrait ::= ApiFldDecl 
     248                 *                        | AbsGetterSetterDecl 
     249                 *                        | PropertyDecl 
     250                 * AbsGoesBackInATrait  ::= AbsMdDecl 
     251                 *                        | PropertyDecl 
     252                 * e.g.) trait List[\alpha\] comprises {Cons[\alpha\],Empty[\alpha\]} 
     253                 *         cons(x: alph): List[\alpha\] 
     254                 *       end 
     255                 * 
     256                 * trait declaration in components 
     257                 * TraitDecl ::= TraitMods? TraitHeaderFront TraitClauses GoInATrait? 
     258                 *               end 
     259                 * TraitClause ::= Excludes | Comprises | Where 
     260                 * Comprises ::= comprises TraitTypes 
     261                 * GoInATrait ::= Coercions? GoFrontInATrait GoBackInATrait? 
     262                 *              | Coercions? GoBackInATrait 
     263                 *              | Coercions 
     264                 * GoesFrontInATrait ::= AbsFldDecl 
     265                 *                     | GetterSetterDecl 
     266                 *                     | PropertyDecl 
     267                 * GoesBackInATrait  ::= MdDecl 
     268                 *                     | PropertyDecl 
     269                 * e.g.) trait List[\alpha\] comprises {Cons[\alpha\],Empty[\alpha\]} 
     270                 *         cons(x: alph): List[\alpha\] = Cons[\alph\](x, self) 
     271                 *       end 
     272                 */ 
     273                TraitDecl(List<BaseType> excludes = Collections.<BaseType>emptyList(), 
     274                          Option<List<BaseType>> comprises 
     275                              = Option.<List<BaseType>>none(), 
     276                          List<Decl> decls) implements GenericDecl; 
     277                /** 
     278                 * object declaration in components or APIs 
     279                 * 
     280                 * object declaration in APIs 
     281                 * AbsObjectDecl ::= AbsObjectMods? ObjectHeader AbsGoInAnObject? end 
     282                 * ObjectHeader ::= object Id StaticParams? ObjectValParam? 
     283                 *                  ExtendsWhere? FnClauses 
     284                 * FnClauses ::= Throws? Where? Contract 
     285                 * Throws ::= throws MayTraitTypes 
     286                 * ObjectValParam ::= ( ObjectParams? ) 
     287                 * ObjectParams ::= (ObjectParam ,)* ObjectKeyword(, ObjectKeyword)* 
     288                 *                | ObjectParam (, ObjectParam)* 
     289                 * ObjectKeyword ::= ObjectParam = Expr 
     290                 * ObjectParam ::= ParamFldMods? Param 
     291                 *               | var Param 
     292                 * AbsGoInAnObject ::= AbsCoercions? AbsGoFrontInAnObject AbsGoBackInAnObject? 
     293                 *                   | AbsCoercions? AbsGoBackInAnObject 
     294                 *                   | AbsCoercions 
     295                 * AbsGoesFrontInAnObject ::= ApiFldDecl 
     296                 *                          | AbsGetterSetterDecl 
     297                 *                          | PropertyDecl 
     298                 * AbsGoesBackInAnObject ::= AbsMdDecl 
     299                 *                         | PropertyDecl 
     300                 * e.g.) object Empty[\alph\]() extends List[\alpha\] end 
     301                 * 
     302                 * object declaration in components 
     303                 * ObjectDecl ::= ObjectMods? ObjectHeader GoInAnObject? end 
     304                 * GoInAnObject ::= Coercions? GoFrontInAnObject GoBackInAnObject? 
     305                 *                | Coercions? GoBackInAnObject 
     306                 *                | Coercions 
     307                 * GoesFrontInAnObject ::= FldDecl 
     308                 *                       | GetterSetterDecl 
     309                 *                       | PropertyDecl 
     310                 * GoesBackInAnObject ::= MdDef 
     311                 *                      | PropertyDecl 
     312                 * e.g.) object Empty[\alph\]() extends List[\alpha\] 
     313                 *         length() = 0 
     314                 *       end 
     315                 */ 
     316                ObjectDecl(Option<List<Param>> params = Option.<List<Param>>none(), 
     317                           Option<List<BaseType>> throwsClause 
     318                               = Option.<List<BaseType>>none(), 
     319                           Option<Contract> contract = Option.<Contract>none(), 
     320                           List<Decl> decls) 
     321                          implements GenericDeclWithParams; 
     322            /** 
     323             * variable declaration in components or APIs 
    235324             * 
    236              * trait declaration in APIs 
    237              * AbsTraitDecl ::= AbsTraitMods? TraitHeaderFront AbsTraitClauses 
    238              *                  AbsGoInATrait? end 
    239              * TraitHeaderFront ::= trait Id StaticParams? ExtendsWhere? 
    240              * ExtendsWhere ::= extends TraitTypeWheres 
    241              * AbsTraitClause ::= Excludes | AbsComprises | Where 
    242              * Excludes ::= excludes TraitTypes 
    243              * AbsComprises ::= comprises ComprisingTypes 
    244              * ComprisingTypes ::= TraitType | { ComprisingTypeList } 
    245              * ComprisingTypeList ::= ... 
    246              *                      | TraitType(, TraitType)*(, ...)? 
    247              * AbsGoInATrait ::= AbsCoercions? AbsGoFrontInATrait AbsGoBackInATrait? 
    248              *                 | AbsCoercions? AbsGoBackInATrait 
    249              *                 | AbsCoercions 
    250              * AbsGoesFrontInATrait ::= ApiFldDecl 
    251              *                        | AbsGetterSetterDecl 
    252              *                        | PropertyDecl 
    253              * AbsGoesBackInATrait  ::= AbsMdDecl 
    254              *                        | PropertyDecl 
    255              * e.g.) trait List[\alpha\] comprises {Cons[\alpha\],Empty[\alpha\]} 
    256              *         cons(x: alph): List[\alpha\] 
    257              *       end 
     325             * variable declaration in APIs 
     326             * AbsVarDecl ::= AbsVarMods? VarWTypes 
     327             *              | AbsVarMods? BindIdOrBindIdTuple : Type ... 
     328             *              | AbsVarMods? BindIdOrBindIdTuple : SimpleTupleType 
     329             * VarWTypes ::= VarWType | ( VarWType(, VarWType)+ ) 
     330             * VarWType ::= BindId IsType 
     331             * BindIdOrBindIdTuple ::= BindId 
     332             *                       | ( BindId , BindIdList ) 
     333             * BindId ::= Id | _ 
     334             * e.g.) var (x, y): ZZ64... 
    258335             * 
    259              * trait declaration in components 
    260              * TraitDecl ::= TraitMods? TraitHeaderFront TraitClauses GoInATrait? 
    261              *               end 
    262              * TraitClause ::= Excludes | Comprises | Where 
    263              * Comprises ::= comprises TraitTypes 
    264              * GoInATrait ::= Coercions? GoFrontInATrait GoBackInATrait? 
    265              *              | Coercions? GoBackInATrait 
    266              *              | Coercions 
    267              * GoesFrontInATrait ::= AbsFldDecl 
    268              *                     | GetterSetterDecl 
    269              *                     | PropertyDecl 
    270              * GoesBackInATrait  ::= MdDecl 
    271              *                     | PropertyDecl 
    272              * e.g.) trait List[\alpha\] comprises {Cons[\alpha\],Empty[\alpha\]} 
    273              *         cons(x: alph): List[\alpha\] = Cons[\alph\](x, self) 
    274              *       end 
    275              */ 
    276             TraitDecl(List<BaseType> excludes = Collections.<BaseType>emptyList(), 
    277                       Option<List<BaseType>> comprises 
    278                           = Option.<List<BaseType>>none(), 
    279                       List<Decl> decls) implements GenericDecl; 
    280             /** 
    281              * object declaration in components or APIs 
     336             * variable declaration in components 
     337             * VarDecl ::= VarMods? VarWTypes InitVal 
     338             *           | VarMods? BindIdOrBindIdTuple = Expr 
     339             *           | VarMods? BindIdOrBindIdTuple : Type ... InitVal 
     340             *           | VarMods? BindIdOrBindIdTuple : SimpleTupleType InitVal 
     341             * InitVal ::= (= | :=) Expr 
     342             * e.g.) var (x, y): ZZ64... = (5, 6) 
     343             */ 
     344            VarDecl(List<LValue> lhs, Option<Expr> init); 
     345            /** 
     346             * Overloading specification 
     347             */ 
     348            _RewriteFnOverloadDecl(IdOrOpName name, 
     349                                   List<IdOrOpName> fns); 
     350            /** 
     351             * functional declaration in components or APIs 
     352             * Names must be unqualified. 
    282353             * 
    283              * object declaration in APIs 
    284              * AbsObjectDecl ::= AbsObjectMods? ObjectHeader AbsGoInAnObject? end 
    285              * ObjectHeader ::= object Id StaticParams? ObjectValParam? 
    286              *                  ExtendsWhere? FnClauses 
    287              * FnClauses ::= Throws? Where? Contract 
    288              * Throws ::= throws MayTraitTypes 
    289              * ObjectValParam ::= ( ObjectParams? ) 
    290              * ObjectParams ::= (ObjectParam ,)* ObjectKeyword(, ObjectKeyword)* 
    291              *                | ObjectParam (, ObjectParam)* 
    292              * ObjectKeyword ::= ObjectParam = Expr 
    293              * ObjectParam ::= ParamFldMods? Param 
    294              *               | var Param 
    295              * AbsGoInAnObject ::= AbsCoercions? AbsGoFrontInAnObject AbsGoBackInAnObject? 
    296              *                   | AbsCoercions? AbsGoBackInAnObject 
    297              *                   | AbsCoercions 
    298              * AbsGoesFrontInAnObject ::= ApiFldDecl 
    299              *                          | AbsGetterSetterDecl 
    300              *                          | PropertyDecl 
    301              * AbsGoesBackInAnObject ::= AbsMdDecl 
    302              *                         | PropertyDecl 
    303              * e.g.) object Empty[\alph\]() extends List[\alpha\] end 
     354             * functional declaration in components or APIs 
     355             * AbsFnDecl ::= AbsFnMods? FnHeaderFront FnHeaderClause 
     356             *             | FnSig 
     357             * FnSig ::= SimpleName : ArrowType 
     358             * FnHeaderFront ::= NamedFnHeaderFront 
     359             *                 | OpHeaderFront 
     360             * NamedFnHeaderFront ::= Id StaticParams? ValParam 
     361             * OpHeaderFront ::= opr StaticParams? BIG? (LeftEncloser | Encloser) 
     362             *                     Params (RightEncloser | Encloser) 
     363             *                 | opr StaticParams? ValParam (Op | ExponentOp) 
     364             *                 | opr BIG? (Op | ^ | Encloser) StaticParams? ValParam 
     365             * FnHeaderClause ::= IsType? FnClauses 
     366             * FnDecl ::= FnMods? FnHeaderFront FnHeaderClause 
     367             *          | FnSig 
     368             * e.g.) swap (x: Object, y: Object): (Object, Object) 
    304369             * 
    305              * object declaration in components 
    306              * ObjectDecl ::= ObjectMods? ObjectHeader GoInAnObject? end 
    307              * GoInAnObject ::= Coercions? GoFrontInAnObject GoBackInAnObject? 
    308              *                | Coercions? GoBackInAnObject 
    309              *                | Coercions 
    310              * GoesFrontInAnObject ::= FldDecl 
    311              *                       | GetterSetterDecl 
    312              *                       | PropertyDecl 
    313              * GoesBackInAnObject ::= MdDef 
    314              *                      | PropertyDecl 
    315              * e.g.) object Empty[\alph\]() extends List[\alpha\] 
    316              *         length() = 0 
    317              *       end 
    318              */ 
    319             ObjectDecl(Option<List<Param>> params = Option.<List<Param>>none(), 
    320                        Option<List<BaseType>> throwsClause 
    321                            = Option.<List<BaseType>>none(), 
    322                        Option<Contract> contract = Option.<Contract>none(), 
    323                        List<Decl> decls) 
    324                       implements GenericDeclWithParams; 
    325         /** 
    326          * variable declaration in components or APIs 
    327          * 
    328          * variable declaration in APIs 
    329          * AbsVarDecl ::= AbsVarMods? VarWTypes 
    330          *              | AbsVarMods? BindIdOrBindIdTuple : Type ... 
    331          *              | AbsVarMods? BindIdOrBindIdTuple : SimpleTupleType 
    332          * VarWTypes ::= VarWType | ( VarWType(, VarWType)+ ) 
    333          * VarWType ::= BindId IsType 
    334          * BindIdOrBindIdTuple ::= BindId 
    335          *                       | ( BindId , BindIdList ) 
    336          * BindId ::= Id | _ 
    337          * e.g.) var (x, y): ZZ64... 
    338          * 
    339          * variable declaration in components 
    340          * VarDecl ::= VarMods? VarWTypes InitVal 
    341          *           | VarMods? BindIdOrBindIdTuple = Expr 
    342          *           | VarMods? BindIdOrBindIdTuple : Type ... InitVal 
    343          *           | VarMods? BindIdOrBindIdTuple : SimpleTupleType InitVal 
    344          * InitVal ::= (= | :=) Expr 
    345          * e.g.) var (x, y): ZZ64... = (5, 6) 
    346          */ 
    347         VarDecl(List<LValue> lhs, Option<Expr> init) implements Decl; 
     370             * functional declaration in components 
     371             * FnDecl ::= FnMods? FnHeaderFront FnHeaderClause = Expr 
     372             * e.g.) swap (x, y) = (y, x) 
     373             */ 
     374            FnDecl(List<Modifier> mods = Collections.<Modifier>emptyList(), 
     375                   IdOrOpOrAnonymousName name, 
     376                   List<StaticParam> staticParams 
     377                       = Collections.<StaticParam>emptyList(), 
     378                   List<Param> params = Collections.<Param>emptyList(), 
     379                   Option<Type> returnType = Option.<Type>none(), 
     380                   Option<List<BaseType>> throwsClause = Option.<List<BaseType>>none(), 
     381                   Option<WhereClause> where = Option.<WhereClause>none(), 
     382                   Option<Contract> contract = Option.<Contract>none(), 
     383                   Id unambiguousName = new Id(in_span, "FN$"+in_span.toString()), 
     384                   Option<Expr> body, 
     385                   Option<Id> implementsUnambiguousName = Option.<Id>none()) 
     386                  implements Applicable, GenericDecl; 
     387            /** 
     388             * dimension and unit declaration 
     389             * DimUnitDecl may represent a single dimension declaration, a single 
     390             * unit declaration, or both dimension and unit declarations. 
     391             * DimUnitDecl ::= dim Id (= Type)? (unit | SI_unit) Id+ (= Expr)? 
     392             *               | dim Id (= Type)? (default Id)? 
     393             *               | (unit | SI_unit) Id+ (: Type)? (= Expr)? 
     394             */ 
     395            abstract DimUnitDecl(); 
     396                /** 
     397                 * dimension declaration 
     398                 * Names for dim and default must be unqualified. 
     399                 * e.g.) dim Length SI_unit meter meters m 
     400                 */ 
     401                DimDecl(Id dim, Option<Type> derived = Option.<Type>none(), 
     402                        Option<Id> default = Option.<Id>none()); 
     403                /** 
     404                 * unit declaration 
     405                 * Names of units must be unqualified. 
     406                 * e.g.) unit inch inches: Length 
     407                 */ 
     408                UnitDecl(boolean si_unit = false, 
     409                         List<Id> units = Collections.<Id>emptyList(), 
     410                         Option<Type> dim = Option.<Type>none(), 
     411                         Option<Expr> def); 
     412            /** 
     413             * test declaration 
     414             * Names must be unqualified. 
     415             * TestDecl ::= test Id [ GeneratorClauseList ] = Expr 
     416             * e.g.) test fxLessThanFy[x <- E, y <- F] = assert(f(x) < f(y)) 
     417             */ 
     418            TestDecl(Id name, List<GeneratorClause> gens, Expr expr); 
     419            /** 
     420             * property declaration 
     421             * Names must be unqualified. 
     422             * PropertyDecl ::= property (Id = )? (FORALL ValParam)? Expr 
     423             * e.g.) property fIsMonotonic = FORALL (x:ZZ, y:ZZ) (x < y) -> (f(x) < f(y)) 
     424             */ 
     425            PropertyDecl(Option<Id> name = Option.<Id>none(), List<Param> params, 
     426                         Expr expr); 
     427            /** 
     428             * type alias declaration 
     429             * TypeAlias ::= type Id StaticParams? = Type 
     430             * e.g.) type IntList = List[\ZZ64\] 
     431             */ 
     432            TypeAlias(Id name, 
     433                      List<StaticParam> staticParams 
     434                          = Collections.<StaticParam>emptyList(), 
     435                      Type type); 
     436            /** 
     437             * grammar declaration 
     438             * Names (but not extends elements) must be unqualified. 
     439             */ 
     440            abstract GrammarDecl(Id name, List<Id> extends); 
     441                /** 
     442                 * grammar definition 
     443                 */ 
     444                GrammarDef(List<GrammarMemberDecl> members, List<TransformerDecl> transformers, 
     445                           boolean native); 
     446            /** 
     447             * grammar member (nonterminal or terminal) declaration 
     448             * Names and params must be unqualified. 
     449             */ 
     450            abstract GrammarMemberDecl(Id name); 
     451                /** 
     452                 * nonterminal declaration 
     453                 */ 
     454                abstract NonterminalDecl(List<SyntaxDecl> syntaxDecls); 
     455                    /** 
     456                     * nonterminal definition in nonterminal declarations 
     457                     */ 
     458                    NonterminalDef(NonterminalHeader header, Option<BaseType> astType); 
     459                    /** 
     460                     * nonterminal extending definition in nonterminal declarations 
     461                     */ 
     462                    NonterminalExtensionDef(); 
     463        /** 
     464         * nonterminal header 
     465         */ 
     466        NonterminalHeader(Option<ModifierPrivate> modifier 
     467                            = Option.<ModifierPrivate>none(), 
     468                          Id name, 
     469                          List<NonterminalParameter> params, 
     470                          List<StaticParam> staticParams 
     471                            = Collections.<StaticParam>emptyList(), 
     472                          Option<Type> type, 
     473                          Option<WhereClause> whereClause 
     474                            = Option.<WhereClause>none()); 
     475 
     476        /** 
     477         * nonterminal parameter 
     478         */ 
     479        NonterminalParameter(Id name, BaseType type); 
     480 
     481        /** 
     482         * syntax declaration 
     483         */ 
     484        abstract SyntaxDecl(Option<String> modifier); 
     485            /** 
     486             * syntax definition in syntax declarations 
     487             */ 
     488            SyntaxDef(List<SyntaxSymbol> syntaxSymbols, 
     489                      TransformerDecl transformer); 
     490 
     491            SuperSyntaxDef(Id nonterminal, Id grammar); 
     492 
     493        /** 
     494          * Transformation declaration 
     495          */ 
     496        abstract TransformerDecl(); 
     497            /** 
     498             * pre transformer definition in transformer declarations 
     499             */ 
     500            PreTransformerDef(Transformer transformer); 
     501            /** 
     502             * transformer definition in transformer declarations 
     503             */ 
     504            NamedTransformerDef(String name, List<NonterminalParameter> parameters, Transformer transformer); 
     505 
     506        /** 
     507         * Transformers 
     508         */ 
     509        abstract Transformer(); 
     510            /** 
     511             * Unparsed template 
     512             */ 
     513            UnparsedTransformer(String transformer, Id nonterminal); 
     514            /** 
     515             * Parsed template 
     516             */ 
     517            NodeTransformer(AbstractNode node); 
     518            /** 
     519             * Case-dispatch transformer expr 
     520             */ 
     521            CaseTransformer(Id gapName, List<CaseTransformerClause> clauses); 
     522 
     523        /** 
     524         * Case transformer clause 
     525         */ 
     526        CaseTransformerClause(Id constructor, List<Id> parameters, Transformer body); 
     527 
     528        /** 
     529          * syntax symbol 
     530          */ 
     531        abstract SyntaxSymbol(); 
     532            /** 
     533             * prefixed syntax symbol 
     534             */ 
     535            PrefixedSymbol(Id id, SyntaxSymbol symbol); 
     536            /** 
     537             * optional syntax symbol 
     538             */ 
     539            OptionalSymbol(SyntaxSymbol symbol); 
     540            /** 
     541             * repeat zero-or-more syntax symbol 
     542             */ 
     543            RepeatSymbol(SyntaxSymbol symbol); 
     544            /** 
     545             * repeat one-or-more syntax symbol 
     546             */ 
     547            RepeatOneOrMoreSymbol(SyntaxSymbol symbol); 
     548            /** 
     549             * ignore following whitespace syntax symbol 
     550             */ 
     551            NoWhitespaceSymbol(SyntaxSymbol symbol); 
     552            /** 
     553             * groups of symbols 
     554             */ 
     555            GroupSymbol(List<SyntaxSymbol> symbols); 
     556            /** 
     557             * special symbols syntax symbol 
     558             */ 
     559            abstract SpecialSymbol(); 
     560                /** 
     561                 * any character syntax symbol 
     562                 */ 
     563                AnyCharacterSymbol(); 
     564                /** 
     565                 * whitespace syntax symbol 
     566                 */ 
     567                WhitespaceSymbol(String s); 
     568                /** 
     569                 * tab syntax symbol 
     570                 */ 
     571                TabSymbol(); 
     572                /** 
     573                 * formfeed syntax symbol 
     574                 */ 
     575                FormfeedSymbol(); 
     576                /** 
     577                 * carriage return syntax symbol 
     578                 */ 
     579                CarriageReturnSymbol(); 
     580                /** 
     581                 * backspace syntax symbol 
     582                 */ 
     583                BackspaceSymbol(); 
     584                /** 
     585                 * newline syntax symbol 
     586                 */ 
     587                NewlineSymbol(); 
     588                /** 
     589                 * breakline syntax symbol 
     590                 */ 
     591                BreaklineSymbol(String s); 
     592            /** 
     593             * item syntax symbol; 
     594             * may be either nonterminal or keyword 
     595             */ 
     596            ItemSymbol(String item); 
     597            /** 
     598             * non-terminal syntax symbol 
     599             */ 
     600            NonterminalSymbol(Id nonterminal); 
     601            /** 
     602             * keyword syntax symbol 
     603             */ 
     604            KeywordSymbol(String token); 
     605            /** 
     606             * token syntax symbol 
     607             */ 
     608            TokenSymbol(String token); 
     609            /** 
     610             * not predicate syntax symbol 
     611             */ 
     612            NotPredicateSymbol(SyntaxSymbol symbol); 
     613            /** 
     614             * and predicate syntax symbol 
     615             */ 
     616            AndPredicateSymbol(SyntaxSymbol symbol); 
     617            /** 
     618             * character class syntax symbol 
     619             */ 
     620            CharacterClassSymbol(List<CharacterSymbol> characters); 
     621            /** 
     622             * character symbols 
     623             */ 
     624            abstract CharacterSymbol(); 
     625                /** 
     626                 * character 
     627                 */ 
     628                CharSymbol(String string); 
     629                /** 
     630                 * character interval 
     631                 */ 
     632                CharacterInterval(String begin, String end); 
    348633        /** 
    349634         * left-hand side of variable declaration 
     
    354639               List<Modifier> mods = Collections.<Modifier>emptyList(), 
    355640               boolean mutable = false) implements Lhs, ImplicitGetterSetter; 
    356         /** 
    357          * Overloading specification 
    358          */ 
    359         _RewriteFnOverloadDecl(IdOrOpName name, 
    360                                List<IdOrOpName> fns) implements Decl; 
    361         /** 
    362          * functional declaration in components or APIs 
    363          * Names must be unqualified. 
    364          * 
    365          * functional declaration in components or APIs 
    366          * AbsFnDecl ::= AbsFnMods? FnHeaderFront FnHeaderClause 
    367          *             | FnSig 
    368          * FnSig ::= SimpleName : ArrowType 
    369          * FnHeaderFront ::= NamedFnHeaderFront 
    370          *                 | OpHeaderFront 
    371          * NamedFnHeaderFront ::= Id StaticParams? ValParam 
    372          * OpHeaderFront ::= opr StaticParams? BIG? (LeftEncloser | Encloser) 
    373          *                     Params (RightEncloser | Encloser) 
    374          *                 | opr StaticParams? ValParam (Op | ExponentOp) 
    375          *                 | opr BIG? (Op | ^ | Encloser) StaticParams? ValParam 
    376          * FnHeaderClause ::= IsType? FnClauses 
    377          * FnDecl ::= FnMods? FnHeaderFront FnHeaderClause 
    378          *          | FnSig 
    379          * e.g.) swap (x: Object, y: Object): (Object, Object) 
    380          * 
    381          * functional declaration in components 
    382          * FnDecl ::= FnMods? FnHeaderFront FnHeaderClause = Expr 
    383          * e.g.) swap (x, y) = (y, x) 
    384          */ 
    385         FnDecl(List<Modifier> mods = Collections.<Modifier>emptyList(), 
    386                IdOrOpOrAnonymousName name, 
    387                List<StaticParam> staticParams 
    388                    = Collections.<StaticParam>emptyList(), 
    389                List<Param> params = Collections.<Param>emptyList(), 
    390                Option<Type> returnType = Option.<Type>none(), 
    391                Option<List<BaseType>> throwsClause = Option.<List<BaseType>>none(), 
    392                Option<WhereClause> where = Option.<WhereClause>none(), 
    393                Option<Contract> contract = Option.<Contract>none(), 
    394                Id unambiguousName = new Id(in_span, "FN$"+in_span.toString()), 
    395                Option<Expr> body, 
    396                Option<Id> implementsUnambiguousName = Option.<Id>none()) 
    397               implements Applicable, GenericDecl; 
    398641        /** 
    399642         * value parameter of functional declarations and object declarations 
     
    423666             */ 
    424667            VarargsParam(Type type); 
    425         /** 
    426          * dimension and unit declaration 
    427          * DimUnitDecl may represent a single dimension declaration, a single 
    428          * unit declaration, or both dimension and unit declarations. 
    429          * DimUnitDecl ::= dim Id (= Type)? (unit | SI_unit) Id+ (= Expr)? 
    430          *               | dim Id (= Type)? (default Id)? 
    431          *               | (unit | SI_unit) Id+ (: Type)? (= Expr)? 
    432          */ 
    433         abstract DimUnitDecl() implements Decl; 
    434             /** 
    435              * dimension declaration 
    436              * Names for dim and default must be unqualified. 
    437              * e.g.) dim Length SI_unit meter meters m 
    438              */ 
    439             DimDecl(Id dim, Option<Type> derived = Option.<Type>none(), 
    440                     Option<Id> default = Option.<Id>none()); 
    441             /** 
    442              * unit declaration 
    443              * Names of units must be unqualified. 
    444              * e.g.) unit inch inches: Length 
    445              */ 
    446             UnitDecl(boolean si_unit = false, 
    447                      List<Id> units = Collections.<Id>emptyList(), 
    448                      Option<Type> dim = Option.<Type>none(), 
    449                      Option<Expr> def); 
    450         /** 
    451          * test declaration 
    452          * Names must be unqualified. 
    453          * TestDecl ::= test Id [ GeneratorClauseList ] = Expr 
    454          * e.g.) test fxLessThanFy[x <- E, y <- F] = assert(f(x) < f(y)) 
    455          */ 
    456         TestDecl(Id name, List<GeneratorClause> gens, Expr expr) 
    457                 implements Decl; 
    458         /** 
    459          * property declaration 
    460          * Names must be unqualified. 
    461          * PropertyDecl ::= property (Id = )? (FORALL ValParam)? Expr 
    462          * e.g.) property fIsMonotonic = FORALL (x:ZZ, y:ZZ) (x < y) -> (f(x) < f(y)) 
    463          */ 
    464         PropertyDecl(Option<Id> name = Option.<Id>none(), List<Param> params, 
    465                      Expr expr) implements Decl; 
    466         /** 
    467          * grammar declaration 
    468          * Names (but not extends elements) must be unqualified. 
    469          */ 
    470         abstract GrammarDecl(Id name, List<Id> extends) implements Decl; 
    471             /** 
    472              * grammar definition 
    473              */ 
    474             GrammarDef(List<GrammarMemberDecl> members, List<TransformerDecl> transformers, 
    475                        boolean native); 
    476         /** 
    477          * grammar member (nonterminal or terminal) declaration 
    478          * Names and params must be unqualified. 
    479          */ 
    480         abstract GrammarMemberDecl(Id name) implements Decl; 
    481             /** 
    482              * nonterminal declaration 
    483              */ 
    484             abstract NonterminalDecl(List<SyntaxDecl> syntaxDecls); 
    485                 /** 
    486                  * nonterminal definition in nonterminal declarations 
    487                  */ 
    488                 NonterminalDef(NonterminalHeader header, Option<BaseType> astType); 
    489                 /** 
    490                  * nonterminal extending definition in nonterminal declarations 
    491                  */ 
    492                 NonterminalExtensionDef(); 
    493         /** 
    494          * nonterminal header 
    495          */ 
    496         NonterminalHeader(Option<ModifierPrivate> modifier 
    497                             = Option.<ModifierPrivate>none(), 
    498                           Id name, 
    499                           List<NonterminalParameter> params, 
    500                           List<StaticParam> staticParams 
    501                             = Collections.<StaticParam>emptyList(), 
    502                           Option<Type> type, 
    503                           Option<WhereClause> whereClause 
    504                             = Option.<WhereClause>none()); 
    505  
    506         /** 
    507          * nonterminal parameter 
    508          */ 
    509         NonterminalParameter(Id name, BaseType type); 
    510  
    511         /** 
    512          * syntax declaration 
    513          */ 
    514         abstract SyntaxDecl(Option<String> modifier) implements Decl; 
    515             /** 
    516              * syntax definition in syntax declarations 
    517              */ 
    518             SyntaxDef(List<SyntaxSymbol> syntaxSymbols, 
    519                       TransformerDecl transformer); 
    520  
    521             SuperSyntaxDef(Id nonterminal, Id grammar); 
    522  
    523         /** 
    524           * Transformation declaration 
    525           */ 
    526         abstract TransformerDecl() implements Decl; 
    527             /** 
    528              * pre transformer definition in transformer declarations 
    529              */ 
    530             PreTransformerDef(Transformer transformer); 
    531             /** 
    532              * transformer definition in transformer declarations 
    533              */ 
    534             NamedTransformerDef(String name, List<NonterminalParameter> parameters, Transformer transformer); 
    535  
    536         /** 
    537          * Transformers 
    538          */ 
    539         abstract Transformer(); 
    540             /** 
    541              * Unparsed template 
    542              */ 
    543             UnparsedTransformer(String transformer, Id nonterminal); 
    544             /** 
    545              * Parsed template 
    546              */ 
    547             NodeTransformer(AbstractNode node); 
    548             /** 
    549              * Case-dispatch transformer expr 
    550              */ 
    551             CaseTransformer(Id gapName, List<CaseTransformerClause> clauses); 
    552  
    553         /** 
    554          * Case transformer clause 
    555          */ 
    556         CaseTransformerClause(Id constructor, List<Id> parameters, Transformer body); 
    557  
    558         /** 
    559           * syntax symbol 
    560           */ 
    561         abstract SyntaxSymbol(); 
    562             /** 
    563              * prefixed syntax symbol 
    564              */ 
    565             PrefixedSymbol(Id id, SyntaxSymbol symbol); 
    566             /** 
    567              * optional syntax symbol 
    568              */ 
    569             OptionalSymbol(SyntaxSymbol symbol); 
    570             /** 
    571              * repeat zero-or-more syntax symbol 
    572              */ 
    573             RepeatSymbol(SyntaxSymbol symbol); 
    574             /** 
    575              * repeat one-or-more syntax symbol 
    576              */ 
    577             RepeatOneOrMoreSymbol(SyntaxSymbol symbol); 
    578             /** 
    579              * ignore following whitespace syntax symbol 
    580              */ 
    581             NoWhitespaceSymbol(SyntaxSymbol symbol); 
    582             /** 
    583              * groups of symbols 
    584              */ 
    585             GroupSymbol(List<SyntaxSymbol> symbols); 
    586             /** 
    587              * special symbols syntax symbol 
    588              */ 
    589             abstract SpecialSymbol(); 
    590                 /** 
    591                  * any character syntax symbol 
    592                  */ 
    593                 AnyCharacterSymbol(); 
    594                 /** 
    595                  * whitespace syntax symbol 
    596                  */ 
    597                 WhitespaceSymbol(String s); 
    598                 /** 
    599                  * tab syntax symbol 
    600                  */ 
    601                 TabSymbol(); 
    602                 /** 
    603                  * formfeed syntax symbol 
    604                  */ 
    605                 FormfeedSymbol(); 
    606                 /** 
    607                  * carriage return syntax symbol 
    608                  */ 
    609                 CarriageReturnSymbol(); 
    610                 /** 
    611                  * backspace syntax symbol 
    612                  */ 
    613                 BackspaceSymbol(); 
    614                 /** 
    615                  * newline syntax symbol 
    616                  */ 
    617                 NewlineSymbol(); 
    618                 /** 
    619                  * breakline syntax symbol 
    620                  */ 
    621                 BreaklineSymbol(String s); 
    622             /** 
    623              * item syntax symbol; 
    624              * may be either nonterminal or keyword 
    625              */ 
    626             ItemSymbol(String item); 
    627             /** 
    628              * non-terminal syntax symbol 
    629              */ 
    630             NonterminalSymbol(Id nonterminal); 
    631             /** 
    632              * keyword syntax symbol 
    633              */ 
    634             KeywordSymbol(String token); 
    635             /** 
    636              * token syntax symbol 
    637              */ 
    638             TokenSymbol(String token); 
    639             /** 
    640              * not predicate syntax symbol 
    641              */ 
    642             NotPredicateSymbol(SyntaxSymbol symbol); 
    643             /** 
    644              * and predicate syntax symbol 
    645              */ 
    646             AndPredicateSymbol(SyntaxSymbol symbol); 
    647             /** 
    648              * character class syntax symbol 
    649              */ 
    650             CharacterClassSymbol(List<CharacterSymbol> characters); 
    651             /** 
    652              * character symbols 
    653              */ 
    654             abstract CharacterSymbol(); 
    655                 /** 
    656                  * character 
    657                  */ 
    658                 CharSymbol(String string); 
    659                 /** 
    660                  * character interval 
    661                  */ 
    662                 CharacterInterval(String begin, String end); 
    663668        /** 
    664669         * expression 
     
    16831688             * e.g.) type IntList = List[\ZZ64\] 
    16841689             */ 
    1685             TypeAlias(Id name, 
    1686                       List<StaticParam> staticParams 
    1687                           = Collections.<StaticParam>emptyList(), 
    1688                       Type type) 
    1689                      implements Decl; 
     1690            WhereTypeAlias(TypeAlias alias); 
    16901691            /** 
    16911692             * coercion constraint declared in where clauses 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildEnvironments.java

    r3096 r3097  
    922922                        interior.putType(string_name, ft); 
    923923                    } 
    924                 } else if (w instanceof TypeAlias) { 
    925                     /* 
    926                      * This is problematic; the type bound to the alias cannot 
    927                      * quite be evaluated yet, but it might be necessary for 
    928                      * some of the other clauses. What we need is a little 
    929                      * topological order. 
    930                      */ 
    931924                } else { 
    932925                    bug(w, errorMsg("Where clause ", w)); 
     
    960953                        } 
    961954                    } 
    962                 } else if (w instanceof TypeAlias) { 
    963                     /* 
    964                      * This is problematic; the type bound to the alias cannot 
    965                      * quite be evaluated yet, but it might be necessary for 
    966                      * some of the other clauses. What we need is a little 
    967                      * topological order. 
    968                      */ 
    969                     // For now, assume that the order in the where clause is 
    970                     // topological. 
    971                     TypeAlias ta = (TypeAlias) w; 
    972                     Id name = ta.getName(); 
    973                     Type type = ta.getType(); 
    974                     interior.putType(NodeUtil.nameString(name), et.evalType(type)); 
    975955                } else { 
    976956                    bug(w, errorMsg("Where clause ", w)); 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/values/SingleFcn.java

    r3053 r3097  
    204204        if ( wcl.isSome() ) { 
    205205            for (WhereConstraint wc : wcl.unwrap().getConstraints()) { 
    206                 if (wc instanceof TypeAlias) { 
    207                     TypeAlias ta = (TypeAlias) wc; 
    208                     NI.nyi("Where clauses - type alias"); 
    209                 } else if (wc instanceof WhereExtends) { 
     206                if (wc instanceof WhereExtends) { 
    210207                    WhereExtends we = (WhereExtends) wc; 
    211208                    String we_name = we.getName().getText(); 
     
    247244        if ( wcl.isSome() ) { 
    248245            for (WhereConstraint wc : wcl.unwrap().getConstraints()) { 
    249                 if (wc instanceof TypeAlias) { 
    250                     NI.nyi("Where clauses - type alias"); 
    251                     TypeAlias ta = (TypeAlias) wc; 
    252                 } else if (wc instanceof WhereExtends) { 
     246                if (wc instanceof WhereExtends) { 
    253247                    WhereExtends we = (WhereExtends) wc; 
    254248                    String we_name = we.getName().getText(); 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/MayNewlineHeader.rats

    r3081 r3097  
    6262       yyValue = new WhereExtends(span, id, a2); 
    6363     } 
    64    / TypeAlias 
     64   / a1:TypeAlias 
     65     { yyValue = new WhereTypeAlias(createSpan(yyStart,yyCount), a1); } 
    6566   / a1:Type w coerces w a2:Type 
    6667     { yyValue = new WhereCoerces(createSpan(yyStart,yyCount), a1, a2); }