From b8d92b72ebcb1106ab22bdeb887c2fedcf7d741f Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 12 Nov 2024 11:28:16 -0800 Subject: [PATCH] work --- rust/pspp/src/command.rs | 10 +++++----- rust/pspp/src/message.rs | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) 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, -- 2.30.2