Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pta2maude
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
real-time maude
pta2maude
Commits
644bea0b
Commit
644bea0b
authored
1 year ago
by
Jaime Arias
Browse files
Options
Downloads
Patches
Plain Diff
wip: fix order in the display of clocks, params, etc.
parent
e77602e8
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pta2maude/src/Parser.py
+8
-12
8 additions, 12 deletions
pta2maude/src/Parser.py
pta2maude/tests/examples/coffee-intrpr.maude
+37
-33
37 additions, 33 deletions
pta2maude/tests/examples/coffee-intrpr.maude
pta2maude/tests/test_parser.py
+1
-1
1 addition, 1 deletion
pta2maude/tests/test_parser.py
with
46 additions
and
46 deletions
pta2maude/src/Parser.py
+
8
−
12
View file @
644bea0b
...
@@ -842,29 +842,27 @@ class InterpreterParser(Parser):
...
@@ -842,29 +842,27 @@ class InterpreterParser(Parser):
return
result
return
result
def
_get_preamble
(
self
,
model
:
Model
)
->
str
:
def
_get_preamble
(
self
,
model
:
Model
)
->
str
:
clocks
=
model
.
clocks
parameters
=
model
.
parameters
# locations
# locations
locations
=
[
locations
=
sorted
(
loc
.
name
for
automaton
in
model
.
automata
for
loc
in
automaton
.
locations
[
loc
.
name
for
automaton
in
model
.
automata
for
loc
in
automaton
.
locations
]
]
)
locations_str
=
self
.
maude
.
operators
(
locations
,
[],
"
Location
"
,
[
"
ctor
"
])
locations_str
=
self
.
maude
.
operators
(
locations
,
[],
"
Location
"
,
[
"
ctor
"
])
# actions
# actions
actions
=
[
a
for
a
in
model
.
actions
]
actions
=
sorted
(
model
.
actions
)
actions_str
=
self
.
maude
.
operators
(
actions
,
[],
"
Action
"
,
[
"
ctor
"
])
actions_str
=
self
.
maude
.
operators
(
actions
,
[],
"
Action
"
,
[
"
ctor
"
])
# automata label
# automata label
names
=
[
automaton
.
name
for
automaton
in
model
.
automata
]
names
=
sorted
(
[
automaton
.
name
for
automaton
in
model
.
automata
]
)
names_str
=
self
.
maude
.
operators
(
names
,
[],
"
Agent
"
,
[
"
ctor
"
])
names_str
=
self
.
maude
.
operators
(
names
,
[],
"
Agent
"
,
[
"
ctor
"
])
# clocks
# clocks
clocks
=
[
clock
for
clock
in
model
.
clocks
]
clocks
=
sorted
(
model
.
clocks
)
clocks_str
=
self
.
maude
.
operators
(
clocks
,
[],
"
Clock
"
,
[
"
ctor
"
])
clocks_str
=
self
.
maude
.
operators
(
clocks
,
[],
"
Clock
"
,
[
"
ctor
"
])
# parameters
# parameters
parameters
=
[
param
for
param
in
model
.
parameters
]
parameters
=
sorted
(
model
.
parameters
)
parameters_str
=
self
.
maude
.
operators
(
parameters
,
[],
"
Parameter
"
,
[
"
ctor
"
])
parameters_str
=
self
.
maude
.
operators
(
parameters
,
[],
"
Parameter
"
,
[
"
ctor
"
])
preamble
=
f
"""
preamble
=
f
"""
...
@@ -968,7 +966,7 @@ class InterpreterParser(Parser):
...
@@ -968,7 +966,7 @@ class InterpreterParser(Parser):
locations_str
=
f
"
,
\n
{
tab
}
"
.
join
(
locations
)
locations_str
=
f
"
,
\n
{
tab
}
"
.
join
(
locations
)
eq_str
=
(
eq_str
=
(
f
"
eq
{
name
.
title
()
}
= <
{
initial_state
}
|
\n
{
tab
}
{
locations_str
}
\n
{
tab
}
>
.
"
f
"
eq
{
name
.
title
()
}
= <
{
initial_state
}
|
\n
{
tab
}
{
locations_str
}
>
\n
{
tab
}
.
"
)
)
result
=
f
"""
result
=
f
"""
...
@@ -997,10 +995,8 @@ class InterpreterParser(Parser):
...
@@ -997,10 +995,8 @@ class InterpreterParser(Parser):
mod MODEL is
mod MODEL is
{
import_dynamics
}
{
import_dynamics
}
{
preamble
}
{
preamble
}
{
equations
}
{
equations
}
{
init
}
{
init
}
{
variables
}
{
variables
}
endm
endm
...
...
This diff is collapsed.
Click to expand it.
pta2maude/tests/examples/coffee-intrpr.maude
+
37
−
33
View file @
644bea0b
load Semantics .
load Semantics .
mod MODEL is
mod MODEL is
extending
DYNAMICS .
extending DYNAMICS .
ops
idle sugar coffee cdone
: -> Location [ctor] .
ops
cdone coffee idle sugar
: -> Location [ctor] .
ops
cup
coffee press sleep : -> Action [ctor] .
ops coffee
cup
press sleep : -> Action [ctor] .
op
s
machine
: -> Agent [ctor] .
op machine : -> Agent [ctor] .
ops x y
: -> Clock [ctor] .
ops x y : -> Clock [ctor] .
ops p1 p2 p3
: -> Parameter [ctor] .
ops p1 p2 p3 : -> Parameter [ctor] .
op Machine : -> Automaton .
op Machine : -> Automaton .
eq Machine = < machine @ idle |
eq Machine = < machine @ idle |
(@ idle inv true :
(@ idle inv true :
(when true local press do { x := 0 ; y := 0 } goto sugar)),
(when true local press do { x := 0 ; y := 0 } goto sugar)),
(@ sugar inv y <= p2 :
(@ sugar inv y <= p2 :
(when p1 <= x
local press do { x := 0 } goto sugar ;
(when x >= p1
local press do { x := 0 } goto sugar ;
when y = p2 local cup goto coffee)),
when y = p2 local cup goto coffee)),
(@ coffee inv y <= p3 :
(@ coffee inv y <= p3 :
(when y = p3 local coffee do { x := 0 } goto cdone)),
(when y = p3 local coffee do { x := 0 } goto cdone)),
(@ cdone inv x <= 10 :
(@ cdone inv x <= 10 :
(when true local press do { x := 0 ; y := 0 } goto sugar ;
(when true local press do { x := 0 ; y := 0 } goto sugar ;
when x = 10 local sleep goto idle))
when x = 10 local sleep goto idle))
>
>
.
.
op init : -> State .
op init : -> State .
eq init = { Machine }
eq init = { Machine }
< tick: tickOk
< tick: tickOk
clocks: (x : 0, y : 0)
clocks: (x : 0, y : 0)
parameters: (p1 : 1, p2 : 1, p3 : 1)
parameters: (p1 : 1, p2 : 1, p3 : 1)
dvariables: empty >
dvariables: empty >
.
.
--- -------------------------
--- -------------------------
var NET
: Network .
var NET : Network .
var CLOCKS : SetAssignment .
var CLOCKS : SetAssignment .
var PARAMS : SetAssignment .
var PARAMS : SetAssignment .
var DVARS
: SetAssignment .
var DVARS : SetAssignment .
var SSTDEF : SStateDef .
var SSTDEF : SStateDef .
--- -------------------------
--- -------------------------
endm
endm
search [1] init =>* { < machine @ cdone | SSTDEF > } < tick: tickNotOk clocks: CLOCKS parameters: PARAMS dvariables: DVARS > .
search [1] init =>* { < machine @ cdone | SSTDEF > } < tick: tickNotOk clocks: CLOCKS parameters: PARAMS dvariables: DVARS > .
\ No newline at end of file
quit .
eof
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pta2maude/tests/test_parser.py
+
1
−
1
View file @
644bea0b
...
@@ -29,7 +29,7 @@ def test_parser(examples_dir, imitator_file, maude_file, version):
...
@@ -29,7 +29,7 @@ def test_parser(examples_dir, imitator_file, maude_file, version):
elif
version
==
"
no-collapsing
"
:
elif
version
==
"
no-collapsing
"
:
parser
=
NoCollapsingParser
()
parser
=
NoCollapsingParser
()
elif
version
==
"
interpreter
"
:
elif
version
==
"
interpreter
"
:
parser
=
InterpreterParser
parser
=
InterpreterParser
()
else
:
else
:
raise
Exception
(
f
"
the version
'
{
version
}
'
is not supported
"
)
raise
Exception
(
f
"
the version
'
{
version
}
'
is not supported
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment