k-user AT lists.cs.illinois.edu
Subject: K-user mailing list
List archive
- From: SITTHISAK Pakakorn <pakakorn.s AT jaist.ac.jp>
- To: k-user AT cs.uiuc.edu
- Subject: [K-user] Creating function problem
- Date: Mon, 25 Aug 2014 19:18:27 +0900 (JST)
- List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
- List-id: <k-user.cs.uiuc.edu>
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] Creating function problem, SITTHISAK Pakakorn, 08/25/2014
- Re: [K-user] Creating function problem, Radu Mereuta, 08/25/2014
Archive powered by MHonArc 2.6.16.