Hook up parser

This commit is contained in:
Joscha 2021-11-07 22:39:50 +00:00
parent 3efb1a26e0
commit 09f83930b4
4 changed files with 120 additions and 21 deletions

View file

@ -1,11 +1,23 @@
use std::cmp::min;
use std::process::Command;
use codespan_reporting::diagnostic::{Diagnostic, Label};
use crate::source::{SourceFile, SourceSpan};
// TODO Add warnings for things like trailing whitespace
#[derive(Debug)]
pub struct ParseError(SourceSpan, String);
impl From<&ParseError> for Diagnostic<usize> {
fn from(e: &ParseError) -> Self {
Self::error()
.with_message(&e.1)
.with_labels(vec![Label::primary(e.0.file_id(), e.0.range())])
}
}
type ParseResult<T> = Result<T, ParseError>;
#[derive(Debug)]
@ -102,6 +114,7 @@ impl<'a> Parser<'a> {
}
fn parse_command(&mut self) -> ParseResult<Command> {
self.critical(self.offset, "idk, ded")?;
todo!()
}
}