Changeset 215

Show
Ignore:
Timestamp:
12/29/06 03:00:42 (2 years ago)
Author:
Ant
Message:

more bugs fixed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/language/d/Parser.d

    r189 r215  
    2626 
    2727//debug=declaration; 
     28//debug=parse; 
    2829 
    2930class ParserDeclaration 
     
    8687        //writefln("tokens up to %d, %d, %d", a, pos, tokens.length); 
    8788        Token[] ret; 
    88         for (pos=pos; pos< tokens.length;pos++) { 
     89        for ( pos=pos ; pos< tokens.length ; pos++)  
     90        { 
    8991            //writefln("adding %s", tokens[pos].str); 
    9092            ret ~= tokens[pos]; 
    9193             
    92             if (tokens[pos].type == a) { 
     94            if (tokens[pos].type == a)  
     95            { 
    9396                //writefln("token %s matches", tokens[pos].str); 
    9497                pos++; 
    9598                return ret; 
    9699            } 
    97             if (tokens[pos].type == b) { 
     100            if (tokens[pos].type == b)  
     101            { 
    98102                pos++; 
    99103                return ret; 
    100104            } 
    101             if (tokens[pos].type == c) { 
     105            if (tokens[pos].type == c)  
     106            { 
    102107                pos++; 
    103108                return ret; 
     
    157162     */ 
    158163     
    159     void parse(Element parent, Token[] tokens) { 
     164    void parse(Element parent, Token[] tokens)  
     165    { 
    160166         
    161167        this.parent = parent; 
     
    163169        Token lastComment = null; 
    164170         
    165         while (pos < tokens.length) { 
     171        while (pos < tokens.length)  
     172        { 
     173debug(parse)writefln("Parse.parse 1 pos=%s", pos); 
     174 
    166175            Token token = tokens[pos]; 
    167176             
     
    176185            } 
    177186             
     187debug(parse)writefln("Parse.parse 1.1 pos=%s", pos); 
    178188            //writefln("testing token: %s / %s", token.str , (pos+1 < tokens.length) ? tokens[pos+1].str : "");//token.dump(); 
    179189            auto decres = testDeclaration(tokens, pos); 
     
    196206                        parseMethod(decres,provend,token, lastComment); 
    197207                        lastComment = null; 
     208debug(parse)writefln("Parse.parse 1.2 pos=%s", pos); 
    198209                        continue; 
    199210                    } 
     
    213224                    parseMethod(decres,provend,token, lastComment); 
    214225                    lastComment = null; 
     226debug(parse)writefln("Parse.parse 1.3 pos=%s", pos); 
    215227                    continue; 
    216228                } 
     
    219231                parseDeclaration(decres,provend,token, lastComment); 
    220232                lastComment = null; 
     233debug(parse)writefln("Parse.parse 1.4 pos=%s", pos); 
    221234                continue; 
    222235                 
     
    224237             
    225238             
     239debug(parse)writefln("Parse.parse 2 pos=%s", pos); 
    226240            switch (token.type) 
    227241            { 
     
    229243                    if (!isNext(Token.T_this)) { 
    230244                        pos++; 
     245debug(parse)writefln("Parse.parse 2.1 pos=%s", pos); 
    231246                        continue; 
    232247                    } 
     
    257272                        parseMethod(decres,provend,token, lastComment); 
    258273                        lastComment = null; 
     274debug(parse)writefln("Parse.parse 2.2 pos=%s", pos); 
    259275                        continue; 
    260276                    } 
    261277                    pos++; 
     278debug(parse)writefln("Parse.parse 2.3 pos=%s", pos); 
    262279                    continue; 
    263280                 
     
    267284                    parseModule(tokensUpto(';'));  //, Token.IDENTIFIER  ';';' 
    268285                    lastComment = null; 
     286debug(parse)writefln("Parse.parse 2.4 pos=%s", pos); 
    269287                    continue; 
    270288                 
     
    275293                    resetStmt(); 
    276294                    lastComment = null; 
     295debug(parse)writefln("Parse.parse 2.5 pos=%s", pos); 
    277296                    continue; 
    278297                    /* 
     
    295314                        nextToken(); 
    296315                        //lastComment = null; 
     316debug(parse)writefln("Parse.parse 2.6 pos=%s", pos); 
    297317                        continue; 
    298318                    } 
     
    306326                        resetStmt(); 
    307327                        lastComment = null; 
     328debug(parse)writefln("Parse.parse 2.7 pos=%s", pos); 
    308329                        continue; 
    309330                    } 
    310331                    stmtStart = pos; 
    311332                    pos++; 
     333debug(parse)writefln("Parse.parse 2.8 pos=%s", pos); 
    312334                    continue; 
    313335                 
     
    322344                    resetStmt(); 
    323345                    lastComment = null; 
     346debug(parse)writefln("Parse.parse 2.9 pos=%s", pos); 
    324347                    continue; 
    325348                 
     
    330353                    resetStmt(); 
    331354                    lastComment = null; 
     355debug(parse)writefln("Parse.parse 2.10 pos=%s", pos); 
    332356                    continue; 
    333357                 
     
    338362                    resetStmt(); 
    339363                    lastComment = null; 
     364debug(parse)writefln("Parse.parse 2.11 pos=%s", pos); 
    340365                    continue; 
    341366                 
     
    350375                    //pos++; //  
    351376                     
     377debug(parse)writefln("Parse.parse 2.12 pos=%s", pos); 
    352378                    continue; 
    353379                     
     
    359385                    resetStmt(); 
    360386                    lastComment = null; 
     387debug(parse)writefln("Parse.parse 2.13 pos=%s", pos); 
    361388                    continue; 
    362389                 
     
    368395                    resetStmt(); 
    369396                    lastComment = null; 
     397debug(parse)writefln("Parse.parse 2.14 pos=%s", pos); 
    370398                    continue; 
    371399                 
     
    378406                    lastComment = null; 
    379407                     
     408debug(parse)writefln("Parse.parse 2.15 pos=%s", pos); 
    380409                    continue; 
    381410                 
     
    386415                        tokensUpto('('); 
    387416                    } 
     417                    // FIXME: TODO: hacked. I ahve no idea why but adding nextToken()  
     418                    // seems to break out of an infinite loop 
     419                    nextToken(); 
     420debug(parse)writefln("Parse.parse 2.16 pos=%s", pos); 
    388421                    continue; 
    389422                // stuff we drop.. 
     
    396429                    lastComment = null; 
    397430                    resetStmt(); 
     431debug(parse)writefln("Parse.parse 2.17 pos=%s", pos); 
    398432                    continue; 
    399433                 
     
    404438                        lastComment = null; 
    405439                        resetStmt(); 
     440debug(parse)writefln("Parse.parse 2.18 pos=%s", pos); 
    406441                        continue; 
    407442                    } 
     
    413448                        resetStmt(); 
    414449                        lastComment = null; 
     450debug(parse)writefln("Parse.parse 2.19 pos=%s", pos); 
    415451                        continue; 
    416452                    } 
     
    429465                    storageClasses ~= token; 
    430466                    pos++; 
     467debug(parse)writefln("Parse.parse 2.20 pos=%s", pos); 
    431468                    continue; 
    432469                  
     
    436473                    tokensUpto('('); 
    437474                    pos++; 
     475debug(parse)writefln("Parse.parse 2.21 pos=%s", pos); 
    438476                    continue; 
    439477                     
     
    441479                        tokensUpto(':'); 
    442480                        pos++; 
     481debug(parse)writefln("Parse.parse 2.22 pos=%s", pos); 
    443482                        continue; 
    444483                     
     
    456495                     
    457496                    pos++; 
     497debug(parse)writefln("Parse.parse 2.23 pos=%s", pos); 
    458498                    continue; 
    459499                 
     
    461501                default: 
    462502                    tokensUpto('{', ';'); // skip it.. 
    463                     if (tokens[pos-1].type == '{') { 
     503                    if (pos <= tokens.length && tokens[pos-1].type == '{') { 
    464504                         
    465505                        pos--; 
     
    468508                    } 
    469509                    resetStmt(); 
     510debug(parse)writefln("Parse.parse 2.24 pos=%s", pos); 
    470511                    continue; 
    471512                     
     
    751792        ret.success = false; 
    752793        int state = 0; 
    753         for (int i=start; i<toks.length;i++) { 
     794        for (int i=start; i<toks.length;i++) 
     795        { 
     796debug (declaration) writefln("Parser.testDeclaration 1"); 
     797debug (declaration) writefln("Parser.testDeclaration 1.1 i=%s toks.length=%s", i, toks.length); 
    754798            Token tok = toks[i]; 
    755799            if (tok.type == Token.COMMENT) { 
     
    765809            // private /protected etc.. 
    766810         
     811debug (declaration) writefln("Parser.testDeclaration 2"); 
    767812            if (state < 1) { 
    768813                switch (tok.type) { 
     
    785830         
    786831         
     832debug (declaration) writefln("Parser.testDeclaration 3"); 
    787833            if (state < 1) { 
    788834                switch (tok.type) { 
     
    798844            } 
    799845             
     846debug (declaration) writefln("Parser.testDeclaration 4"); 
    800847            if (state < 3) { 
    801848                switch (tok.type) {  
     
    820867            } 
    821868             
     869debug (declaration) writefln("Parser.testDeclaration 5"); 
    822870            if (state < 3) { // BaseType - only one! 
    823871                switch (tok.type) {  
     
    913961            } 
    914962             
     963debug (declaration) writefln("Parser.testDeclaration 6"); 
    915964            if (state==3)  { 
    916965                if ((tok.type == Token.T_function) || (tok.type == Token.T_delegate)) { 
     
    932981                } 
    933982                 
     983debug (declaration) writefln("Parser.testDeclaration 7"); 
    934984                if (tok.type == '!') { 
    935985                    while (i < toks.length) { 
     
    9581008            } 
    9591009                  
     1010debug (declaration) writefln("Parser.testDeclaration 8"); 
    9601011            if (state > 2) { 
    9611012                 
     
    9901041                 
    9911042            } 
     1043debug (declaration) writefln("Parser.testDeclaration 9"); 
    9921044             
    9931045            return ret; // failure.. 
     
    9961048         
    9971049        }    
     1050debug (declaration) writefln("Parser.testDeclaration 10"); 
    9981051        return ret; // failure..    
    9991052    } 
  • trunk/src/leds/CodeView.d

    r209 r215  
    546546    body 
    547547    { 
    548          
    549548        this.fileName = fileName.dup; 
    550549        String input; 
     
    15641563            return false; 
    15651564        } 
    1566         if (!Leds.leds.getPropValue("autoHelp",true) ) { 
     1565        if (!Leds.leds.getPropValue("autoHelp",false) ) { 
    15671566            return false; 
    15681567        } 
     
    26792678                if (((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') ||  
    26802679                       (ch == '.') || (ch == '_') || (ch == '-') || (ch == '>') ) 
    2681                     && Leds.leds.getPropValue("autoComplete",true) ) 
     2680                    && Leds.leds.getPropValue("autoComplete",false) ) 
    26822681                    { 
    26832682                        if ( this.getLanguageHandler().canAutoComplete()) { 
  • trunk/src/leds/LanguageD.d

    r209 r215  
    6161    static void setProps(Properties props) 
    6262    { 
    63      
    64         props.add(PropsTypes.TEXT, "dmd", "\\dmd\\bin\\dmd", "dmd","","D."); 
    65         props.add(PropsTypes.DIRECTORY, "phobos", "\\dmd\\src\\phobos", "phobos","","D."); 
     63        version(Win32) 
     64        { 
     65            props.add(PropsTypes.TEXT, "dmd", "\\dmd\\bin\\dmd", "dmd","","D."); 
     66            props.add(PropsTypes.DIRECTORY, "phobos", "\\dmd\\src\\phobos", "phobos","","D."); 
     67        } 
     68        else 
     69        { 
     70            props.add(PropsTypes.TEXT, "dmd", "~/dmd/bin/dmd", "dmd","","D."); 
     71            props.add(PropsTypes.DIRECTORY, "phobos", "~/dmd/src/phobos", "phobos","","D."); 
     72        } 
    6673        //props.add(PropsTypes.FILE, "DUI", "", "dui","",""); 
    6774 
     
    884891    Module getCachedModule() 
    885892    { 
    886          
    887         String[] imports = codeview.getProject().getPropValue("importDirs","").split("\n"); 
    888         imports ~=codeview.getProject().getPropValue("phobos",""); 
    889         imports ~= new String(codeview.getProject().getBaseDir()  ~ Path.sep ~ "src"); 
     893        Project project = codeview.getProject(); 
     894        String[] imports; 
     895        if ( project !is null ) 
     896        { 
     897            imports = project.getPropValue("importDirs","").split("\n"); 
     898            imports ~=project.getPropValue("phobos",""); 
     899            imports ~= new String(project.getBaseDir()  ~ Path.sep ~ "src"); 
     900        } 
    890901        //writefln("trying to get cached view"); 
    891902        // we probably do not want to keep reloading this.. 
    892903        bool usecache = true; 
    893         if (!LanguageD.cachedString || !LanguageD.cachedString.length || !LanguageD.cachedModule) { 
     904        if (!LanguageD.cachedString || !LanguageD.cachedString.length || !LanguageD.cachedModule)  
     905        { 
    894906            usecache = false; 
    895907        } 
    896908        // same file.. 
    897         if (usecache && ( codeview.getFileName() != LanguageD.cachedFilename)) { 
     909        if (usecache && ( codeview.getFileName() != LanguageD.cachedFilename))  
     910        { 
    898911            usecache = false; 
    899912        } 
    900913         
    901914        // this is a little memory intensive!? 
    902         if (usecache && ( codeview.getText() != LanguageD.cachedString)) { 
     915        if (usecache && ( codeview.getText() != LanguageD.cachedString))  
     916        { 
    903917            // dont keep parsing.. 
    904             if (LanguageD.cachedModuleReadTime +5 >  std.date.getUTCtime()) { 
     918            if (LanguageD.cachedModuleReadTime +5 >  std.date.getUTCtime())  
     919            { 
    905920                usecache = false; 
    906921            } 
     
    909924         
    910925         
    911         if (usecache) { 
     926        if (usecache)  
     927        { 
    912928            //  writefln("returning cached data for %s", codeview.getFileName()); 
    913929            //force an update.. 
  • trunk/src/leds/Leds.d

    r206 r215  
    553553        props.add(PropsTypes.YES_NO, "smartCurlyBrace", "yes", "Smart Curly Brace","","Editor."); 
    554554 
    555         props.add(PropsTypes.YES_NO, "autoHelp", "yes", "show Definition when clicking in editor","","Editor."); 
    556         props.add(PropsTypes.YES_NO, "autoComplete", "yes", "Auto complete when typing","","Editor."); 
     555        props.add(PropsTypes.YES_NO, "autoHelp", "no", "show Definition when clicking in editor","","Editor."); 
     556        props.add(PropsTypes.YES_NO, "autoComplete", "no", "Auto complete when typing","","Editor."); 
    557557 
    558558        // configurable keys 
  • trunk/src/leds/Workspace.d

    r209 r215  
    905905            project.buildTarget(); 
    906906        } 
     907        else 
     908        { 
     909            compileCodeView(); 
     910        } 
     911    } 
     912     
     913    /** 
     914     * Compile the current buffer 
     915     */ 
     916    public void compileCodeView() 
     917    { 
     918        FileView cv = getCurrentFileView(); 
     919        if ( cv !is null ) 
     920        { 
     921            getSystemConsole().exec(new String("."), Leds.leds.getPropValue("dmd", "dmd") ~ " " ~ cv.getFileName()); 
     922        } 
     923    } 
     924     
     925    /** 
     926     * Runs the current buffer 
     927     */ 
     928    public void runCodeView() 
     929    { 
     930        FileView cv = getCurrentFileView(); 
     931        if ( cv !is null ) 
     932        { 
     933            String execFile = Path.addExt(cv.getFileName(), ""); 
     934            if ( execFile.length > 1 ) execFile.length = execFile.length -1; 
     935            writefln("Workspace.runCodeView fileName = %s", execFile); 
     936            getSystemConsole().exec(new String("."), execFile.prepend("."~Path.sep)); 
     937        } 
    907938    } 
    908939     
    909940    public void runButtonClicked(ToolButton toolButton) 
    910941    { 
    911         repeatCommand(prevRunCommand); 
     942        if ( !repeatCommand(prevRunCommand) ) 
     943        { 
     944            runCodeView(); 
     945        } 
    912946    } 
    913947     
     
    960994     * Execute a repeatable run command 
    961995     */ 
    962     public void execRunCommand(String baseDir, String command, bit newConsole, String tabTitle) 
    963     { 
    964         repeatCommand(prevRunCommand, baseDir, command, newConsole, tabTitle); 
     996    public bool execRunCommand(String baseDir, String command, bit newConsole, String tabTitle) 
     997    { 
     998        return repeatCommand(prevRunCommand, baseDir, command, newConsole, tabTitle); 
    965999    } 
    9661000     
     
    9751009     * Execute a new command and save it as to be repeated 
    9761010     */ 
    977     void repeatCommand(inout RepeatableCommand repeatableCommand, 
     1011    bool repeatCommand(inout RepeatableCommand repeatableCommand, 
    9781012                        String baseDir, String command, bit newConsole, String tabTitle) 
    9791013    { 
     
    9831017        repeatableCommand.tabTitle = tabTitle.dup; 
    9841018 
    985         repeatCommand(repeatableCommand); 
    986     } 
    987  
    988     public void repeatCommand(RepeatableCommand repeatableCommand ) 
    989     { 
    990          
     1019        return repeatCommand(repeatableCommand); 
     1020    } 
     1021 
     1022    public bool repeatCommand(RepeatableCommand repeatableCommand ) 
     1023    { 
     1024        bool executed = false; 
    9911025        if ( repeatableCommand.command !is null ) 
    9921026        { 
     
    9961030                addConsole(execConsole); 
    9971031                execConsole.exec(repeatableCommand.baseDir, repeatableCommand.command, true); 
     1032                executed = true; 
    9981033            } 
    9991034            else 
     
    10021037                execConsole.clearWidget(); 
    10031038                execConsole.exec(repeatableCommand.baseDir, repeatableCommand.command, true); 
    1004             } 
    1005         } 
     1039                executed = true; 
     1040            } 
     1041        } 
     1042        return executed; 
    10061043    } 
    10071044