• 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()
318 fn ident_not_raw(input: Cursor) -> PResult<&str> { in ident_not_raw()
319 let mut chars = input.char_indices(); in ident_not_raw()
326 let mut end = input.len(); in ident_not_raw()
334 Ok((input.advance(end), &input.rest[..end])) in ident_not_raw()
337 pub(crate) fn literal(input: Cursor) -> PResult<Literal> { in literal()
338 let rest = literal_nocapture(input)?; in literal()
339 let end = input.len() - rest.len(); in literal()
340 Ok((rest, Literal::_new(input.rest[..end].to_string()))) in literal()
343 fn literal_nocapture(input: Cursor) -> Result<Cursor, Reject> { in literal_nocapture()
344 if let Ok(ok) = string(input) { in literal_nocapture()
346 } else if let Ok(ok) = byte_string(input) { in literal_nocapture()
348 } else if let Ok(ok) = c_string(input) { in literal_nocapture()
350 } else if let Ok(ok) = byte(input) { in literal_nocapture()
352 } else if let Ok(ok) = character(input) { in literal_nocapture()
354 } else if let Ok(ok) = float(input) { in literal_nocapture()
356 } else if let Ok(ok) = int(input) { in literal_nocapture()
363 fn literal_suffix(input: Cursor) -> Cursor { in literal_suffix()
364 match ident_not_raw(input) { in literal_suffix()
365 Ok((input, _)) => input, in literal_suffix()
366 Err(Reject) => input, in literal_suffix()
370 fn string(input: Cursor) -> Result<Cursor, Reject> { in string()
371 if let Ok(input) = input.parse("\"") { in string()
372 cooked_string(input) in string()
373 } else if let Ok(input) = input.parse("r") { in string()
374 raw_string(input) in string()
380 fn cooked_string(mut input: Cursor) -> Result<Cursor, Reject> { in cooked_string()
381 let mut chars = input.char_indices(); in cooked_string()
386 let input = input.advance(i + 1); in cooked_string() localVariable
387 return Ok(literal_suffix(input)); in cooked_string()
402 input = input.advance(newline + 1); in cooked_string()
403 trailing_backslash(&mut input, ch as u8)?; in cooked_string()
404 chars = input.char_indices(); in cooked_string()
414 fn raw_string(input: Cursor) -> Result<Cursor, Reject> { in raw_string()
415 let (input, delimiter) = delimiter_of_raw_string(input)?; in raw_string()
416 let mut bytes = input.bytes().enumerate(); in raw_string()
419 b'"' if input.rest[i + 1..].starts_with(delimiter) => { in raw_string()
420 let rest = input.advance(i + 1 + delimiter.len()); in raw_string()
433 fn byte_string(input: Cursor) -> Result<Cursor, Reject> { in byte_string()
434 if let Ok(input) = input.parse("b\"") { in byte_string()
435 cooked_byte_string(input) in byte_string()
436 } else if let Ok(input) = input.parse("br") { in byte_string()
437 raw_byte_string(input) in byte_string()
443 fn cooked_byte_string(mut input: Cursor) -> Result<Cursor, Reject> { in cooked_byte_string()
444 let mut bytes = input.bytes().enumerate(); in cooked_byte_string()
448 let input = input.advance(offset + 1); in cooked_byte_string() localVariable
449 return Ok(literal_suffix(input)); in cooked_byte_string()
461 input = input.advance(newline + 1); in cooked_byte_string()
462 trailing_backslash(&mut input, b)?; in cooked_byte_string()
463 bytes = input.bytes().enumerate(); in cooked_byte_string()
474 fn delimiter_of_raw_string(input: Cursor) -> PResult<&str> { in delimiter_of_raw_string()
475 for (i, byte) in input.bytes().enumerate() { in delimiter_of_raw_string()
482 return Ok((input.advance(i + 1), &input.rest[..i])); in delimiter_of_raw_string()
491 fn raw_byte_string(input: Cursor) -> Result<Cursor, Reject> { in raw_byte_string()
492 let (input, delimiter) = delimiter_of_raw_string(input)?; in raw_byte_string()
493 let mut bytes = input.bytes().enumerate(); in raw_byte_string()
496 b'"' if input.rest[i + 1..].starts_with(delimiter) => { in raw_byte_string()
497 let rest = input.advance(i + 1 + delimiter.len()); in raw_byte_string()
514 fn c_string(input: Cursor) -> Result<Cursor, Reject> { in c_string()
515 if let Ok(input) = input.parse("c\"") { in c_string()
516 cooked_c_string(input) in c_string()
517 } else if let Ok(input) = input.parse("cr") { in c_string()
518 raw_c_string(input) in c_string()
524 fn raw_c_string(input: Cursor) -> Result<Cursor, Reject> { in raw_c_string()
525 let (input, delimiter) = delimiter_of_raw_string(input)?; in raw_c_string()
526 let mut bytes = input.bytes().enumerate(); in raw_c_string()
529 b'"' if input.rest[i + 1..].starts_with(delimiter) => { in raw_c_string()
530 let rest = input.advance(i + 1 + delimiter.len()); in raw_c_string()
544 fn cooked_c_string(mut input: Cursor) -> Result<Cursor, Reject> { in cooked_c_string()
545 let mut chars = input.char_indices(); in cooked_c_string()
550 let input = input.advance(i + 1); in cooked_c_string() localVariable
551 return Ok(literal_suffix(input)); in cooked_c_string()
568 input = input.advance(newline + 1); in cooked_c_string()
569 trailing_backslash(&mut input, ch as u8)?; in cooked_c_string()
570 chars = input.char_indices(); in cooked_c_string()
581 fn byte(input: Cursor) -> Result<Cursor, Reject> { in byte()
582 let input = input.parse("b'")?; in byte() localVariable
583 let mut bytes = input.bytes().enumerate(); in byte()
596 if !input.chars().as_str().is_char_boundary(offset) { in byte()
599 let input = input.advance(offset).parse("'")?; in byte() localVariable
600 Ok(literal_suffix(input)) in byte()
603 fn character(input: Cursor) -> Result<Cursor, Reject> { in character()
604 let input = input.parse("'")?; in character() localVariable
605 let mut chars = input.char_indices(); in character()
619 let input = input.advance(idx).parse("'")?; in character() localVariable
620 Ok(literal_suffix(input)) in character()
692 fn trailing_backslash(input: &mut Cursor, mut last: u8) -> Result<(), Reject> { in trailing_backslash()
693 let mut whitespace = input.bytes().enumerate(); in trailing_backslash()
703 *input = input.advance(offset); in trailing_backslash()
711 fn float(input: Cursor) -> Result<Cursor, Reject> { in float()
712 let mut rest = float_digits(input)?; in float()
721 fn float_digits(input: Cursor) -> Result<Cursor, Reject> { in float_digits()
722 let mut chars = input.chars().peekable(); in float_digits()
767 Ok(input.advance(len - 1)) in float_digits()
803 Ok(input.advance(len)) in float_digits()
806 fn int(input: Cursor) -> Result<Cursor, Reject> { in int()
807 let mut rest = digits(input)?; in int()
816 fn digits(mut input: Cursor) -> Result<Cursor, Reject> { in digits()
817 let base = if input.starts_with("0x") { in digits()
818 input = input.advance(2); in digits()
820 } else if input.starts_with("0o") { in digits()
821 input = input.advance(2); in digits()
823 } else if input.starts_with("0b") { in digits()
824 input = input.advance(2); in digits()
832 for b in input.bytes() { in digits()
867 Ok(input.advance(len)) in digits()
871 fn punct(input: Cursor) -> PResult<Punct> { in punct()
872 let (rest, ch) = punct_char(input)?; in punct()
888 fn punct_char(input: Cursor) -> PResult<char> { in punct_char()
889 if input.starts_with("//") || input.starts_with("/*") { in punct_char()
894 let mut chars = input.chars(); in punct_char()
903 Ok((input.advance(first.len_utf8()), first)) in punct_char()
909 fn doc_comment<'a>(input: Cursor<'a>, trees: &mut TokenStreamBuilder) -> PResult<'a, ()> { in doc_comment()
911 let lo = input.off; in doc_comment()
912 let (rest, (comment, inner)) = doc_comment_contents(input)?; in doc_comment()
957 fn doc_comment_contents(input: Cursor) -> PResult<(&str, bool)> { in doc_comment_contents()
958 if input.starts_with("//!") { in doc_comment_contents()
959 let input = input.advance(3); in doc_comment_contents() localVariable
960 let (input, s) = take_until_newline_or_eof(input); in doc_comment_contents()
961 Ok((input, (s, true))) in doc_comment_contents()
962 } else if input.starts_with("/*!") { in doc_comment_contents()
963 let (input, s) = block_comment(input)?; in doc_comment_contents()
964 Ok((input, (&s[3..s.len() - 2], true))) in doc_comment_contents()
965 } else if input.starts_with("///") { in doc_comment_contents()
966 let input = input.advance(3); in doc_comment_contents() localVariable
967 if input.starts_with_char('/') { in doc_comment_contents()
970 let (input, s) = take_until_newline_or_eof(input); in doc_comment_contents()
971 Ok((input, (s, false))) in doc_comment_contents()
972 } else if input.starts_with("/**") && !input.rest[3..].starts_with('*') { in doc_comment_contents()
973 let (input, s) = block_comment(input)?; in doc_comment_contents()
974 Ok((input, (&s[3..s.len() - 2], false))) in doc_comment_contents()
980 fn take_until_newline_or_eof(input: Cursor) -> (Cursor, &str) { in take_until_newline_or_eof()
981 let chars = input.char_indices(); in take_until_newline_or_eof()
985 return (input.advance(i), &input.rest[..i]); in take_until_newline_or_eof()
986 } else if ch == '\r' && input.rest[i + 1..].starts_with('\n') { in take_until_newline_or_eof()
987 return (input.advance(i + 1), &input.rest[..i]); in take_until_newline_or_eof()
991 (input.advance(input.len()), input.rest) in take_until_newline_or_eof()