Clear up some code a bit

This commit is contained in:
greg 2018-11-17 01:10:23 -08:00
parent 1f527f7949
commit 0af6fed505
3 changed files with 16 additions and 16 deletions

View File

@ -2,7 +2,6 @@ use std::rc::Rc;
use std::convert::From;
use source_map::{SourceMap};
use builtin::{BinOp, PrefixOp};
#[derive(Debug, PartialEq)]

View File

@ -87,6 +87,7 @@ impl Parser {
self.token_handler.next()
}
/*
fn next_mapped(&mut self) -> SourceMap<TokenKind> {
let tt = self.next();
SourceMap {
@ -94,6 +95,7 @@ impl Parser {
data: Some(SourceData { line_number: 420, char_idx: 69 })
}
}
*/
pub fn parse(&mut self) -> ParseResult<AST> {
self.program()
@ -1024,24 +1026,21 @@ impl Parser {
#[recursive_descent_method]
fn int_literal(&mut self) -> ParseResult<Expression> {
use self::ExpressionType::*;
match self.next_mapped() {
t => match t.get() {
BinNumberSigil => {
let digits = self.digits()?;
let n = parse_binary(digits)?;
Ok(Expression(NatLiteral(n), None))
},
HexLiteral(text) => {
let digits: String = text.chars().filter(|c| c.is_digit(16)).collect();
let n = parse_hex(digits)?;
Ok(Expression(NatLiteral(n), None))
},
_ => return ParseError::new("Expected '0x' or '0b'"),
}
match self.next() {
BinNumberSigil => {
let digits = self.digits()?;
let n = parse_binary(digits)?;
Ok(Expression(NatLiteral(n), None))
},
HexLiteral(text) => {
let digits: String = text.chars().filter(|c| c.is_digit(16)).collect();
let n = parse_hex(digits)?;
Ok(Expression(NatLiteral(n), None))
},
_ => return ParseError::new("Expected '0x' or '0b'"),
}
}
#[recursive_descent_method]
fn float_literal(&mut self) -> ParseResult<Expression> {
use self::ExpressionType::*;

View File

@ -10,9 +10,11 @@ impl<T> SourceMap<T> {
&self.node
}
/*
pub fn get_source_data(&self) -> Option<SourceData> {
self.data.clone()
}
*/
}
#[derive(Debug, Clone)]