Fix parsing arithmetic expressions
This commit is contained in:
		
							parent
							
								
									082981f203
								
							
						
					
					
						commit
						529008a1fc
					
				| @ -1,3 +1,3 @@ | ||||
| let number = 2 + 5 * 2 + 5 + 1 * 10 + 1; | ||||
| let number = 2 * 5 * 2 - 10 + 5 * 7; | ||||
| let text = "" + number; | ||||
| print(text); | ||||
| @ -149,11 +149,10 @@ impl ArithmeticExpression { | ||||
|         // Replace all (expr, "*"), (expr, any) => ((mult_expr, any)
 | ||||
|         let clone = list.clone(); | ||||
|         let iter = clone.iter().enumerate().rev(); | ||||
|         let mut previous: Option<(Expression, Option<String>)> = None; | ||||
|         for (idx, (exp, sign)) in iter { | ||||
|             if let Some(sign) = sign { | ||||
|                 if sign == "*" { | ||||
|                     if let Some((exp2, sign2)) = previous { | ||||
|                     if let Some((exp2, sign2)) = list.clone().get(idx + 1) { | ||||
|                         list.remove(idx + 1); | ||||
|                         list.remove(idx); | ||||
|                         let expr = Expression::ArithmeticExpression( | ||||
| @ -164,7 +163,6 @@ impl ArithmeticExpression { | ||||
|                     }; | ||||
|                 } | ||||
|             } | ||||
|             previous = Some((exp.clone(), sign.clone())); | ||||
|         } | ||||
| 
 | ||||
|         let mut ret = Err(SyntaxError::Fatal); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user