Add a b'x' byte literal of type u8.

This commit is contained in:
Simon Sapin 2014-06-06 16:04:04 +01:00
parent 2fd618e77a
commit bccdba0296
16 changed files with 169 additions and 5 deletions

View file

@ -47,6 +47,7 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
ast::LitBool(b) => {
accumulator.push_str(format!("{}", b).as_slice());
}
ast::LitByte(..) |
ast::LitBinary(..) => {
cx.span_err(e.span, "cannot concatenate a binary literal");
}

View file

@ -436,6 +436,12 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> Gc<ast::Expr> {
vec!(mk_binop(cx, sp, binop)));
}
LIT_BYTE(i) => {
let e_byte = cx.expr_lit(sp, ast::LitByte(i));
return cx.expr_call(sp, mk_token_path(cx, sp, "LIT_BYTE"), vec!(e_byte));
}
LIT_CHAR(i) => {
let e_char = cx.expr_lit(sp, ast::LitChar(i));