• Home
  • Raw
  • Download

Lines Matching full:input

77 fn skip_whitespace(input: Cursor) -> Cursor {  in skip_whitespace()
78 let mut s = input; in skip_whitespace()
125 fn block_comment(input: Cursor) -> PResult<&str> { in block_comment()
126 if !input.starts_with("/*") { in block_comment()
131 let bytes = input.as_bytes(); in block_comment()
142 return Ok((input.advance(i + 2), &input.rest[..i + 2])); in block_comment()
157 fn word_break(input: Cursor) -> Result<Cursor, Reject> { in word_break()
158 match input.chars().next() { in word_break()
160 Some(_) | None => Ok(input), in word_break()
168 pub(crate) fn token_stream(mut input: Cursor) -> Result<TokenStream, LexError> { in token_stream()
173 input = skip_whitespace(input); in token_stream()
175 if let Ok((rest, ())) = doc_comment(input, &mut trees) { in token_stream()
176 input = rest; in token_stream()
181 let lo = input.off; in token_stream()
183 let first = match input.bytes().next() { in token_stream()
199 b'(' if !input.starts_with(ERROR) => Some(Delimiter::Parenthesis), in token_stream()
204 input = input.advance(1); in token_stream()
218 None => return Err(lex_error(input)), in token_stream()
224 return Err(lex_error(input)); in token_stream()
226 input = input.advance(1); in token_stream()
232 hi: input.off, in token_stream()
237 let (rest, mut tt) = match leaf_token(input) { in token_stream()
239 Err(Reject) => return Err(lex_error(input)), in token_stream()
248 input = rest; in token_stream()
266 fn leaf_token(input: Cursor) -> PResult<TokenTree> { in leaf_token()
267 if let Ok((input, l)) = literal(input) { in leaf_token()
269 Ok((input, TokenTree::Literal(crate::Literal::_new_fallback(l)))) in leaf_token()
270 } else if let Ok((input, p)) = punct(input) { in leaf_token()
271 Ok((input, TokenTree::Punct(p))) in leaf_token()
272 } else if let Ok((input, i)) = ident(input) { in leaf_token()
273 Ok((input, TokenTree::Ident(i))) in leaf_token()
274 } else if input.starts_with(ERROR) { in leaf_token()
275 let rest = input.advance(ERROR.len()); in leaf_token()
283 fn ident(input: Cursor) -> PResult<crate::Ident> { in ident()
288 .any(|prefix| input.starts_with(prefix)) in ident()
292 ident_any(input) in ident()
296 fn ident_any(input: Cursor) -> PResult<crate::Ident> { in ident_any()
297 let raw = input.starts_with("r#"); in ident_any()
298 let rest = input.advance((raw as usize) << 1); in ident_any()
322 fn ident_not_raw(input: Cursor) -> PResult<&str> { in ident_not_raw()
323 let mut chars = input.char_indices(); in ident_not_raw()
330 let mut end = input.len(); in ident_not_raw()
338 Ok((input.advance(end), &input.rest[..end])) in ident_not_raw()
341 pub(crate) fn literal(input: Cursor) -> PResult<Literal> { in literal()
342 let rest = literal_nocapture(input)?; in literal()
343 let end = input.len() - rest.len(); in literal()
344 Ok((rest, Literal::_new(input.rest[..end].to_string()))) in literal()
347 fn literal_nocapture(input: Cursor) -> Result<Cursor, Reject> { in literal_nocapture()
348 if let Ok(ok) = string(input) { in literal_nocapture()
350 } else if let Ok(ok) = byte_string(input) { in literal_nocapture()
352 } else if let Ok(ok) = c_string(input) { in literal_nocapture()
354 } else if let Ok(ok) = byte(input) { in literal_nocapture()
356 } else if let Ok(ok) = character(input) { in literal_nocapture()
358 } else if let Ok(ok) = float(input) { in literal_nocapture()
360 } else if let Ok(ok) = int(input) { in literal_nocapture()
367 fn literal_suffix(input: Cursor) -> Cursor { in literal_suffix()
368 match ident_not_raw(input) { in literal_suffix()
369 Ok((input, _)) => input, in literal_suffix()
370 Err(Reject) => input, in literal_suffix()
374 fn string(input: Cursor) -> Result<Cursor, Reject> { in string()
375 if let Ok(input) = input.parse("\"") { in string()
376 cooked_string(input) in string()
377 } else if let Ok(input) = input.parse("r") { in string()
378 raw_string(input) in string()
384 fn cooked_string(mut input: Cursor) -> Result<Cursor, Reject> { in cooked_string()
385 let mut chars = input.char_indices(); in cooked_string()
390 let input = input.advance(i + 1); in cooked_string() localVariable
391 return Ok(literal_suffix(input)); in cooked_string()
406 input = input.advance(newline + 1); in cooked_string()
407 trailing_backslash(&mut input, ch as u8)?; in cooked_string()
408 chars = input.char_indices(); in cooked_string()
418 fn raw_string(input: Cursor) -> Result<Cursor, Reject> { in raw_string()
419 let (input, delimiter) = delimiter_of_raw_string(input)?; in raw_string()
420 let mut bytes = input.bytes().enumerate(); in raw_string()
423 b'"' if input.rest[i + 1..].starts_with(delimiter) => { in raw_string()
424 let rest = input.advance(i + 1 + delimiter.len()); in raw_string()
437 fn byte_string(input: Cursor) -> Result<Cursor, Reject> { in byte_string()
438 if let Ok(input) = input.parse("b\"") { in byte_string()
439 cooked_byte_string(input) in byte_string()
440 } else if let Ok(input) = input.parse("br") { in byte_string()
441 raw_byte_string(input) in byte_string()
447 fn cooked_byte_string(mut input: Cursor) -> Result<Cursor, Reject> { in cooked_byte_string()
448 let mut bytes = input.bytes().enumerate(); in cooked_byte_string()
452 let input = input.advance(offset + 1); in cooked_byte_string() localVariable
453 return Ok(literal_suffix(input)); in cooked_byte_string()
465 input = input.advance(newline + 1); in cooked_byte_string()
466 trailing_backslash(&mut input, b)?; in cooked_byte_string()
467 bytes = input.bytes().enumerate(); in cooked_byte_string()
478 fn delimiter_of_raw_string(input: Cursor) -> PResult<&str> { in delimiter_of_raw_string()
479 for (i, byte) in input.bytes().enumerate() { in delimiter_of_raw_string()
486 return Ok((input.advance(i + 1), &input.rest[..i])); in delimiter_of_raw_string()
495 fn raw_byte_string(input: Cursor) -> Result<Cursor, Reject> { in raw_byte_string()
496 let (input, delimiter) = delimiter_of_raw_string(input)?; in raw_byte_string()
497 let mut bytes = input.bytes().enumerate(); in raw_byte_string()
500 b'"' if input.rest[i + 1..].starts_with(delimiter) => { in raw_byte_string()
501 let rest = input.advance(i + 1 + delimiter.len()); in raw_byte_string()
518 fn c_string(input: Cursor) -> Result<Cursor, Reject> { in c_string()
519 if let Ok(input) = input.parse("c\"") { in c_string()
520 cooked_c_string(input) in c_string()
521 } else if let Ok(input) = input.parse("cr") { in c_string()
522 raw_c_string(input) in c_string()
528 fn raw_c_string(input: Cursor) -> Result<Cursor, Reject> { in raw_c_string()
529 let (input, delimiter) = delimiter_of_raw_string(input)?; in raw_c_string()
530 let mut bytes = input.bytes().enumerate(); in raw_c_string()
533 b'"' if input.rest[i + 1..].starts_with(delimiter) => { in raw_c_string()
534 let rest = input.advance(i + 1 + delimiter.len()); in raw_c_string()
548 fn cooked_c_string(mut input: Cursor) -> Result<Cursor, Reject> { in cooked_c_string()
549 let mut chars = input.char_indices(); in cooked_c_string()
554 let input = input.advance(i + 1); in cooked_c_string() localVariable
555 return Ok(literal_suffix(input)); in cooked_c_string()
572 input = input.advance(newline + 1); in cooked_c_string()
573 trailing_backslash(&mut input, ch as u8)?; in cooked_c_string()
574 chars = input.char_indices(); in cooked_c_string()
585 fn byte(input: Cursor) -> Result<Cursor, Reject> { in byte()
586 let input = input.parse("b'")?; in byte() localVariable
587 let mut bytes = input.bytes().enumerate(); in byte()
600 if !input.chars().as_str().is_char_boundary(offset) { in byte()
603 let input = input.advance(offset).parse("'")?; in byte() localVariable
604 Ok(literal_suffix(input)) in byte()
607 fn character(input: Cursor) -> Result<Cursor, Reject> { in character()
608 let input = input.parse("'")?; in character() localVariable
609 let mut chars = input.char_indices(); in character()
623 let input = input.advance(idx).parse("'")?; in character() localVariable
624 Ok(literal_suffix(input)) in character()
696 fn trailing_backslash(input: &mut Cursor, mut last: u8) -> Result<(), Reject> { in trailing_backslash()
697 let mut whitespace = input.bytes().enumerate(); in trailing_backslash()
707 *input = input.advance(offset); in trailing_backslash()
715 fn float(input: Cursor) -> Result<Cursor, Reject> { in float()
716 let mut rest = float_digits(input)?; in float()
725 fn float_digits(input: Cursor) -> Result<Cursor, Reject> { in float_digits()
726 let mut chars = input.chars().peekable(); in float_digits()
771 Ok(input.advance(len - 1)) in float_digits()
807 Ok(input.advance(len)) in float_digits()
810 fn int(input: Cursor) -> Result<Cursor, Reject> { in int()
811 let mut rest = digits(input)?; in int()
820 fn digits(mut input: Cursor) -> Result<Cursor, Reject> { in digits()
821 let base = if input.starts_with("0x") { in digits()
822 input = input.advance(2); in digits()
824 } else if input.starts_with("0o") { in digits()
825 input = input.advance(2); in digits()
827 } else if input.starts_with("0b") { in digits()
828 input = input.advance(2); in digits()
836 for b in input.bytes() { in digits()
871 Ok(input.advance(len)) in digits()
875 fn punct(input: Cursor) -> PResult<Punct> { in punct()
876 let (rest, ch) = punct_char(input)?; in punct()
892 fn punct_char(input: Cursor) -> PResult<char> { in punct_char()
893 if input.starts_with("//") || input.starts_with("/*") { in punct_char()
898 let mut chars = input.chars(); in punct_char()
907 Ok((input.advance(first.len_utf8()), first)) in punct_char()
913 fn doc_comment<'a>(input: Cursor<'a>, trees: &mut TokenStreamBuilder) -> PResult<'a, ()> { in doc_comment()
915 let lo = input.off; in doc_comment()
916 let (rest, (comment, inner)) = doc_comment_contents(input)?; in doc_comment()
961 fn doc_comment_contents(input: Cursor) -> PResult<(&str, bool)> { in doc_comment_contents()
962 if input.starts_with("//!") { in doc_comment_contents()
963 let input = input.advance(3); in doc_comment_contents() localVariable
964 let (input, s) = take_until_newline_or_eof(input); in doc_comment_contents()
965 Ok((input, (s, true))) in doc_comment_contents()
966 } else if input.starts_with("/*!") { in doc_comment_contents()
967 let (input, s) = block_comment(input)?; in doc_comment_contents()
968 Ok((input, (&s[3..s.len() - 2], true))) in doc_comment_contents()
969 } else if input.starts_with("///") { in doc_comment_contents()
970 let input = input.advance(3); in doc_comment_contents() localVariable
971 if input.starts_with_char('/') { in doc_comment_contents()
974 let (input, s) = take_until_newline_or_eof(input); in doc_comment_contents()
975 Ok((input, (s, false))) in doc_comment_contents()
976 } else if input.starts_with("/**") && !input.rest[3..].starts_with('*') { in doc_comment_contents()
977 let (input, s) = block_comment(input)?; in doc_comment_contents()
978 Ok((input, (&s[3..s.len() - 2], false))) in doc_comment_contents()
984 fn take_until_newline_or_eof(input: Cursor) -> (Cursor, &str) { in take_until_newline_or_eof()
985 let chars = input.char_indices(); in take_until_newline_or_eof()
989 return (input.advance(i), &input.rest[..i]); in take_until_newline_or_eof()
990 } else if ch == '\r' && input.rest[i + 1..].starts_with('\n') { in take_until_newline_or_eof()
991 return (input.advance(i + 1), &input.rest[..i]); in take_until_newline_or_eof()
995 (input.advance(input.len()), input.rest) in take_until_newline_or_eof()