Skip to Content.
Sympa Menu

k-user - Re: [K-user] Creating function problem

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] Creating function problem


Chronological Thread 
  • From: Radu Mereuta <headness13 AT gmail.com>
  • To: SITTHISAK Pakakorn <pakakorn.s AT jaist.ac.jp>
  • Cc: "k-user AT cs.uiuc.edu" <k-user AT cs.uiuc.edu>
  • Subject: Re: [K-user] Creating function problem
  • Date: Mon, 25 Aug 2014 10:18:59 -0500
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

I just tested this and it doesn't compile.
Are you sure you gave me the right definition?

Radu Mereuta


On Mon, Aug 25, 2014 at 5:18 AM, SITTHISAK Pakakorn <pakakorn.s AT jaist.ac.jp> wrote:
Hi,

I have a problem creating function accepting new syntactical category as input.
Consider my test module, I would like to create new sort call Int8, which represent 8 bit-integer.
Then, I would like to create function changing 0 to 0 and non-zero to 1 for representing boolean value.

module TEST
       syntax Int8 ::= Lexer{[\-\+]? [0-9]} [notInRules]
                       | Lexer{[\-\+]? [0-9][0-9] } [notInRules]
                       | Lexer{[\-\+]? [1][0-1][0-9] } [notInRules]
                       | Lexer{[\-\+]? [1][2][0-7] } [notInRules]
                       | Token{"-128"} [notInRules]
        syntax Int8 ::= bool(Int8) [function]
        rule bool(0:Int8) => 0
        rule bool(1:Int8) => 1
endmodule

K compiles this successfully. However, when I run input

bool(0)

it did not rewrite. I checked AST and found that 0 in bool(0) was Int8.

Can anybody suggest me how to solve this problem?
I have no idea what is wrong I did.

Pakakorn


_______________________________________________
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