diff --git a/schala-lang/language/src/parsing/mod.rs b/schala-lang/language/src/parsing/mod.rs index fe04297..20247d3 100644 --- a/schala-lang/language/src/parsing/mod.rs +++ b/schala-lang/language/src/parsing/mod.rs @@ -226,7 +226,7 @@ struct TokenHandler { impl TokenHandler { fn new(tokens: Vec) -> TokenHandler { let end_of_file = match tokens.last() { - None => Location { line_num: 0, char_num: 0 }, + None => Location { line_num: 0, char_num: 0, offset: 0 }, Some(t) => t.location, }; TokenHandler { idx: 0, tokens, end_of_file } diff --git a/schala-lang/language/src/tokenizing.rs b/schala-lang/language/src/tokenizing.rs index 6326a11..4b1a93c 100644 --- a/schala-lang/language/src/tokenizing.rs +++ b/schala-lang/language/src/tokenizing.rs @@ -17,6 +17,7 @@ use itertools::Itertools; pub struct Location { pub(crate) line_num: u32, pub(crate) char_num: u16, + pub(crate) offset: usize, } impl fmt::Display for Location { @@ -221,8 +222,11 @@ pub fn tokenize(input: &str) -> Vec { c if is_operator(&c) => handle_operator(c, &mut input), unknown => Error(format!("Unexpected character: {}", unknown)), }; - let location = - Location { line_num: line_num.try_into().unwrap(), char_num: char_num.try_into().unwrap() }; + let location = Location { + offset: 0, + line_num: line_num.try_into().unwrap(), + char_num: char_num.try_into().unwrap(), + }; tokens.push(Token { kind: cur_tok_kind, location }); } tokens