Add support for matchers nonterminals.
This commit is contained in:
parent
cabee6391d
commit
caa83b41bb
@ -272,7 +272,13 @@ fn parse_nt(p: parser, name: str) -> whole_nt {
|
||||
+ token::to_str(*p.reader.interner(), copy p.token)) }
|
||||
} }
|
||||
"path" { token::w_path(p.parse_path_with_tps(false)) }
|
||||
"tt" { token::w_tt(@p.parse_token_tree()) }
|
||||
"tt" {
|
||||
p.quote_depth += 1u;
|
||||
let res = token::w_tt(@p.parse_token_tree());
|
||||
p.quote_depth -= 1u;
|
||||
res
|
||||
}
|
||||
"mtcs" { token::w_mtcs(p.parse_matchers()) }
|
||||
_ { p.fatal("Unsupported builtin nonterminal parser: " + name)}
|
||||
}
|
||||
}
|
||||
|
@ -1249,13 +1249,17 @@ class parser {
|
||||
};
|
||||
}
|
||||
|
||||
fn parse_matchers() -> ~[matcher] {
|
||||
let name_idx = @mut 0u;
|
||||
ret self.parse_seq(token::LBRACE, token::RBRACE,
|
||||
common::seq_sep_none(),
|
||||
|p| p.parse_matcher(name_idx)).node;
|
||||
}
|
||||
|
||||
/* temporary */
|
||||
fn parse_tt_mac_demo() -> @expr {
|
||||
import ext::tt::earley_parser::{parse,success,failure};
|
||||
let name_idx = @mut 0u;
|
||||
let ms = self.parse_seq(token::LBRACE, token::RBRACE,
|
||||
common::seq_sep_none(),
|
||||
|p| p.parse_matcher(name_idx)).node;
|
||||
let ms = self.parse_matchers();
|
||||
self.quote_depth += 1u;
|
||||
let tt_rhs= self.parse_token_tree();
|
||||
self.quote_depth -= 1u;
|
||||
|
@ -96,10 +96,8 @@ enum whole_nt {
|
||||
w_ty( @ast::ty),
|
||||
w_ident(str_num, bool),
|
||||
w_path(@ast::path),
|
||||
// TODO: this seems to cause infinite recursion in
|
||||
// type_structually_contains if it's not an @-box. We should at least get
|
||||
// failure instead.
|
||||
w_tt(@ast::token_tree),
|
||||
w_tt( @ast::token_tree), //needs @ed to break a circularity
|
||||
w_mtcs(~[ast::matcher])
|
||||
}
|
||||
|
||||
fn binop_to_str(o: binop) -> str {
|
||||
@ -193,8 +191,8 @@ fn to_str(in: interner<@str>, t: token) -> str {
|
||||
w_stmt(*) { "statement" } w_pat(*) { "pattern" }
|
||||
w_expr(*) { "expression" } w_ty(*) { "type" }
|
||||
w_ident(*) { "identifier" } w_path(*) { "path" }
|
||||
w_tt(*) { "tt" }
|
||||
}
|
||||
w_tt(*) { "tt" } w_mtcs(*) { "matcher sequence" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user