From d7b8ba8a97ab676e475a18b2bae67e193c5c96ae Mon Sep 17 00:00:00 2001 From: Jake Date: Tue, 24 Sep 2024 13:56:05 -0700 Subject: [PATCH] Add stack and vars keywords --- src/lexer.rs | 5 +++++ src/parse.rs | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/lexer.rs b/src/lexer.rs index 127d96c..cc243c4 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -101,6 +101,9 @@ pub enum TokenType { SingleQuote, DoubleQuote, + StackKeyword, + VarsKeyword, + TypeNumberKeyword, // "int" TypeIntKeyword, @@ -137,6 +140,8 @@ fn is_type(maybe_type: &str) -> TokenType { "fn" => TokenType::Function, "true" => TokenType::BoolLiteral, "false" => TokenType::BoolLiteral, + "vars" => TokenType::VarsKeyword, + "stack" => TokenType::StackKeyword, // Other types // "literal" | "type" | "option" | "string" => true, diff --git a/src/parse.rs b/src/parse.rs index 46f0e38..499c6ae 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -330,6 +330,18 @@ impl Parser for ParserState { } } + TokenType::StackKeyword => { + for var in &self.stack { + println!("{:?}", var); + } + } + + TokenType::VarsKeyword => { + for var in &self.local_memory { + println!("{:?}", var); + } + } + TokenType::Identifier => { let var = self.local_memory.get(&token.value); let func = self.function_memory.get(&token.value);