super limited set of expressions that are supported in strings for convenience
(
input: &mut Input<'heap, 'span, 'source>,
)
| 180 | |
| 181 | // super limited set of expressions that are supported in strings for convenience |
| 182 | pub(crate) fn parse_expr<'heap, 'span, 'source, E>( |
| 183 | input: &mut Input<'heap, 'span, 'source>, |
| 184 | ) -> ModalResult<Expr<'heap>, E> |
| 185 | where |
| 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)] |
| 208 | mod tests { |
no test coverage detected