Skip to content

Commit

Permalink
Add stack and vars keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeRoggenbuck committed Sep 24, 2024
1 parent e138fff commit d7b8ba8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ pub enum TokenType {
SingleQuote,
DoubleQuote,

StackKeyword,
VarsKeyword,

TypeNumberKeyword,
// "int"
TypeIntKeyword,
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d7b8ba8

Please sign in to comment.