Skip to Content.
Sympa Menu

k-user - Re: [K-user] Passing a K object between two different K definitions

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] Passing a K object between two different K definitions


Chronological Thread 
  • From: "Park, Daejun" <dpark69 AT illinois.edu>
  • To: Chris Hathhorn <chathhorn AT gmail.com>
  • Cc: Jiho Choi <jray319 AT gmail.com>, "k-user AT cs.uiuc.edu" <k-user AT cs.uiuc.edu>, "Shull, Thomas Edward" <shull1 AT illinois.edu>
  • Subject: Re: [K-user] Passing a K object between two different K definitions
  • Date: Thu, 12 Dec 2013 02:54:02 +0000
  • Accept-language: en-US
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

Thank you, Traian and Chris!
It is very helpful to me! :)

BTW, Chris:
Is the option '--load-cfg' has the same meaning with the option '--parser "kast --parser binary"'?

Also, while the following commands
krun -d d1 --output binary --output-file pgm.bin pgm.lang
krun -d d2 --load-cfg pgm.bin
generate the following result:
<T>
    <k>
        <generatedTop>
            <T>
                <k>
                   ...
                </k>
            </T>
        </generatedTop>
    </k>
</T>
It this result intended, or did I something wrong?
How to get a result without the <generatedTop> wrapper?

Thanks,
Daejun

On Dec 11, 2013, at 4:15 PM, Chris Hathhorn <chathhorn AT gmail.com> wrote:

On Wed, Dec 11, 2013 at 4:01 PM, Traian Florin Șerbănuță
<traian.serbanuta AT info.uaic.ro> wrote:
What could work is some hooked code which Dwight wrote (and used in the
Python semantics), which can be found at the end of uris.k
more precisely, you probably want to use:
 syntax K ::= String2K(String) [function, hook(#K-PARSER:string2k)]
 syntax String ::= K2String(K) [function, hook(#K-PRINTER:k2string)]

These should probably work regardless of changes in K, because Dwight uses
reflection in Maude to implement them.

See lines 28-50 of python-semantics-builtin-modules.k[1] and lines
32-34 of Makefile[2] (per Dwight's email from a few months ago) for
examples of this.

FWIW, I tried that method with the C semantics and found the overhead
(in terms of saving/loading time) to be pretty atrocious. It's
probably practical for smaller configurations, though. Currently I'm
using the "--load-cfg" option I added to krun in order to load
configurations saved with the "binary" output mode. It just loads the
deserialized configuration into the $PGM configuration variable
instead of a program. It's pretty hackish, though -- I'd certainly
appreciate it were you to rework this into some more general
mechanism.

[1] - https://github.com/kframework/python-semantics/blob/master/python-semantics-builtin-modules.k
[2] - https://github.com/kframework/python-semantics/blob/master/Makefile

Chris




Archive powered by MHonArc 2.6.16.

Top of Page