Lines Matching full:literal
8 use proc_macro2::{Ident, Literal, Span};
18 /// A Rust literal such as a string or integer or boolean.
27 /// A UTF-8 string literal: `"foo"`.
30 /// A byte string literal: `b"foo"`.
33 /// A nul-terminated C-string literal: `c"foo"`.
36 /// A byte literal: `b'f'`.
39 /// A character literal: `'a'`.
42 /// An integer literal: `1` or `1u16`.
45 /// A floating point literal: `1f64` or `1.0e10f64`.
50 /// A boolean literal: `true` or `false`.
53 /// A raw token literal not interpreted by Syn.
54 Verbatim(Literal),
59 /// A UTF-8 string literal: `"foo"`.
66 /// A byte string literal: `b"foo"`.
73 /// A nul-terminated C-string literal: `c"foo"`.
80 /// A byte literal: `b'f'`.
87 /// A character literal: `'a'`.
94 token: Literal,
99 /// An integer literal: `1` or `1u16`.
106 token: Literal,
112 /// A floating point literal: `1f64` or `1.0e10f64`.
121 token: Literal,
127 /// A boolean literal: `true` or `false`.
136 let mut token = Literal::string(value); in new()
152 /// Parse a syntax tree node from the content of this string literal.
189 /// Invoke parser on the content of this string literal.
206 /// // Parse a string literal like "a::b::c" into a Path, not allowing
239 // Parse string literal into a token stream with every span equal to the in parse_with()
240 // original literal's span. in parse_with()
251 format!("unexpected suffix `{}` on string literal", suffix), in parse_with()
270 pub fn token(&self) -> Literal { in token() argument
277 let mut token = Literal::byte_string(value); in new()
305 pub fn token(&self) -> Literal { in token() argument
312 let mut token = Literal::c_string(value); in new()
340 pub fn token(&self) -> Literal { in token() argument
347 let mut token = Literal::u8_suffixed(value); in new()
375 pub fn token(&self) -> Literal { in token() argument
382 let mut token = Literal::character(value); in new()
410 pub fn token(&self) -> Literal { in token() argument
419 None => panic!("not an integer literal: `{}`", repr), in new()
422 let mut token: Literal = repr.parse().unwrap(); in new()
437 /// Parses the literal into a selected number type.
440 /// resulting errors will be correctly spanned to point to the literal token
481 pub fn token(&self) -> Literal { in token() argument
486 impl From<Literal> for LitInt {
487 fn from(token: Literal) -> Self { in from()
498 panic!("not an integer literal: `{}`", repr); in from()
513 None => panic!("not a float literal: `{}`", repr), in new()
516 let mut token: Literal = repr.parse().unwrap(); in new()
553 pub fn token(&self) -> Literal { in token() argument
558 impl From<Literal> for LitFloat {
559 fn from(token: Literal) -> Self { in from()
570 panic!("not a float literal: `{}`", repr); in from()
832 /// The style of a string literal, either plain quoted or a raw string like
863 use proc_macro2::{Literal, Punct, Span};
871 if let Some((lit, rest)) = cursor.literal() { in parse()
894 Err(cursor.error("expected literal")) in parse()
900 let (lit, rest) = cursor.literal()?; in parse_negative_lit()
909 let mut token: Literal = repr.parse().unwrap(); in parse_negative_lit()
924 let mut token: Literal = repr.parse().unwrap(); in parse_negative_lit()
944 _ => Err(head.error("expected string literal")), in parse()
955 _ => Err(head.error("expected byte string literal")), in parse()
966 _ => Err(head.error("expected C string literal")), in parse()
977 _ => Err(head.error("expected byte literal")), in parse()
988 _ => Err(head.error("expected character literal")), in parse()
999 _ => Err(head.error("expected integer literal")), in parse()
1010 _ => Err(head.error("expected floating point literal")), in parse()
1021 _ => Err(head.error("expected boolean literal")), in parse()
1034 ($display:literal $name:ty) => {
1052 impl_token!("literal" Lit);
1053 impl_token!("string literal" LitStr);
1054 impl_token!("byte string literal" LitByteStr);
1055 impl_token!("C-string literal" LitCStr);
1056 impl_token!("byte literal" LitByte);
1057 impl_token!("character literal" LitChar);
1058 impl_token!("integer literal" LitInt);
1059 impl_token!("floating point literal" LitFloat);
1060 impl_token!("boolean literal" LitBool);
1132 use proc_macro2::{Literal, Span};
1139 /// Interpret a Syn literal from a proc-macro2 literal.
1140 pub fn new(token: Literal) -> Self { in new()
1217 panic!("unrecognized literal: `{}`", repr); in new()
1301 assert!(byte <= 0x7F, "invalid \\x byte in string literal"); in parse_lit_str_cooked()
1324 "unexpected byte '{}' after \\ character in string literal", in parse_lit_str_cooked()
1415 "unexpected byte '{}' after \\ character in byte-string literal", in parse_lit_byte_str_cooked()
1472 assert!(b != 0, "\\x00 is not allowed in C-string literal"); in parse_lit_c_str_cooked()
1478 assert!(ch != '\0', "\\u{{0}} is not allowed in C-string literal"); in parse_lit_c_str_cooked()
1498 "unexpected byte '{}' after \\ character in byte literal", in parse_lit_c_str_cooked()
1553 "unexpected byte '{}' after \\ character in byte literal", in parse_lit_byte()
1582 assert!(byte <= 0x7F, "invalid \\x byte in character literal"); in parse_lit_char()
1598 "unexpected byte '{}' after \\ character in character literal", in parse_lit_char()
1716 // If looking at a floating point literal, we don't want to in parse_lit_int()