Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
V
VerifyTESLA
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
joydeep
VerifyTESLA
Commits
65de0238
Commit
65de0238
authored
May 14, 2015
by
Andrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added code for handling errors where a Substitution is not properly sorted.
parent
01867425
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
10 deletions
+22
-10
PSL-Syntax.maude
PSL-Syntax.maude
+1
-0
psl.maude
psl.maude
+1
-1
psl.py
psl.py
+20
-9
No files found.
PSL-Syntax.maude
View file @
65de0238
...
...
@@ -336,6 +336,7 @@ fmod ATTACK-SYNTAX is
op _|->_ : Msg MsgNumSet -> MsgPair [prec 30] .
op $none : -> MsgPairs .
op __ : MsgPairs MsgPairs -> MsgPairs [ctor assoc comm id: $none] .
op _$$$;;;$$$_ : [MsgPairs] [MsgPairs] -> [MsgPairs] [ctor assoc comm id: $none] .
---Stores the information on an invalid substitution. The Python code
---invoking this Maude code then scans the output for the presence of
---this term. If the Python code finds this term, then it extracts the
...
...
psl.maude
View file @
65de0238
...
...
@@ -809,7 +809,7 @@ rl [translateAttackWithoutNever] :
eq $checkSorts($none) = id .
---Checks if the sort of the first argument is a supersort of the sort of
---the second ar
ug
ment.
---the second ar
gu
ment.
op $isValidPair : Msg Msg Nat -> Mapping .
ceq $isValidPair(D:Msg, R:Msg, N) =
if sortLeq(META-MOD:Module, getType(metaReduce(META-MOD:Module, upTerm(R:Msg))), getType(metaReduce(META-MOD:Module, upTerm(D:Msg))))
...
...
psl.py
View file @
65de0238
...
...
@@ -274,7 +274,7 @@ def maudify():
theoryFileName
=
build_theory
(
parseTree
,
os
.
path
.
dirname
(
pslFilePath
),
fileName
)
#TODO: Need to invoke different functions depending on whether we're doing protocol composition, or normal PSL translation.
intermediate
=
gen_intermediate
(
parseTree
,
theoryFileName
)
gen_NPA_code
(
intermediate
,
theoryFileName
)
gen_NPA_code
(
intermediate
,
theoryFileName
,
parseTree
)
DEF_KEY_ROLE
=
0
DEF_KEY_TERM
=
1
...
...
@@ -325,7 +325,7 @@ def gen_intermediate(parseTree, theoryFileName):
code
.
append
(
'.'
)
return
code
def
gen_NPA_code
(
maudeCode
,
theoryFileName
):
def
gen_NPA_code
(
maudeCode
,
theoryFileName
,
parseTree
):
maudeCommand
=
[
MAUDE_COMMAND
,
NO_PRELUDE
,
'-no-banner'
,
'-no-advise'
,
'-no-wrap'
,
PRELUDE
,
NPA_SYNTAX
,
theoryFileName
,
TRANSLATION_FILE
]
maudeExecution
=
subprocess
.
Popen
(
maudeCommand
,
stdout
=
subprocess
.
PIPE
,
...
...
@@ -370,7 +370,7 @@ def gen_NPA_code(maudeCode, theoryFileName):
except
ValueError
:
errorResult
=
"result [TranslationData]:"
errorIndex
=
stdout
.
index
(
errorResult
)
+
len
(
errorResult
)
process_error
(
stdout
[
errorIndex
:])
process_error
(
stdout
[
errorIndex
:]
,
parseTree
)
else
:
endOfModule
=
stdout
.
rfind
(
"Maude>"
)
module
=
'
\n
'
+
stdout
[
index
:
endOfModule
].
strip
()
...
...
@@ -378,7 +378,7 @@ def gen_NPA_code(maudeCode, theoryFileName):
maudeFile
.
write
(
module
)
maudeFile
.
write
(
'
\n
select MAUDE-NPA .'
)
def
process_error
(
error
):
def
process_error
(
error
,
parseTree
):
"""
Given a partially evaluated PSL specification, extracts the offending error term, and extracts from the error term the information
need for a usable error message. Then raises a TranslationError containing said usable error message.
...
...
@@ -427,7 +427,18 @@ def process_error(error):
in
zip
(
problemTerms
,
lineNumbers
)])]))
raise
pslErrors
.
TranslationError
(
'
\n
'
.
join
(
errorMsg
))
elif
errorType
.
strip
()
==
"$$$invalidSorting"
:
pass
var
,
termLineNum
=
[
s
.
strip
()
for
s
in
errorTerm
.
split
(
'|->'
)]
var
,
variableSort
=
var
.
split
(
':'
)
termLineNum
=
termLineNum
.
replace
(
'${'
,
''
).
replace
(
'}$'
,
''
)
lineNumberIndex
=
termLineNum
.
rindex
(
';'
)
+
1
lineNum
=
termLineNum
[
lineNumberIndex
:].
strip
()
term
=
termLineNum
[:
lineNumberIndex
-
1
].
strip
()
raise
pslErrors
.
TranslationError
(
' '
.
join
([
pslErrors
.
error
,
pslErrors
.
color_line_number
(
lineNum
),
"Variable"
,
pslErrors
.
color_token
(
var
),
"has sort"
,
pslErrors
.
color_token
(
variableSort
),
"but term"
,
pslErrors
.
color_token
(
term
),
"does not."
]))
...
...
@@ -451,7 +462,7 @@ def compute_end_of_term(errorType, errorTerm):
raise
ValueError
(
' '
.
join
([
"End of error term of type: "
,
errorType
,
"not found when trying to extract the term from:"
,
errorTerm
]))
MAX_ITERATIONS
=
100
def
compute_sorts
(
defMap
,
syntaxFileName
,
p
sl
Tree
):
def
compute_sorts
(
defMap
,
syntaxFileName
,
p
arse
Tree
):
"""
Computes the sorts of the user-defined shorthand.
...
...
@@ -464,7 +475,7 @@ def compute_sorts(defMap, syntaxFileName, pslTree):
Returns a dictionary mapping shorthand to their respective sorts.
"""
is_function
(
defMap
)
role_variables_correct
(
defMap
,
p
sl
Tree
)
role_variables_correct
(
defMap
,
p
arse
Tree
)
SHORTHAND
=
0
LINE_NUMBER
=
1
ROLE
=
0
...
...
@@ -563,14 +574,14 @@ def is_function(defMap):
else
:
definedShorthand
[
shorthand
]
=
(
term
,
lineNumber
)
def
role_variables_correct
(
defMap
,
p
sl
Tree
):
def
role_variables_correct
(
defMap
,
p
arse
Tree
):
"""
Given a mapping from pairs (role, term) |-> (shorthand, lineNum)
checks to make sure that the variables in term are allowed
to show up in terms associated with role.
"""
#Working on modifying the disjoint_vars code from pslTree.py to work here.
protocol
=
p
sl
Tree
.
get_protocol
()
protocol
=
p
arse
Tree
.
get_protocol
()
roleMap
=
protocol
.
variables_per_role
()
declaredVars
=
protocol
.
declared_variables
()
roleTermPairs
=
defMap
.
keys
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment