This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 5th, 2012  |  syntax: D  |  size: 0.94 KB  |  views: 96  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. mport dmd.Module;
  2. import dmd.parser;
  3. import dmd.identifier;
  4. import dmd.token;
  5. import std.stdio;
  6. import std.file;
  7. import dmd.dsymbol;
  8. int main(string[] args)
  9. {
  10. void next(string s)
  11.    {
  12.       write("press Enter...");
  13.       stdin.readln();
  14.       write(s);
  15.    }
  16.  
  17.    auto str1 = "syntactically Wrong{ int Code Buffer; }";
  18.    auto str2 = "struct Much{ int better; string now; char[] here; } ";
  19.    auto m = new Module("test", new Identifier("Testy", TOKidentifier), false, false);
  20.    auto p = new Parser(m, str1, false);
  21.    writeln("Parsing bad code...");
  22.    p.parseModule();
  23.    write(m.toChars());
  24.    next("\x0aA little better...\x0a");
  25.    p.setBuf(str2);
  26.    p.nextToken();
  27.    Dsymbol[] d = p.parseDeclDefs(0);
  28.    write(d[0].toChars());
  29.    next("Now watch this...\x0apress Enter!");
  30.    stdin.readln();
  31.    p.setBuf(readText!(char[])("main.d"));
  32.    p.parseModule();
  33.    write(m.toChars());
  34.    writeln("Pretty cool, huh?");
  35.    return 0;
  36. }
clone this paste RAW Paste Data