Fixed a minor bug

pull/2/head
Mark 2023-07-31 16:01:21 -07:00
parent 99f4919fea
commit b072ff3691
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
2 changed files with 11 additions and 3 deletions

View File

@ -23,7 +23,10 @@ fn lookback_signs(
=> {
if o == "-" {
g.insert(i, Token::Operator(*l, String::from("neg")));
} else if o == "+" {
} else if o == "+" && g.len() != 0 {
// Don't remove "+" if it's the only token,
// this is a syntax error that is caught later.e
continue; // We should not increment i if we remove a token
} else {g.insert(i, a);}
},

View File

@ -288,11 +288,16 @@ pub fn treeify(
context: &Context
) -> Result<Expression, (LineLocation, ParserError)> {
let g_inner: &mut VecDeque<Token> = match g {
Token::Group(_, ref mut x) => x,
let (l, g_inner): (LineLocation, &mut VecDeque<Token>) = match g {
Token::Group(l, ref mut x) => (l, x),
_ => panic!()
};
if g_inner.len() == 0 {
// This shouldn't ever happen.
return Err((l, ParserError::EmptyGroup));
}
let mut left_associative = true;
let mut j: i64 = 0;
while g_inner.len() > 1 {