rename crates/ to engrams/; add el-compiler el package with bootstrap artifact
- crates/ → engrams/ (Rust engrams live here)
- el-compiler/ added: el self-hosting compiler as an el package
- src/{compiler,lexer,parser,codegen}.el
- bootstrap/el-compiler.elc (114KB, Rust-compiled seed)
- el.toml Cargo.toml workspace paths updated
- neuron-rs cross-repo path deps fixed (were pointing to products/ instead of foundation/)
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
//! Parser error types.
|
||||
|
||||
use thiserror::Error;
|
||||
use el_lexer::{Span, Token};
|
||||
|
||||
#[derive(Debug, Clone, Error)]
|
||||
#[error("{kind} at {span}")]
|
||||
pub struct ParseError {
|
||||
pub kind: ParseErrorKind,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl ParseError {
|
||||
pub fn new(kind: ParseErrorKind, span: Span) -> Self {
|
||||
Self { kind, span }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Error)]
|
||||
pub enum ParseErrorKind {
|
||||
#[error("unexpected token {got}, expected {expected}")]
|
||||
UnexpectedToken { expected: String, got: String },
|
||||
|
||||
#[error("unexpected end of file")]
|
||||
UnexpectedEof,
|
||||
|
||||
#[error("invalid expression starting with {0}")]
|
||||
InvalidExprStart(String),
|
||||
|
||||
#[error("invalid type expression: {0}")]
|
||||
InvalidTypeExpr(String),
|
||||
|
||||
#[error("invalid pattern: {0}")]
|
||||
InvalidPattern(String),
|
||||
|
||||
#[error("expected identifier, got {0}")]
|
||||
ExpectedIdent(String),
|
||||
}
|
||||
|
||||
impl ParseError {
|
||||
pub fn expected(expected: impl Into<String>, got: &Token, span: Span) -> Self {
|
||||
Self::new(
|
||||
ParseErrorKind::UnexpectedToken {
|
||||
expected: expected.into(),
|
||||
got: got.to_string(),
|
||||
},
|
||||
span,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn eof(span: Span) -> Self {
|
||||
Self::new(ParseErrorKind::UnexpectedEof, span)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user