Start working on importing

This commit is contained in:
0x4261756D 2023-01-23 03:58:53 +01:00
parent 4064309b26
commit 4286fb4424
1 changed files with 7 additions and 2 deletions

View File

@ -16,6 +16,7 @@ enum Token
BoolLit(String, i32, i32),
Keyword(String, i32, i32),
Apply(String, String, i32, i32),
Import(i32, i32),
}
enum TokenizerState
@ -1448,7 +1449,7 @@ fn extract_functions(tokens: &mut Vec<Token>, intrinsics: &HashMap<&str, (Vec<Da
{
match token
{
Token::IntLit(_, line, col) | Token::StringLit(_, line, col) | Token::BoolLit(_, line, col) |
Token::IntLit(_, line, col) | Token::StringLit(_, line, col) | Token::BoolLit(_, line, col) | Token::Import(line, col) |
Token::Apply(_, _, line, col) =>
{
return Err(format!("Expected input parameters for a function but got {:?} instead at {}:{}", token, line, col));
@ -1487,7 +1488,7 @@ fn extract_functions(tokens: &mut Vec<Token>, intrinsics: &HashMap<&str, (Vec<Da
{
match token
{
Token::IntLit(_, line, col) | Token::StringLit(_, line, col) | Token::BoolLit(_, line, col) |
Token::IntLit(_, line, col) | Token::StringLit(_, line, col) | Token::BoolLit(_, line, col) | Token::Import(line, col) |
Token::Apply(_, _, line, col) =>
{
return Err(format!("Expected input parameters for a function but got {:?} instead at {}:{}", token, line, col));
@ -1586,6 +1587,10 @@ fn parse_until_delimiter(tokens_iter: &mut Peekable<std::slice::Iter<Token>>, in
{
operations.push(Operation::Apply(sanitize_name(name.clone()), word.clone(), *line, *col));
}
Token::Import(line, col) =>
{
todo!()
}
Token::Keyword(word, line, col) =>
{
if intrinsics.contains_key(word.as_str())