Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
feat(rustup): Update aster and syntex versions
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed Nov 23, 2015
1 parent df3a4ab commit f1da953
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 24 deletions.
4 changes: 2 additions & 2 deletions quasi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quasi"
version = "0.3.7"
version = "0.3.8"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0"
description = "A quasi-quoting macro system"
Expand All @@ -10,4 +10,4 @@ repository = "https://github.com/erickt/rust-quasi"
with-syntex = ["syntex_syntax"]

[dependencies]
syntex_syntax = { version = "^0.20.0", optional = true }
syntex_syntax = { version = "^0.22.0", optional = true }
38 changes: 38 additions & 0 deletions quasi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use syntax::ast::{self, TokenTree, Generics, Expr};
use syntax::codemap::{DUMMY_SP, Spanned, dummy_spanned};
use syntax::ext::base::ExtCtxt;
use syntax::parse::{self, classify, parse_tts_from_source_str, token};
use syntax::parse::parser::Parser;
use syntax::print::pprust;
use syntax::ptr::P;

Expand Down Expand Up @@ -326,3 +327,40 @@ impl<'a> ExtParseUtils for ExtCtxt<'a> {
self.parse_sess())
}
}

macro_rules! panictry {
($e:expr) => ({
match $e {
Ok(e) => e,
Err(err) => panic!(err)
}
})
}

pub fn parse_expr_panic(parser: &mut Parser) -> P<ast::Expr> {
panictry!(parser.parse_expr())
}

pub fn parse_item_panic(parser: &mut Parser) -> Option<P<ast::Item>> {
panictry!(parser.parse_item())
}

pub fn parse_pat_panic(parser: &mut Parser) -> P<ast::Pat> {
panictry!(parser.parse_pat())
}

pub fn parse_arm_panic(parser: &mut Parser) -> ast::Arm {
panictry!(parser.parse_arm())
}

pub fn parse_ty_panic(parser: &mut Parser) -> P<ast::Ty> {
panictry!(parser.parse_ty())
}

pub fn parse_stmt_panic(parser: &mut Parser) -> Option<P<ast::Stmt>> {
panictry!(parser.parse_stmt())
}

pub fn parse_attribute_panic(parser: &mut Parser, permit_inner: bool) -> ast::Attribute {
panictry!(parser.parse_attribute(permit_inner))
}
8 changes: 4 additions & 4 deletions quasi_codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quasi_codegen"
version = "0.3.7"
version = "0.3.8"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0"
description = "A quasi-quoting macro system"
Expand All @@ -11,6 +11,6 @@ default = ["with-syntex"]
with-syntex = ["syntex", "syntex_syntax", "aster/with-syntex"]

[dependencies]
aster = { version = "^0.7.0", default-features = false }
syntex = { version = "^0.17.0", optional = true }
syntex_syntax = { version = "^0.20.0", optional = true }
aster = { version = "^0.8.0", default-features = false }
syntex = { version = "^0.22.0", optional = true }
syntex_syntax = { version = "^0.22.0", optional = true }
19 changes: 11 additions & 8 deletions quasi_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn expand_quote_ty<'cx>(
let expanded = expand_parse_call(
cx,
sp,
&["syntax", "parse", "parser", "Parser", "parse_ty_panic"],
&["quasi", "parse_ty_panic"],
vec!(),
tts);
base::MacEager::expr(expanded)
Expand All @@ -71,7 +71,7 @@ fn expand_quote_expr<'cx>(
let expanded = expand_parse_call(
cx,
sp,
&["syntax", "parse", "parser", "Parser", "parse_expr_panic"],
&["quasi", "parse_expr_panic"],
Vec::new(),
tts);
base::MacEager::expr(expanded)
Expand All @@ -85,7 +85,7 @@ fn expand_quote_stmt<'cx>(
let expanded = expand_parse_call(
cx,
sp,
&["syntax", "parse", "parser", "Parser", "parse_stmt_panic"],
&["quasi", "parse_stmt_panic"],
vec!(),
tts);
base::MacEager::expr(expanded)
Expand All @@ -101,7 +101,7 @@ fn expand_quote_attr<'cx>(
let expanded = expand_parse_call(
cx,
sp,
&["syntax", "parse", "parser", "Parser", "parse_attribute_panic"],
&["quasi", "parse_attribute_panic"],
vec![builder.expr().bool(true)],
tts);

