Changeset 215
- Timestamp:
- 12/29/06 03:00:42 (2 years ago)
- Files:
-
- trunk/src/language/d/Parser.d (modified) (42 diffs)
- trunk/src/leds/CodeView.d (modified) (3 diffs)
- trunk/src/leds/LanguageD.d (modified) (3 diffs)
- trunk/src/leds/Leds.d (modified) (1 diff)
- trunk/src/leds/Workspace.d (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/language/d/Parser.d
r189 r215 26 26 27 27 //debug=declaration; 28 //debug=parse; 28 29 29 30 class ParserDeclaration … … 86 87 //writefln("tokens up to %d, %d, %d", a, pos, tokens.length); 87 88 Token[] ret; 88 for (pos=pos; pos< tokens.length;pos++) { 89 for ( pos=pos ; pos< tokens.length ; pos++) 90 { 89 91 //writefln("adding %s", tokens[pos].str); 90 92 ret ~= tokens[pos]; 91 93 92 if (tokens[pos].type == a) { 94 if (tokens[pos].type == a) 95 { 93 96 //writefln("token %s matches", tokens[pos].str); 94 97 pos++; 95 98 return ret; 96 99 } 97 if (tokens[pos].type == b) { 100 if (tokens[pos].type == b) 101 { 98 102 pos++; 99 103 return ret; 100 104 } 101 if (tokens[pos].type == c) { 105 if (tokens[pos].type == c) 106 { 102 107 pos++; 103 108 return ret; … … 157 162 */ 158 163 159 void parse(Element parent, Token[] tokens) { 164 void parse(Element parent, Token[] tokens) 165 { 160 166 161 167 this.parent = parent; … … 163 169 Token lastComment = null; 164 170 165 while (pos < tokens.length) { 171 while (pos < tokens.length) 172 { 173 debug(parse)writefln("Parse.parse 1 pos=%s", pos); 174 166 175 Token token = tokens[pos]; 167 176 … … 176 185 } 177 186 187 debug(parse)writefln("Parse.parse 1.1 pos=%s", pos); 178 188 //writefln("testing token: %s / %s", token.str , (pos+1 < tokens.length) ? tokens[pos+1].str : "");//token.dump(); 179 189 auto decres = testDeclaration(tokens, pos); … … 196 206 parseMethod(decres,provend,token, lastComment); 197 207 lastComment = null; 208 debug(parse)writefln("Parse.parse 1.2 pos=%s", pos); 198 209 continue; 199 210 } … … 213 224 parseMethod(decres,provend,token, lastComment); 214 225 lastComment = null; 226 debug(parse)writefln("Parse.parse 1.3 pos=%s", pos); 215 227 continue; 216 228 } … … 219 231 parseDeclaration(decres,provend,token, lastComment); 220 232 lastComment = null; 233 debug(parse)writefln("Parse.parse 1.4 pos=%s", pos); 221 234 continue; 222 235 … … 224 237 225 238 239 debug(parse)writefln("Parse.parse 2 pos=%s", pos); 226 240 switch (token.type) 227 241 { … … 229 243 if (!isNext(Token.T_this)) { 230 244 pos++; 245 debug(parse)writefln("Parse.parse 2.1 pos=%s", pos); 231 246 continue; 232 247 } … … 257 272 parseMethod(decres,provend,token, lastComment); 258 273 lastComment = null; 274 debug(parse)writefln("Parse.parse 2.2 pos=%s", pos); 259 275 continue; 260 276 } 261 277 pos++; 278 debug(parse)writefln("Parse.parse 2.3 pos=%s", pos); 262 279 continue; 263 280 … … 267 284 parseModule(tokensUpto(';')); //, Token.IDENTIFIER ';';' 268 285 lastComment = null; 286 debug(parse)writefln("Parse.parse 2.4 pos=%s", pos); 269 287 continue; 270 288 … … 275 293 resetStmt(); 276 294 lastComment = null; 295 debug(parse)writefln("Parse.parse 2.5 pos=%s", pos); 277 296 continue; 278 297 /* … … 295 314 nextToken(); 296 315 //lastComment = null; 316 debug(parse)writefln("Parse.parse 2.6 pos=%s", pos); 297 317 continue; 298 318 } … … 306 326 resetStmt(); 307 327 lastComment = null; 328 debug(parse)writefln("Parse.parse 2.7 pos=%s", pos); 308 329 continue; 309 330 } 310 331 stmtStart = pos; 311 332 pos++; 333 debug(parse)writefln("Parse.parse 2.8 pos=%s", pos); 312 334 continue; 313 335 … … 322 344 resetStmt(); 323 345 lastComment = null; 346 debug(parse)writefln("Parse.parse 2.9 pos=%s", pos); 324 347 continue; 325 348 … … 330 353 resetStmt(); 331 354 lastComment = null; 355 debug(parse)writefln("Parse.parse 2.10 pos=%s", pos); 332 356 continue; 333 357 … … 338 362 resetStmt(); 339 363 lastComment = null; 364 debug(parse)writefln("Parse.parse 2.11 pos=%s", pos); 340 365 continue; 341 366 … … 350 375 //pos++; // 351 376 377 debug(parse)writefln("Parse.parse 2.12 pos=%s", pos); 352 378 continue; 353 379 … … 359 385 resetStmt(); 360 386 lastComment = null; 387 debug(parse)writefln("Parse.parse 2.13 pos=%s", pos); 361 388 continue; 362 389 … … 368 395 resetStmt(); 369 396 lastComment = null; 397 debug(parse)writefln("Parse.parse 2.14 pos=%s", pos); 370 398 continue; 371 399 … … 378 406 lastComment = null; 379 407 408 debug(parse)writefln("Parse.parse 2.15 pos=%s", pos); 380 409 continue; 381 410 … … 386 415 tokensUpto('('); 387 416 } 417 // FIXME: TODO: hacked. I ahve no idea why but adding nextToken() 418 // seems to break out of an infinite loop 419 nextToken(); 420 debug(parse)writefln("Parse.parse 2.16 pos=%s", pos); 388 421 continue; 389 422 // stuff we drop.. … … 396 429 lastComment = null; 397 430 resetStmt(); 431 debug(parse)writefln("Parse.parse 2.17 pos=%s", pos); 398 432 continue; 399 433 … … 404 438 lastComment = null; 405 439 resetStmt(); 440 debug(parse)writefln("Parse.parse 2.18 pos=%s", pos); 406 441 continue; 407 442 } … … 413 448 resetStmt(); 414 449 lastComment = null; 450 debug(parse)writefln("Parse.parse 2.19 pos=%s", pos); 415 451 continue; 416 452 } … … 429 465 storageClasses ~= token; 430 466 pos++; 467 debug(parse)writefln("Parse.parse 2.20 pos=%s", pos); 431 468 continue; 432 469 … … 436 473 tokensUpto('('); 437 474 pos++; 475 debug(parse)writefln("Parse.parse 2.21 pos=%s", pos); 438 476 continue; 439 477 … … 441 479 tokensUpto(':'); 442 480 pos++; 481 debug(parse)writefln("Parse.parse 2.22 pos=%s", pos); 443 482 continue; 444 483 … … 456 495 457 496 pos++; 497 debug(parse)writefln("Parse.parse 2.23 pos=%s", pos); 458 498 continue; 459 499 … … 461 501 default: 462 502 tokensUpto('{', ';'); // skip it.. 463 if ( tokens[pos-1].type == '{') {503 if (pos <= tokens.length && tokens[pos-1].type == '{') { 464 504 465 505 pos--; … … 468 508 } 469 509 resetStmt(); 510 debug(parse)writefln("Parse.parse 2.24 pos=%s", pos); 470 511 continue; 471 512 … … 751 792 ret.success = false; 752 793 int state = 0; 753 for (int i=start; i<toks.length;i++) { 794 for (int i=start; i<toks.length;i++) 795 { 796 debug (declaration) writefln("Parser.testDeclaration 1"); 797 debug (declaration) writefln("Parser.testDeclaration 1.1 i=%s toks.length=%s", i, toks.length); 754 798 Token tok = toks[i]; 755 799 if (tok.type == Token.COMMENT) { … … 765 809 // private /protected etc.. 766 810 811 debug (declaration) writefln("Parser.testDeclaration 2"); 767 812 if (state < 1) { 768 813 switch (tok.type) { … … 785 830 786 831 832 debug (declaration) writefln("Parser.testDeclaration 3"); 787 833 if (state < 1) { 788 834 switch (tok.type) { … … 798 844 } 799 845 846 debug (declaration) writefln("Parser.testDeclaration 4"); 800 847 if (state < 3) { 801 848 switch (tok.type) { … … 820 867 } 821 868 869 debug (declaration) writefln("Parser.testDeclaration 5"); 822 870 if (state < 3) { // BaseType - only one! 823 871 switch (tok.type) { … … 913 961 } 914 962 963 debug (declaration) writefln("Parser.testDeclaration 6"); 915 964 if (state==3) { 916 965 if ((tok.type == Token.T_function) || (tok.type == Token.T_delegate)) { … … 932 981 } 933 982 983 debug (declaration) writefln("Parser.testDeclaration 7"); 934 984 if (tok.type == '!') { 935 985 while (i < toks.length) { … … 958 1008 } 959 1009 1010 debug (declaration) writefln("Parser.testDeclaration 8"); 960 1011 if (state > 2) { 961 1012 … … 990 1041 991 1042 } 1043 debug (declaration) writefln("Parser.testDeclaration 9"); 992 1044 993 1045 return ret; // failure.. … … 996 1048 997 1049 } 1050 debug (declaration) writefln("Parser.testDeclaration 10"); 998 1051 return ret; // failure.. 999 1052 } trunk/src/leds/CodeView.d
r209 r215 546 546 body 547 547 { 548 549 548 this.fileName = fileName.dup; 550 549 String input; … … 1564 1563 return false; 1565 1564 } 1566 if (!Leds.leds.getPropValue("autoHelp", true) ) {1565 if (!Leds.leds.getPropValue("autoHelp",false) ) { 1567 1566 return false; 1568 1567 } … … 2679 2678 if (((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || 2680 2679 (ch == '.') || (ch == '_') || (ch == '-') || (ch == '>') ) 2681 && Leds.leds.getPropValue("autoComplete", true) )2680 && Leds.leds.getPropValue("autoComplete",false) ) 2682 2681 { 2683 2682 if ( this.getLanguageHandler().canAutoComplete()) { trunk/src/leds/LanguageD.d
r209 r215 61 61 static void setProps(Properties props) 62 62 { 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 } 66 73 //props.add(PropsTypes.FILE, "DUI", "", "dui","",""); 67 74 … … 884 891 Module getCachedModule() 885 892 { 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 } 890 901 //writefln("trying to get cached view"); 891 902 // we probably do not want to keep reloading this.. 892 903 bool usecache = true; 893 if (!LanguageD.cachedString || !LanguageD.cachedString.length || !LanguageD.cachedModule) { 904 if (!LanguageD.cachedString || !LanguageD.cachedString.length || !LanguageD.cachedModule) 905 { 894 906 usecache = false; 895 907 } 896 908 // same file.. 897 if (usecache && ( codeview.getFileName() != LanguageD.cachedFilename)) { 909 if (usecache && ( codeview.getFileName() != LanguageD.cachedFilename)) 910 { 898 911 usecache = false; 899 912 } 900 913 901 914 // this is a little memory intensive!? 902 if (usecache && ( codeview.getText() != LanguageD.cachedString)) { 915 if (usecache && ( codeview.getText() != LanguageD.cachedString)) 916 { 903 917 // dont keep parsing.. 904 if (LanguageD.cachedModuleReadTime +5 > std.date.getUTCtime()) { 918 if (LanguageD.cachedModuleReadTime +5 > std.date.getUTCtime()) 919 { 905 920 usecache = false; 906 921 } … … 909 924 910 925 911 if (usecache) { 926 if (usecache) 927 { 912 928 // writefln("returning cached data for %s", codeview.getFileName()); 913 929 //force an update.. trunk/src/leds/Leds.d
r206 r215 553 553 props.add(PropsTypes.YES_NO, "smartCurlyBrace", "yes", "Smart Curly Brace","","Editor."); 554 554 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."); 557 557 558 558 // configurable keys trunk/src/leds/Workspace.d
r209 r215 905 905 project.buildTarget(); 906 906 } 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 } 907 938 } 908 939 909 940 public void runButtonClicked(ToolButton toolButton) 910 941 { 911 repeatCommand(prevRunCommand); 942 if ( !repeatCommand(prevRunCommand) ) 943 { 944 runCodeView(); 945 } 912 946 } 913 947 … … 960 994 * Execute a repeatable run command 961 995 */ 962 public voidexecRunCommand(String baseDir, String command, bit newConsole, String tabTitle)963 { 964 re peatCommand(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); 965 999 } 966 1000 … … 975 1009 * Execute a new command and save it as to be repeated 976 1010 */ 977 voidrepeatCommand(inout RepeatableCommand repeatableCommand,1011 bool repeatCommand(inout RepeatableCommand repeatableCommand, 978 1012 String baseDir, String command, bit newConsole, String tabTitle) 979 1013 { … … 983 1017 repeatableCommand.tabTitle = tabTitle.dup; 984 1018 985 re peatCommand(repeatableCommand);986 } 987 988 public voidrepeatCommand(RepeatableCommand repeatableCommand )989 { 990 1019 return repeatCommand(repeatableCommand); 1020 } 1021 1022 public bool repeatCommand(RepeatableCommand repeatableCommand ) 1023 { 1024 bool executed = false; 991 1025 if ( repeatableCommand.command !is null ) 992 1026 { … … 996 1030 addConsole(execConsole); 997 1031 execConsole.exec(repeatableCommand.baseDir, repeatableCommand.command, true); 1032 executed = true; 998 1033 } 999 1034 else … … 1002 1037 execConsole.clearWidget(); 1003 1038 execConsole.exec(repeatableCommand.baseDir, repeatableCommand.command, true); 1004 } 1005 } 1039 executed = true; 1040 } 1041 } 1042 return executed; 1006 1043 } 1007 1044
