diff --git a/quasi/Cargo.toml b/quasi/Cargo.toml index 8a855f46..4454b779 100644 --- a/quasi/Cargo.toml +++ b/quasi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "quasi" -version = "0.3.6" +version = "0.3.7" authors = ["Erick Tryzelaar "] license = "MIT/Apache-2.0" description = "A quasi-quoting macro system" @@ -10,4 +10,4 @@ repository = "https://github.com/erickt/rust-quasi" with-syntex = ["syntex_syntax"] [dependencies] -syntex_syntax = { version = "^0.19.0", optional = true } +syntex_syntax = { version = "^0.20.0", optional = true } diff --git a/quasi/src/lib.rs b/quasi/src/lib.rs index ad0be62b..a8622bbe 100644 --- a/quasi/src/lib.rs +++ b/quasi/src/lib.rs @@ -73,49 +73,49 @@ impl ToTokens for Option { impl ToTokens for ast::Ident { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - vec![ast::TtToken(DUMMY_SP, token::Ident(*self, token::Plain))] + vec![ast::TokenTree::Token(DUMMY_SP, token::Ident(*self, token::Plain))] } } impl ToTokens for ast::Path { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - vec![ast::TtToken(DUMMY_SP, token::Interpolated(token::NtPath(Box::new(self.clone()))))] + vec![ast::TokenTree::Token(DUMMY_SP, token::Interpolated(token::NtPath(Box::new(self.clone()))))] } } impl ToTokens for ast::Ty { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - vec![ast::TtToken(self.span, token::Interpolated(token::NtTy(P(self.clone()))))] + vec![ast::TokenTree::Token(self.span, token::Interpolated(token::NtTy(P(self.clone()))))] } } impl ToTokens for P { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - vec![ast::TtToken(self.span, token::Interpolated(token::NtTy(self.clone())))] + vec![ast::TokenTree::Token(self.span, token::Interpolated(token::NtTy(self.clone())))] } } impl ToTokens for P { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - vec![ast::TtToken(self.span, token::Interpolated(token::NtBlock(self.clone())))] + vec![ast::TokenTree::Token(self.span, token::Interpolated(token::NtBlock(self.clone())))] } } impl ToTokens for P { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - vec![ast::TtToken(self.span, token::Interpolated(token::NtItem(self.clone())))] + vec![ast::TokenTree::Token(self.span, token::Interpolated(token::NtItem(self.clone())))] } } impl ToTokens for P { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - vec![ast::TtToken(self.span, token::Interpolated(token::NtImplItem(self.clone())))] + vec![ast::TokenTree::Token(self.span, token::Interpolated(token::NtImplItem(self.clone())))] } } impl ToTokens for P { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - vec![ast::TtToken(self.span, token::Interpolated(token::NtTraitItem(self.clone())))] + vec![ast::TokenTree::Token(self.span, token::Interpolated(token::NtTraitItem(self.clone())))] } } @@ -140,12 +140,12 @@ impl ToTokens for ast::WhereClause { impl ToTokens for P { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { let mut tts = vec![ - ast::TtToken(self.span, token::Interpolated(token::NtStmt(self.clone()))) + ast::TokenTree::Token(self.span, token::Interpolated(token::NtStmt(self.clone()))) ]; // Some statements require a trailing semicolon. if classify::stmt_ends_with_semi(&self.node) { - tts.push(ast::TtToken(self.span, token::Semi)); + tts.push(ast::TokenTree::Token(self.span, token::Semi)); } tts @@ -154,19 +154,19 @@ impl ToTokens for P { impl ToTokens for P { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - vec![ast::TtToken(self.span, token::Interpolated(token::NtExpr(self.clone())))] + vec![ast::TokenTree::Token(self.span, token::Interpolated(token::NtExpr(self.clone())))] } } impl ToTokens for P { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - vec![ast::TtToken(self.span, token::Interpolated(token::NtPat(self.clone())))] + vec![ast::TokenTree::Token(self.span, token::Interpolated(token::NtPat(self.clone())))] } } impl ToTokens for ast::Arm { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - vec![ast::TtToken(DUMMY_SP, token::Interpolated(token::NtArm(self.clone())))] + vec![ast::TokenTree::Token(DUMMY_SP, token::Interpolated(token::NtArm(self.clone())))] } } @@ -187,12 +187,12 @@ macro_rules! impl_to_tokens_slice { }; } -impl_to_tokens_slice! { ast::Ty, [ast::TtToken(DUMMY_SP, token::Comma)] } +impl_to_tokens_slice! { ast::Ty, [ast::TokenTree::Token(DUMMY_SP, token::Comma)] } impl_to_tokens_slice! { P, [] } impl ToTokens for P { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - vec![ast::TtToken(DUMMY_SP, token::Interpolated(token::NtMeta(self.clone())))] + vec![ast::TokenTree::Token(DUMMY_SP, token::Interpolated(token::NtMeta(self.clone())))] } } @@ -200,11 +200,11 @@ impl ToTokens for ast::Attribute { fn to_tokens(&self, cx: &ExtCtxt) -> Vec { let mut r = vec![]; // FIXME: The spans could be better - r.push(ast::TtToken(self.span, token::Pound)); + r.push(ast::TokenTree::Token(self.span, token::Pound)); if self.node.style == ast::AttrStyle::Inner { - r.push(ast::TtToken(self.span, token::Not)); + r.push(ast::TokenTree::Token(self.span, token::Not)); } - r.push(ast::TtDelimited(self.span, Rc::new(ast::Delimited { + r.push(ast::TokenTree::Delimited(self.span, Rc::new(ast::Delimited { delim: token::Bracket, open_span: self.span, tts: self.node.value.to_tokens(cx), @@ -224,7 +224,7 @@ impl ToTokens for str { impl ToTokens for () { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - vec![ast::TtDelimited(DUMMY_SP, Rc::new(ast::Delimited { + vec![ast::TokenTree::Delimited(DUMMY_SP, Rc::new(ast::Delimited { delim: token::Paren, open_span: DUMMY_SP, tts: vec![], diff --git a/quasi_codegen/Cargo.toml b/quasi_codegen/Cargo.toml index 3a1c1f60..7d97eb4e 100644 --- a/quasi_codegen/Cargo.toml +++ b/quasi_codegen/Cargo.toml @@ -11,6 +11,6 @@ default = ["with-syntex"] with-syntex = ["syntex", "syntex_syntax", "aster/with-syntex"] [dependencies] -aster = { version = "^0.6.0", default-features = false } +aster = { version = "^0.7.0", default-features = false } syntex = { version = "^0.17.0", optional = true } -syntex_syntax = { version = "^0.19.0", optional = true } +syntex_syntax = { version = "^0.20.0", optional = true } diff --git a/quasi_codegen/src/lib.rs b/quasi_codegen/src/lib.rs index 6ec28c16..1ed650d9 100644 --- a/quasi_codegen/src/lib.rs +++ b/quasi_codegen/src/lib.rs @@ -57,7 +57,7 @@ fn expand_quote_ty<'cx>( let expanded = expand_parse_call( cx, sp, - &["syntax", "parse", "parser", "Parser", "parse_ty"], + &["syntax", "parse", "parser", "Parser", "parse_ty_panic"], vec!(), tts); base::MacEager::expr(expanded) @@ -71,7 +71,7 @@ fn expand_quote_expr<'cx>( let expanded = expand_parse_call( cx, sp, - &["syntax", "parse", "parser", "Parser", "parse_expr"], + &["syntax", "parse", "parser", "Parser", "parse_expr_panic"], Vec::new(), tts); base::MacEager::expr(expanded) @@ -85,7 +85,7 @@ fn expand_quote_stmt<'cx>( let expanded = expand_parse_call( cx, sp, - &["syntax", "parse", "parser", "Parser", "parse_stmt"], + &["syntax", "parse", "parser", "Parser", "parse_stmt_panic"], vec!(), tts); base::MacEager::expr(expanded) @@ -101,7 +101,7 @@ fn expand_quote_attr<'cx>( let expanded = expand_parse_call( cx, sp, - &["syntax", "parse", "attr", "ParserAttr", "parse_attribute"], + &["syntax", "parse", "parser", "Parser", "parse_attribute_panic"], vec![builder.expr().bool(true)], tts); @@ -135,7 +135,7 @@ fn expand_quote_pat<'cx>( let expanded = expand_parse_call( cx, sp, - &["syntax", "parse", "parser", "Parser", "parse_pat"], + &["syntax", "parse", "parser", "Parser", "parse_pat_panic"], vec!(), tts); base::MacEager::expr(expanded) @@ -149,7 +149,7 @@ fn expand_quote_arm<'cx>( let expanded = expand_parse_call( cx, sp, - &["syntax", "parse", "parser", "Parser", "parse_arm"], + &["syntax", "parse", "parser", "Parser", "parse_arm_panic"], vec!(), tts); base::MacEager::expr(expanded) @@ -177,7 +177,7 @@ fn expand_quote_item<'cx>( let expanded = expand_parse_call( cx, sp, - &["syntax", "parse", "parser", "Parser", "parse_item"], + &["syntax", "parse", "parser", "Parser", "parse_item_panic"], vec!(), tts); base::MacEager::expr(expanded) @@ -231,6 +231,13 @@ fn mk_ast_path(builder: &aster::AstBuilder, name: &str) -> P { .build() } +fn mk_tt_path(builder: &aster::AstBuilder, name: &str) -> P { + builder.expr().path() + .global() + .ids(&["syntax", "ast", "TokenTree", name]) + .build() +} + fn mk_token_path(builder: &aster::AstBuilder, name: &str) -> P { builder.expr().path() .global() @@ -452,7 +459,7 @@ fn statements_mk_tt(tt: &ast::TokenTree, matcher: bool) -> Vec> { let builder = aster::AstBuilder::new(); match *tt { - ast::TtToken(sp, SubstNt(ident, _)) => { + ast::TokenTree::Token(sp, SubstNt(ident, _)) => { // tt.extend($ident.to_tokens(ext_cx).into_iter()) let builder = builder.clone().span(sp); @@ -479,18 +486,18 @@ fn statements_mk_tt(tt: &ast::TokenTree, matcher: bool) -> Vec> { vec![builder.stmt().build_expr(e_push)] } - ref tt @ ast::TtToken(_, MatchNt(..)) if !matcher => { + ref tt @ ast::TokenTree::Token(_, MatchNt(..)) if !matcher => { let mut seq = vec![]; for i in 0..tt.len() { seq.push(tt.get_tt(i)); } statements_mk_tts(&seq[..], matcher) } - ast::TtToken(sp, ref tok) => { + ast::TokenTree::Token(sp, ref tok) => { let builder = builder.clone().span(sp); let e_tok = builder.expr().call() - .build(mk_ast_path(&builder, "TtToken")) + .build(mk_tt_path(&builder, "Token")) .arg().id("_sp") .with_arg(expr_mk_token(&builder, tok)) .build(); @@ -502,16 +509,16 @@ fn statements_mk_tt(tt: &ast::TokenTree, matcher: bool) -> Vec> { vec![builder.stmt().build_expr(e_push)] }, - ast::TtDelimited(_, ref delimed) => { + ast::TokenTree::Delimited(_, ref delimed) => { statements_mk_tt(&delimed.open_tt(), matcher).into_iter() .chain(delimed.tts.iter() .flat_map(|tt| statements_mk_tt(tt, matcher).into_iter())) .chain(statements_mk_tt(&delimed.close_tt(), matcher).into_iter()) .collect() }, - ast::TtSequence(sp, ref seq) => { + ast::TokenTree::Sequence(sp, ref seq) => { if !matcher { - panic!("TtSequence in quote!"); + panic!("TokenTree::Sequence in quote!"); } let builder = builder.clone().span(sp); @@ -551,7 +558,7 @@ fn statements_mk_tt(tt: &ast::TokenTree, matcher: bool) -> Vec> { .build(e_seq_struct); let e_tok = builder.expr().call() - .build(mk_ast_path(&builder, "TtSequence")) + .build(mk_tt_path(&builder, "Sequence")) .arg().build(e_sp) .arg().build(e_rc_new) .build(); diff --git a/quasi_macros/Cargo.toml b/quasi_macros/Cargo.toml index 356a6d89..940fc329 100644 --- a/quasi_macros/Cargo.toml +++ b/quasi_macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "quasi_macros" -version = "0.3.6" +version = "0.3.7" authors = ["Erick Tryzelaar "] license = "MIT/Apache-2.0" description = "A quasi-quoting macro system" @@ -14,5 +14,5 @@ plugin = true quasi_codegen = { version = "*", path = "../quasi_codegen", default-features = false } [dev-dependencies] -aster = "^0.6.0" +aster = "^0.7.0" quasi = { version = "*", path = "../quasi" } diff --git a/quasi_tests/Cargo.toml b/quasi_tests/Cargo.toml index 90b52759..608f64c7 100644 --- a/quasi_tests/Cargo.toml +++ b/quasi_tests/Cargo.toml @@ -12,7 +12,7 @@ quasi_codegen = { version = "*", path = "../quasi_codegen" } syntex = { version = "^0.17.0" } [dev-dependencies] -aster = { version = "^0.6.0", features = ["with-syntex"] } +aster = { version = "^0.7.0", features = ["with-syntex"] } quasi = { version = "*", path = "../quasi", features = ["with-syntex"] } syntex = { version = "^0.17.0" } -syntex_syntax = { version = "^0.19.0" } +syntex_syntax = { version = "^0.20.0" }