Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
nic-gaffney committed Jun 28, 2023
1 parent 309a9f4 commit 9993ba9
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
10 changes: 6 additions & 4 deletions sloth/src/analysis/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ pub(super) fn propagate_types_stmt(node: &mut Stmt) -> Result<(), AnalysisError>
propagate_types(condition)?;
propagate_types_stmt(body)?;
}
StmtKind::ForStmt { iterator, identifier, body } => {
StmtKind::ForStmt {
iterator,
identifier,
body,
} => {
propagate_types(iterator)?;
propagate_types_stmt(body)?;
}
Expand Down Expand Up @@ -194,9 +198,7 @@ pub(super) fn propagate_types(node: &mut Expr) -> Result<(), AnalysisError> {
AnalysisError::UnknownIdentifier(node.line, identifier.to_owned()),
)?
}
ExprKind::Iterator() => {

}
ExprKind::Iterator() => {}
ExprKind::BinaryOp { lhs, rhs, op } => {
// Propagating the types to the children
propagate_types(lhs)?;
Expand Down
6 changes: 5 additions & 1 deletion sloth/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ impl<'ctx> Codegen<'ctx> {
// Position the builder at the end of the loop
self.builder.position_at_end(after_bb);
}
StmtKind::ForStmt { iterator, identifier, body } => {
StmtKind::ForStmt {
iterator,
identifier,
body,
} => {
// Get the current function
let func = self.current_func.unwrap();

Expand Down
6 changes: 5 additions & 1 deletion sloth/src/parser/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ impl Stmt {
children.push(condition.as_node());
children.push(body.as_node());
}
StmtKind::ForStmt { iterator, identifier, body} => {
StmtKind::ForStmt {
iterator,
identifier,
body,
} => {
children.push(iterator.as_node());
children.push(body.as_node());
}
Expand Down
12 changes: 10 additions & 2 deletions sloth/src/parser/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ impl GraphBuilder {
self.traverse_expr0(condition)?;
self.traverse_stmt0(body)?;
}
StmtKind::ForStmt { iterator, identifier, body } => {
StmtKind::ForStmt {
iterator,
identifier,
body,
} => {
writeln!(
&mut self.graph,
"N{} [shape=box label=\"ForStmt\"];",
Expand Down Expand Up @@ -249,7 +253,11 @@ impl GraphBuilder {
self.traverse_expr(condition)?;
self.traverse_stmt(body)?;
}
StmtKind::ForStmt { iterator, identifier, body } => {
StmtKind::ForStmt {
iterator,
identifier,
body,
} => {
writeln!(
&mut self.graph,
"N{} -> N{} [label = \"Iterator\"];",
Expand Down
2 changes: 1 addition & 1 deletion sloth/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<'a> AstParser<'a> {
let mut statements = Vec::new();
while !parser.eof() {
statements.push(parser.statement()?);
}
}

let root = Stmt::new(
parser.reserve_id(),
Expand Down
1 change: 0 additions & 1 deletion sloth/src/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ impl<'a> AstParser<'a> {
// Consume the for token
self.consume(TokenType::For, "Expected for")?;


let identifier = self.consume_identifier()?;
self.consume(TokenType::In, "Expected in")?;
let iterator = self.expression()?;
Expand Down

0 comments on commit 9993ba9

Please sign in to comment.