2005-11-16 16:49:47 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2005-11-16 19:07:19 +00:00
|
|
|
import pprint
|
|
|
|
|
2005-11-16 18:19:50 +00:00
|
|
|
def unfold(arg):
|
|
|
|
for x in arg:
|
2005-11-16 19:07:19 +00:00
|
|
|
pprint.pprint(x)
|
|
|
|
|
|
|
|
def intruderKnowledge(x):
|
|
|
|
print "Intruder knowledge"
|
2005-11-16 19:37:42 +00:00
|
|
|
print x[0], str(x[1])
|
2005-11-16 19:07:19 +00:00
|
|
|
|
|
|
|
def scenario(x):
|
|
|
|
print "Scenario",x,"ignoring for now"
|
2005-11-16 18:19:50 +00:00
|
|
|
|
|
|
|
def initialState(arg):
|
2005-11-16 19:07:19 +00:00
|
|
|
arg = arg[0] # One level deeper (has no implication rule)
|
2005-11-16 18:19:50 +00:00
|
|
|
print "Initial State"
|
2005-11-16 19:07:19 +00:00
|
|
|
print len(arg)
|
|
|
|
for x in arg:
|
|
|
|
if x[0] == "h":
|
|
|
|
print "Some stupid semi time thing"
|
|
|
|
if x[0] == "i":
|
|
|
|
intruderKnowledge(x),"ignoring for now"
|
|
|
|
elif x[0] == "w":
|
|
|
|
scenario(x)
|
2005-11-16 18:19:50 +00:00
|
|
|
|
2005-11-16 19:07:19 +00:00
|
|
|
# Ignore for now
|
2005-11-16 18:19:50 +00:00
|
|
|
def protocolRules(arg):
|
2005-11-16 19:07:19 +00:00
|
|
|
return
|
2005-11-16 18:19:50 +00:00
|
|
|
|
|
|
|
# Goals: ignored for now
|
|
|
|
def goal(arg):
|
|
|
|
return
|
|
|
|
|
|
|
|
def labeledRule(lr):
|
|
|
|
type = None
|
|
|
|
label = None
|
|
|
|
if lr[0] == "lb":
|
|
|
|
label = lr[1]
|
|
|
|
if lr[2] == "type":
|
|
|
|
type = lr[3]
|
|
|
|
arg = lr[4]
|
|
|
|
|
|
|
|
if type == "Init":
|
|
|
|
initialState(arg)
|
|
|
|
elif type == "Protocol_Rules":
|
|
|
|
protocolRules(arg)
|
|
|
|
elif type == "Goal":
|
|
|
|
goal(arg)
|
|
|
|
|
2005-11-16 16:49:47 +00:00
|
|
|
def generateSpdl(ll):
|
2005-11-16 18:19:50 +00:00
|
|
|
if ll[0] == "option":
|
|
|
|
print "Option [" + ll[1] + "]"
|
|
|
|
for i in ll[2]:
|
|
|
|
labeledRule(i)
|
|
|
|
return
|
|
|
|
|
|
|
|
print "Not understood element: "
|
2005-11-16 16:49:47 +00:00
|
|
|
print ll[0]
|