Initialize Aster project with basic structure, including Cargo configuration, lexer, parser, interpreter, and AST definitions. Add a sample script and README documentation. Implement basic error handling and environment management for variable storage.

This commit is contained in:
0264408
2026-02-04 16:42:51 +08:00
commit f86300f3ce
19 changed files with 1484 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
use crate::lexer::Token;
#[derive(Debug)]
pub enum RuntimeError {
ParseError { message: String, token: Token },
RuntimeError { message: String, token: Option<Token> },
}
impl std::fmt::Display for RuntimeError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
RuntimeError::ParseError { message, token } => {
write!(f, "[Parse Error] {} at line {}, column {}", message, token.line, token.column)
}
RuntimeError::RuntimeError { message, token } => {
if let Some(tok) = token {
write!(f, "[Runtime Error] {} at line {}, column {}", message, tok.line, tok.column)
} else {
write!(f, "[Runtime Error] {}", message)
}
}
}
}
}
impl std::error::Error for RuntimeError {}
+3
View File
@@ -0,0 +1,3 @@
pub mod error;
pub use error::*;