mirror of https://github.com/rm-dr/daisy
Fixed a minor bug
parent
99f4919fea
commit
b072ff3691
|
@ -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);}
|
||||||
},
|
},
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue