diff --git a/src/parser/stage/find_subs.rs b/src/parser/stage/find_subs.rs index 79287bc..058cf54 100644 --- a/src/parser/stage/find_subs.rs +++ b/src/parser/stage/find_subs.rs @@ -89,11 +89,11 @@ pub fn find_subs( if target.is_none() { // Even if nothing changed, we need to update token location - let l = t.get_mut_line_location(); + let l = t.get_mut_linelocation(); *l = LineLocation{pos: l.pos - offset, len: l.len}; } else { let target = target.unwrap(); - let l = t.get_mut_line_location(); + let l = t.get_mut_linelocation(); r.push_back((*l, String::from(target))); let old_len = l.len; diff --git a/src/parser/stage/groupify.rs b/src/parser/stage/groupify.rs index 8d87366..3b108ca 100644 --- a/src/parser/stage/groupify.rs +++ b/src/parser/stage/groupify.rs @@ -203,7 +203,7 @@ pub fn groupify( (LineLocation, DaisyError) > { - let last_linelocation: LineLocation = *g.back().unwrap().get_line_location(); + let last_linelocation: LineLocation = g.back().unwrap().get_linelocation(); // Vector of grouping levels let mut levels: Vec<(LineLocation, VecDeque)> = Vec::with_capacity(8); diff --git a/src/parser/stage/treeify.rs b/src/parser/stage/treeify.rs index e453bfc..984cf16 100644 --- a/src/parser/stage/treeify.rs +++ b/src/parser/stage/treeify.rs @@ -66,7 +66,7 @@ fn treeify_binary( } { return Ok(false); } else { - let tl = *this.get_line_location() + *l; + let tl = this.get_linelocation() + *l; return Err((tl, DaisyError::Syntax)); // left argument isn't valid } } @@ -82,7 +82,7 @@ fn treeify_binary( } { return Ok(false); } else { - let tl = *this.get_line_location() + *l; + let tl = this.get_linelocation() + *l; return Err((tl, DaisyError::Syntax)); // right argument isn't valid (two operators next to each other) } } @@ -203,14 +203,14 @@ fn treeify_unary( } else { // Previous operator is invalid return Err(( - *this.get_line_location(), + this.get_linelocation(), DaisyError::Syntax )); } } if let Token::Operator(l, _) = next { - let tl = *this.get_line_location() + *l; + let tl = this.get_linelocation() + *l; // Argument is invalid return Err((tl, DaisyError::Syntax)); } else { diff --git a/src/parser/token.rs b/src/parser/token.rs index bba2be4..2c68674 100644 --- a/src/parser/token.rs +++ b/src/parser/token.rs @@ -27,7 +27,7 @@ pub enum Token { impl Token { #[inline(always)] - pub fn get_line_location(&self) -> &LineLocation { + pub fn get_linelocation(&self) -> LineLocation { match self { Token::Quantity(l, _) | Token::Word(l, _) @@ -35,14 +35,14 @@ impl Token { | Token::GroupStart(l) | Token::GroupEnd(l) | Token::Group(l, _) - => l, + => l.clone(), Token::Container(_) => panic!("Containers do not have a linelocation.") } } #[inline(always)] - pub fn get_mut_line_location(&mut self) -> &mut LineLocation { + pub fn get_mut_linelocation(&mut self) -> &mut LineLocation { match self { Token::Quantity(l, _) | Token::Word(l, _)