aboutsummaryrefslogtreecommitdiff
path: root/sloth/src/parser
diff options
context:
space:
mode:
Diffstat (limited to 'sloth/src/parser')
-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
4 files changed, 16 insertions, 5 deletions
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()?;