update built-in examples to use newly introduced syntax

This commit is contained in:
りき萌 2025-09-03 16:57:10 +02:00
parent b5cdfdb1b6
commit 914da923f7
4 changed files with 53 additions and 55 deletions

View file

@ -603,29 +603,19 @@ fn is_prefix_token((kind, spaces): (TokenKind, Spaces)) -> bool {
}
fn prefix(p: &mut Parser) -> Closed {
let (kind, spaces) = p.peek_with_spaces();
match kind {
match p.peek() {
TokenKind::Ident => one(p, NodeKind::Ident),
TokenKind::Tag => one(p, NodeKind::Tag),
TokenKind::Number => one(p, NodeKind::Number),
TokenKind::Color => one(p, NodeKind::Color),
TokenKind::LBrack => list(p),
TokenKind::Minus if spaces.pair() == (true, false) => unary(p),
TokenKind::Minus => unary(p),
TokenKind::Not => unary(p),
TokenKind::LParen => paren(p),
TokenKind::Backslash => lambda(p),
TokenKind::If => if_expr(p),
TokenKind::Minus if spaces.pair() == (false, true) => {
let span = p.span();
p.emit(Diagnostic::error(
span,
"`-` operator must be surrounded by an equal amount of spaces",
));
p.advance_with_error()
}
_ => {
assert!(
!is_prefix_token(p.peek_with_spaces()),

View file

@ -28,8 +28,6 @@ pub enum TokenKind {
Greater,
GreaterEqual,
Not,
Dot,
Pipe,
// Punctuation
Newline,
@ -42,6 +40,8 @@ pub enum TokenKind {
Colon,
Backslash,
RArrow,
Dot,
Pipe,
// Keywords
Underscore,