Rename method, make sourcemap optional

This commit is contained in:
greg 2018-11-16 12:53:33 -08:00
parent a0fa50392c
commit 58779f8470
2 changed files with 5 additions and 9 deletions

View File

@ -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<TokenType> {
fn next_mapped(&mut self) -> SourceMap<TokenType> {
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<Expression> {
use self::ExpressionType::*;
match self.next_with_map() {
match self.next_mapped() {
t => match t.get() {
BinNumberSigil => {
let digits = self.digits()?;

View File

@ -2,7 +2,7 @@
#[derive(Debug, Clone)]
pub struct SourceMap<T> {
pub node: T,
pub data: SourceData
pub data: Option<SourceData>
}
impl<T> SourceMap<T> {
@ -10,7 +10,7 @@ impl<T> SourceMap<T> {
&self.node
}
pub fn get_source_data(&self) -> SourceData {
pub fn get_source_data(&self) -> Option<SourceData> {
self.data.clone()
}
}