WIP source map stuff
This commit is contained in:
parent
e42f0c644c
commit
d357876b16
@ -6,6 +6,7 @@ use tokenizing::*;
|
||||
use tokenizing::Kw::*;
|
||||
use tokenizing::TokenType::*;
|
||||
|
||||
use source_map::{SourceMap, SourceData};
|
||||
use ast::*;
|
||||
|
||||
use builtin::{BinOp, PrefixOp};
|
||||
@ -90,8 +91,12 @@ impl Parser {
|
||||
self.token_handler.next()
|
||||
}
|
||||
|
||||
fn next_with_metadata(&mut self) -> Token {
|
||||
self.token_handler.next_with_metadata()
|
||||
fn next_with_map(&mut self) -> SourceMap<TokenType> {
|
||||
let tt = self.next();
|
||||
SourceMap {
|
||||
node: tt,
|
||||
data: SourceData { line_number: 420, char_idx: 69 }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse(&mut self) -> ParseResult<AST> {
|
||||
@ -1023,7 +1028,8 @@ impl Parser {
|
||||
#[recursive_descent_method]
|
||||
fn int_literal(&mut self) -> ParseResult<Expression> {
|
||||
use self::ExpressionType::*;
|
||||
match self.next_with_metadata().get_token_type() {
|
||||
match self.next_with_map() {
|
||||
t => match t.get() {
|
||||
BinNumberSigil => {
|
||||
let digits = self.digits()?;
|
||||
let n = parse_binary(digits)?;
|
||||
@ -1037,6 +1043,8 @@ impl Parser {
|
||||
_ => return ParseError::new("Expected '0x' or '0b'"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[recursive_descent_method]
|
||||
fn float_literal(&mut self) -> ParseResult<Expression> {
|
||||
|
@ -1,12 +1,23 @@
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SourceMap<T> {
|
||||
node: T,
|
||||
data: SourceData
|
||||
pub node: T,
|
||||
pub data: SourceData
|
||||
}
|
||||
|
||||
struct SourceData {
|
||||
line_number: usize,
|
||||
char_idx: usize
|
||||
impl<T> SourceMap<T> {
|
||||
pub fn get(&self) -> &T {
|
||||
&self.node
|
||||
}
|
||||
|
||||
pub fn get_source_data(&self) -> SourceData {
|
||||
So
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SourceData {
|
||||
pub line_number: usize,
|
||||
pub char_idx: usize
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user