From cac3ea86cf8dd9bb108969022993615772160ca6 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 11 Sep 2017 03:13:19 -0700 Subject: [PATCH] Import TokenType and Kw everywhere --- src/schala_lang/parsing.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/schala_lang/parsing.rs b/src/schala_lang/parsing.rs index a674e8a..e73a3e0 100644 --- a/src/schala_lang/parsing.rs +++ b/src/schala_lang/parsing.rs @@ -29,6 +29,7 @@ pub enum TokenType { Error(String), } +use self::TokenType::*; #[derive(Debug, Clone, Copy, PartialEq)] pub enum Kw { @@ -41,6 +42,7 @@ pub enum Kw { Trait, Impl, True, False } +use self::Kw::*; lazy_static! { static ref KEYWORDS: HashMap<&'static str, Kw> = @@ -87,8 +89,6 @@ fn is_digit(c: &char) -> bool { type CharIter<'a> = Peekable>>; pub fn tokenize(input: &str) -> Vec { - use self::TokenType::*; - let mut tokens: Vec = Vec::new(); let mut input: CharIter = input.chars().enumerate().peekable(); @@ -124,8 +124,6 @@ pub fn tokenize(input: &str) -> Vec { } fn handle_digit(c: char, input: &mut CharIter) -> TokenType { - use self::TokenType::*; - if c == '0' && input.peek().map_or(false, |&(_, c)| { c == 'x' }) { input.next(); HexNumberSigil @@ -366,7 +364,6 @@ pub enum Expression { impl Parser { fn program(&mut self) -> ParseResult { - use self::TokenType::*; let mut statements = Vec::new(); loop { match self.peek() { @@ -382,7 +379,6 @@ impl Parser { } fn statement(&mut self) -> ParseResult { - use self::TokenType::*; use self::Kw::*; //TODO handle error recovery here match self.peek() { @@ -409,14 +405,12 @@ impl Parser { } fn literal(&mut self) -> ParseResult { - use self::TokenType::*; match self.peek() { DigitGroup(_) | HexNumberSigil | BinNumberSigil | Period => self.number_literal(), _ => unimplemented!(), } } fn number_literal(&mut self) -> ParseResult { - use self::TokenType::*; match self.peek() { HexNumberSigil | BinNumberSigil => self.int_literal(), _ => self.float_literal(), @@ -459,7 +453,6 @@ impl Parser { } fn digits(&mut self) -> ParseResult { - use self::TokenType::*; let mut ds = String::new(); loop { match self.peek() {