k-user AT lists.cs.illinois.edu
Subject: K-user mailing list
List archive
- From: <isaacdefrain AT gmail.com>
- To: k-user AT lists.cs.illinois.edu
- Subject: [[K-user] ] CellBags & Functions
- Date: Sun, 04 Aug 2019 11:29:10 -0500
Hello and good day,
I'm defining a programming language whose configuration has multiple cells
with multiplicity="*", some of which are nested in cells with
multiplicity="*"; e.g. something like
module MOD-SYNTAX
syntax Term ::= "Stop" | Bool | Int | String // the exact definition is
not important
syntax Terms ::= Term > Term "," Term [right]
endmodule
endmodule
module MOD
configuration
<T>
<k> .K </k>
<one>
<alpha multiplicity="*"> .K </alpha>
</one>
<two>
<beta multiplicity="*">
<gamma>
<delta multiplicity="*"> .K </delta>
</gamma>
</beta>
</two>
</T>
// a bunch of rules
endmodule
I want to define two kinds of functions: the first from Terms to DeltaCellBag;
the second from AlphaCellBag to Terms. So in the MOD module, I have something
like
syntax AlphaCellBag
syntax DeltaCellBag
syntax DeltaCellBag ::= "fun1(" Terms ")" [function]
syntax Terms ::= "fun2(" AlphaCellBag ")" [function]
rule fun1( A:Term ) => <delta> A </delta>
rule fun1( A:Term , B:Terms ) => <delta> A </delta> fun1(B)
rule fun2( .AlphaCellBag ) => Stop
rule fun2( <alpha> A:Term </alpha> ) => A
rule fun2( <alpha> A:Term </alpha> B:AlphaCellBag ) => A , fun2(B)
But the compiler complains about the second rule for fun1 and the third rule
for fun2 (I'm using RV-K version 1.0-SNAPSHOT
Git revision: 1e310cd
Git branch: UNKNOWN
Build date: Thu Jan 31 03:38:17 EST 2019)
It's not clear to me why this is an error. Can someone help me understand why
this error occurs and whether there is a way to define such functions (without
errors)?
Thank you!
- [[K-user] ] CellBags & Functions, isaacdefrain, 08/04/2019
Archive powered by MHonArc 2.6.19.