Implement core lexer and parser

This commit is contained in:
2026-06-16 02:02:17 +09:00
parent 12a6e9a84c
commit ddcee75c8d
7 changed files with 1083 additions and 1 deletions
+41
View File
@@ -0,0 +1,41 @@
use alloc::string::String;
use crate::span::Span;
pub type Result<T> = core::result::Result<T, Diagnostic>;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Diagnostic {
pub kind: DiagnosticKind,
pub span: Span,
pub message: String,
}
impl Diagnostic {
pub fn new(kind: DiagnosticKind, span: Span, message: impl Into<String>) -> Self {
Self {
kind,
span,
message: message.into(),
}
}
pub fn syntax(span: Span, message: impl Into<String>) -> Self {
Self::new(DiagnosticKind::Syntax, span, message)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DiagnosticKind {
Syntax,
UnresolvedIdentifier,
TypeMismatch,
ConstraintViolation,
Conflict,
DefaultConflict,
Cycle,
Import,
MatchFailure,
Materialize,
UnsupportedFeature,
}