k-legacy
k-legacy copied to clipboard
how to get input from user in k
Can you provide me syntax or semantics which take input from user in k in imp language?
Declare a cell with stream="stdin"
attribute and match an item in it, then you can get an input for it.
Please refer to IMP++
tutorial for details:
https://github.com/kframework/k/blob/master/k-distribution/tutorial/1_k/4_imp%2B%2B/lesson_8/imp.k#L189
https://github.com/kframework/k/blob/master/k-distribution/tutorial/1_k/4_imp%2B%2B/lesson_8/imp.k#L378-L379
Thank you sir for your kind help. sir one more thing I want to know that how to show the value of a variable during execution( for example: assume while loop, in each iteration variable value gets updated)... Is there any option to trace the program execution with krun command?
Thanking You.
With Regards. Harshita
On Sat, Mar 5, 2016 at 3:59 AM, Daejun Park [email protected] wrote:
Declare a cell with stream="stdin" attribute and match an item in it, then you can get an input for it.
Please refer to IMP++ tutorial for details:
https://github.com/kframework/k/blob/master/k-distribution/tutorial/1_k/4_imp%2B%2B/lesson_8/imp.k#L369
— Reply to this email directly or view it on GitHub https://github.com/kframework/k/issues/2153#issuecomment-192500672.
There is no explicit option for that, but you can easily modify (by augmenting) the semantics to print out values of variables whenever they are updated.
Printing out values is similar with reading inputs. Please refer to the following for details: https://github.com/kframework/k/blob/master/k-distribution/tutorial/1_k/4_imp%2B%2B/lesson_8/imp.k#L190 https://github.com/kframework/k/blob/master/k-distribution/tutorial/1_k/4_imp%2B%2B/lesson_8/imp.k#L405-L407
The --debugger flag to krun may also be of help here. https://github.com/kframework/k/wiki/K-Debugger
Thankyou sir for kind help. sir, i am writing program as int x,y; x=read(); // I assume read as high type y=x+5; // as x is high then y should also be high I m trying to write the rule using type system to make x and y of type high in k rule but not able to consumed the k cell. what rule should be added to print x and y of type high.
On Sat, Mar 5, 2016 at 3:59 AM, Daejun Park [email protected] wrote:
Declare a cell with stream="stdin" attribute and match an item in it, then you can get an input for it.
Please refer to IMP++ tutorial for details:
https://github.com/kframework/k/blob/master/k-distribution/tutorial/1_k/4_imp%2B%2B/lesson_8/imp.k#L369
— Reply to this email directly or view it on GitHub https://github.com/kframework/k/issues/2153#issuecomment-192500672.
In general, you can have additional information in the configuration, and control behavior using the information. For the type information, for example, you can either associate each variable to a tuple of its value and its type in your memory cell, or have a separate map from each variable to its type. Why don't you take a look: https://github.com/kframework/k/tree/master/k-distribution/tutorial/1_k/5_types/lesson_9
sir,I am getting problem to assign a new type( high or low ) to a variable which is of type int in k type system.kindly give me a little hint to write the rule for assigning new type.
On Thu, Mar 10, 2016 at 3:53 AM, Daejun Park [email protected] wrote:
In general, you can have additional information in the configuration, and control behavior using the information. For the type information, for example, you can either associate each variable to a tuple of its value and its type in your memory cell, or have a separate map from each variable to its type. Why don't you take a look: https://github.com/kframework/k/tree/master/k-distribution/tutorial/1_k/5_types/lesson_9
— Reply to this email directly or view it on GitHub https://github.com/kframework/k/issues/2153#issuecomment-194536948.
I have gone through https://github.com/kframework/k/tree/master/k-distribution/tutorial/1_k/5_types/lesson_9 but I am unable to understand as i am new lambda calculus.I am trying to assign a new type to a variable as i maintained in my previous mail. your rules for assigning new type to a variable will help us alot.Actually i need to flow the type of a variable from one statement to another statement(type inferencer).
On Wed, Mar 16, 2016 at 5:27 PM, HARSHITA GOSWAMI <[email protected]
wrote:
sir,I am getting problem to assign a new type( high or low ) to a variable which is of type int in k type system.kindly give me a little hint to write the rule for assigning new type.
On Thu, Mar 10, 2016 at 3:53 AM, Daejun Park [email protected] wrote:
In general, you can have additional information in the configuration, and control behavior using the information. For the type information, for example, you can either associate each variable to a tuple of its value and its type in your memory cell, or have a separate map from each variable to its type. Why don't you take a look: https://github.com/kframework/k/tree/master/k-distribution/tutorial/1_k/5_types/lesson_9
— Reply to this email directly or view it on GitHub https://github.com/kframework/k/issues/2153#issuecomment-194536948.
I am getting problem to assign a new type( high or low ) to a variable which is of type int in k type system
What is the problem specifically?
I am trying to write a rule which can assign value of that type on that statement,further that value should be used if the behaviour change. for example, int x,y; x = read(); // as we taking input from user x should become high type y = x; // as x is assign to y therefore y will become of high type i m trying to write k rule for that statement but didn't get success in doing that. x value get map at that position but it will not have effect on further statement.(like type inferencer ). I m trying to use that effect on further position.if possible please provide me rule for that so that i can use it.
On Wed, Mar 16, 2016 at 7:48 PM, Cosmin Radoi [email protected] wrote:
I am getting problem to assign a new type( high or low ) to a variable which is of type int in k type system
What is the problem specifically?
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/kframework/k/issues/2153#issuecomment-197351382
@20harshita, tutorial/1_k/5_types/lesson_9 is a good example of how you can do this.
What is the precise problem you are encountering? Does K throw an error? Is there a specific rule that you expect to be applied and it isn't?
If you simply do not know how to approach this in general, the K tutorial should give you answers to most questions: http://www.kframework.org/index.php/K_Tutorial