aboutsummaryrefslogtreecommitdiff
path: root/src/parser.rs
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2026-04-30 16:53:14 +0100
committertslil <tslil@posteo.de>2026-04-30 17:30:22 +0100
commit0f7efe7518b925d9688dad4c6f6e87f84015e2c1 (patch)
treef4cdfa08c7d3e7a69860570f3f7826119f3bcdef /src/parser.rs
parentd57f1d3c845220c741db73c1fada017a75b11992 (diff)
wip case for instances
Diffstat (limited to 'src/parser.rs')
-rw-r--r--src/parser.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/parser.rs b/src/parser.rs
index 1aed3f8..d95c190 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -175,6 +175,9 @@ parser! {
// instance layer
+ rule inst_case_arm() -> InstCaseArm
+ = t:inject() _ x:elem_var() _ "=>" _ body:instance() { InstCaseArm { tag: t, bound: x, body } }
+
rule inst_assign() -> InstAssign
= n:project_upper() _ "=" _ i:instance()
{ InstAssign { name: n, instance: i } }
@@ -183,9 +186,9 @@ parser! {
= _ s:set() _ "::" _ kw_Set() _ { s }
rule atom_inst() -> Instance
- = v:inst_var() { Instance::Var(v) }
+ = s:explicit_set_coerce() { Instance::SetCoerce(Box::new(s)) }
+ / v:inst_var() { Instance::Var(v) }
/ f:sig_var() { Instance::Var(f) }
- / s:explicit_set_coerce() { Instance::SetCoerce(Box::new(s)) }
/ "{" fs:(inst_assign() ** ",") _ "}" { Instance::Record(fs) }
/ "(" _ i:instance() _ ")" { i }
@@ -207,6 +210,7 @@ parser! {
rule instance() -> Instance
= kw_for() __ ps:param_list() _ "," _ body:instance() { Instance::For { params: ps, body: Box::new(body) } }
+ / kw_case() __ scrut:element() _ kw_of() _ "[" arms:(_ a:inst_case_arm() _ { a }) ** "|" _ "]" { Instance::Case { scrutinee: Box::new(scrut), arms } }
/ app_inst()
// declarations