adding '_ = <expr>' syntax
This commit is contained in:
parent
61250c906a
commit
999b25df8b
|
@ -1008,9 +1008,9 @@ create_back_buffer := fn(total_pages: int): ^u32 {
|
|||
remaining := total_pages - 0xFF
|
||||
loop if remaining <= 0 break else {
|
||||
if remaining < 0xFF {
|
||||
_f := request_page(@intcast(remaining))
|
||||
_ = request_page(@intcast(remaining))
|
||||
} else {
|
||||
_f := request_page(0xFF)
|
||||
_ = request_page(0xFF)
|
||||
}
|
||||
remaining -= 0xFF
|
||||
}
|
||||
|
|
|
@ -346,6 +346,7 @@ impl<'a> Formatter<'a> {
|
|||
self.fmt(val, f)
|
||||
}
|
||||
Expr::Return { val: None, .. } => f.write_str("return"),
|
||||
Expr::Wildcard { .. } => f.write_str("_"),
|
||||
Expr::Ident { pos, is_ct, .. } => {
|
||||
if is_ct {
|
||||
f.write_str("$")?;
|
||||
|
|
|
@ -148,6 +148,7 @@ pub enum TokenKind {
|
|||
RBrack = b']',
|
||||
Xor = b'^',
|
||||
Tick = b'`',
|
||||
Under = b'_',
|
||||
// Unused = a-z
|
||||
LBrace = b'{',
|
||||
Bor = b'|',
|
||||
|
@ -308,6 +309,7 @@ gen_token_kind! {
|
|||
Null = b"null",
|
||||
Idk = b"idk",
|
||||
Die = b"die",
|
||||
Under = b"_",
|
||||
#[punkt]
|
||||
Ctor = ".{",
|
||||
Tupl = ".(",
|
||||
|
|
|
@ -392,6 +392,7 @@ impl<'a, 'b> Parser<'a, 'b> {
|
|||
let (id, is_first) = self.resolve_ident(token);
|
||||
E::Ident { pos, is_ct: token.kind == T::CtIdent, id, is_first }
|
||||
}
|
||||
T::Under => E::Wildcard { pos },
|
||||
T::If => E::If {
|
||||
pos,
|
||||
cond: self.ptr_expr()?,
|
||||
|
@ -800,6 +801,9 @@ generate_expr! {
|
|||
pos: Pos,
|
||||
val: Option<&'a Self>,
|
||||
},
|
||||
Wildcard {
|
||||
pos: Pos,
|
||||
},
|
||||
/// note: ':unicode:' is any utf-8 character except ascii
|
||||
/// `'[a-zA-Z_:unicode:][a-zA-Z0-9_:unicode:]*'`
|
||||
Ident {
|
||||
|
|
|
@ -2666,6 +2666,10 @@ impl<'a> Codegen<'a> {
|
|||
self.assign_pattern(left, right);
|
||||
Some(Value::VOID)
|
||||
}
|
||||
Expr::BinOp { left: Expr::Wildcard { .. }, op: TokenKind::Assign, right, .. } => {
|
||||
self.expr(right)?;
|
||||
Some(Value::VOID)
|
||||
}
|
||||
Expr::BinOp { left, pos, op: TokenKind::Assign, right } => {
|
||||
let dest = self.raw_expr(left)?;
|
||||
let mut value = self.expr_ctx(right, Ctx::default().with_ty(dest.ty))?;
|
||||
|
|
Loading…
Reference in a new issue