Skip to Content.
Sympa Menu

k-user - [[K-user] ] How to iterate through list

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

[[K-user] ] How to iterate through list


Chronological Thread 
  • From: "Ayushi Rastogi" <rastogiayushi98 AT gmail.com>
  • To: k-user AT lists.cs.illinois.edu
  • Subject: [[K-user] ] How to iterate through list
  • Date: Mon, 10 Jun 2019 23:56:30 -0500

Respected Sir/Mam

I have been working on K framework from last few days and while working on
same, I am facing following problems:
I defined a list called Glist as follows:
syntax L ::= String
syntax Global ::= Id "," L
syntax Glist ::={Global,","}
Now while writing semantics I wanted to check whether particular id "X" exist
in the list "Glist" or not without knowing value of L. The check applied must
return bool value.
Also if the value X exists in Glist then the L portion of corresponding X must
be replaced with another string S. I have tried to solve the problem using if
else rule as follows:
syntax AExp ::= Int | Id
> AExp "+" AExp
syntax Str ::= String
| Id
| String "+String" String
| Str "$" Str
| "(" Str ")"
rule S1 +String S2 => S1S2 //for concatenation
rule S1 $ S2 => S1 +String S2 when S1=/=String S2
rule X in X, _ => true
rule X in .Glist => false
rule X in _, G => X in G [owise]
/* In the following rule,Pc is a temporary variable that I want to create with
a particular string value p at the moment parameters are passed but I could
not find suitable method to implement the same .Also statement X:=X $ Pc must
change the L value of X(Id) in Glist as X$ Pc is a string from above code
snippets */

rule X:Id:=R:AExp; => if (notBool(X in Glist)) begin if (X =/=String (R $
Pc)) halt; else begin end end else X:= X $ Pc

I hope you would help me solve my query and direct me with possible solution
to help me with same

Thank you



Archive powered by MHonArc 2.6.19.

Top of Page