Skip to Content.
Sympa Menu

k-user - [[K-user] ] CellBags & Functions

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

[[K-user] ] CellBags & Functions


Chronological Thread 
  • From: <isaacdefrain AT gmail.com>
  • To: k-user AT lists.cs.illinois.edu
  • Subject: [[K-user] ] CellBags & Functions
  • Date: Thu, 17 Oct 2019 15:50:26 -0500

Hello and good day,

I asked before, but did not get a response so I'm trying again :-)

I'm defining a programming language whose configuration has multiple cells
with multiplicity="*", some of which are nested in cells also with
multiplicity="*"; e.g. something like

module MOD-SYNTAX
syntax Term ::= "Stop" | Bool | Int | String | "[" Terms "]" // the exact
definition is
not important
syntax Terms ::= Term > Term "," Term [right]
endmodule

endmodule

module MOD
configuration
<T>
<k> $PGM:Term </k>
<one>
<alpha multiplicity="*"> .K </alpha>
</one>
<two>
<beta multiplicity="*">
<gamma>
<delta multiplicity="*"> .K </delta>
</gamma>
</beta>
</two>
</T>

// a bunch of semantic rules
endmodule

I'd like 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!



Archive powered by MHonArc 2.6.19.

Top of Page