Changeset 1907

Show
Ignore:
Timestamp:
06/13/08 07:38:58 (6 months ago)
Author:
jdn
Message:

[Syntax] Factored gaps out of the Core Fortress parser and into the template parser

Files:

Legend:

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

    r1899 r1907  
    724724        abstract DelimitedExpr(); 
    725725            /** 
     726             * Template gap for expressions 
     727             */ 
     728            TemplateGapDelimitedExpr(Id id, List<Id> templateParams) implements TemplateGap; 
     729            /** 
    726730             * sequence of block elements implicitly enclosed by do/end 
    727731             * BlockElems ::= BlockElem+ 
     
    9991003        abstract SimpleExpr(); 
    10001004            /** 
     1005             * Template gap for simple expressions 
     1006             */ 
     1007            TemplateGapSimpleExpr(Id id, List<Id> templateParams) implements TemplateGap; 
     1008            /** 
    10011009             * subscripting expression 
    10021010             * SubscriptExpr ::= Primary LeftEncloser ExprList? RightEncloser 
     
    10121020             */ 
    10131021            abstract Primary(); 
     1022                /** 
     1023                 * Template gap for primary expressions 
     1024                 */ 
     1025                TemplateGapPrimary(Id id, List<Id> templateParams) implements TemplateGap; 
    10141026                /** 
    10151027                 * literal 
     
    19411953    abstract Name(); 
    19421954        /** 
     1955         * Template gap for names 
     1956         */ 
     1957        TemplateGapName(Id id, List<Id> templateParams) implements TemplateGap; 
     1958        /** 
    19431959         * unstructured sequence of ids naming an API or component 
    19441960         * APIName ::= Id(.Id)* 
  • trunk/ProjectFortress/build.xml

    r1905 r1907  
    541541    </target> 
    542542 
    543     <target name="testSyntaxAbs" depends="compile" 
     543    <target name="testsyntax" depends="compile" 
    544544            description="Run SyntaxAbstractionJUTests."> 
    545545        <mkdir dir="${test.results}"/> 
  • trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ExprFactory.java

    r1899 r1907  
    8585import com.sun.fortress.nodes.SubscriptingMI; 
    8686import com.sun.fortress.nodes.TemplateGapCharLiteralExpr; 
     87import com.sun.fortress.nodes.TemplateGapDelimitedExpr; 
    8788import com.sun.fortress.nodes.TemplateGapExpr; 
    8889import com.sun.fortress.nodes.TemplateGapFloatLiteralExpr; 
    8990import com.sun.fortress.nodes.TemplateGapFnExpr; 
     91import com.sun.fortress.nodes.TemplateGapName; 
    9092import com.sun.fortress.nodes.TemplateGapId; 
    9193import com.sun.fortress.nodes.TemplateGapIntLiteralExpr; 
     
    9395import com.sun.fortress.nodes.TemplateGapLooseJuxt; 
    9496import com.sun.fortress.nodes.TemplateGapNumberLiteralExpr; 
     97import com.sun.fortress.nodes.TemplateGapPrimary; 
     98import com.sun.fortress.nodes.TemplateGapSimpleExpr; 
    9599import com.sun.fortress.nodes.TemplateGapStringLiteralExpr; 
    96100import com.sun.fortress.nodes.TemplateGapVoidLiteralExpr; 
     
    811815    } 
    812816     
     817    public static TemplateGapDelimitedExpr makeTemplateGapDelimitedExpr(Span s, Id id, List<Id> params) { 
     818        return new TemplateGapDelimitedExpr(s, id, params); 
     819    } 
     820     
     821    public static TemplateGapSimpleExpr makeTemplateGapSimpleExpr(Span s, Id id, List<Id> params) { 
     822        return new TemplateGapSimpleExpr(s, id, params); 
     823    } 
     824     
     825    public static TemplateGapPrimary makeTemplateGapPrimary(Span s, Id id, List<Id> params) { 
     826        return new TemplateGapPrimary(s, id, params); 
     827    } 
     828     
    813829    public static TemplateGapFnExpr makeTemplateGapFnExpr(Span s, Id id, List<Id> params) { 
    814830        Expr body = new VarRef(id); 
     
    820836    } 
    821837 
     838    public static TemplateGapName makeTemplateGapName(Span s, Id id, List<Id> params) { 
     839        return new TemplateGapName(s, id, params); 
     840    } 
     841     
    822842    public static TemplateGapId makeTemplateGapId(Span s, Id id, List<Id> params) { 
    823843        return new TemplateGapId(s, "IdGap:"+id.getText(), id, params); 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/Expression.rats

    r1899 r1907  
    2222                                          MayNewlineHeader, Type, DelimitedExpr, 
    2323                                          Literal, Identifier, Keyword, Symbol, 
    24                                           Spacing, Gaps); 
     24                                          Spacing); 
    2525 
    2626import Param; 
     
    3434import Symbol; 
    3535import Spacing; 
    36 import Gaps; 
    3736 
    3837/* Expr ::= 
     
    5352   / DelimitedExpr 
    5453   / <Flow> FlowExpr 
    55    / ExprGap 
    56    / FnExprGap 
    5754   / <Fn> fn w a1:ValParam a2:(w IsType)? a3:(w Throws)? w match w a4:Expr 
    5855     { Option<Type> ty_opt = Option.wrap(a2); 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/Fortress.rats

    r1895 r1907  
    8787                                               DelimitedExpr, Literal, 
    8888                                               Identifier, Keyword, Symbol, 
    89                                                Spacing, Gaps
     89                                               Spacing
    9090            as Expression; 
    9191instantiate com.sun.fortress.parser.DelimitedExpr(TraitObject, NoNewlineHeader, 
     
    103103instantiate com.sun.fortress.parser.Literal(MayNewlineHeader, DelimitedExpr, 
    104104                                            NoSpaceExpr, Symbol, 
    105                                             Spacing, Identifier, Gaps
     105                                            Spacing, Identifier
    106106            as Literal; 
    107107instantiate com.sun.fortress.parser.LocalDecl(Variable, Function, Parameter, 
     
    112112            as LocalDecl; 
    113113instantiate com.sun.fortress.parser.Identifier(Keyword, Symbol, 
    114                                                Unicode, Spacing, Gaps
     114                                               Unicode, Spacing
    115115            as Identifier; 
    116116instantiate com.sun.fortress.parser.Symbol(DelimitedExpr, LocalDecl, 
     
    124124instantiate com.sun.fortress.parser.Unicode 
    125125            as Unicode; 
    126 instantiate com.sun.fortress.parser.Gaps(Symbol, Spacing, Identifier) 
    127             as Gaps; 
    128126 
    129127header { 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/Identifier.rats

    r1849 r1907  
    2020 */ 
    2121module com.sun.fortress.parser.Identifier(Keyword, Symbol, Unicode, 
    22                                           Spacing, Gaps); 
     22                                          Spacing); 
    2323 
    2424import Keyword; 
     
    2626import Unicode; 
    2727import Spacing; 
    28 import Gaps; 
    2928 
    3029option setOfString(FORTRESS_KEYWORDS); 
     
    5251 
    5352Id Id =  
    54      IdGap 
    55    / a1:IdText { yyValue = new Id(createSpan(yyStart,yyCount), a1); }; 
     53     <FIRST> a1:IdText { yyValue = new Id(createSpan(yyStart,yyCount), a1); }; 
    5654 
    5755/* BindId ::= Id / _ */ 
     
    6967 */ 
    7068List<Id> BindIdOrBindIdTuple = 
    71      BindIdOrBindIdTupleGap 
    72    / a1:BindId 
     69     <FIRST> a1:BindId 
    7370     { yyValue = FortressUtil.mkList(a1); } 
    7471   / openparen w a1:BindId w comma w a2s:BindIdList w closeparen 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/Literal.rats

    r1849 r1907  
    2121module com.sun.fortress.parser.Literal(MayNewlineHeader, DelimitedExpr, 
    2222                                       NoSpaceExpr, Symbol, Spacing, 
    23                                        Identifier, Gaps); 
     23                                       Identifier); 
    2424 
    2525import MayNewlineHeader; 
     
    2929import Spacing; 
    3030import Identifier; 
    31 import Gaps; 
    3231 
    3332/* LiteralExpr ::= 
     
    3837 */ 
    3938Expr LiteralExpr = 
    40      ExprGap 
    41    / LooseJuxtGap 
    42    / LiteralExprGap 
    43    / <VOID> VoidLiteralExpr 
     39   <VOID> VoidLiteralExpr 
    4440   / <NUMERICAL> NumericLiteralExpr 
    4541   / <CHAR>CharLiteralExpr 
     
    6965 
    7066Expr VoidLiteralExpr = 
    71      VoidLiteralExprGap 
    72    / <VOID> openparen w closeparen 
     67     <FIRST> openparen w closeparen 
    7368     { yyValue = ExprFactory.makeVoidLiteralExpr(createSpan(yyStart,yyCount)); }; 
    7469 
    7570NumberLiteralExpr NumericLiteralExpr = 
    76      NumberLiteralExprGap 
    77    / FloatLiteralExpr 
     71     FloatLiteralExpr 
    7872   / IntLiteralExpr ; 
    7973 
    8074transient FloatLiteralExpr FloatLiteralExpr =  
    81      FloatLiteralExprGap 
    82    / a1:DigitString dot a2:DigitString 
     75     <FIRST> a1:DigitString dot a2:DigitString 
    8376     { yyValue = ExprFactory.makeFloatLiteralExpr(createSpan(yyStart,yyCount), 
    8477                                                  a1 + "." + a2); }; 
    8578 
    8679transient IntLiteralExpr IntLiteralExpr =  
    87      IntLiteralExprGap 
    88    / a1:DigitString 
     80     <FIRST> a1:DigitString 
    8981     { yyValue = ExprFactory.makeIntLiteralExpr(createSpan(yyStart,yyCount), 
    9082                                                a1); 
     
    9486 
    9587CharLiteralExpr CharLiteralExpr = 
    96      CharLiteralExprGap 
    97    / "'" a1:CharLiteralContent "'" 
     88     <FIRST> "'" a1:CharLiteralContent "'" 
    9889     { yyValue = ExprFactory.makeCharLiteralExpr(createSpan(yyStart,yyCount), 
    9990                                                 a1); 
     
    10192 
    10293StringLiteralExpr StringLiteralExpr =  
    103      StringLiteralExprGap 
    104    / ["] a1:StringLiteralContent* ["] 
     94     <FIRST> ["] a1:StringLiteralContent* ["] 
    10595     { String str = ""; 
    10696       for (String c : (List<String>)a1.list()) { 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/preparser/PreFortress.rats

    r1895 r1907  
    2323 
    2424instantiate com.sun.fortress.parser.Spacing (PreSymbol) as Spacing; 
    25 instantiate com.sun.fortress.parser.Identifier (Keyword, PreSymbol, Unicode, Spacing, Gaps) as Identifier; 
     25instantiate com.sun.fortress.parser.Identifier (Keyword, PreSymbol, Unicode, Spacing) as Identifier; 
    2626instantiate com.sun.fortress.parser.Keyword (Identifier) as Keyword; 
    2727instantiate com.sun.fortress.parser.Unicode as Unicode; 
    28 instantiate com.sun.fortress.parser.Gaps(PreSymbol, Spacing, Identifier) as Gaps; 
    2928instantiate com.sun.fortress.parser.preparser.PreSymbol (Identifier, Spacing, Keyword) as PreSymbol; 
    3029 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/templateparser/Expression.rats

    r1903 r1907  
    3838modify com.sun.fortress.parser.Expression(Param, NoNewlineHeader, 
    3939MayNewlineHeader, Type, DelimitedExpr, Literal, Identifier, Keyword, 
    40 Symbol, Spacing, Gaps); 
     40Symbol, Spacing); 
     41 
     42 
     43Expr ExprFront += 
     44     ExprGap  
     45   / LooseJuxtGap 
     46   / FnExprGap 
     47   / <Fn> ... ; 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/templateparser/Gaps.rats

    r1903 r1907  
    3838     }; 
    3939 
     40Expr DelimitedExprGap = 
     41     <GAP> prefix "DelimitedExpr" w a1:Id params:ParamList? w suffix 
     42     { if (params == null) params = new LinkedList<Id>(); 
     43       yyValue = ExprFactory.makeTemplateGapDelimitedExpr(createSpan(yyStart,yyCount), a1, params); 
     44     }; 
     45 
     46Expr SimpleExprGap = 
     47     <GAP> prefix "SimpleExpr" w a1:Id params:ParamList? w suffix 
     48     { if (params == null) params = new LinkedList<Id>(); 
     49       yyValue = ExprFactory.makeTemplateGapSimpleExpr(createSpan(yyStart,yyCount), a1, params); 
     50     }; 
     51 
     52Expr PrimaryGap = 
     53     <GAP> prefix "Primary" w a1:Id params:ParamList? w suffix 
     54     { if (params == null) params = new LinkedList<Id>(); 
     55       yyValue = ExprFactory.makeTemplateGapPrimary(createSpan(yyStart,yyCount), a1, params); 
     56     }; 
     57 
    4058FnExpr FnExprGap = 
    4159     <GAP> prefix "FnExpr" w a1:Id params:ParamList? w suffix 
     
    5169 
    5270List<Id> BindIdOrBindIdTupleGap = 
    53      <GAP> prefix "BindIdOrBindIdTuple" w a1:Id params:ParamList? w suffix 
     71     <GAP> prefix "List<Id>" w a1:Id params:ParamList? w suffix 
    5472     { if (params == null) params = new LinkedList<Id>(); 
    5573       TemplateGapId t = ExprFactory.makeTemplateGapId(createSpan(yyStart,yyCount), a1, params); 
    5674       yyValue = FortressUtil.<Id, TemplateGapId>mkList(t); 
     75     }; 
     76 
     77Name NameGap =  
     78     <GAP> prefix "Name" w a1:Id params:ParamList? w suffix 
     79     { if (params == null) params = new LinkedList<Id>(); 
     80       yyValue = ExprFactory.makeTemplateGapName(createSpan(yyStart,yyCount), a1, params); 
    5781     }; 
    5882 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/templateparser/Identifier.rats

    r1903 r1907  
    2929 
    3030modify com.sun.fortress.parser.Identifier(Keyword, Symbol, Unicode, 
    31 Gaps, Spacing); 
     31Spacing); 
     32 
     33 
     34Id Id +=  
     35     NameGap 
     36   / IdGap 
     37   / <FIRST> ... ; 
     38 
     39List<Id> BindIdOrBindIdTuple += 
     40     BindIdOrBindIdTupleGap 
     41   / <FIRST> ... ; 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/templateparser/Literal.rats

    r1903 r1907  
    3232 
    3333modify com.sun.fortress.parser.Literal(MayNewlineHeader, 
    34 DelimitedExpr, NoSpaceExpr, Symbol, Spacing, Identifier, Gaps); 
     34DelimitedExpr, NoSpaceExpr, Symbol, Spacing, Identifier); 
     35 
     36Expr LiteralExpr += 
     37     ExprGap 
     38   / LooseJuxtGap 
     39   / SimpleExprGap 
     40   / PrimaryGap 
     41   / LiteralExprGap 
     42   / <VOID> ...; 
     43 
     44Expr VoidLiteralExpr += 
     45     VoidLiteralExprGap 
     46   / <FIRST> ...; 
     47 
     48FloatLiteralExpr FloatLiteralExpr +=  
     49     NumberLiteralExprGap 
     50   / FloatLiteralExprGap 
     51   / <FIRST> ...; 
     52 
     53IntLiteralExpr IntLiteralExpr +=  
     54     NumberLiteralExprGap 
     55   / IntLiteralExprGap 
     56   / <FIRST> ...; 
     57 
     58CharLiteralExpr CharLiteralExpr += 
     59     CharLiteralExprGap 
     60   / <FIRST> ...; 
     61 
     62StringLiteralExpr StringLiteralExpr +=  
     63     StringLiteralExprGap 
     64   / <FIRST> ... ; 
     65 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/templateparser/TemplateParser.rats

    r1903 r1907  
    124124instantiate com.sun.fortress.parser.templateparser.Unicode 
    125125            as Unicode; 
    126 instantiate com.sun.fortress.parser.Gaps(Symbol, Spacing, Identifier) 
     126instantiate com.sun.fortress.parser.templateparser.Gaps(Symbol, Spacing, Identifier) 
    127127            as Gaps; 
    128128 
  • trunk/ProjectFortress/src/com/sun/fortress/syntax_abstractions/phases/ModuleEnvironment.java

    r1899 r1907  
    193193            m.getDependencies().add(new ModuleImport(identifier)); 
    194194            m.getParameters().add(identifier); 
    195             ModuleName gaps = new ModuleName("Gaps"); 
    196             m.getDependencies().add(new ModuleImport(gaps)); 
    197             m.getParameters().add(gaps); 
    198195        } 
    199196        m.getParameters().addAll(makeParameters(nt.getDependencies())); 
  • trunk/ProjectFortress/src/com/sun/fortress/syntax_abstractions/rats/util/ModuleInfo.java

    r1899 r1907  
    6161        fortressModules.add("Fortress"); 
    6262        fortressModules.add("Function"); 
    63         fortressModules.add("Gaps"); 
    6463        fortressModules.add("Header"); 
    6564        fortressModules.add("Identifier");