Skip to content

Commit 1dff39f

Browse files
committed
chore(fmt): apply rustfmt after merging PR #52
1 parent 5eb1247 commit 1dff39f

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/parser/parser_stmt.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ use crate::ir::ast::Type;
1313
use crate::ir::ast::{FormalArgument, Function, Statement};
1414
use crate::parser::parser_common::{
1515
identifier, keyword, ASSERTEQ_KEYWORD, ASSERTFALSE_KEYWORD, ASSERTNEQ_KEYWORD,
16-
ASSERTTRUE_KEYWORD, ASSERT_KEYWORD, COLON_CHAR, COMMA_CHAR, DEF_KEYWORD, ELSE_KEYWORD,
17-
END_KEYWORD, EQUALS_CHAR, FOR_KEYWORD, FUNCTION_ARROW, IF_KEYWORD, IN_KEYWORD, LEFT_PAREN,
18-
RIGHT_PAREN, SEMICOLON_CHAR, VAL_KEYWORD, VAR_KEYWORD, WHILE_KEYWORD, ELIF_KEYWORD
16+
ASSERTTRUE_KEYWORD, ASSERT_KEYWORD, COLON_CHAR, COMMA_CHAR, DEF_KEYWORD, ELIF_KEYWORD,
17+
ELSE_KEYWORD, END_KEYWORD, EQUALS_CHAR, FOR_KEYWORD, FUNCTION_ARROW, IF_KEYWORD, IN_KEYWORD,
18+
LEFT_PAREN, RIGHT_PAREN, SEMICOLON_CHAR, VAL_KEYWORD, VAR_KEYWORD, WHILE_KEYWORD,
1919
};
2020
use crate::parser::parser_expr::parse_expression;
2121
use crate::parser::parser_type::parse_type;
@@ -108,11 +108,10 @@ fn parse_if_else_statement(input: &str) -> IResult<&str, Statement> {
108108
}
109109

110110
pub fn parse_if_chain_statement(input: &str) -> IResult<&str, Statement> {
111-
112111
let (input_after_if, _) = keyword(IF_KEYWORD)(input)?;
113112
let (input_after_expr, cond_if) = parse_expression(input_after_if)?;
114113
let (input_after_block, block_if) = parse_block(input_after_expr)?;
115-
114+
116115
let mut branches = vec![(Box::new(cond_if), Box::new(block_if))];
117116
let mut current_input = input_after_block;
118117

@@ -509,7 +508,6 @@ mod tests {
509508

510509
#[test]
511510
fn test_parse_if_chain_statement() {
512-
513511
// Cenário 1: Apenas um "if", sem "elif" ou "else".
514512
let input_if_only = "if True: x = 1; end";
515513
let expected_if_only = Statement::IfChain {
@@ -569,22 +567,31 @@ mod tests {
569567
};
570568
let (_, parsed_if_elif_else) = parse_if_chain_statement(input_if_elif_else).unwrap();
571569
assert_eq!(parsed_if_elif_else, expected_if_elif_else);
572-
570+
573571
// Cenário 4: "if" com múltiplos "elif" e sem "else".
574572
let input_multi_elif = "if a: x=1; end elif b: y=2; end elif c: z=3; end";
575573
let expected_multi_elif = Statement::IfChain {
576574
branches: vec![
577575
(
578576
Box::new(Expression::Var("a".to_string())),
579-
Box::new(Statement::Block(vec![Statement::Assignment("x".to_string(), Box::new(Expression::CInt(1)))])),
577+
Box::new(Statement::Block(vec![Statement::Assignment(
578+
"x".to_string(),
579+
Box::new(Expression::CInt(1)),
580+
)])),
580581
),
581582
(
582583
Box::new(Expression::Var("b".to_string())),
583-
Box::new(Statement::Block(vec![Statement::Assignment("y".to_string(), Box::new(Expression::CInt(2)))])),
584+
Box::new(Statement::Block(vec![Statement::Assignment(
585+
"y".to_string(),
586+
Box::new(Expression::CInt(2)),
587+
)])),
584588
),
585589
(
586590
Box::new(Expression::Var("c".to_string())),
587-
Box::new(Statement::Block(vec![Statement::Assignment("z".to_string(), Box::new(Expression::CInt(3)))])),
591+
Box::new(Statement::Block(vec![Statement::Assignment(
592+
"z".to_string(),
593+
Box::new(Expression::CInt(3)),
594+
)])),
588595
),
589596
],
590597
else_branch: None,
@@ -867,5 +874,3 @@ mod tests {
867874
}
868875
}
869876
}
870-
871-

0 commit comments

Comments
 (0)