Bugfix: obey the tt_lexer's own invariants.
This commit is contained in:
parent
1e36d216be
commit
2f8be7dcbb
@ -1,11 +1,11 @@
|
||||
import std::map::hashmap;
|
||||
|
||||
import ast::{crate, expr_, expr_mac, mac_invoc};
|
||||
import ast::{crate, expr_, expr_mac, mac_invoc, mac_invoc_tt,
|
||||
tt_delim, tt_flat};
|
||||
import fold::*;
|
||||
import ext::base::*;
|
||||
import ext::qquote::{qq_helper};
|
||||
import parse::parser;
|
||||
import parse::parse_expr_from_source_str;
|
||||
import parse::{parser, parse_expr_from_source_str, new_parser_from_tt};
|
||||
|
||||
|
||||
import codemap::{span, expanded_from};
|
||||
@ -49,10 +49,6 @@ fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt,
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
mac_invoc_tt(path, body) {
|
||||
let p = new_parser_from_tt(cx.sess, cx.cfg, )
|
||||
}*/
|
||||
_ { cx.span_bug(mac.span, "naked syntactic bit") }
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,14 @@
|
||||
import dvec::extensions;
|
||||
|
||||
export parse_sess;
|
||||
export new_parse_sess;
|
||||
export new_parse_sess_special_handler;
|
||||
export new_parse_sess, new_parse_sess_special_handler;
|
||||
export next_node_id;
|
||||
export new_parser_from_file;
|
||||
export new_parser_etc_from_file;
|
||||
export new_parser_from_file, new_parser_etc_from_file;
|
||||
export new_parser_from_source_str;
|
||||
export parse_crate_from_file;
|
||||
export parse_crate_from_crate_file;
|
||||
export new_parser_from_tt;
|
||||
export parse_crate_from_file, parse_crate_from_crate_file;
|
||||
export parse_crate_from_source_str;
|
||||
export parse_expr_from_source_str;
|
||||
export parse_item_from_source_str;
|
||||
export parse_expr_from_source_str, parse_item_from_source_str;
|
||||
export parse_from_source_str;
|
||||
|
||||
import parser::parser;
|
||||
@ -199,7 +196,7 @@ fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg, +path: str,
|
||||
}
|
||||
|
||||
fn new_parser_from_tt(sess: parse_sess, cfg: ast::crate_cfg,
|
||||
tt: ast::token_tree) -> parser {
|
||||
tt: [ast::token_tree]) -> parser {
|
||||
let trdr = lexer::new_tt_reader(sess.span_diagnostic, sess.interner, tt);
|
||||
ret parser(sess, cfg, trdr as reader, parser::SOURCE_FILE)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import diagnostic;
|
||||
import ast::{tt_delim,tt_flat};
|
||||
|
||||
export reader, string_reader, new_string_reader, is_whitespace;
|
||||
export tt_reader, new_tt_reader;
|
||||
export tt_reader, new_tt_reader;
|
||||
export nextch, is_eof, bump, get_str_from;
|
||||
export string_reader_as_reader, tt_reader_as_reader;
|
||||
|
||||
@ -20,8 +20,8 @@ enum tt_frame_up { /* to break a circularity */
|
||||
tt_frame_up(option<tt_frame>)
|
||||
}
|
||||
|
||||
#[doc = "an unzipping of `token_tree`s"]
|
||||
type tt_frame = @{
|
||||
/* invariant: readme[idx] is always a tt_flat */
|
||||
readme: [ast::token_tree],
|
||||
mut idx: uint,
|
||||
up: tt_frame_up
|
||||
@ -37,10 +37,10 @@ type tt_reader = @{
|
||||
};
|
||||
|
||||
fn new_tt_reader(span_diagnostic: diagnostic::span_handler,
|
||||
itr: @interner::interner<@str>, src: ast::token_tree)
|
||||
itr: @interner::interner<@str>, src: [ast::token_tree])
|
||||
-> tt_reader {
|
||||
let r = @{span_diagnostic: span_diagnostic, interner: itr,
|
||||
mut cur: @{readme: [src], mut idx: 0u,
|
||||
mut cur: @{readme: src, mut idx: 0u,
|
||||
up: tt_frame_up(option::none)},
|
||||
mut cur_tok: token::EOF, /* dummy value, never read */
|
||||
mut cur_chpos: 0u /* dummy value, never read */
|
||||
|
Loading…
Reference in New Issue
Block a user