aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNic Gaffney <gaffney_nic@protonmail.com>2023-06-28 14:39:51 -0500
committerNic Gaffney <gaffney_nic@protonmail.com>2023-06-28 14:39:51 -0500
commit9993ba916f60ead48df114951c82fb79295abb10 (patch)
tree74922aec9845589a24a77f6755cc5f5a03fb5185
parent309a9f40c37587579614ad7e64637576d9d478dd (diff)
downloadsloth-9993ba916f60ead48df114951c82fb79295abb10.tar.gz
fmt
-rw-r--r--sloth/src/analysis/setup.rs10
-rw-r--r--sloth/src/codegen/mod.rs6
-rw-r--r--sloth/src/parser/ast.rs6
-rw-r--r--sloth/src/parser/graph.rs12
-rw-r--r--sloth/src/parser/mod.rs2
-rw-r--r--sloth/src/parser/stmt.rs1
6 files changed, 27 insertions, 10 deletions
diff --git a/sloth/src/analysis/setup.rs b/sloth/src/analysis/setup.rs
index 1da3df7..62b9e8f 100644
--- a/sloth/src/analysis/setup.rs
+++ b/sloth/src/analysis/setup.rs
@@ -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)?;
}
@@ -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)?;
diff --git a/sloth/src/codegen/mod.rs b/sloth/src/codegen/mod.rs
index 86e1ff0..f484d52 100644
--- a/sloth/src/codegen/mod.rs
+++ b/sloth/src/codegen/mod.rs
@@ -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();
diff --git a/sloth/src/parser/ast.rs b/sloth/src/parser/ast.rs
index a676a9b..089a362 100644
--- a/sloth/src/parser/ast.rs
+++ b/sloth/src/parser/ast.rs
@@ -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());
}
diff --git a/sloth/src/parser/graph.rs b/sloth/src/parser/graph.rs
index 34c759f..dde7481 100644
--- a/sloth/src/parser/graph.rs
+++ b/sloth/src/parser/graph.rs
@@ -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\"];",
@@ -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\"];",
diff --git a/sloth/src/parser/mod.rs b/sloth/src/parser/mod.rs
index 9bf4dd6..09a26fd 100644
--- a/sloth/src/parser/mod.rs
+++ b/sloth/src/parser/mod.rs
@@ -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(),
diff --git a/sloth/src/parser/stmt.rs b/sloth/src/parser/stmt.rs
index 4771abc..c326a0c 100644
--- a/sloth/src/parser/stmt.rs
+++ b/sloth/src/parser/stmt.rs
@@ -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()?;