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:
@@ -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 {}
|
||||
@@ -0,0 +1,3 @@
|
||||
pub mod error;
|
||||
|
||||
pub use error::*;
|
||||
Reference in New Issue
Block a user