Try using error formatting
This commit is contained in:
parent
b1ffcd709b
commit
34fd29ebca
@ -1,3 +1,4 @@
|
||||
#![feature(or_patterns)]
|
||||
#![feature(trace_macros)]
|
||||
//#![feature(unrestricted_attribute_tokens)]
|
||||
#![feature(slice_patterns, box_patterns, box_syntax)]
|
||||
|
@ -215,6 +215,13 @@ fn expression_kind(text: &str) -> ParseResult<ExpressionKind> {
|
||||
}
|
||||
|
||||
pub fn perform_parsing(input: &str) -> Result<String, String> {
|
||||
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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user