Changeset 203

Show
Ignore:
Timestamp:
06/18/06 10:10:52 (2 years ago)
Author:
pragma
Message:

Fixed several codegen bugs.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/enki/BaseParser.d

    r202 r203  
    6969        return data[start..end]; 
    7070    } 
    71      
    72     /** conversion helpers **/ 
    73      
    74     protected String hexToChar(String hexValue){ 
    75         return "\\x" ~ hexValue; 
    76     } 
    7771         
    7872    /** error handling **/ 
     
    116110    } 
    117111     
    118     /** rudimentary parsers **/    
     112    /** IParser hooks **/  
    119113     
    120114    public ResultString terminal(String str){ 
     
    128122        return ResultString(data[start..pos]); 
    129123    } 
     124         
     125    public ResultString terminal(ubyte start){ 
     126        if(pos >= data.length || data[pos] != cast(char)start){ 
     127            //TODO: find an error message for this 
     128            //setError("Expected char"); 
     129            return ResultString(); 
     130        } 
     131        pos++; 
     132        return ResultString(data[pos-1..pos]);   
     133    }  
    130134     
    131135    public ResultString regexp(String str){ 
     
    140144        return ResultString(); 
    141145    } 
     146     
     147    public ResultString range(uint start,uint end){ 
     148        assert(false,"32bit/dchar ranges not supported"); 
     149    } 
     150     
     151    public ResultString range(short start,short end){ 
     152        assert(false,"16bit/wchar ranges not supported"); 
     153    } 
     154     
     155    public ResultString range(ubyte start,ubyte end){ 
     156        if(pos >= data.length || !(data[pos] >= cast(char)start && data[pos] <= cast(char)end)){ 
     157            //TODO: find an error message for this 
     158            //setError("Expected range"); 
     159            return ResultString(); 
     160        } 
     161        pos++; 
     162        return ResultString(data[pos-1..pos]);   
     163    } 
     164     
     165    /** rudimentary parsers **/  
    142166     
    143167    public ResultBool parse_eoi(){ 
  • trunk/enki/CodeGenerator.d

    r196 r203  
    7070     
    7171    public void render(CodeGenerator generator,Statement passterm,Statement failterm){ 
    72         generator.emit(name ~ ":"); 
     72        generator.emit(name ~ ": ;"); 
    7373    } 
    7474} 
     
    147147    String tabs; 
    148148    String code; 
    149      
    150     public this(){ 
     149    String parsetype; 
     150     
     151    public this(String parsetype){ 
    151152        counter = 0; 
    152153        tabs = ""; 
     154        this.parsetype = parsetype; 
     155    } 
     156     
     157    public String getParseType(){ 
     158        return this.parsetype; 
    153159    } 
    154160     
  • trunk/enki/Directive.d

    r202 r203  
    109109} 
    110110 
    111 class StartDirective : Directive{ 
    112     String prod; 
    113      
    114     public this(String prod){ 
    115         this.prod = prod; 
    116     } 
    117      
    118     public void semanticPass(BaseEnkiParser root){ 
    119         root.getTypeForRule(prod); // prod root to determine if this is valid 
    120         root.setStartProduction(prod); 
    121     } 
    122                  
    123     public String toBNF(){ 
    124         return ".start(\"" ~ prod ~ "\");\n"; 
    125     } 
    126      
    127     public String toString(){ 
    128         return "Start Directive"; 
    129     }    
    130 } 
    131  
    132111class DefineDirective : Directive{ 
    133112    String returnType; 
     
    178157     
    179158    public void semanticPass(BaseEnkiParser root){ 
     159        // cannot reference the parser duing bootstrap - it doesn't exist yet 
    180160        version(Bootstrap){ 
    181161            throw new Exception("Include directive is meaningless during bootstrap phase."); 
     
    185165                throw new Exception("Cannot include '" ~ filename ~ "'; file doesn't exist."); 
    186166            } 
    187             // cannot reference the parser duing bootstrap - it doesn't exist yet 
    188167                 
    189168            auto parser = new EnkiParser(); 
     
    193172            if(result.success){ 
    194173                auto syntax = result.result; 
    195                 parser.semanticPass(); 
    196174                root.add(parser); 
    197175            } 
     
    278256    }    
    279257} 
     258 
     259class TypelibDirective : Directive{ 
     260    String moduleName; 
     261         
     262    public this(String moduleName){ 
     263        this.moduleName = moduleName; 
     264    } 
     265     
     266    public void semanticPass(BaseEnkiParser root){ 
     267        root.setTypelibName(moduleName); 
     268    } 
     269     
     270    public String toBNF(){ 
     271        return ".typelib(\"" ~ moduleName ~ "\");\n"; 
     272    } 
     273     
     274    public String toString(){ 
     275        return "Typelib Directive"; 
     276    }    
     277} 
     278 
     279class ParseTypeDirective : Directive{ 
     280    String typeName; 
     281         
     282    public this(String typeName){ 
     283        this.typeName = typeName; 
     284    } 
     285     
     286    public void semanticPass(BaseEnkiParser root){ 
     287        root.setParseType(typeName); 
     288    } 
     289     
     290    public String toBNF(){ 
     291        return ".parsetype(\"" ~ typeName ~ "\");\n"; 
     292    } 
     293     
     294    public String toString(){ 
     295        return "Parse-Type Directive"; 
     296    }    
     297} 
  • trunk/enki/EnkiBackend.d

    r196 r203  
    6262    String classname; 
    6363    String moduleName; 
    64     String startProduction; 
     64    String typelib; 
     65    String parseType; 
    6566    UserProduction[] userProductions; 
    6667 
    6768    public this(){ 
    68         this.startProduction = "Syntax"; 
    6969        this.baseclass = "BaseParser"; 
    7070        this.classname = "Parser"; 
    71     } 
    72      
    73     public bool createSyntax(SyntaxLine[] lines){ 
     71        this.typelib = "enki.types"; 
     72        this.parseType = "String"; 
     73    } 
     74     
     75    public void createSyntax(SyntaxLine[] lines){ 
    7476        this.lines = lines; 
    75         return true; 
    7677    } 
    7778     
     
    107108    } 
    108109     
    109     public void setStartProduction(String prod){ 
    110         startProduction = prod; 
     110    public void setTypelibName(String name){ 
     111        typelib = name; 
     112    } 
     113     
     114    public void setParseType(String name){ 
     115        debug writefln("parse type set to: %s",name); 
     116        parseType = name; 
     117    } 
     118     
     119    public String getParseType(){ 
     120        return parseType; 
    111121    } 
    112122     
     
    123133        if(name in rules) throw new Exception("Rule '" ~ name ~ "' is already defined."); 
    124134        rules[name] = rule; 
     135    } 
     136     
     137    public Rule[String] getRules(){ 
     138        return this.rules; 
    125139    } 
    126140     
     
    178192         
    179193    String render(){ 
    180         auto CodeGenerator generator = new CodeGenerator(); 
     194        auto CodeGenerator generator = new CodeGenerator(this.parseType); 
    181195        with(generator){ 
    182196            emit("//auto-generated parser"); 
     
    185199            } 
    186200            emit("debug private import std.stdio;"); 
     201             
     202            if(typelib != ""){ 
     203                emit("private import " ~ typelib ~ ";"); 
     204            } 
    187205            foreach(imp; imports){ 
    188206                emit("private import " ~ imp ~ ";"); 
  • trunk/enki/EnkiParser.d

    r202 r203  
    3737     
    3838Syntax 
    39     = bool createSyntax(SyntaxLine[] lines) 
    40     ::=  ws { ( Rule:~lines | Comment:~lines | Directive:~lines )  ws} eoi; 
    41  
    42     */ 
    43     public ResultT!(bool) parse_Syntax(){ 
     39    = void createSyntax(SyntaxLine[] lines) 
     40    ::=  ws { ( Rule:~lines | Comment:~lines | Directive:~lines )  ws} eoi; 
     41 
     42    */ 
     43    public ResultT!(String) parse_Syntax(){ 
    4444        debug writefln("parse_Syntax()"); 
    4545        uint start = position; 
     
    5555                uint start = position; 
    5656                uint termPos; 
    57             loop5: 
     57            loop5: ; 
    5858                termPos = position; 
    59                 {//Expression 
    60                     uint start = position; 
    61                     if((parse_eoi().success)){ 
    62                         clearErrors(); 
    63                         goto loopend6; 
    64                     }else{ 
    65                         position = start; 
    66                     } 
     59                if(parse_eoi().success){ 
     60                    goto loopend6; 
    6761                } 
    6862                {//Expression 
     
    8276                    } 
    8377                    goto match7; 
    84                 mismatch8: 
     78                mismatch8: ; 
    8579                    position = start; 
    8680                    goto mismatch4; 
    87                 match7: 
     81                match7: ; 
    8882                    clearErrors(); 
    8983                    goto loop5; 
    9084                } 
    91             loopend6: 
    92                 {} 
     85            loopend6: ; 
    9386            } 
    9487            goto match3; 
    95         mismatch4: 
     88        mismatch4: ; 
    9689            setError("Expected Whitespace."); 
    9790            position = start; 
    9891            goto mismatch2; 
    99         match3: 
     92        match3: ; 
    10093            clearErrors(); 
    10194            goto match1; 
    10295        } 
    103     match1: 
     96    match1: ; 
    10497        debug writefln("parse_Syntax() PASS"); 
    105         auto value = createSyntax(bind_lines); 
    106         return ResultT!(bool)(value); 
    107     mismatch2: 
    108         position = start; 
    109         return ResultT!(bool)(); 
     98        createSyntax(bind_lines); 
     99        return ResultT!(String)(sliceData(start,position)); 
     100    mismatch2: ; 
     101        position = start; 
     102        return ResultT!(String)(); 
    110103    } 
    111104 
     
    176169            } 
    177170            goto match11; 
    178         mismatch12: 
     171        mismatch12: ; 
    179172            setError("Expected Whitespace."); 
    180173            position = start; 
    181174            goto mismatch10; 
    182         match11: 
     175        match11: ; 
    183176            clearErrors(); 
    184177            goto match9; 
    185178        } 
    186     match9: 
     179    match9: ; 
    187180        debug writefln("parse_Rule() PASS"); 
    188181        ResultT!(Rule) passed = ResultT!(Rule)(new Rule(bind_name,bind_pred,bind_expr,bind_decl)); 
    189182        return passed; 
    190     mismatch10: 
     183    mismatch10: ; 
    191184        position = start; 
    192185        ResultT!(Rule) failed = ResultT!(Rule)(); 
     
    218211            } 
    219212        } 
    220     match13: 
     213    match13: ; 
    221214        debug writefln("parse_RuleDecl() PASS"); 
    222215        ResultT!(RuleDecl) passed = ResultT!(RuleDecl)(new RuleDecl(bind_params)); 
    223216        return passed; 
    224     mismatch14: 
     217    mismatch14: ; 
    225218        position = start; 
    226219        ResultT!(RuleDecl) failed = ResultT!(RuleDecl)(); 
     
    260253            } 
    261254            goto match17; 
    262         mismatch18: 
     255        mismatch18: ; 
    263256            position = start; 
    264257            goto mismatch16; 
    265         match17: 
     258        match17: ; 
    266259            clearErrors(); 
    267260            goto match15; 
    268261        } 
    269     match15: 
     262    match15: ; 
    270263        debug writefln("parse_RulePredicate() PASS"); 
    271264        return ResultT!(RulePredicate)(bind_pred); 
    272     mismatch16: 
     265    mismatch16: ; 
    273266        position = start; 
    274267        return ResultT!(RulePredicate)(); 
     
    299292            } 
    300293        } 
    301     match19: 
     294    match19: ; 
    302295        debug writefln("parse_ClassPredicate() PASS"); 
    303296        ResultT!(ClassPredicate) passed = ResultT!(ClassPredicate)(new ClassPredicate(bind_name,bind_params)); 
    304297        return passed; 
    305     mismatch20: 
     298    mismatch20: ; 
    306299        position = start; 
    307300        ResultT!(ClassPredicate) failed = ResultT!(ClassPredicate)(); 
     
    334327            } 
    335328        } 
    336     match21: 
     329    match21: ; 
    337330        debug writefln("parse_FunctionPredicate() PASS"); 
    338331        ResultT!(FunctionPredicate) passed = ResultT!(FunctionPredicate)(new FunctionPredicate(bind_decl,bind_params)); 
    339332        return passed; 
    340     mismatch22: 
     333    mismatch22: ; 
    341334        position = start; 
    342335        ResultT!(FunctionPredicate) failed = ResultT!(FunctionPredicate)(); 
     
    368361            } 
    369362        } 
    370     match23: 
     363    match23: ; 
    371364        debug writefln("parse_BindingPredicate() PASS"); 
    372365        ResultT!(BindingPredicate) passed = ResultT!(BindingPredicate)(new BindingPredicate(bind_param)); 
    373366        return passed; 
    374     mismatch24: 
     367    mismatch24: ; 
    375368        position = start; 
    376369        ResultT!(BindingPredicate) failed = ResultT!(BindingPredicate)(); 
     
    410403                    {//ZeroOrMoreExpr 
    411404                        uint termPos; 
    412                     loop31: 
     405                    loop31: ; 
    413406                        termPos = position; 
    414407                        {//Expression 
     
    422415                            } 
    423416                        } 
    424                     loopend32: 
    425                         {} 
     417                    loopend32: ; 
    426418                    } 
    427419                    goto match29; 
    428                 mismatch30: 
     420                mismatch30: ; 
    429421                    position = start; 
    430                 match29: 
     422                match29: ; 
    431423                    clearErrors(); 
    432424                } 
     
    436428            } 
    437429            goto match27; 
    438         mismatch28: 
     430        mismatch28: ; 
    439431            position = start; 
    440432            goto mismatch26; 
    441         match27: 
     433        match27: ; 
    442434            clearErrors(); 
    443435            goto match25; 
    444436        } 
    445     match25: 
     437    match25: ; 
    446438        debug writefln("parse_ParamsExpr() PASS"); 
    447439        return ResultT!(Param[])(bind_params); 
    448     mismatch26: 
     440    mismatch26: ; 
    449441        position = start; 
    450442        return ResultT!(Param[])(); 
     
    475467            } 
    476468        } 
    477     match33: 
     469    match33: ; 
    478470        debug writefln("parse_Param() PASS"); 
    479471        return ResultT!(Param)(bind_param); 
    480     mismatch34: 
     472    mismatch34: ; 
    481473        position = start; 
    482474        return ResultT!(Param)(); 
     
    507499            } 
    508500        } 
    509     match35: 
     501    match35: ; 
    510502        debug writefln("parse_WeakParam() PASS"); 
    511503        ResultT!(Param) passed = ResultT!(Param)(new Param(bind_name)); 
    512504        return passed; 
    513     mismatch36: 
     505    mismatch36: ; 
    514506        position = start; 
    515507        ResultT!(Param) failed = ResultT!(Param)(); 
     
    554546            } 
    555547            goto match39; 
    556         mismatch40: 
     548        mismatch40: ; 
    557549            setError("Expected Identifier."); 
    558550            position = start; 
    559551            goto mismatch38; 
    560         match39: 
     552        match39: ; 
    561553            clearErrors(); 
    562554            goto match37; 
    563555        } 
    564     match37: 
     556    match37: ; 
    565557        debug writefln("parse_ExplicitParam() PASS"); 
    566558        ResultT!(Param) passed = ResultT!(Param)(new Param(bind_isArray,bind_type,bind_name)); 
    567559        return passed; 
    568     mismatch38: 
     560    mismatch38: ; 
    569561        position = start; 
    570562        ResultT!(Param) failed = ResultT!(Param)(); 
     
    595587            {//ZeroOrMoreExpr 
    596588                uint termPos; 
    597             loop45: 
     589            loop45: ; 
    598590                termPos = position; 
    599591                {//Expression 
     
    607599                    } 
    608600                } 
    609             loopend46: 
    610                 {} 
     601            loopend46: ; 
    611602            } 
    612603            goto match43; 
    613         mismatch44: 
     604        mismatch44: ; 
    614605            setError("Expected Term."); 
    615606            position = start; 
    616607            goto mismatch42; 
    617         match43: 
     608        match43: ; 
    618609            clearErrors(); 
    619610            goto match41; 
    620611        } 
    621     match41: 
     612    match41: ; 
    622613        debug writefln("parse_Expression() PASS"); 
    623614        ResultT!(Expression) passed = ResultT!(Expression)(new Expression(bind_terms)); 
    624615        return passed; 
    625     mismatch42: 
     616    mismatch42: ; 
    626617        position = start; 
    627618        ResultT!(Expression) failed = ResultT!(Expression)(); 
     
    652643            {//ZeroOrMoreExpr 
    653644                uint termPos; 
    654             loop51: 
     645            loop51: ; 
    655646                termPos = position; 
    656647                {//Expression 
     
    665656                    } 
    666657                } 
    667             loopend52: 
    668                 {} 
     658            loopend52: ; 
    669659            } 
    670660            goto match49; 
    671         mismatch50: 
     661        mismatch50: ; 
    672662            setError("Expected SubExpression."); 
    673663            position = start; 
    674664            goto mismatch48; 
    675         match49: 
     665        match49: ; 
    676666            clearErrors(); 
    677667            goto match47; 
    678668        } 
    679     match47: 
     669    match47: ; 
    680670        debug writefln("parse_Term() PASS"); 
    681671        return ResultT!(SubExpression[])(bind_factors); 
    682     mismatch48: 
     672    mismatch48: ; 
    683673        position = start; 
    684674        return ResultT!(SubExpression[])(); 
     
    689679SubExpression 
    690680    = SubExpression expr 
    691     ::=  Production:expr | Substitution:expr | Terminal:expr | Regexp:expr | GroupExpr:expr | OptionalExpr:expr | ZeroOrMoreExpr:expr | NegateExpr:expr | TestExpr:expr | LiteralExpr:expr | CustomTerminal:expr ; 
     681    ::=  Production:expr | Substitution:expr | Terminal:expr | Range:expr | Regexp:expr | GroupExpr:expr | OptionalExpr:expr | ZeroOrMoreExpr:expr | NegateExpr:expr | TestExpr:expr | LiteralExpr:expr | CustomTerminal:expr ; 
    692682 
    693683    */ 
     
    700690        {//Expression 
    701691            uint start = position; 
    702             if((parse_Production().assign!(SubExpression)(bind_expr)) || (parse_Substitution().assign!(SubExpression)(bind_expr)) || (parse_Terminal().assign!(SubExpression)(bind_expr)) || (parse_Regexp().assign!(SubExpression)(bind_expr)) || (parse_GroupExpr().assign!(SubExpression)(bind_expr)) || (parse_OptionalExpr().assign!(SubExpression)(bind_expr)) || (parse_ZeroOrMoreExpr().assign!(SubExpression)(bind_expr)) || (parse_NegateExpr().assign!(SubExpression)(bind_expr)) || (parse_TestExpr().assign!(SubExpression)(bind_expr)) || (parse_LiteralExpr().assign!(SubExpression)(bind_expr)) || (parse_CustomTerminal().assign!(SubExpression)(bind_expr))){ 
     692            if((parse_Production().assign!(SubExpression)(bind_expr)) || (parse_Substitution().assign!(SubExpression)(bind_expr)) || (parse_Terminal().assign!(SubExpression)(bind_expr)) || (parse_Range().assign!(SubExpression)(bind_expr)) || (parse_Regexp().assign!(SubExpression)(bind_expr)) || (parse_GroupExpr().assign!(SubExpression)(bind_expr)) || (parse_OptionalExpr().assign!(SubExpression)(bind_expr)) || (parse_ZeroOrMoreExpr().assign!(SubExpression)(bind_expr)) || (parse_NegateExpr().assign!(SubExpression)(bind_expr)) || (parse_TestExpr().assign!(SubExpression)(bind_expr)) || (parse_LiteralExpr().assign!(SubExpression)(bind_expr)) || (parse_CustomTerminal().assign!(SubExpression)(bind_expr))){ 
    703693                clearErrors(); 
    704694                goto match53; 
    705695            }else{ 
    706                 setError("Expected Production, Substitution, Terminal, Regexp, GroupExpr, OptionalExpr, ZeroOrMoreExpr, NegateExpr, TestExpr, LiteralExpr or CustomTerminal."); 
     696                setError("Expected Production, Substitution, Terminal, Range, Regexp, GroupExpr, OptionalExpr, ZeroOrMoreExpr, NegateExpr, TestExpr, LiteralExpr or CustomTerminal."); 
    707697                position = start; 
    708698                goto mismatch54; 
    709699            } 
    710700        } 
    711     match53: 
     701    match53: ; 
    712702        debug writefln("parse_SubExpression() PASS"); 
    713703        return ResultT!(SubExpression)(bind_expr); 
    714     mismatch54: 
     704    mismatch54: ; 
    715705        position = start; 
    716706        return ResultT!(SubExpression)(); 
     
    721711Production 
    722712    = new Production(String name,Binding binding,ProductionArg[] args) 
    723     ::=  Identifier:name  ws [ "!(" ws ProductionArg:~args  { ws "," ws ProductionArg:~args } ")"]  [ Binding:binding ] ; 
     713    ::=  Identifier:name  ws [ "!(" ws ProductionArg:~args  { ws "," ws ProductionArg:~args } ")"]  [ Binding:binding ] ; 
    724714 
    725715    */ 
     
    755745                        uint start = position; 
    756746                        uint termPos; 
    757                     loop61: 
     747                    loop61: ; 
    758748                        termPos = position; 
    759                         {//Expression 
    760                             uint start = position; 
    761                             if((terminal(")").success)){ 
    762                                 clearErrors(); 
    763                                 goto loopend62; 
    764                             }else{ 
    765                                 position = start; 
    766                             } 
     749                        if(terminal(")").success){ 
     750                            goto loopend62; 
    767751                        } 
    768752                        {//Expression 
     
    777761                            } 
    778762                        } 
    779                     loopend62: 
    780                         {} 
     763                    loopend62: ; 
    781764                    } 
    782765                    goto match59; 
    783                 mismatch60: 
     766                mismatch60: ; 
    784767                    position = start; 
    785                 match59: 
     768                match59: ; 
    786769                    clearErrors(); 
    787770                } 
     
    798781            } 
    799782            goto match57; 
    800         mismatch58: 
     783        mismatch58: ; 
    801784            setError("Expected Identifier."); 
    802785            position = start; 
    803786            goto mismatch56; 
    804         match57: 
     787        match57: ; 
    805788            clearErrors(); 
    806789            goto match55; 
    807790        } 
    808     match55: 
     791    match55: ; 
    809792        debug writefln("parse_Production() PASS"); 
    810793        ResultT!(Production) passed = ResultT!(Production)(new Production(bind_name,bind_binding,bind_args)); 
    811794        return passed; 
    812     mismatch56: 
     795    mismatch56: ; 
    813796        position = start; 
    814797        ResultT!(Production) failed = ResultT!(Production)(); 
     
    840823            } 
    841824        } 
    842     match63: 
     825    match63: ; 
    843826        debug writefln("parse_ProductionArg() PASS"); 
    844827        return ResultT!(ProductionArg)(bind_arg); 
    845     mismatch64: 
     828    mismatch64: ; 
    846829        position = start; 
    847830        return ResultT!(ProductionArg)(); 
     
    872855            } 
    873856        } 
    874     match65: 
     857    match65: ; 
    875858        debug writefln("parse_StringProductionArg() PASS"); 
    876859        ResultT!(StringProductionArg) passed = ResultT!(StringProductionArg)(new StringProductionArg(bind_value)); 
    877860        return passed; 
    878     mismatch66: 
     861    mismatch66: ; 
    879862        position = start; 
    880863        ResultT!(StringProductionArg) failed = ResultT!(StringProductionArg)(); 
     
    906889            } 
    907890        } 
    908     match67: 
     891    match67: ; 
    909892        debug writefln("parse_BindingProductionArg() PASS"); 
    910893        ResultT!(BindingProductionArg) passed = ResultT!(BindingProductionArg)(new BindingProductionArg(bind_value)); 
    911894        return passed; 
    912     mismatch68: 
     895    mismatch68: ; 
    913896        position = start; 
    914897        ResultT!(BindingProductionArg) failed = ResultT!(BindingProductionArg)(); 
     
    952935            } 
    953936            goto match71; 
    954         mismatch72: 
     937        mismatch72: ; 
    955938            position = start; 
    956939            goto mismatch70; 
    957         match71: 
     940        match71: ; 
    958941            clearErrors(); 
    959942            goto match69; 
    960943        } 
    961     match69: 
     944    match69: ; 
    962945        debug writefln("parse_Substitution() PASS"); 
    963946        ResultT!(Substitution) passed = ResultT!(Substitution)(new Substitution(bind_name,bind_binding)); 
    964947        return passed; 
    965     mismatch70: 
     948    mismatch70: ; 
    966949        position = start; 
    967950        ResultT!(Substitution) failed = ResultT!(Substitution)(); 
     
    1014997            } 
    1015998            goto match75; 
    1016         mismatch76: 
     999        mismatch76: ; 
    10171000            position = start; 
    10181001            goto mismatch74; 
    1019         match75: 
     1002        match75: ; 
    10201003            clearErrors(); 
    10211004            goto match73; 
    10221005        } 
    1023     match73: 
     1006    match73: ; 
    10241007        debug writefln("parse_GroupExpr() PASS"); 
    10251008        ResultT!(GroupExpr) passed = ResultT!(GroupExpr)(new GroupExpr(bind_expr,bind_binding)); 
    10261009        return passed; 
    1027     mismatch74: 
     1010    mismatch74: ; 
    10281011        position = start; 
    10291012        ResultT!(GroupExpr) failed = ResultT!(GroupExpr)(); 
     
    10761059            } 
    10771060            goto match79; 
    1078         mismatch80: 
     1061        mismatch80: ; 
    10791062            position = start; 
    10801063            goto mismatch78; 
    1081         match79: 
     1064        match79: ; 
    10821065            clearErrors(); 
    10831066            goto match77; 
    10841067        } 
    1085     match77: 
     1068    match77: ; 
    10861069        debug writefln("parse_OptionalExpr() PASS"); 
    10871070        ResultT!(OptionalExpr) passed = ResultT!(OptionalExpr)(new OptionalExpr(bind_expr,bind_binding)); 
    10881071        return passed; 
    1089     mismatch78: 
     1072    mismatch78: ; 
    10901073        position = start; 
    10911074        ResultT!(OptionalExpr) failed = ResultT!(OptionalExpr)(); 
     
    10961079     
    10971080ZeroOrMoreExpr 
    1098     = new ZeroOrMoreExpr(Expression expr,Binding binding,Expression term) 
    1099     ::=  "{" ws Expression:expr  ws "}" ws [ Binding:binding  ws]  [ Expression:term ] ; 
     1081    = new ZeroOrMoreExpr(Expression expr,Binding binding,SubExpression term) 
     1082    ::=  "{" ws Expression:expr  ws "}" ws [ Binding:binding  ws]  [ SubExpression:term ] ; 
    11001083 
    11011084    */ 
     
    11051088        Expression bind_expr; 
    11061089        Binding bind_binding; 
    1107         Expression bind_term; 
     1090        SubExpression bind_term; 
    11081091         
    11091092         
     
    11411124                {//Expression 
    11421125                    uint start = position; 
    1143                     if((parse_Expression().assign!(Expression)(bind_term))){ 
     1126                    if((parse_SubExpression().assign!(SubExpression)(bind_term))){ 
    11441127                        clearErrors(); 
    11451128                    }else{ 
     
    11491132            } 
    11501133            goto match83; 
    1151         mismatch84: 
     1134        mismatch84: ; 
    11521135            position = start; 
    11531136            goto mismatch82; 
    1154         match83: 
     1137        match83: ; 
    11551138            clearErrors(); 
    11561139            goto match81; 
    11571140        } 
    1158     match81: 
     1141    match81: ; 
    11591142        debug writefln("parse_ZeroOrMoreExpr() PASS"); 
    11601143        ResultT!(ZeroOrMoreExpr) passed = ResultT!(ZeroOrMoreExpr)(new ZeroOrMoreExpr(bind_expr,bind_binding,bind_term)); 
    11611144        return passed; 
    1162     mismatch82: 
     1145    mismatch82: ; 
    11631146        position = start; 
    11641147        ResultT!(ZeroOrMoreExpr) failed = ResultT!(ZeroOrMoreExpr)(); 
     
    11701153Terminal 
    11711154    = new Terminal(String text,Binding binding) 
    1172     ::=  ( String:text | HexChar:text )  ws [ Binding:binding ] ; 
     1155    ::=  String:text  ws [ Binding:binding ] ; 
    11731156 
    11741157    */ 
     
    11821165        {//Expression 
    11831166            uint start = position; 
    1184             {//Expression 
    1185                 uint start = position; 
    1186                 if((parse_String().assign!(String)(bind_text)) || (parse_HexChar().assign!(String)(bind_text))){ 
    1187                     clearErrors(); 
    1188                 }else{ 
    1189                     setError("Expected String or HexChar."); 
    1190                     position = start; 
    1191                     goto mismatch88; 
    1192                 } 
     1167            if(!(parse_String().assign!(String)(bind_text))){ 
     1168                goto mismatch88; 
    11931169            } 
    11941170            if(!(parse_ws().success)){ 
     
    12061182            } 
    12071183            goto match87; 
    1208         mismatch88: 
     1184        mismatch88: ; 
     1185            setError("Expected String."); 
    12091186            position = start; 
    12101187            goto mismatch86; 
    1211         match87: 
     1188        match87: ; 
    12121189            clearErrors(); 
    12131190            goto match85; 
    12141191        } 
    1215     match85: 
     1192    match85: ; 
    12161193        debug writefln("parse_Terminal() PASS"); 
    12171194        ResultT!(Terminal) passed = ResultT!(Terminal)(new Terminal(bind_text,bind_binding)); 
    12181195        return passed; 
    1219     mismatch86: 
     1196    mismatch86: ; 
    12201197        position = start; 
    12211198        ResultT!(Terminal) failed = ResultT!(Terminal)(); 
     1199        return failed; 
     1200    } 
     1201 
     1202    /* 
     1203     
     1204Range 
     1205    = new Range(String start,String end,Binding binding) 
     1206    ::=  HexExpr:start  ws [ "-" ws HexExpr:end  ws]  [ Binding:binding ] ; 
     1207 
     1208    */ 
     1209    public ResultT!(Range) parse_Range(){ 
     1210        debug writefln("parse_Range()"); 
     1211        uint start = position; 
     1212        String bind_start; 
     1213        String bind_end; 
     1214        Binding bind_binding; 
     1215         
     1216         
     1217        {//Expression 
     1218            uint start = position; 
     1219            if(!(parse_HexExpr().assign!(String)(bind_start))){ 
     1220                goto mismatch92; 
     1221            } 
     1222            if(!(parse_ws().success)){ 
     1223                goto mismatch92; 
     1224            } 
     1225            {//OptionalExpr 
     1226                {//Expression 
     1227                    uint start = position; 
     1228                    if((terminal("-").success && parse_ws().success && parse_HexExpr().assign!(String)(bind_end) && parse_ws().success)){ 
     1229                        clearErrors(); 
     1230                    }else{ 
     1231                        position = start; 
     1232                    } 
     1233                } 
     1234            } 
     1235            {//OptionalExpr 
     1236                {//Expression 
     1237                    uint start = position; 
     1238                    if((parse_Binding().assign!(Binding)(bind_binding))){ 
     1239                        clearErrors(); 
     1240                    }else{ 
     1241                        position = start; 
     1242                    } 
     1243                } 
     1244            } 
     1245            goto match91; 
     1246        mismatch92: ; 
     1247            setError("Expected HexExpr."); 
     1248            position = start; 
     1249            goto mismatch90; 
     1250        match91: ; 
     1251            clearErrors(); 
     1252            goto match89; 
     1253        } 
     1254    match89: ; 
     1255        debug writefln("parse_Range() PASS"); 
     1256        ResultT!(Range) passed = ResultT!(Range)(new Range(bind_start,bind_end,bind_binding)); 
     1257