Improve error for statement-failure
This commit is contained in:
		
							parent
							
								
									8f45c8cf92
								
							
						
					
					
						commit
						5c5c9c5f7b
					
				| @ -94,13 +94,5 @@ fn str_length(string: *char, position: u32) -> u32 { | ||||
| 
 | ||||
| pub fn add_num_to_str(string: &mut String, num: u64) { | ||||
|     if num == 0 { add_char(string, '0'); }  | ||||
|     else { if num == 1 { add_char(string, '1'); }  | ||||
|     else { if num == 2 { add_char(string, '2'); }  | ||||
|     else { if num == 3 { add_char(string, '3'); }  | ||||
|     else { if num == 4 { add_char(string, '4'); }  | ||||
|     else { if num == 5 { add_char(string, '5'); }  | ||||
|     else { if num == 6 { add_char(string, '6'); }  | ||||
|     else { if num == 7 { add_char(string, '7'); }  | ||||
|     else { if num == 8 { add_char(string, '8'); }  | ||||
|     else { if num == 9 { add_char(string, '9'); } } } } } } } } } } | ||||
|     else if num == 1 { add_char(string, '1'); } | ||||
| } | ||||
| @ -224,7 +224,7 @@ impl Parse for PrimaryExpression { | ||||
|                     stream.expect(Token::BracketClose)?; | ||||
|                     Expression(Kind::Array(expressions), stream.get_range().unwrap()) | ||||
|                 } | ||||
|                 _ => Err(stream.expected_err("expression")?)?, | ||||
|                 _ => Err(stream.expected_err("expression inner")?)?, | ||||
|             } | ||||
|         } else { | ||||
|             Err(stream.expected_err("expression")?)? | ||||
| @ -662,14 +662,11 @@ impl Parse for BlockLevelStatement { | ||||
|                 if let Ok(SetStatement(ident, expr, range)) = stream.parse() { | ||||
|                     Stmt::Set(ident, expr, range) | ||||
|                 } else { | ||||
|                     if let Ok(e) = stream.parse() { | ||||
|                         if stream.expect(Token::Semi).is_ok() { | ||||
|                             Stmt::Expression(e) | ||||
|                         } else { | ||||
|                             Stmt::Return(ReturnType::Soft, e) | ||||
|                         } | ||||
|                     let e = stream.parse()?; | ||||
|                     if stream.expect(Token::Semi).is_ok() { | ||||
|                         Stmt::Expression(e) | ||||
|                     } else { | ||||
|                         Err(stream.expecting_err("expression")?)? | ||||
|                         Stmt::Return(ReturnType::Soft, e) | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user