k-user AT lists.cs.illinois.edu
Subject: K-user mailing list
List archive
- From: Gurvan Le Guernic <gleguern AT gmail.com>
- To: k-user AT lists.cs.illinois.edu
- Subject: [[K-user] ] K4 and function use
- Date: Thu, 22 Sep 2016 20:00:05 +0200
Hi,
I'm experimenting with K4. With the following definition :module POINTS-DSL-SYNTAX
syntax Point ::= "(" Int "," Int ")"
syntax PointExp ::= Point
| PointExp PointPointOp PointExp [right,strict(1,3)]
| PointExp PointIntOp Int [strict(1)]
| "(" PointExp ")" [bracket]
syntax PointPointOp ::= "+" | "-"
syntax PointIntOp ::= "*" | "/"
syntax PointExpInnerSet ::= PointExp
| PointExp ";" PointExpInnerSet [strict(1)]
syntax PointExpSet ::= "{" PointExpInnerSet "}" [strict]
syntax PointSetExp ::= PointExpSet
| PointSetExp PsPsOp PointSetExp [right,strict(1,3)]
| "(" PointSetExp ")" [bracket]
syntax PsPsOp ::= "U"
endmodule
module POINTS-DSL
imports POINTS-DSL-SYNTAX
configuration
<k> $PGM:K </k>
syntax KResult ::= Point
rule ( X1:Int , Y1:Int ) + ( X2:Int , Y2:Int ) => ( X1 +Int X2 , Y1 +Int Y2 )
rule ( X1:Int , Y1:Int ) - ( X2:Int , Y2:Int ) => ( X1 -Int X2 , Y1 -Int Y2 )
rule ( X:Int , Y:Int ) * I:Int => ( X *Int I , Y *Int I )
rule ( X:Int , Y:Int ) / I:Int => ( X /Int I , Y /Int I ) requires I =/=Int 0
rule { P:Point ; T:PointExpInnerSet } => { P } U { T }
// Using my own 'PointSet' to handle point sets
syntax PointSet ::= "[" PointInnerSet "]"
syntax PointInnerSet ::= Point | Point ";" PointInnerSet
//syntax PointExpInnerSet ::= PointInnerSet // I now get an error with this line
syntax PointSetExp ::= PointSet
syntax KResult ::= PointSet
rule { P:Point } => [ P ]
syntax PointInnerSet ::= "merge" "(" PointInnerSet "&" PointInnerSet ")" [function]
rule merge( P1:Point & P2:Point ) => P1 ; P2 requires P1 =/=K P2
rule merge( P1:Point & P2:Point ) => P1 requires P1 ==K P2
rule merge( P1:Point ; Tail:PointInnerSet & P2:Point ) => P1 ; merge( Tail & P2 )
requires P1 =/=K P2
rule merge( P1:Point ; Tail:PointInnerSet & P2:Point ) => P1 ; Tail
requires P1 ==K P2
rule merge( S:PointInnerSet & P2:Point ; Tail:PointInnerSet ) => merge( merge( S & P2 ) & Tail )
rule [ S1:PointInnerSet ] U [ S2:PointInnerSet ] => [ merge( S1 & S2 ) ]
endmodule
[Error] Compiler: Had 1 parsing errors.
[Error] Inner Parser: Parse error: unexpected end of file.
Source(/mnt/partage/offices/gurvan/PFPML/K-definitions/points/./points-DSL.k4)
Location(...,55,...,56)
rule [ S1:PointInnerSet ] U [ S2:PointInnerSet ] => [ ( merge( S1 & S2 ) ) ]
{ (2,4) } U { ( 5,5)} U { ( 2,5) ; (3,3)} U {(7,8)}produces :
<k> [ ( 2 , 4 ) ; ( ( 5 , 5 ) ; ( ( 2 , 5 ) ; ( ( 3 , 3 ) ; ( 7 , 8 ) ) ) ) ] </k>
Why do I get the compilation error and how do I fix it ?
Thanks,
Gurvan
- [[K-user] ] K4 and function use, Gurvan Le Guernic, 09/22/2016
Archive powered by MHonArc 2.6.19.