Skip to Content.
Sympa Menu

k-user - Re: [K-user] file read/write

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] file read/write


Chronological Thread 
  • From: "Michael D. Adams" <adamsmd AT illinois.edu>
  • To: "Park, Daejun" <dpark69 AT illinois.edu>
  • Cc: "k-user AT cs.uiuc.edu" <k-user AT cs.uiuc.edu>
  • Subject: Re: [K-user] file read/write
  • Date: Fri, 8 Nov 2013 09:17:10 -0600
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

What I try to do that, the configuration gets stuck with:

<k>
#write ( (#open ( "file" )) , "content" ) ~> #close ( (#open ( "file" ))
)
</k>

Have you gotten it to not get stuck? Could you post a complete example (including commandlines)?

On 11/01/2013 09:03 PM, Park, Daejun wrote:
Hi Michael,

If you want to write something to a file at once, you can go with #open and
#write .

For example,

rule <k> run => writeFile("file", "content") ... </k>

syntax K ::= writeFile(String,String)
rule writeFile(File:String, Content:String)
=> writeFD(#open(File), Content)

syntax K ::= writeFD(Int,String)
rule writeFD(FD:Int, Content:String)
=> #write(FD, Content) ~> #close(FD)

I'll get back to you after figuring out how to read from a file.

Daejun

On Nov 1, 2013, at 12:54 PM, Michael D. Adams
<adamsmd AT illinois.edu>
wrote:

If you figure out how to do this, let me know. I need it in the AST
generator.

For my use, it would be nice if we had some high-level functions like
Haskell's readFile and writeFile that read or write the entire file in one go.

On 11/01/2013 12:52 PM, Park, Daejun wrote:
Thank you very much, Brandon!!

Daejun

On Nov 1, 2013, at 12:43 PM, "Moore, Brandon Michael"
<bmmoore AT illinois.edu>
wrote:

The first thing grep suggests is
tests/regression/java-rewrite-engine/io/test1
None of the tutorials or samples call #open.

Brandon
________________________________________
From:
k-user-bounces AT cs.uiuc.edu

[k-user-bounces AT cs.uiuc.edu]
on behalf of Park, Daejun
[dpark69 AT illinois.edu]
Sent: Friday, November 01, 2013 12:35 PM
To:
k-user AT cs.uiuc.edu
Subject: [K-user] file read/write

Hi all,

Is there an easy way to read/write a file in K?
While dealing with stdin/stdout is very simple, how can I do such a thing for
a file?
I'd appreciate it if you give a pointer to an example.

Thanks,
Daejun
_______________________________________________
k-user mailing list
k-user AT cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/k-user



_______________________________________________
k-user mailing list
k-user AT cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/k-user


_______________________________________________
k-user mailing list
k-user AT cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/k-user






Archive powered by MHonArc 2.6.16.

Top of Page