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