From 58779f84709568ecd61ccd9c974a510ad14199df Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 16 Nov 2018 12:53:33 -0800 Subject: [PATCH] Rename method, make sourcemap optional --- schala-lang/language/src/parsing.rs | 10 +++------- schala-lang/language/src/source_map.rs | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/schala-lang/language/src/parsing.rs b/schala-lang/language/src/parsing.rs index 87e7b91..d28c72c 100644 --- a/schala-lang/language/src/parsing.rs +++ b/schala-lang/language/src/parsing.rs @@ -65,10 +65,6 @@ impl TokenHandler { fn next(&mut self) -> TokenType { self.tokens.next().map(|ref t| { t.token_type.clone() }).unwrap_or(TokenType::EOF) } - - fn next_with_metadata(&mut self) -> Token { - self.tokens.next().unwrap_or(Token { token_type: TokenType::EOF, offset: (0, 0) }) - } } impl Parser { @@ -91,11 +87,11 @@ impl Parser { self.token_handler.next() } - fn next_with_map(&mut self) -> SourceMap { + fn next_mapped(&mut self) -> SourceMap { let tt = self.next(); SourceMap { node: tt, - data: SourceData { line_number: 420, char_idx: 69 } + data: Some(SourceData { line_number: 420, char_idx: 69 }) } } @@ -1028,7 +1024,7 @@ impl Parser { #[recursive_descent_method] fn int_literal(&mut self) -> ParseResult { use self::ExpressionType::*; - match self.next_with_map() { + match self.next_mapped() { t => match t.get() { BinNumberSigil => { let digits = self.digits()?; diff --git a/schala-lang/language/src/source_map.rs b/schala-lang/language/src/source_map.rs index 5785202..681868a 100644 --- a/schala-lang/language/src/source_map.rs +++ b/schala-lang/language/src/source_map.rs @@ -2,7 +2,7 @@ #[derive(Debug, Clone)] pub struct SourceMap { pub node: T, - pub data: SourceData + pub data: Option } impl SourceMap { @@ -10,7 +10,7 @@ impl SourceMap { &self.node } - pub fn get_source_data(&self) -> SourceData { + pub fn get_source_data(&self) -> Option { self.data.clone() } }