Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
51 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import codemap::span; | ||
import ext::base::ext_ctxt; | ||
import ast::tt_delim; | ||
import parse::lexer::{new_tt_reader, reader}; | ||
import parse::parser::{parser, SOURCE_FILE}; | ||
import parse::common::parser_common; | ||
|
||
fn expand_trace_macros(cx: ext_ctxt, sp: span, | ||
tt: ~[ast::token_tree]) -> base::mac_result | ||
{ | ||
let sess = cx.parse_sess(); | ||
let cfg = cx.cfg(); | ||
let tt_rdr = new_tt_reader(cx.parse_sess().span_diagnostic, | ||
cx.parse_sess().interner, none, tt); | ||
let rdr = tt_rdr as reader; | ||
let rust_parser = parser(sess, cfg, rdr.dup(), SOURCE_FILE); | ||
|
||
let arg = rust_parser.parse_ident(); | ||
match arg { | ||
@~"true" => cx.set_trace_macros(true), | ||
@~"false" => cx.set_trace_macros(false), | ||
_ => cx.span_fatal(sp, ~"trace_macros! only accepts `true` or `false`") | ||
} | ||
let rust_parser = parser(sess, cfg, rdr.dup(), SOURCE_FILE); | ||
let result = rust_parser.parse_expr(); | ||
base::mr_expr(result) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,4 +89,6 @@ mod ext { | |
mod check; | ||
mod liveness; | ||
} | ||
|
||
mod trace_macros; | ||
} |