MCPcopy Create free account
hub / github.com/hashintel/hash / parse_input

Function parse_input

libs/@local/hashql/syntax-jexpr/src/lib.rs:86–98  ·  view source on GitHub ↗

Attempt to parse an input string and return either a successful result or formatted error.

(input: &'static str)

Source from the content-addressed store, hash-verified

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() {

Callers 4

parse_literal_expressionFunction · 0.85
parse_invalid_jsonFunction · 0.85

Calls 6

OkInterface · 0.85
ErrInterface · 0.85
parse_exprMethod · 0.80
syntax_dump_to_stringMethod · 0.80
render_diagnosticFunction · 0.70
as_bytesMethod · 0.45

Tested by 4

parse_literal_expressionFunction · 0.68
parse_invalid_jsonFunction · 0.68