aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler.rs')
-rw-r--r--src/compiler.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/compiler.rs b/src/compiler.rs
index 70c9a51..9d9deaa 100644
--- a/src/compiler.rs
+++ b/src/compiler.rs
@@ -787,6 +787,27 @@ impl Compiler {
}
}
+ fn blob_statement(&mut self, _block: &mut Block) {
+ expect!(self, Token::Blob, "Expected blob when declaring a blob");
+ let name = if let Token::Identifier(name) = self.eat() {
+ name
+ } else {
+ error!(self, "Expected identifier after 'blob'.");
+ return;
+ };
+
+ expect!(self, Token::LeftBrace, "Expected 'blob' body. AKA '{'.");
+
+ loop {
+ if matches!(self.peek(), Token::EOF | Token::RightBrace) { break; }
+ if matches!(self.peek(), Token::Newline) { self.eat(); continue; }
+ }
+
+ expect!(self, Token::RightBrace, "Expected '}' 'blob' body. AKA '}'.");
+
+ println!("Blob: {}", name);
+ }
+
fn statement(&mut self, block: &mut Block) {
self.clear_panic();
@@ -820,6 +841,10 @@ impl Compiler {
self.assign(&name, block);
}
+ (Token::Blob, Token::Identifier(name), ..) => {
+ self.blob_statement(block);
+ }
+
(Token::If, ..) => {
self.if_statment(block);
}