Add new literal type Err
This commit is contained in:
parent
e2f221c759
commit
d19294feee
5 changed files with 6 additions and 0 deletions
|
|
@ -329,6 +329,7 @@ fn hash_token<'a, 'gcx, W: StableHasherResult>(
|
|||
match *lit {
|
||||
token::Lit::Byte(val) |
|
||||
token::Lit::Char(val) |
|
||||
token::Lit::Err(val) |
|
||||
token::Lit::Integer(val) |
|
||||
token::Lit::Float(val) |
|
||||
token::Lit::Str_(val) |
|
||||
|
|
|
|||
|
|
@ -646,6 +646,7 @@ fn expr_mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P<ast::Expr> {
|
|||
|
||||
token::Literal(token::Byte(i), suf) => return mk_lit!("Byte", suf, i),
|
||||
token::Literal(token::Char(i), suf) => return mk_lit!("Char", suf, i),
|
||||
token::Literal(token::Err(i), suf) => return mk_lit!("Err", suf, i),
|
||||
token::Literal(token::Integer(i), suf) => return mk_lit!("Integer", suf, i),
|
||||
token::Literal(token::Float(i), suf) => return mk_lit!("Float", suf, i),
|
||||
token::Literal(token::Str_(i), suf) => return mk_lit!("Str_", suf, i),
|
||||
|
|
|
|||
|
|
@ -466,6 +466,7 @@ crate fn lit_token(lit: token::Lit, suf: Option<Symbol>, diag: Option<(Span, &Ha
|
|||
match lit {
|
||||
token::Byte(i) => (true, Some(LitKind::Byte(byte_lit(&i.as_str()).0))),
|
||||
token::Char(i) => (true, Some(LitKind::Char(char_lit(&i.as_str(), diag).0))),
|
||||
token::Err(i) => (true, Some(LitKind::Char(char_lit(&i.as_str(), diag).0))),
|
||||
|
||||
// There are some valid suffixes for integer and float literals,
|
||||
// so all the handling is done internally.
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ impl DelimToken {
|
|||
pub enum Lit {
|
||||
Byte(ast::Name),
|
||||
Char(ast::Name),
|
||||
Err(ast::Name),
|
||||
Integer(ast::Name),
|
||||
Float(ast::Name),
|
||||
Str_(ast::Name),
|
||||
|
|
@ -73,6 +74,7 @@ impl Lit {
|
|||
match *self {
|
||||
Byte(_) => "byte literal",
|
||||
Char(_) => "char literal",
|
||||
Err(_) => "error literal",
|
||||
Integer(_) => "integer literal",
|
||||
Float(_) => "float literal",
|
||||
Str_(_) | StrRaw(..) => "string literal",
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@ pub fn token_to_string(tok: &Token) -> String {
|
|||
let mut out = match lit {
|
||||
token::Byte(b) => format!("b'{}'", b),
|
||||
token::Char(c) => format!("'{}'", c),
|
||||
token::Err(c) => format!("'{}'", c),
|
||||
token::Float(c) |
|
||||
token::Integer(c) => c.to_string(),
|
||||
token::Str_(s) => format!("\"{}\"", s),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue