Skip to content

Commit

Permalink
Auto merge of #27447 - eefriedman:parser-cleanup, r=alexcrichton
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed Aug 1, 2015
2 parents 6beaeda + f9692d5 commit f50518e
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions src/libsyntax/parse/obsolete.rs
Expand Up @@ -13,11 +13,8 @@
//!
//! Obsolete syntax that becomes too hard to parse can be removed.

use ast::{Expr, ExprTup};
use codemap::Span;
use parse::parser;
use parse::token;
use ptr::P;

/// The specific types of unsupported syntax
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
Expand All @@ -29,17 +26,12 @@ pub enum ObsoleteSyntax {
pub trait ParserObsoleteMethods {
/// Reports an obsolete syntax non-fatal error.
fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax);
/// Reports an obsolete syntax non-fatal error, and returns
/// a placeholder expression
fn obsolete_expr(&mut self, sp: Span, kind: ObsoleteSyntax) -> P<Expr>;
fn report(&mut self,
sp: Span,
kind: ObsoleteSyntax,
kind_str: &str,
desc: &str,
error: bool);
fn is_obsolete_ident(&mut self, ident: &str) -> bool;
fn eat_obsolete_ident(&mut self, ident: &str) -> bool;
}

impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
Expand All @@ -61,13 +53,6 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
self.report(sp, kind, kind_str, desc, error);
}

/// Reports an obsolete syntax non-fatal error, and returns
/// a placeholder expression
fn obsolete_expr(&mut self, sp: Span, kind: ObsoleteSyntax) -> P<Expr> {
self.obsolete(sp, kind);
self.mk_expr(sp.lo, sp.hi, ExprTup(vec![]))
}

fn report(&mut self,
sp: Span,
kind: ObsoleteSyntax,
Expand All @@ -89,20 +74,4 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
self.obsolete_set.insert(kind);
}
}

fn is_obsolete_ident(&mut self, ident: &str) -> bool {
match self.token {
token::Ident(sid, _) => sid.name == ident,
_ => false,
}
}

fn eat_obsolete_ident(&mut self, ident: &str) -> bool {
if self.is_obsolete_ident(ident) {
panictry!(self.bump());
true
} else {
false
}
}
}

0 comments on commit f50518e

Please sign in to comment.