k-user AT lists.cs.illinois.edu
Subject: K-user mailing list
List archive
- From: Dorel Lucanu <dlucanu AT info.uaic.ro>
- To: k-user AT cs.uiuc.edu
- Subject: Re: [K-user] Ellipsis in cells of UserDefinedList type
- Date: Mon, 10 Sep 2012 11:25:24 +0300
- List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
- List-id: <k-user.cs.uiuc.edu>
Hi Bram, The current version of K does not support "associative lists", as you expected. Only the "cons" lists are supprted, i.e. lists where only constructors are the empty list and that defined by separator. The constructor defined by the separator has a list item and a list as arguments; it is similar to cons from Lisp lists. The correct definition (as a cons list) for your declaration is: - .FunctionDeclList is a FunctionDeclList - if F is FunctionDecl and and L a FunctionDeclList, then F L is a FunctionDeclList. A solution for your problem is to use sets for keeping function declarations in the cell "decls". There is a wrapper, "SetItem" that injects K into Set. Here is the declaration of the cell <decls> .Set </decls>and here is the modified rule: (I guess that the rule is incomplete because in this form it can be infinitely applied).rule [linearize-func2]: <decls> ... SetItem(F:FunctionDecl) ... </decls> <nextLabel> L => L +Int 1 </nextLabel> [transition] Note that the syntactical categories of your language are subsorted to K. In your case, FunctionDecl and FunctionDeclLists are subsorts of K; therefore the compiler supposed that in the cell "decls" is a K list, which is associative. I hope this is of help for you. Dorel On 9/10/12 10:56 AM, Bram Geron wrote:
Hi guys, |
- [K-user] Ellipsis in cells of UserDefinedList type, Bram Geron, 09/10/2012
- Re: [K-user] Ellipsis in cells of UserDefinedList type, Dorel Lucanu, 09/10/2012
- Re: [K-user] Ellipsis in cells of UserDefinedList type, Dorel Lucanu, 09/10/2012
- Re: [K-user] Ellipsis in cells of UserDefinedList type, Bram Geron, 09/10/2012
- Re: [K-user] Ellipsis in cells of UserDefinedList type, Dorel Lucanu, 09/10/2012
- Re: [K-user] Ellipsis in cells of UserDefinedList type, Andrei Arusoaie, 09/10/2012
- Re: [K-user] Ellipsis in cells of UserDefinedList type, Dorel Lucanu, 09/10/2012
Archive powered by MHonArc 2.6.16.