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

Function parse_expr

libs/@local/hashql/syntax-jexpr/src/parser/string/expr.rs:182–205  ·  view source on GitHub ↗

super limited set of expressions that are supported in strings for convenience

(
    input: &mut Input<'heap, 'span, 'source>,
)

Source from the content-addressed store, hash-verified

180
181// super limited set of expressions that are supported in strings for convenience
182pub(crate) fn parse_expr<'heap, 'span, 'source, E>(
183 input: &mut Input<'heap, 'span, 'source>,
184) -> ModalResult<Expr<'heap>, E>
185where
186 E: ParserError<Input<'heap, 'span, 'source>>
187 + FromExternalError<Input<'heap, 'span, 'source>, ParseIntError>
188 + AddContext<Input<'heap, 'span, 'source>, StrContext>,
189{
190 let alt = alt((
191 terminated('_', ws(eof)).span().map(Alt2::Left),
192 parse_expr_path.map(Alt2::Right),
193 ))
194 .context(StrContext::Label("expression"))
195 .parse_next(input)?;
196
197 match alt {
198 Alt2::Left(span) => Ok(Expr {
199 id: NodeId::PLACEHOLDER,
200 span: input.state.span(span),
201 kind: ExprKind::Underscore,
202 }),
203 Alt2::Right(right) => Ok(right),
204 }
205}
206
207#[cfg(test)]
208mod tests {

Callers 7

parse_labelled_argumentFunction · 0.50
parse_arrayFunction · 0.50
parse_dict_objectFunction · 0.50
parse_dict_arrayFunction · 0.50
parse_structFunction · 0.50
parse_tupleFunction · 0.50
parse_listFunction · 0.50

Calls 6

wsFunction · 0.85
OkInterface · 0.85
LabelClass · 0.50
contextMethod · 0.45
mapMethod · 0.45
spanMethod · 0.45

Tested by

no test coverage detected