aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornic-gaffney <gaffney_nic@protonmail.com>2023-04-13 23:47:25 -0500
committernic-gaffney <gaffney_nic@protonmail.com>2023-04-13 23:47:25 -0500
commita97d9f4a7f8c1e8c1e9d2921b40b34aad3643481 (patch)
tree032725940ffbd28907abee8b6b1099b5590fe520
parent8d548081d53781bd918dccf0714200f0fc995d8b (diff)
downloadsloth-a97d9f4a7f8c1e8c1e9d2921b40b34aad3643481.tar.gz
Fixed for loops
-rw-r--r--crates/sloth/src/lexer.rs6
-rw-r--r--crates/sloth/src/parser/ast.rs4
-rw-r--r--crates/sloth/src/parser/expr.rs2
-rw-r--r--crates/sloth/src/parser/stmt.rs3
-rw-r--r--examples/hello.sloth2
5 files changed, 10 insertions, 7 deletions
diff --git a/crates/sloth/src/lexer.rs b/crates/sloth/src/lexer.rs
index cc17b3d..0afaf1c 100644
--- a/crates/sloth/src/lexer.rs
+++ b/crates/sloth/src/lexer.rs
@@ -293,12 +293,14 @@ impl<'a> Iterator for Lexer<'a> {
let tt = match self.window {
['#', '#', ..] => {
self.advance_while(|it| it[0] != '\n');
- TokenType::DocComment
+ // TODO: TokenType::DocComment
+ return self.next();
}
['#', ..] => {
self.advance_while(|it| it[0] != '\n');
- TokenType::Comment
+ // TODO: okenType::Comment
+ return self.next();
}
// Blocks
diff --git a/crates/sloth/src/parser/ast.rs b/crates/sloth/src/parser/ast.rs
index 99bbf52..3c8cdeb 100644
--- a/crates/sloth/src/parser/ast.rs
+++ b/crates/sloth/src/parser/ast.rs
@@ -39,7 +39,7 @@ pub enum Literal {
Char(char),
String(String),
Regex(String),
- List(Vec<Expr>), // TODO: holy shit we forgor listys
+ List(Vec<Expr>),
}
#[derive(Debug, PartialEq)]
pub enum Expr {
@@ -59,7 +59,7 @@ pub enum Expr {
},
Variable(String),
Literal(Literal),
- Lambda, // TODO: Lambda bitch
+ Lambda, // TODO: Lambda
}
#[derive(PartialEq, Debug)]
pub struct FuncArgs {
diff --git a/crates/sloth/src/parser/expr.rs b/crates/sloth/src/parser/expr.rs
index 0cc3a93..ad35d20 100644
--- a/crates/sloth/src/parser/expr.rs
+++ b/crates/sloth/src/parser/expr.rs
@@ -134,7 +134,7 @@ macro_rules! binary_expr {
TokenType::BangEq => BinaryOp::NotEq,
TokenType::AmpAmp => BinaryOp::LogAnd,
TokenType::PipePipe => BinaryOp::LogOr,
- _ => panic!("uh oh spagghetio"), // TODO: Idk how to not have this shit
+ _ => panic!("uh oh spagghetio"),
};
let rhs = self.$parent();
diff --git a/crates/sloth/src/parser/stmt.rs b/crates/sloth/src/parser/stmt.rs
index 0d28131..2c48da8 100644
--- a/crates/sloth/src/parser/stmt.rs
+++ b/crates/sloth/src/parser/stmt.rs
@@ -51,7 +51,7 @@ impl<'a> AstParser<'a> {
fn mut_statement(&mut self) -> Stmt {
let TokenType::Identifier(ident) = self.peek().tt.clone() else {
- panic!("uh oh {:?}", self.peek());
+ panic!("Identifier error {:?}", self.peek());
};
self.advance();
@@ -195,6 +195,7 @@ impl<'a> AstParser<'a> {
while !self.eof() && self.peek().tt != TokenType::ClosingBrace {
body.push(self.statement());
}
+ self.advance();
Stmt::For {
name: (binding),
diff --git a/examples/hello.sloth b/examples/hello.sloth
index 3dbc685..8201dae 100644
--- a/examples/hello.sloth
+++ b/examples/hello.sloth
@@ -1,6 +1,6 @@
print("Hello World!");
-## A basic for loop greeting the user in multiple languages
+# Comment
for greeting in ["Hello", "Hola", "你好"] {
print(greeting + " World!");
}