Attempt to parse an input string and return either a successful result or formatted error.
(input: &'static str)
| 84 | |
| 85 | /// Attempt to parse an input string and return either a successful result or formatted error. |
| 86 | fn parse_input(input: &'static str) -> Result<ParseTestResult, String> { |
| 87 | let heap = Heap::new(); |
| 88 | let mut spans = SpanTable::new(SourceId::new_unchecked(0x00)); |
| 89 | let mut parser = Parser::new(&heap, &mut spans); |
| 90 | |
| 91 | match parser.parse_expr(input.as_bytes()) { |
| 92 | Ok(expr) => Ok(ParseTestResult { |
| 93 | dump: expr.syntax_dump_to_string(), |
| 94 | input, |
| 95 | }), |
| 96 | Err(diagnostic) => Err(render_diagnostic(input, &diagnostic, &spans)), |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | #[test] |
| 101 | fn parse_literal_expression() { |