Expand Down Expand Up @@ -135,7 +135,7 @@ fn expand_quote_pat<'cx>(
let expanded = expand_parse_call(
cx,
sp,
&["syntax", "parse", "parser", "Parser", "parse_pat_panic"],
&["quasi", "parse_pat_panic"],
vec!(),
tts);
base::MacEager::expr(expanded)
Expand All @@ -149,7 +149,7 @@ fn expand_quote_arm<'cx>(
let expanded = expand_parse_call(
cx,
sp,
&["syntax", "parse", "parser", "Parser", "parse_arm_panic"],
&["quasi", "parse_arm_panic"],
vec!(),
tts);
base::MacEager::expr(expanded)
Expand Down Expand Up @@ -177,7 +177,7 @@ fn expand_quote_item<'cx>(
let expanded = expand_parse_call(
cx,
sp,
&["syntax", "parse", "parser", "Parser", "parse_item_panic"],
&["quasi", "parse_item_panic"],
vec!(),
tts);
base::MacEager::expr(expanded)
Expand Down Expand Up @@ -583,7 +583,10 @@ fn parse_arguments_to_quote(cx: &ExtCtxt, tts: &[ast::TokenTree])
let mut p = cx.new_parser_from_tts(tts);
p.quote_depth += 1;

let cx_expr = p.parse_expr_panic();
let cx_expr = match p.parse_expr() {
Ok(expr) => expr,
Err(err) => panic!(err),
};
if !p.eat(&token::Comma).ok().unwrap() {
let _ = p.fatal("expected token `,`");
}
Expand Down
4 changes: 2 additions & 2 deletions quasi_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quasi_macros"
version = "0.3.7"
version = "0.3.8"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0"
description = "A quasi-quoting macro system"
Expand All @@ -14,5 +14,5 @@ plugin = true
quasi_codegen = { version = "*", path = "../quasi_codegen", default-features = false }

[dev-dependencies]
aster = "^0.7.0"
aster = "^0.8.0"
quasi = { version = "*", path = "../quasi" }
8 changes: 4 additions & 4 deletions quasi_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ build = "build.rs"

[build-dependencies]
quasi_codegen = { version = "*", path = "../quasi_codegen" }
syntex = { version = "^0.17.0" }
syntex = { version = "^0.22.0" }

[dev-dependencies]
aster = { version = "^0.7.0", features = ["with-syntex"] }
aster = { version = "^0.8.0", features = ["with-syntex"] }
quasi = { version = "*", path = "../quasi", features = ["with-syntex"] }
syntex = { version = "^0.17.0" }
syntex_syntax = { version = "^0.20.0" }
syntex = { version = "^0.22.0" }
syntex_syntax = { version = "^0.22.0" }
8 changes: 4 additions & 4 deletions quasi_tests/tests/test.rs.in
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ fn test_quote_with_macro() {
s == "{\n macro_rules! value(( ) => 6);\n value!{ }\n}");

// Make sure we don't expand macros in the quote.
macro_rules! value { () => 5 }
macro_rules! value { () => { 5i32 } }
let block = quote_block!(&cx, { value!() }).ok().unwrap();

// FIXME: Rust 1.2 and nightly pretty print slightly differently.
//assert_eq!(pprust::block_to_string(&block), "{ value!() }");
let s = pprust::block_to_string(&block);
assert!(s == "{ value!() }" || s == "{ value!{ } }");
assert_eq!(pprust::block_to_string(&block), "{ value!() }");
//let s = pprust::block_to_string(&block);
//assert!(s == "{ value!() }" || s == "{ value!{ } }");
}

#[test]
Expand Down

0 comments on commit f1da953

Please sign in to comment.