use ast::{ItemEnum, ItemFn, ItemForeignMod, ItemImpl, ItemConst};
use ast::{ItemMac, ItemMod, ItemStruct, ItemTrait, ItemTy, ItemDefaultImpl};
use ast::{ItemExternCrate, ItemUse};
-use ast::{Lit, Lit_, UintTy};
-use ast::{LitBool, LitChar, LitByte, LitByteStr};
-use ast::{LitStr, LitInt, Local};
+use ast::{Lit, LitKind, UintTy};
+use ast::Local;
use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces};
use ast::{MutImmutable, MutMutable, Mac_};
use ast::{MutTy, Mutability};
use ast::{Pat, PatBox, PatEnum, PatIdent, PatLit, PatQPath, PatMac, PatRange};
use ast::{PatRegion, PatStruct, PatTup, PatVec, PatWild};
use ast::{PolyTraitRef, QSelf};
-use ast::{Stmt, StmtDecl};
-use ast::{StmtExpr, StmtSemi, StmtMac, VariantData, StructField};
+use ast::{Stmt, StmtKind};
+use ast::{VariantData, StructField};
use ast::StrStyle;
use ast::SelfKind;
use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
}
/// Matches token_lit = LIT_INTEGER | ...
- pub fn lit_from_token(&self, tok: &token::Token) -> PResult<'a, Lit_> {
+ pub fn lit_from_token(&self, tok: &token::Token) -> PResult<'a, LitKind> {
match *tok {
token::Interpolated(token::NtExpr(ref v)) => {
match v.node {
}
token::Literal(lit, suf) => {
let (suffix_illegal, out) = match lit {
- token::Byte(i) => (true, LitByte(parse::byte_lit(&i.as_str()).0)),
- token::Char(i) => (true, LitChar(parse::char_lit(&i.as_str()).0)),
+ token::Byte(i) => (true, LitKind::Byte(parse::byte_lit(&i.as_str()).0)),
+ token::Char(i) => (true, LitKind::Char(parse::char_lit(&i.as_str()).0)),
// there are some valid suffixes for integer and
// float literals, so all the handling is done
token::Str_(s) => {
(true,
- LitStr(token::intern_and_get_ident(&parse::str_lit(&s.as_str())),
- ast::CookedStr))
+ LitKind::Str(token::intern_and_get_ident(&parse::str_lit(&s.as_str())),
+ ast::CookedStr))
}
token::StrRaw(s, n) => {
(true,
- LitStr(
+ LitKind::Str(
token::intern_and_get_ident(&parse::raw_str_lit(&s.as_str())),
ast::RawStr(n)))
}
token::ByteStr(i) =>
- (true, LitByteStr(parse::byte_str_lit(&i.as_str()))),
+ (true, LitKind::ByteStr(parse::byte_str_lit(&i.as_str()))),
token::ByteStrRaw(i, _) =>
(true,
- LitByteStr(Rc::new(i.to_string().into_bytes()))),
+ LitKind::ByteStr(Rc::new(i.to_string().into_bytes()))),
};
if suffix_illegal {
pub fn parse_lit(&mut self) -> PResult<'a, Lit> {
let lo = self.span.lo;
let lit = if self.eat_keyword(keywords::True) {
- LitBool(true)
+ LitKind::Bool(true)
} else if self.eat_keyword(keywords::False) {
- LitBool(false)
+ LitKind::Bool(false)
} else {
let token = self.bump_and_get();
let lit = try!(self.lit_from_token(&token));
pub fn mk_lit_u32(&mut self, i: u32, attrs: ThinAttributes) -> P<Expr> {
let span = &self.span;
let lv_lit = P(codemap::Spanned {
- node: LitInt(i as u64, ast::UnsignedIntLit(UintTy::U32)),
+ node: LitKind::Int(i as u64, ast::LitIntType::Unsigned(UintTy::U32)),
span: *span
});
try!(self.expect_keyword(keywords::Let));
let decl = try!(self.parse_let(attrs.into_thin_attrs()));
let hi = decl.span.hi;
- let stmt = StmtDecl(decl, ast::DUMMY_NODE_ID);
+ let stmt = StmtKind::Decl(decl, ast::DUMMY_NODE_ID);
spanned(lo, hi, stmt)
} else if self.token.is_ident()
&& !self.token.is_any_keyword()
};
if id.name == token::special_idents::invalid.name {
- let stmt = StmtMac(P(spanned(lo,
- hi,
- Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT })),
- style,
- attrs.into_thin_attrs());
+ let mac = P(spanned(lo, hi, Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT }));
+ let stmt = StmtKind::Mac(mac, style, attrs.into_thin_attrs());
spanned(lo, hi, stmt)
} else {
// if it has a special ident, it's definitely an item
followed by a semicolon");
}
}
- spanned(lo, hi, StmtDecl(
+ spanned(lo, hi, StmtKind::Decl(
P(spanned(lo, hi, DeclKind::Item(
self.mk_item(
lo, hi, id /*id is good here*/,
Some(i) => {
let hi = i.span.hi;
let decl = P(spanned(lo, hi, DeclKind::Item(i)));
- spanned(lo, hi, StmtDecl(decl, ast::DUMMY_NODE_ID))
+ spanned(lo, hi, StmtKind::Decl(decl, ast::DUMMY_NODE_ID))
}
None => {
let unused_attrs = |attrs: &[_], s: &mut Self| {
let e = try!(self.parse_expr_res(
Restrictions::RESTRICTION_STMT_EXPR, Some(attrs.into_thin_attrs())));
let hi = e.span.hi;
- let stmt = StmtExpr(e, ast::DUMMY_NODE_ID);
+ let stmt = StmtKind::Expr(e, ast::DUMMY_NODE_ID);
spanned(lo, hi, stmt)
}
}
continue;
};
match node {
- StmtExpr(e, _) => {
+ StmtKind::Expr(e, _) => {
try!(self.handle_expression_like_statement(e, span, &mut stmts, &mut expr));
}
- StmtMac(mac, MacStmtWithoutBraces, attrs) => {
+ StmtKind::Mac(mac, MacStmtWithoutBraces, attrs) => {
// statement macro without braces; might be an
// expr depending on whether a semicolon follows
match self.token {
token::Semi => {
stmts.push(P(Spanned {
- node: StmtMac(mac, MacStmtWithSemicolon, attrs),
+ node: StmtKind::Mac(mac, MacStmtWithSemicolon, attrs),
span: mk_sp(span.lo, self.span.hi),
}));
self.bump();
}
}
}
- StmtMac(m, style, attrs) => {
+ StmtKind::Mac(m, style, attrs) => {
// statement macro; might be an expr
match self.token {
token::Semi => {
stmts.push(P(Spanned {
- node: StmtMac(m, MacStmtWithSemicolon, attrs),
+ node: StmtKind::Mac(m, MacStmtWithSemicolon, attrs),
span: mk_sp(span.lo, self.span.hi),
}));
self.bump();
}
_ => {
stmts.push(P(Spanned {
- node: StmtMac(m, style, attrs),
+ node: StmtKind::Mac(m, style, attrs),
span: span
}));
}
expn_id: span.expn_id,
};
stmts.push(P(Spanned {
- node: StmtSemi(e, ast::DUMMY_NODE_ID),
+ node: StmtKind::Semi(e, ast::DUMMY_NODE_ID),
span: span_with_semi,
}));
}
token::CloseDelim(token::Brace) => *last_block_expr = Some(e),
_ => {
stmts.push(P(Spanned {
- node: StmtExpr(e, ast::DUMMY_NODE_ID),
+ node: StmtKind::Expr(e, ast::DUMMY_NODE_ID),
span: span
}));
}