From 34fd29ebcac13546c4be6a541063aa591b6f2830 Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 7 Mar 2020 03:12:24 -0800 Subject: [PATCH] Try using error formatting --- schala-lang/language/src/lib.rs | 1 + schala-lang/language/src/parser.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/schala-lang/language/src/lib.rs b/schala-lang/language/src/lib.rs index c4c983f..6d90ceb 100644 --- a/schala-lang/language/src/lib.rs +++ b/schala-lang/language/src/lib.rs @@ -1,3 +1,4 @@ +#![feature(or_patterns)] #![feature(trace_macros)] //#![feature(unrestricted_attribute_tokens)] #![feature(slice_patterns, box_patterns, box_syntax)] diff --git a/schala-lang/language/src/parser.rs b/schala-lang/language/src/parser.rs index 260ac46..3064d11 100644 --- a/schala-lang/language/src/parser.rs +++ b/schala-lang/language/src/parser.rs @@ -215,6 +215,13 @@ fn expression_kind(text: &str) -> ParseResult { } pub fn perform_parsing(input: &str) -> Result { - let output = expression_kind(input); - Ok(format!("{:?}", output)) + let output = match expression_kind(input) { + Ok((rest, ast)) => format!("{:?}", ast), + Err(nom::Err::Incomplete(needed)) => format!("Incomplete: {:?}" ,needed), + Err(nom::Err::Error(verbose_error) | nom::Err::Failure(verbose_error)) => { + nom::error::convert_error(input, verbose_error) + } + }; + + Ok(output) }