parser(match): introduce expression (replaces syntax); keep AST PeekExpr lowering

- Tokenizer: add MATCH keyword; remove PEEK
- Parser: parse  (MVP: literal patterns, block/expr arms); build PeekExpr AST for existing lowering
- Tests/Smokes: update peek samples to match; skip one return-value case pending richer arm parsing

Notes: MIR unchanged; existing PeekExpr lowerers continue to work.
This commit is contained in:
Selfhosting Dev
2025-09-19 07:58:01 +09:00
parent 45e1d57536
commit a6f28a8980
6 changed files with 39 additions and 41 deletions

View File

@ -1,13 +1,13 @@
use crate::parser::NyashParser;
#[test]
fn parse_peek_with_block_arm() {
fn parse_match_with_block_arm() {
let src = r#"
local x = 2
local y = peek x {
local y = match x {
1 => { local a = 10 a }
2 => { 20 }
else => { 30 }
_ => { 30 }
}
"#;
let ast = NyashParser::parse_from_string(src).expect("parse ok");
@ -26,4 +26,3 @@ fn parse_peek_with_block_arm() {
}
assert!(find_peek(&ast), "expected peek with block arms in AST");
}