aboutsummaryrefslogtreecommitdiffstats
path: root/modelica-parser-lalrpop/src
diff options
context:
space:
mode:
Diffstat (limited to 'modelica-parser-lalrpop/src')
-rw-r--r--modelica-parser-lalrpop/src/lib.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/modelica-parser-lalrpop/src/lib.rs b/modelica-parser-lalrpop/src/lib.rs
index f6f1e8b..a109607 100644
--- a/modelica-parser-lalrpop/src/lib.rs
+++ b/modelica-parser-lalrpop/src/lib.rs
@@ -45,15 +45,23 @@ pub fn pp_parseerror(raw: &str, pe: ParseError<usize, (usize, &str), ()>) -> Str
"parse error:".red().bold(),
pp_segment(raw, location, location+1)) },
ParseError::UnrecognizedToken{token: Some((start, (_, tok), end)), expected} => {
- format!("{} unrecognized token '{}' (expected one of {:?}):\n{}",
+ format!("{} unrecognized token '{}'{}:\n{}",
"parse error:".red().bold(),
tok,
- expected,
+ if expected.len() > 0 {
+ format!(" (expected one of {:?})", expected)
+ } else {
+ format!("")
+ },
pp_segment(raw, start, end)) },
ParseError::UnrecognizedToken{token: None, expected} => {
- format!("{} premature end-of-file (expected one of {:?})",
+ format!("{} premature end-of-file{}",
"parse error:".red().bold(),
- expected) },
+ if expected.len() > 0 {
+ format!(" (expected one of {:?})", expected)
+ } else {
+ format!("")
+ }) },
ParseError::ExtraToken{token: (start, (_, tok), end)} => {
format!("{} unexpected extra token '{}':\n{}",
"parse error:".red().bold(),