From: Ben Pfaff Date: Tue, 12 Nov 2024 19:28:16 +0000 (-0800) Subject: work X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8d92b72ebcb1106ab22bdeb887c2fedcf7d741f;p=pspp work --- diff --git a/rust/pspp/src/command.rs b/rust/pspp/src/command.rs index 802641d853..a1e4be5e0a 100644 --- a/rust/pspp/src/command.rs +++ b/rust/pspp/src/command.rs @@ -12,7 +12,7 @@ use crate::{ lexer::{LexToken, TokenSlice}, token::{Punct, Token}, }, - message::Diagnostic, + message::{Diagnostic, Diagnostics}, }; flags! { @@ -108,11 +108,11 @@ struct Subcommand { #[derive(Debug)] enum ParseError { - Error(Diagnostic), - Mismatch(Diagnostic), + Error(Diagnostics), + Mismatch(Diagnostics), } -type ParseResult<'a, T> = Result<(T, TokenSlice<'a>), ParseError>; +type ParseResult<'a, T> = Result<(T, TokenSlice<'a>, Diagnostics), ParseError>; trait MismatchToError { fn mismatch_to_error(self) -> Self; @@ -142,7 +142,7 @@ where Self: Sized, { match T::from_tokens(input) { - Ok((value, rest)) => Ok((Some(value), rest)), + Ok((value, rest, diagnostics)) => Ok((Some(value), rest, diagnostics)), Err(ParseError::Mismatch(_)) => Ok((None, input)), Err(ParseError::Error(error)) => Err(ParseError::Error(error)), } diff --git a/rust/pspp/src/message.rs b/rust/pspp/src/message.rs index aa7aef640a..58e9671a26 100644 --- a/rust/pspp/src/message.rs +++ b/rust/pspp/src/message.rs @@ -164,6 +164,9 @@ pub struct Stack { description: String, } +#[derive(Debug)] +pub struct Diagnostics(Vec); + pub struct Diagnostic { pub severity: Severity, pub category: Category,