
Untitled
By: a guest on
Jul 5th, 2012 | syntax:
D | size: 0.94 KB | hits: 77 | expires: Never
mport dmd.Module;
import dmd.parser;
import dmd.identifier;
import dmd.token;
import std.stdio;
import std.file;
import dmd.dsymbol;
int main(string[] args)
{
void next(string s)
{
write("press Enter...");
stdin.readln();
write(s);
}
auto str1 = "syntactically Wrong{ int Code Buffer; }";
auto str2 = "struct Much{ int better; string now; char[] here; } ";
auto m = new Module("test", new Identifier("Testy", TOKidentifier), false, false);
auto p = new Parser(m, str1, false);
writeln("Parsing bad code...");
p.parseModule();
write(m.toChars());
next("\x0aA little better...\x0a");
p.setBuf(str2);
p.nextToken();
Dsymbol[] d = p.parseDeclDefs(0);
write(d[0].toChars());
next("Now watch this...\x0apress Enter!");
stdin.readln();
p.setBuf(readText!(char[])("main.d"));
p.parseModule();
write(m.toChars());
writeln("Pretty cool, huh?");
return 0;
}