-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nulluser0
committed
Jun 17, 2024
1 parent
0338180
commit 63e2b6c
Showing
5 changed files
with
76 additions
and
87 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use thiserror::Error; | ||
|
||
use crate::frontend::{ast::Expr, lexer::Token}; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum ParserError { | ||
#[error("Error at position {position}: {message}. Expected {expected:?}, but found {found:?}")] | ||
UnexpectedToken { | ||
expected: Token, | ||
found: Token, | ||
position: usize, | ||
message: String, | ||
}, | ||
|
||
#[error("Error: `async` must be followed by `fn`")] | ||
MissingAsyncFn, | ||
|
||
#[error("Error at position {0}: `break` found outside of loop context")] | ||
BreakOutsideLoop(usize), | ||
|
||
#[error("Error at position {0}: `return` found outside of function context")] | ||
ReturnOutsideFunction(usize), | ||
|
||
#[error("Error at position {0}: Missing function identifier")] | ||
MissingFunctionIdentifier(usize), | ||
|
||
#[error("Error at position {0}: Invalid function parameter")] | ||
InvalidFunctionParameter(usize), | ||
|
||
#[error("Error at position {0}: Cannot use `mut` with `const`")] | ||
MutConstConflict(usize), | ||
|
||
#[error("Error at position {0}: Missing identifier")] | ||
MissingIdentifier(usize), | ||
|
||
#[error("Error at position {0}: `const` must have an assigned value")] | ||
ConstWithoutValue(usize), | ||
|
||
#[error("Error at position {0}: Object literal key expected")] | ||
ObjectLiteralKeyExpected(usize), | ||
|
||
#[error("Error at position {0}: Invalid operator {1:?}")] | ||
InvalidOperator(usize, Token), | ||
|
||
#[error("Error at position {0}: Invalid property access using dot operator {1:?}")] | ||
InvalidDotProperty(usize, Expr), | ||
// Add other error variants here if needed | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod backend; | ||
pub mod errors; | ||
pub mod frontend; | ||
pub mod utils; |