Skip to Content.
Sympa Menu

k-user - Re: [[K-user] ] Bad 'function call' rule

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [[K-user] ] Bad 'function call' rule


Chronological Thread 
  • From: Everett Hildenbrandt <hildenb2 AT illinois.edu>
  • To: Mihály Palenik <palenik.mihaly AT gmail.com>
  • Cc: <k-user AT lists.cs.illinois.edu>
  • Subject: Re: [[K-user] ] Bad 'function call' rule
  • Date: Thu, 9 Mar 2017 22:37:17 -0600

Hey Mihály,

Can you provide a more complete example of the code you're trying to run? It's
hard to see what the issue is without more context.

One thing you might try is using the debugger to see where it's getting stuck.
When you call `krun`, just add the `--debugger` option. You can then use `s`
to
tell it to take one step, `p` to tell it to print the current state, `b` to go
back some states, and `j` to jump to a state.

Here is a sample file I'm running:

```test.k
module ISSUE-SYNTAX

syntax MyKey ::= "0" | "1" | "2"
syntax MyValue ::= "a" | "b" | "c"

syntax K ::= continue(MyKey)

endmodule

module ISSUE
import ISSUE-SYNTAX
configuration <k> $PGM:K </k> <a> a </a>

rule <k> continue(0 => 1) </k>
<a> a => b </a>

rule <k> continue(1 => 2) </k>
<a> b => c </a>

rule <k> continue(2 => 0) </k>
<a> c => a </a>
endmodule
```

And I'm starting it with this file:

```init.test
continue(0)
```
And here is how I'm interacting with it in KDebug:

```sh
$ kompile --main-module ISSUE test.k
$ krun --debugger init.issue

KDebug> p
initGeneratedTopCell ( .Map $STDIN |-> "" $IO |-> "off" $PGM |-> continue ( 0
) )

// Take a single step
KDebug> s
1 Step(s) Taken.

// Print the output
KDebug> p
<generatedTop> <k> continue ( 1 ) </k> <a> b </a> </generatedTop>

// Take another step and print
KDebug> s
1 Step(s) Taken.
KDebug> p
<generatedTop> <k> continue ( 2 ) </k> <a> c </a> </generatedTop>

// Take multiple steps
KDebug> s 2
2 Step(s) Taken.
KDebug> p
<generatedTop> <k> continue ( 1 ) </k> <a> b </a> </generatedTop>
KDebug> s 4
4 Step(s) Taken.
KDebug> p
<generatedTop> <k> continue ( 2 ) </k> <a> c </a> </generatedTop>

// Go back 2 steps
KDebug> b 2
Took -2 step(s)
KDebug> p
<generatedTop> <k> continue ( 0 ) </k> <a> a </a> </generatedTop>

// Jump to point 3
KDebug> j 3
Jumped to Step Number 3
KDebug> p
<generatedTop> <k> continue ( 0 ) </k> <a> a </a> </generatedTop>
KDebug>
```

This can help you figure out where your semantics is getting stuck.

Everett H.

On Fri, Mar 10, 2017 at 02:22:19AM +0100, Mihály Palenik wrote:
> Hello,
>
> I have the following sorts:
>
> • In COMMON module
>
> syntax Exps ::= List{Exp, ","} [strict]
> syntax Exp ::= "{" Exps "}" [strict] // tuple
> syntax Exp ::= "case" Exp "of" Match "end" [strict(1)]
>
> • In LANG module
>
> syntax Value ::= Int | Bool | "{" Values "}"
> syntax Values ::= List{Value, ","}
> syntax KResult ::= Value | Values
>
> And I have this function call rule:
> rule Name(Args) => case { Args } of getMatch end
>
> case rule is work perfectly, but when I use function call rule, K stuck in
> case. It can't find out that { Args } is a Value.
>
> For example I want to call foo() func, then it stuck
> <k> case { .Exps } of { .Exps } -> "something" end </k>
>
> But If I write case { .Exps } of { .Exps } -> "something" end in source
> code it
> works and the result is "something".
>
> Thank you your answers in advance!
>
> Best regards,
> Mihály Palenik
>
>



Archive powered by MHonArc 2.6.19.

Top of Page