| 25 | } |
| 26 | |
| 27 | fn report_expected(expected: &[String]) -> Vec<String> { |
| 28 | if expected.is_empty() { |
| 29 | return Vec::new(); |
| 30 | } |
| 31 | use pretty::RcDoc; |
| 32 | let doc: RcDoc<()> = RcDoc::intersperse( |
| 33 | expected.iter().map(RcDoc::text), |
| 34 | RcDoc::text(",").append(RcDoc::softline()), |
| 35 | ); |
| 36 | let header = if expected.len() == 1 { |
| 37 | "Expects" |
| 38 | } else { |
| 39 | "Expects one of" |
| 40 | }; |
| 41 | let doc = RcDoc::text(header).append(RcDoc::softline().append(doc)); |
| 42 | vec![doc.pretty(70).to_string()] |
| 43 | } |
| 44 | |
| 45 | pub fn pretty_parse<T>(name: &str, str: &str) -> Result<T, ParserError> |
| 46 | where |