Changeset 2170

Show
Ignore:
Timestamp:
07/03/08 09:02:42 (3 months ago)
Author:
jon
Message:

[ast] add ellipses node explicitly for syntax abstraction

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ProjectFortress/astgen/Fortress.ast

    r2109 r2170  
    689689         */ 
    690690        abstract Expr(boolean parenthesized = false); 
     691 
     692            /** 
     693             * Repeated expression in a macro 
     694             */ 
     695            _EllipsesExpr(Expr expr); 
     696 
    691697            /** 
    692698             * Template gap for expressions 
  • trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ExprFactory.java

    r2163 r2170  
    4444import com.sun.fortress.nodes.Do; 
    4545import com.sun.fortress.nodes.DoFront; 
     46import com.sun.fortress.nodes._EllipsesExpr; 
    4647import com.sun.fortress.nodes.Enclosing; 
    4748import com.sun.fortress.nodes.Exit; 
     
    648649        return expr.accept(new NodeAbstractVisitor<Expr>() { 
    649650            @Override 
    650    public Expr for_RewriteFnApp(_RewriteFnApp that) { 
    651              return new _RewriteFnApp(that.getSpan(),true,that.getFunction(),that.getArgument()); 
    652    } 
    653    @Override 
    654    public Expr for_RewriteObjectRef(_RewriteObjectRef that) { 
    655     return new _RewriteObjectRef(that.getSpan(),true,that.getObj(),that.getStaticArgs()); 
    656    } 
    657    public Expr forAsExpr(AsExpr e) { 
    658                 return new AsExpr(e.getSpan(), true, e.getExpr(), e.getType()); 
    659             } 
    660             public Expr forAsIfExpr(AsIfExpr e) { 
    661                 return new AsIfExpr(e.getSpan(), true, e.getExpr(), e.getType()); 
    662             } 
    663             public Expr forAssignment(Assignment e) { 
    664                 return new Assignment(e.getSpan(), true, e.getLhs(), e.getOpr(), 
    665                         e.getRhs()); 
    666             } 
    667             public Expr forBlock(Block e) { 
    668                 return new Block(e.getSpan(), true, e.getExprs()); 
    669             } 
    670             public Expr forCaseExpr(CaseExpr e) { 
    671                 return new CaseExpr(e.getSpan(), true, e.getParam(), 
    672                         e.getCompare(), e.getClauses(), 
    673                         e.getElseClause()); 
    674             } 
    675             public Expr forDo(Do e) { 
    676                 return new Do(e.getSpan(), true, e.getFronts()); 
    677             } 
    678             public Expr forFor(For e) { 
    679                 return new For(e.getSpan(), true, e.getGens(), e.getBody()); 
    680             } 
    681             public Expr forIf(If e) { 
    682                 return new If(e.getSpan(), true, e.getClauses(), 
    683                         e.getElseClause()); 
    684             } 
    685             public Expr forLabel(Label e) { 
    686                 return new Label(e.getSpan(), true, e.getName(), e.getBody()); 
    687             } 
    688             public Expr forMathPrimary(MathPrimary e) { 
    689                 return new MathPrimary(e.getSpan(), true, e.getFront(), 
    690                         e.getRest()); 
    691             } 
    692             public Expr forObjectExpr(ObjectExpr e) { 
    693                 return new ObjectExpr(e.getSpan(), true, e.getExtendsClause(), 
    694                         e.getDecls()); 
    695             } 
    696             public Expr for_RewriteObjectExpr(_RewriteObjectExpr e) { 
    697                 return new _RewriteObjectExpr(e.getSpan(), true, 
    698                         e.getExtendsClause(), e.getDecls(), 
    699                         e.getImplicitTypeParameters(), 
    700                         e.getGenSymName(), 
    701                         e.getStaticParams(), 
    702                         e.getStaticArgs(), e.getParams()); 
    703             } 
    704             public Expr forTry(Try e) { 
    705                 return new Try(e.getSpan(), true, e.getBody(), 
    706                         e.getCatchClause(), e.getForbid(), 
    707                         e.getFinallyClause()); 
    708             } 
    709             public Expr forArgExpr(ArgExpr e) { 
    710                 return new ArgExpr(e.getSpan(), true, e.getExprs(), e.getVarargs()); 
    711             } 
    712             public Expr forTupleExpr(TupleExpr e) { 
    713                 return new TupleExpr(e.getSpan(), true, e.getExprs()); 
    714             } 
    715             public Expr forTypecase(Typecase e) { 
    716                 return new Typecase(e.getSpan(), true, e.getBindIds(), 
    717                                     e.getBindExpr(), e.getClauses(), 
    718                                     e.getElseClause()); 
    719             } 
    720             public Expr forWhile(While e) { 
    721                 return new While(e.getSpan(), true, e.getTest(), e.getBody()); 
    722             } 
    723             public Expr forAccumulator(Accumulator e) { 
    724                 return new Accumulator(e.getSpan(), true, e.getStaticArgs(), 
    725                         e.getOpr(), e.getGens(), e.getBody()); 
    726             } 
    727             public Expr forAtomicExpr(AtomicExpr e) { 
    728                 return new AtomicExpr(e.getSpan(), true, e.getExpr()); 
    729             } 
    730             public Expr forExit(Exit e) { 
    731                 return new Exit(e.getSpan(), true, e.getTarget(), e.getReturnExpr()); 
    732             } 
    733             public Expr forSpawn(Spawn e) { 
    734                 return new Spawn(e.getSpan(), true, e.getBody()); 
    735             } 
    736             public Expr forThrow(Throw e) { 
    737                 return new Throw(e.getSpan(), true, e.getExpr()); 
    738             } 
    739             public Expr forTryAtomicExpr(TryAtomicExpr e) { 
    740                 return new TryAtomicExpr(e.getSpan(), true, e.getExpr()); 
    741             } 
    742             public Expr forFnExpr(FnExpr e) { 
    743                 return new FnExpr(e.getSpan(), true, e.getName(), 
    744                         e.getStaticParams(), e.getParams(), 
    745                         e.getReturnType(), e.getWhere(), 
    746                         e.getThrowsClause(), e.getBody()); 
    747             } 
    748             public Expr forGeneratedExpr(GeneratedExpr e) { 
    749                 return new GeneratedExpr(e.getSpan(), true, 
    750                         e.getExpr(), e.getGens()); 
    751             } 
    752             public Expr forLetFn(LetFn e) { 
    753                 return new LetFn(e.getSpan(), true, e.getBody(), e.getFns()); 
    754             } 
    755             public Expr forLocalVarDecl(LocalVarDecl e) { 
    756                 return new LocalVarDecl(e.getSpan(), true, e.getBody(), 
    757                         e.getLhs(), e.getRhs()); 
    758             } 
    759             public Expr forOpExpr(OpExpr e) { 
    760                 return new OpExpr(e.getSpan(), true, e.getOp(), e.getArgs()); 
    761             } 
    762             public Expr forArrayElement(ArrayElement e) { 
    763                 return new ArrayElement(e.getSpan(), true, e.getElement()); 
    764             } 
    765             public Expr forArrayElements(ArrayElements e) { 
    766                 return new ArrayElements(e.getSpan(), true, e.getDimension(), 
    767                         e.getElements()); 
    768             } 
    769             public Expr forFloatLiteralExpr(FloatLiteralExpr e) { 
    770                 return new FloatLiteralExpr(e.getSpan(), true, e.getText(), 
    771                         e.getIntPart(), e.getNumerator(), 
    772                         e.getDenomBase(), e.getDenomPower()); 
    773             } 
    774             public Expr forIntLiteralExpr(IntLiteralExpr e) { 
    775                 return new IntLiteralExpr(e.getSpan(), true, e.getText(), 
    776                         e.getVal()); 
    777             } 
    778             public Expr forCharLiteralExpr(CharLiteralExpr e) { 
    779                 return new CharLiteralExpr(e.getSpan(), true, e.getText(), 
    780                         e.getVal()); 
    781             } 
    782             public Expr forStringLiteralExpr(StringLiteralExpr e) { 
    783                 return new StringLiteralExpr(e.getSpan(), true, e.getText()); 
    784             } 
    785             public Expr forVoidLiteralExpr(VoidLiteralExpr e) { 
    786                 return new VoidLiteralExpr(e.getSpan(), true, e.getText()); 
    787             } 
    788             public Expr forVarRef(VarRef e) { 
    789                 return new VarRef(e.getSpan(), true, e.getVar()); 
    790             } 
    791             public Expr forArrayComprehension(ArrayComprehension e) { 
    792                 return new ArrayComprehension(e.getSpan(), true, e.getClauses()); 
    793             } 
    794             public Expr forChainExpr(ChainExpr e) { 
    795                 return new ChainExpr(e.getSpan(), true, e.getFirst(), 
    796                                      e.getLinks()); 
    797             } 
    798             public Expr forFieldRef(FieldRef e) { 
    799                 return new FieldRef(e.getSpan(), true, e.getObj(), 
    800                                     e.getField()); 
    801             } 
    802             public Expr forMethodInvocation(MethodInvocation e) { 
    803                 return new MethodInvocation(e.getSpan(), true, e.getObj(), 
    804                                             e.getMethod(), e.getStaticArgs(), 
    805                                             e.getArg()); 
    806             } 
    807             public Expr forLooseJuxt(LooseJuxt e) { 
    808                 return new LooseJuxt(e.getSpan(), true, e.getExprs()); 
    809             } 
    810             public Expr forTightJuxt(TightJuxt e) { 
    811                 return new TightJuxt(e.getSpan(), true, e.getExprs()); 
    812             } 
    813             public Expr forFnRef(FnRef e) { 
    814                 return new FnRef(e.getSpan(), true, e.getOriginalName(), e.getFns(), 
    815                         e.getStaticArgs()); 
    816             } 
    817             public Expr forOpRef(OpRef e) { 
    818                 return new OpRef(e.getSpan(), true, e.getOriginalName(), e.getOps(), 
    819                         e.getStaticArgs()); 
    820             } 
    821             public Expr forSubscriptExpr(SubscriptExpr e) { 
    822                 return new SubscriptExpr(e.getSpan(), true, e.getObj(), 
    823                         e.getSubs(), e.getOp(), 
    824                         e.getStaticArgs()); 
    825             } 
    826             public Expr forTemplateGapExpr(TemplateGapExpr e) { 
    827                 return new TemplateGapExpr(e.getSpan(), true, e.getId(), e.getTemplateParams()); 
    828             } 
    829             public Expr defaultCase(Node x) { 
    830                 return bug(x, "makeInParentheses: " + x.getClass() + 
    831                         " is not a subtype of Expr."); 
    832             } 
     651            public Expr for_RewriteFnApp(_RewriteFnApp that) { 
     652                return new _RewriteFnApp(that.getSpan(),true,that.getFunction(),that.getArgument()); 
     653            } 
     654        @Override 
     655            public Expr for_RewriteObjectRef(_RewriteObjectRef that) { 
     656                return new _RewriteObjectRef(that.getSpan(),true,that.getObj(),that.getStaticArgs()); 
     657            } 
     658        public Expr forAsExpr(AsExpr e) { 
     659            return new AsExpr(e.getSpan(), true, e.getExpr(), e.getType()); 
     660        } 
     661        public Expr forAsIfExpr(AsIfExpr e) { 
     662            return new AsIfExpr(e.getSpan(), true, e.getExpr(), e.getType()); 
     663        } 
     664        @Override 
     665        public Expr for_EllipsesExpr(_EllipsesExpr e){ 
     666            return new _EllipsesExpr(e.getSpan(), true, e.getExpr()); 
     667        } 
     668 
     669        public Expr forAssignment(Assignment e) { 
     670            return new Assignment(e.getSpan(), true, e.getLhs(), e.getOpr(), 
     671                e.getRhs()); 
     672        } 
     673        public Expr forBlock(Block e) { 
     674            return new Block(e.getSpan(), true, e.getExprs()); 
     675        } 
     676        public Expr forCaseExpr(CaseExpr e) { 
     677            return new CaseExpr(e.getSpan(), true, e.getParam(), 
     678                    e.getCompare(), e.getClauses(), 
     679                    e.getElseClause()); 
     680        } 
     681        public Expr forDo(Do e) { 
     682            return new Do(e.getSpan(), true, e.getFronts()); 
     683        } 
     684        public Expr forFor(For e) { 
     685            return new For(e.getSpan(), true, e.getGens(), e.getBody()); 
     686        } 
     687        public Expr forIf(If e) { 
     688            return new If(e.getSpan(), true, e.getClauses(), 
     689                    e.getElseClause()); 
     690        } 
     691        public Expr forLabel(Label e) { 
     692            return new Label(e.getSpan(), true, e.getName(), e.getBody()); 
     693        } 
     694        public Expr forMathPrimary(MathPrimary e) { 
     695            return new MathPrimary(e.getSpan(), true, e.getFront(), 
     696                    e.getRest()); 
     697        } 
     698        public Expr forObjectExpr(ObjectExpr e) { 
     699            return new ObjectExpr(e.getSpan(), true, e.getExtendsClause(), 
     700                    e.getDecls()); 
     701        } 
     702        public Expr for_RewriteObjectExpr(_RewriteObjectExpr e) { 
     703            return new _RewriteObjectExpr(e.getSpan(), true, 
     704                    e.getExtendsClause(), e.getDecls(), 
     705                    e.getImplicitTypeParameters(), 
     706                    e.getGenSymName(), 
     707                    e.getStaticParams(), 
     708                    e.getStaticArgs(), e.getParams()); 
     709        } 
     710        public Expr forTry(Try e) { 
     711            return new Try(e.getSpan(), true, e.getBody(), 
     712                    e.getCatchClause(), e.getForbid(), 
     713                    e.getFinallyClause()); 
     714        } 
     715        public Expr forArgExpr(ArgExpr e) { 
     716            return new ArgExpr(e.getSpan(), true, e.getExprs(), e.getVarargs()); 
     717        } 
     718        public Expr forTupleExpr(TupleExpr e) { 
     719            return new TupleExpr(e.getSpan(), true, e.getExprs()); 
     720        } 
     721        public Expr forTypecase(Typecase e) { 
     722            return new Typecase(e.getSpan(), true, e.getBindIds(), 
     723                    e.getBindExpr(), e.getClauses(), 
     724                    e.getElseClause()); 
     725        } 
     726        public Expr forWhile(While e) { 
     727            return new While(e.getSpan(), true, e.getTest(), e.getBody()); 
     728        } 
     729        public Expr forAccumulator(Accumulator e) { 
     730            return new Accumulator(e.getSpan(), true, e.getStaticArgs(), 
     731                    e.getOpr(), e.getGens(), e.getBody()); 
     732        } 
     733        public Expr forAtomicExpr(AtomicExpr e) { 
     734            return new AtomicExpr(e.getSpan(), true, e.getExpr()); 
     735        } 
     736        public Expr forExit(Exit e) { 
     737            return new Exit(e.getSpan(), true, e.getTarget(), e.getReturnExpr()); 
     738        } 
     739        public Expr forSpawn(Spawn e) { 
     740            return new Spawn(e.getSpan(), true, e.getBody()); 
     741        } 
     742        public Expr forThrow(Throw e) { 
     743            return new Throw(e.getSpan(), true, e.getExpr()); 
     744        } 
     745        public Expr forTryAtomicExpr(TryAtomicExpr e) { 
     746            return new TryAtomicExpr(e.getSpan(), true, e.getExpr()); 
     747        } 
     748        public Expr forFnExpr(FnExpr e) { 
     749            return new FnExpr(e.getSpan(), true, e.getName(), 
     750                    e.getStaticParams(), e.getParams(), 
     751                    e.getReturnType(), e.getWhere(), 
     752                    e.getThrowsClause(), e.getBody()); 
     753        } 
     754        public Expr forGeneratedExpr(GeneratedExpr e) { 
     755            return new GeneratedExpr(e.getSpan(), true, 
     756                    e.getExpr(), e.getGens()); 
     757        } 
     758        public Expr forLetFn(LetFn e) { 
     759            return new LetFn(e.getSpan(), true, e.getBody(), e.getFns()); 
     760        } 
     761        public Expr forLocalVarDecl(LocalVarDecl e) { 
     762            return new LocalVarDecl(e.getSpan(), true, e.getBody(), 
     763                    e.getLhs(), e.getRhs()); 
     764        } 
     765        public Expr forOpExpr(OpExpr e) { 
     766            return new OpExpr(e.getSpan(), true, e.getOp(), e.getArgs()); 
     767        } 
     768        public Expr forArrayElement(ArrayElement e) { 
     769            return new ArrayElement(e.getSpan(), true, e.getElement()); 
     770        } 
     771        public Expr forArrayElements(ArrayElements e) { 
     772            return new ArrayElements(e.getSpan(), true, e.getDimension(), 
     773                    e.getElements()); 
     774        } 
     775        public Expr forFloatLiteralExpr(FloatLiteralExpr e) { 
     776            return new FloatLiteralExpr(e.getSpan(), true, e.getText(), 
     777                    e.getIntPart(), e.getNumerator(), 
     778                    e.getDenomBase(), e.getDenomPower()); 
     779        } 
     780        public Expr forIntLiteralExpr(IntLiteralExpr e) { 
     781            return new IntLiteralExpr(e.getSpan(), true, e.getText(), 
     782                    e.getVal()); 
     783        } 
     784        public Expr forCharLiteralExpr(CharLiteralExpr e) { 
     785            return new CharLiteralExpr(e.getSpan(), true, e.getText(), 
     786                    e.getVal()); 
     787        } 
     788        public Expr forStringLiteralExpr(StringLiteralExpr e) { 
     789            return new StringLiteralExpr(e.getSpan(), true, e.getText()); 
     790        } 
     791        public Expr forVoidLiteralExpr(VoidLiteralExpr e) { 
     792            return new VoidLiteralExpr(e.getSpan(), true, e.getText()); 
     793        } 
     794        public Expr forVarRef(VarRef e) { 
     795            return new VarRef(e.getSpan(), true, e.getVar()); 
     796        } 
     797        public Expr forArrayComprehension(ArrayComprehension e) { 
     798            return new ArrayComprehension(e.getSpan(), true, e.getClauses()); 
     799        } 
     800        public Expr forChainExpr(ChainExpr e) { 
     801            return new ChainExpr(e.getSpan(), true, e.getFirst(), 
     802                    e.getLinks()); 
     803        } 
     804        public Expr forFieldRef(FieldRef e) { 
     805            return new FieldRef(e.getSpan(), true, e.getObj(), 
     806                    e.getField()); 
     807        } 
     808        public Expr forMethodInvocation(MethodInvocation e) { 
     809            return new MethodInvocation(e.getSpan(), true, e.getObj(), 
     810                    e.getMethod(), e.getStaticArgs(), 
     811                    e.getArg()); 
     812        } 
     813        public Expr forLooseJuxt(LooseJuxt e) { 
     814            return new LooseJuxt(e.getSpan(), true, e.getExprs()); 
     815        } 
     816        public Expr forTightJuxt(TightJuxt e) { 
     817            return new TightJuxt(e.getSpan(), true, e.getExprs()); 
     818        } 
     819        public Expr forFnRef(FnRef e) { 
     820            return new FnRef(e.getSpan(), true, e.getOriginalName(), e.getFns(), 
     821                    e.getStaticArgs()); 
     822        } 
     823        public Expr forOpRef(OpRef e) { 
     824            return new OpRef(e.getSpan(), true, e.getOriginalName(), e.getOps(), 
     825                    e.getStaticArgs()); 
     826        } 
     827        public Expr forSubscriptExpr(SubscriptExpr e) { 
     828            return new SubscriptExpr(e.getSpan(), true, e.getObj(), 
     829                    e.getSubs(), e.getOp(), 
     830                    e.getStaticArgs()); 
     831        } 
     832        public Expr forTemplateGapExpr(TemplateGapExpr e) { 
     833            return new TemplateGapExpr(e.getSpan(), true, e.getId(), e.getTemplateParams()); 
     834        } 
     835        public Expr defaultCase(Node x) { 
     836            return bug(x, "makeInParentheses: " + x.getClass() + 
     837                    " is not a subtype of Expr."); 
     838        } 
    833839        }); 
    834840    } 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/Expression.rats

    r2168 r2170  
    6262     <As> As 
    6363   / <Asif> AsIf 
    64    / <DoubleStar> Star 
     64   / <DoubleStar> Ellipsis 
    6565   ; 
    6666 
     
    8383     }; 
    8484 
    85 constant inline Action<Expr> Star
     85constant inline Action<Expr> Ellipsis
    8686     DoubleStar 
    8787     { yyValue = new Action<Expr>() { 
    8888           public Expr run(Expr base) { 
    89                return base
     89               return new _EllipsesExpr(base)
    9090           }}; 
    9191     }; 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/NoNewlineExpr.rats

    r2168 r2170  
    6161     <As> NoNewlineAs 
    6262   / <AsIf> NoNewlineAsIf 
    63    / <DoubleStar> NoNewlineStar 
     63   / <DoubleStar> NoNewlineEllipsis 
    6464   ; 
    6565 
     
    8484     }; 
    8585 
    86 constant inline Action<Expr> NoNewlineStar
     86constant inline Action<Expr> NoNewlineEllipsis
    8787     DoubleStar 
    8888     { yyValue = new Action<Expr>() { 
    8989           public Expr run(Expr base) { 
    90                return base
     90               return new _EllipsesExpr(base)
    9191           }}; 
    9292     };