(input: ParseStream)
| 190 | ]; |
| 191 | |
| 192 | pub(crate) fn scan_expr(input: ParseStream) -> Result<()> { |
| 193 | let mut state = INIT.as_slice(); |
| 194 | let mut depth = 0usize; |
| 195 | 'table: loop { |
| 196 | for rule in state { |
| 197 | if match rule.0 { |
| 198 | Input::Keyword(expected) => input.step(|cursor| match cursor.ident() { |
| 199 | Some((ident, rest)) if ident == expected => Ok((true, rest)), |
| 200 | _ => Ok((false, *cursor)), |
| 201 | })?, |
| 202 | Input::Punct(expected) => input.step(|cursor| { |
| 203 | let begin = *cursor; |
| 204 | let mut cursor = begin; |
| 205 | for (i, ch) in expected.chars().enumerate() { |
| 206 | match cursor.punct() { |
| 207 | Some((punct, _)) if punct.as_char() != ch => break, |
| 208 | Some((_, rest)) if i == expected.len() - 1 => { |
| 209 | return Ok((true, rest)); |
| 210 | } |
| 211 | Some((punct, rest)) if punct.spacing() == Spacing::Joint => { |
| 212 | cursor = rest; |
| 213 | } |
| 214 | _ => break, |
| 215 | } |
| 216 | } |
| 217 | Ok((false, begin)) |
| 218 | })?, |
| 219 | Input::ConsumeAny => input.parse::<Option<TokenTree>>()?.is_some(), |
| 220 | Input::ConsumeBinOp => input.parse::<BinOp>().is_ok(), |
| 221 | Input::ConsumeBrace | Input::ConsumeNestedBrace => { |
| 222 | (matches!(rule.0, Input::ConsumeBrace) || depth > 0) |
| 223 | && input.step(|cursor| match cursor.group(Delimiter::Brace) { |
| 224 | Some((_inside, _span, rest)) => Ok((true, rest)), |
| 225 | None => Ok((false, *cursor)), |
| 226 | })? |
| 227 | } |
| 228 | Input::ConsumeDelimiter => input.step(|cursor| match cursor.any_group() { |
| 229 | Some((_inside, _delimiter, _span, rest)) => Ok((true, rest)), |
| 230 | None => Ok((false, *cursor)), |
| 231 | })?, |
| 232 | Input::ConsumeIdent => input.parse::<Option<Ident>>()?.is_some(), |
| 233 | Input::ConsumeLifetime => input.parse::<Option<Lifetime>>()?.is_some(), |
| 234 | Input::ConsumeLiteral => input.parse::<Option<Lit>>()?.is_some(), |
| 235 | Input::ExpectPath => { |
| 236 | input.parse::<ExprPath>()?; |
| 237 | true |
| 238 | } |
| 239 | Input::ExpectTurbofish => { |
| 240 | if input.peek(Token![::]) { |
| 241 | input.parse::<AngleBracketedGenericArguments>()?; |
| 242 | } |
| 243 | true |
| 244 | } |
| 245 | Input::ExpectType => { |
| 246 | Type::without_plus(input)?; |
| 247 | true |
| 248 | } |
| 249 | Input::CanBeginExpr => Expr::peek(input), |
no outgoing calls
no test coverage detected