add export keyword

This commit is contained in:
2024-10-19 22:13:41 -04:00
parent 5a8354f1ad
commit 3027ef4820
6 changed files with 103 additions and 55 deletions

View File

@@ -84,6 +84,7 @@ pub enum Op {
Tail,
Init,
Fini,
Export,
}
#[derive(Debug, Clone, PartialEq)]
@@ -128,6 +129,7 @@ impl Token {
"tail" => Ok(Token::Operator(Op::Tail)),
"init" => Ok(Token::Operator(Op::Init)),
"fini" => Ok(Token::Operator(Op::Fini)),
"export" => Ok(Token::Operator(Op::Export)),
// Types
"Any" => Ok(Token::Type(Type::Any)),
@@ -412,4 +414,20 @@ impl<R: BufRead> std::iter::Iterator for Tokenizer<R> {
Err(e) => Some(Err(TokenizeError::IO(e))),
}
}
}
#[cfg(test)]
mod tests {
use std::str::FromStr;
use super::*;
#[test]
fn a() {
let program = ":. map : f .? x [Any] -> [Any]";
let tokens: Vec<Token> = Tokenizer::from_str(program).unwrap().collect::<Result<_, _>>().unwrap();
println!("{tokens:?}");
}
}