Implement core lexer and parser
This commit is contained in:
@@ -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,
|
||||
}
|
||||
Reference in New Issue
Block a user