Skip to Content.
Sympa Menu

k-user - RE: [[K-user] ] Quoting in K

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

RE: [[K-user] ] Quoting in K


Chronological Thread 
  • From: "Chen, Xiaohong" <xc3 AT illinois.edu>
  • To: Derek Sorensen <derek AT pyrofex.net>, "k-user AT lists.cs.illinois.edu" <k-user AT lists.cs.illinois.edu>
  • Subject: RE: [[K-user] ] Quoting in K
  • Date: Fri, 25 May 2018 01:27:29 +0000
  • Accept-language: en-US
  • Authentication-results: illinois.edu; spf=pass smtp.mailfrom=xc3 AT illinois.edu; dmarc=pass header.from=illinois.edu

Hi Derek,

One possible solution would be to define a symbol

syntax String ::= toString(K)

and define for each language construct their string representation,
which should be straightforward. For example,

rule toString(if B then S1 else S2)
=> "if" +String "(" +String toString(B) +String ")" +String toString(S1)
+String toString(S2)

Maybe K has a toString() function built in. You might want to examine
the k-distribution/include/builtin/domains.k to see if there's anything
related.

Hope it helps.
Xiaohong

-------------------------
Chen, Xiaohong
BSc, Peking University
PhD student, UIUC

________________________________________
From: Derek Sorensen
[derek AT pyrofex.net]
Sent: Thursday, May 24, 2018 5:28 PM
To:
k-user AT lists.cs.illinois.edu
Subject: [[K-user] ] Quoting in K

Hi all,

I would like to quote something in a rewrite rule—in particular, I would like
to take two statements S1 and S2 and see if they are equal as strings. Is
there a way to do this? I would like to define some sort of rule where S1 =>
“S1” in the sense that it’s the string corresponding to the statement S1, but
no the literal string “S1”.

Any help would be greatly appreciated.

Best,
Derek Sorensen



Archive powered by MHonArc 2.6.19.

Top of Page