Advertisement
Guest User

Untitled

a guest
Jul 5th, 2012
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.94 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement