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 == "-" { if o == "-" {
g.insert(i, Token::Operator(*l, String::from("neg"))); 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 continue; // We should not increment i if we remove a token
} else {g.insert(i, a);} } else {g.insert(i, a);}
}, },

View File

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