Skip to Content.
Sympa Menu

k-user - Re: [K-user] Unsupported sort of fresh variable

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] Unsupported sort of fresh variable


Chronological Thread 
  • From: Andrei Stefanescu <andreistef AT gmail.com>
  • To: Omar Duhaiby <3omarz AT gmail.com>
  • Cc: "k-user AT cs.uiuc.edu" <k-user AT cs.uiuc.edu>, "Musab A. AlTurki" <musab AT kfupm.edu.sa>
  • Subject: Re: [K-user] Unsupported sort of fresh variable
  • Date: Mon, 17 Nov 2014 14:55:00 -0600
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

You should use !NewVar:LowerCaseId as you initially did, you should not call the function directly. The framework will call the function for you, with an appropriate value for the integer argument.

As for the function itself, you can use #parseToken to create a LowerCaseId from a String:
rule freshLowerCaseId(I:Int) => #parseToken("LowerCaseId", "_" +String Int2String(I))

You can take a look in k-distribution/include/builtins/id.k to see exactly how it is done for Id.

Andrei

On Mon, Nov 17, 2014 at 2:37 PM, Omar Duhaiby <3omarz AT gmail.com> wrote:
OK, I can make my own, but when I call it, I have to provide an Int. And using String2Id will always return a type Id. The compiler complains about that. The only way to do it that I can see is to keep a global Int that increments with each run of the rule.

On Mon, Nov 17, 2014 at 8:40 PM, Andrei Stefanescu <andreistef AT gmail.com> wrote:
Hi Omar,

The !X notation is syntactic sugar for a function that generates a "fresh" element given an integer argument. This is the function for Id (from builtins/id.k):
  syntax Id ::= freshId(Int)    [freshGenerator, function]
  rule freshId(I:Int) => String2Id("_" +String Int2String(I))
You can add you own for LowerCaseId in a similar way.

Let me know if I can help you further,

Andrei


On Sat, Nov 15, 2014 at 11:56 AM, Omar Duhaiby <3omarz AT gmail.com> wrote:
Hello,

I'm doing this:
rule E:Exp (0) => E -> !NewVar:LowerCaseId        [macro]

However, the compiler says "Only sorts [Id, Int] admit fresh variables". But I don't want to use Id because it can start with an upper case. My LowerCaseId starts only with a lower case. What should I do?

_______________________________________________
k-user mailing list
k-user AT cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/k-user







Archive powered by MHonArc 2.6.16.

Top of Page