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:
@ -1,10 +1,10 @@
|
||||
static box Main {
|
||||
main(args) {
|
||||
local d = "1"
|
||||
local dv = peek d {
|
||||
local dv = match d {
|
||||
"0" => { print("found zero") 0 }
|
||||
"1" => { print("found one") 1 }
|
||||
else => { print("other") 0 }
|
||||
_ => { print("other") 0 }
|
||||
}
|
||||
return dv
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
static box Main {
|
||||
main(args) {
|
||||
// Use peek as an expression to produce a value
|
||||
// Use match as an expression to produce a value
|
||||
local d = "1"
|
||||
local v = peek d {
|
||||
"0" => { 0 }
|
||||
"1" => { 1 }
|
||||
else => { 0 }
|
||||
local v = match d {
|
||||
"0" => 0,
|
||||
"1" => 1,
|
||||
_ => 0
|
||||
}
|
||||
// Show the result and finish
|
||||
local console = new ConsoleBox()
|
||||
|
||||
Reference in New Issue
Block a user