Add session, span tracking, error reporting, beginning of a function to parse an item to rustc.
This commit is contained in:
parent
b90e6b93c1
commit
eb90be7798
7 changed files with 165 additions and 35 deletions
|
|
@ -25,9 +25,10 @@ fn main(vec[str] args) {
|
|||
log "You want rustboot, the compiler next door.";
|
||||
|
||||
auto i = 0;
|
||||
auto sess = session.session();
|
||||
for (str filename in args) {
|
||||
if (i > 0) {
|
||||
auto p = parser.new_parser(filename);
|
||||
auto p = parser.new_parser(sess, filename);
|
||||
log "opened file: " + filename;
|
||||
auto tok = p.peek();
|
||||
while (true) {
|
||||
|
|
|
|||
37
src/comp/driver/session.rs
Normal file
37
src/comp/driver/session.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import util.common.span;
|
||||
import std._uint;
|
||||
|
||||
io obj session() {
|
||||
io fn span_err(span sp, str msg) {
|
||||
let str s = sp.filename;
|
||||
s += ':' as u8;
|
||||
// We really need #fmt soon!
|
||||
s += _uint.to_str(sp.lo.line, 10u);
|
||||
s += ':' as u8;
|
||||
s += _uint.to_str(sp.lo.col, 10u);
|
||||
s += ':' as u8;
|
||||
s += _uint.to_str(sp.hi.line, 10u);
|
||||
s += ':' as u8;
|
||||
s += _uint.to_str(sp.hi.col, 10u);
|
||||
s += ": error: ";
|
||||
s += msg;
|
||||
log s;
|
||||
fail;
|
||||
}
|
||||
|
||||
io fn err(str msg) {
|
||||
let str s = "error: ";
|
||||
s += msg;
|
||||
log s;
|
||||
fail;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Local Variables:
|
||||
// fill-column: 78;
|
||||
// indent-tabs-mode: nil
|
||||
// c-basic-offset: 4
|
||||
// buffer-file-coding-system: utf-8-unix
|
||||
// compile-command: "make -k -C ../.. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
||||
// End:
|
||||
Loading…
Add table
Add a link
Reference in a new issue