moved tokens

This commit is contained in:
Shautvast 2025-11-17 11:07:12 +01:00
parent b5d49ed6eb
commit 719238bd77
14 changed files with 23 additions and 24 deletions

View file

@ -1,8 +1,8 @@
use crate::compiler::ast_pass::Parameter;
use crate::builtins::{FunctionMap, Signature, add, expected};
use crate::errors::RuntimeError;
use crate::tokens::TokenType;
use crate::tokens::TokenType::U64;
use crate::compiler::tokens::TokenType;
use crate::compiler::tokens::TokenType::U64;
use crate::value::{Value, u64};
use std::collections::HashMap;

View file

@ -3,7 +3,7 @@ mod list;
use crate::builtins::string::string_functions;
use crate::errors::{CompilerError, RuntimeError};
use crate::tokens::TokenType;
use crate::compiler::tokens::TokenType;
use crate::value::Value;
use std::collections::HashMap;
use std::sync::LazyLock;

View file

@ -1,6 +1,6 @@
use crate::builtins::{FunctionMap, Parameter, Signature, add, expected};
use crate::errors::RuntimeError;
use crate::tokens::TokenType::{StringType, U64};
use crate::compiler::tokens::TokenType::{StringType, U64};
use crate::value::{Value, bool, string, u64};
use regex::Regex;
use std::collections::HashMap;

View file

@ -1,5 +1,5 @@
use crate::compiler::ast_pass::Parameter;
use crate::tokens::TokenType;
use crate::compiler::tokens::TokenType;
use crate::value::Value;
use crate::vm::{
OP_ADD, OP_BITAND, OP_BITOR, OP_BITXOR, OP_CALL, OP_CONSTANT, OP_DEF_BOOL, OP_DEF_F32,

View file

@ -6,14 +6,14 @@ use crate::errors::CompilerError::{
};
use crate::errors::CompilerErrorAtLine;
use crate::symbol_builder::{Symbol, calculate_type, infer_type};
use crate::tokens::TokenType::{
use crate::compiler::tokens::TokenType::{
Bang, Bool, Char, Colon, DateTime, Dot, Else, Eof, Eol, Equal, False, FloatingPoint, Fn, For,
Greater, GreaterEqual, GreaterGreater, Identifier, If, In, Indent, Integer, LeftBrace,
LeftBracket, LeftParen, Less, LessEqual, LessLess, Let, ListType, MapType, Minus, Object, Plus,
Print, Range, RightBrace, RightBracket, RightParen, SingleRightArrow, Slash, Star, StringType,
True, U32, U64, Unknown,
};
use crate::tokens::{Token, TokenType};
use crate::compiler::tokens::{Token, TokenType};
use crate::value::Value;
use crate::{Expr, Stmt, SymbolTable};
use log::debug;

View file

@ -5,8 +5,8 @@ use crate::chunk::Chunk;
use crate::errors::CompilerError::{IncompatibleTypes, UndeclaredVariable};
use crate::errors::{CompilerError, CompilerErrorAtLine};
use crate::symbol_builder::{Symbol, calculate_type, infer_type};
use crate::tokens::TokenType;
use crate::tokens::TokenType::Unknown;
use crate::compiler::tokens::TokenType;
use crate::compiler::tokens::TokenType::Unknown;
use crate::value::Value;
use crate::vm::{OP_ADD, OP_AND, OP_ASSIGN, OP_BITAND, OP_BITOR, OP_BITXOR, OP_CALL, OP_CALL_BUILTIN, OP_CONSTANT, OP_DEF_LIST, OP_DEF_MAP, OP_DIVIDE, OP_DUP, OP_EQUAL, OP_GET, OP_GOTO, OP_GOTO_IF, OP_GOTO_NIF, OP_GREATER, OP_GREATER_EQUAL, OP_LESS, OP_LESS_EQUAL, OP_LIST_GET, OP_MULTIPLY, OP_NEGATE, OP_NOT, OP_OR, OP_POP, OP_PRINT, OP_RETURN, OP_SHL, OP_SHR, OP_SUBTRACT};
use crate::{Registry, SymbolTable};
@ -182,6 +182,8 @@ impl Compiler {
self.chunk.code[goto_addr2] = self.chunk.code.len() as u16; // fill in the placeholder
self.chunk.code[goto_addr3] = self.chunk.code.len() as u16; // fill in the placeholder
} else {
self.chunk.code[goto_addr1] = self.chunk.code.len() as u16;
}
}
Statement::ForStatement {

View file

@ -2,3 +2,4 @@ mod compiler_tests;
pub mod bytecode_pass;
pub mod scan_pass;
pub mod ast_pass;
pub mod tokens;

View file

@ -1,12 +1,10 @@
use crate::errors::CompilerError::{IllegalCharLength, UnexpectedIdentifier, Unterminated};
use crate::errors::{CompilerError, CompilerErrorAtLine};
use crate::tokens::TokenType::{BitXor, FloatingPoint, Integer, Question, U32, U64};
use crate::{
keywords,
tokens::{
Token,
TokenType::{self},
},
use crate::compiler::tokens::TokenType::{BitXor, FloatingPoint, Integer, Question, U32, U64};
use crate::keywords;
use crate::compiler::tokens::{
Token,
TokenType::{self},
};
pub fn scan(source: &str) -> Result<Vec<Token>, CompilerErrorAtLine> {

View file

@ -1,4 +1,4 @@
use crate::tokens::TokenType;
use crate::compiler::tokens::TokenType;
use std::fmt::Display;
use thiserror::Error;

View file

@ -1,4 +1,4 @@
use crate::tokens::TokenType;
use crate::compiler::tokens::TokenType;
pub(crate) fn get_keyword(lexeme: &str) -> Option<TokenType> {
match lexeme {

View file

@ -3,7 +3,6 @@ use crate::compiler::ast_pass::{Expression, Statement};
use crate::errors::CrudLangError::Platform;
use crate::errors::{CompilerErrorAtLine, CrudLangError};
use crate::symbol_builder::Symbol;
use crate::value::Value::Void;
use std::collections::HashMap;
use std::fs;
use walkdir::WalkDir;
@ -16,7 +15,6 @@ pub mod file_watch;
mod keywords;
pub mod repl;
mod symbol_builder;
mod tokens;
mod value;
pub mod vm;

View file

@ -2,12 +2,12 @@ use crate::compiler::ast_pass::{Expression, Parameter, Statement};
use crate::builtins::lookup;
use crate::errors::CompilerError;
use crate::errors::CompilerError::IncompatibleTypes;
use crate::tokens::TokenType::{
use crate::compiler::tokens::TokenType::{
Bool, DateTime, F32, F64, FloatingPoint, Greater, GreaterEqual, I32, I64, Integer, Less,
LessEqual, ListType, MapType, Minus, ObjectType, Plus, SignedInteger, StringType, U32, U64,
Unknown, UnsignedInteger,
};
use crate::tokens::{Token, TokenType};
use crate::compiler::tokens::{Token, TokenType};
use log::debug;
use std::collections::HashMap;
use std::ops::Deref;

View file

@ -2,7 +2,7 @@ use crate::Registry;
use crate::chunk::Chunk;
use crate::errors::RuntimeError::Something;
use crate::errors::{RuntimeError, ValueError};
use crate::tokens::TokenType;
use crate::compiler::tokens::TokenType;
use crate::value::{Object, Value};
use arc_swap::Guard;
use std::collections::HashMap;