We have blocks & scopes

This commit is contained in:
2026-07-08 05:22:32 -05:00
parent 4aa9341bf3
commit 3c7cd3c4c7
5 changed files with 88 additions and 15 deletions
+2
View File
@@ -3,6 +3,7 @@ use super::{ whitespace_chars, Token };
#[derive(Debug)]
pub enum Keyword {
Let,
Fn,
}
macro_rules! match_keyword {
@@ -15,5 +16,6 @@ macro_rules! match_keyword {
pub fn parse_keyword(input: &str) -> Option<(Token, &str)> {
match_keyword!("let", Token::Kw(Keyword::Let), input);
match_keyword!("fn", Token::Kw(Keyword::Fn), input);
None
}
+4
View File
@@ -4,6 +4,8 @@ use super::Token;
pub enum Symbol {
EqualSign,
Semicolon,
OpenBrace,
CloseBrace,
}
pub fn parse_symbol(input: &str) -> Option<(Token, &str)> {
@@ -12,6 +14,8 @@ pub fn parse_symbol(input: &str) -> Option<(Token, &str)> {
match c {
'=' => Some((Token::Sym(Symbol::EqualSign), input)),
';' => Some((Token::Sym(Symbol::Semicolon), input)),
'{' => Some((Token::Sym(Symbol::OpenBrace), input)),
'}' => Some((Token::Sym(Symbol::CloseBrace), input)),
_ => None
}
}