Skip to Content.
Sympa Menu

k-user - [[K-user] ] Troubles handling inputs

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

[[K-user] ] Troubles handling inputs


Chronological Thread 
  • From: Gurvan Le Guernic <gleguern AT gmail.com>
  • To: k-user AT cs.uiuc.edu
  • Subject: [[K-user] ] Troubles handling inputs
  • Date: Wed, 27 May 2020 20:02:12 +0200
  • Authentication-results: illinois.edu; spf=softfail smtp.mailfrom=gleguern AT gmail.com; dkim=pass header.d=gmail.com header.s=20161025; dmarc=pass header.from=gmail.com

Hi,

I have some troubles to handle inputs. I need to "load" adhoc data
type values from a file. I am unsuccessful when trying to input adhoc
data types and unable to use start up variables.

I use todays version of K (worked similarly with a previous version)
RV-K version 1.0-SNAPSHOT
Git revision: 396a314
Git branch: UNKNOWN
Build date: Wed May 27 18:38:26 CEST 2020

I built the MWE pasted below and also provided in the attachment.

When using stdin and Int, it works even thow the final output of K is
"project:Int ( #EOF )".

When using stdin and DType, K is unable to parse the integer and gets
stuck with the following <inputs> cell:
<inputs>
ListItem ( #parseInput ( "DType" , " \n\t\r" ) )
ListItem ( #buffer ( "24\n" ) )
ListItem ( "on" )
ListItem ( #istream ( 0 ) )
</inputs>

When using IN variable and Int, K does not output anything except
"project:List ( 24 12 5 13 67 99 .IntList )".

When using IN variable and DType, K does not output anything except
"project:List ( 24 12 5 13 67 99 .DTypeList )".

How can I sequentially input adhoc data type values from a file ?

Thanks,
Gurvan LE GUERNIC

====================================================================

module INPUTOUTPUT-SYNTAX
imports DOMAINS-SYNTAX

syntax IntList ::= List{Int, " "}
syntax DataList ::= List{Data," \n\t\r"}
syntax DTypeList ::= List{DType," \n\t\r"}

syntax Data ::= ".Data" | Int
syntax DType ::= Int
syntax Program ::= "forward" | "drop" | "duplicate"
endmodule

module INPUTOUTPUT
imports DOMAINS
imports INPUTOUTPUT-SYNTAX

configuration
<T>
<inputs stream="stdin"> .List </inputs>
// <inputs> $IN:List </inputs>
<data> . </data>
<k> $PGM </k>
<outputs stream="stdout"> .List </outputs>
</T>

rule
<inputs> ListItem(Input:DType) => .List ... </inputs>
// <inputs> ListItem(Input:Int) => .List ... </inputs>
<data> . => Input </data>

rule
<data> Data:DType => . </data>
<k> forward </k>
<outputs> ... .List => ( ListItem(Data) ListItem("\n") ) </outputs>

rule
<data> Data:DType => . </data>
<k> drop </k>

rule
<data> Data:DType => . </data>
<k> duplicate </k>
<outputs> ... .List => ( ListItem(Data) ListItem("\n")
ListItem(Data) ListItem("\n") ) </outputs>

endmodule

Attachment: inputOutputMWE.zip
Description: Zip archive



  • [[K-user] ] Troubles handling inputs, Gurvan Le Guernic, 05/27/2020

Archive powered by MHonArc 2.6.19.

Top of Page