Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NPTAV2Maude
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
NPTAV2Maude
Commits
c24dc165
Commit
c24dc165
authored
1 year ago
by
Jaime Arias
Browse files
Options
Downloads
Patches
Plain Diff
update README
parent
3b4b5cf3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
nptav2maude/README.md
+6
-8
6 additions, 8 deletions
nptav2maude/README.md
nptav2maude/app.py
+1
-1
1 addition, 1 deletion
nptav2maude/app.py
nptav2maude/src/Parser.py
+38
-60
38 additions, 60 deletions
nptav2maude/src/Parser.py
with
45 additions
and
69 deletions
nptav2maude/README.md
+
6
−
8
View file @
c24dc165
...
...
@@ -26,23 +26,21 @@ It takes as input an [`Imitator`](https://www.imitator.fr/) model and returns an
specification.
```
python3 app.py -
-help
usage: app.py [-h] [--output OUTPUT]
[--collapsing | --no-collapsing]
--input INPUT
λ>
python3 app.py -
h
usage: app.py [-h] [--output OUTPUT] --input INPUT
From Imitator to Maude specifications
options:
-h, --help show this help message and exit
--output OUTPUT Maude output file (default: ./model.maude)
--collapsing, --no-collapsing
Use collapsing approach (default: False)
--input INPUT Imitator file (default: None)
-h, --help show this help message and exit
--output OUTPUT Maude output file (default: ./model.maude)
--input INPUT Imitator file (default: None)
```
Next, an example of use:
```
python3 app.py
--no-collapsing
--input tests/examples/
ex1x
.imi
python3 app.py --input tests/examples/
coffee
.imi
```
## Running Test
...
...
This diff is collapsed.
Click to expand it.
nptav2maude/app.py
+
1
−
1
View file @
c24dc165
import
argparse
from
src.Parser
import
CollapsingParser
,
InterpreterParser
,
NoCollapsing
Parser
from
src.Parser
import
Interpreter
Parser
def
main
(
input_filename
,
output_filename
):
...
...
This diff is collapsed.
Click to expand it.
nptav2maude/src/Parser.py
+
38
−
60
View file @
c24dc165
import
os
import
re
import
textwrap
from
abc
import
ABC
,
abstractmethod
import
antlr4
from
src.dist.ImitatorLexer
import
ImitatorLexer
from
src.dist.ImitatorParser
import
ImitatorParser
from
src.Imitator
import
Automaton
,
Location
,
Model
,
Transition
from
src.Imitator
import
Automaton
,
Model
,
Transition
from
src.ImitatorVisitor
import
MyVisitor
from
src.Maude
import
ImportType
,
Maude
class
Parser
(
ABC
):
"""
An abstract class to represent the parser of Imitator
Attributes
----------
maude : Maude
Object containing methods to generate Maude statements
"""
def
__init__
(
self
)
->
None
:
"""
Constructor of the class
"""
self
.
maude
=
Maude
()
@abstractmethod
def
to_maude
(
self
,
model
:
Model
)
->
str
:
"""
Parse Imitator model to Maude model
"""
pass
def
parse_file
(
self
,
filename
:
str
)
->
str
:
"""
Parse an Imitator file into a Maude model
Parameters
----------
filename : str
Imitator file
sync_product : bool
Computes the synchronisation product of the automata
Returns
-------
str
"""
fs_in
=
antlr4
.
FileStream
(
filename
,
encoding
=
"
utf8
"
)
# lexer
lexer
=
ImitatorLexer
(
fs_in
)
stream
=
antlr4
.
CommonTokenStream
(
lexer
)
# parser
parser
=
ImitatorParser
(
stream
)
tree
=
parser
.
main
()
# evaluator
visitor
=
MyVisitor
()
model
=
visitor
.
visit
(
tree
)
# parse to Maude
output
=
self
.
to_maude
(
model
)
return
output
class
InterpreterParser
(
Parser
):
class
InterpreterParser
:
"""
A class to represent the parser of Imitator to Maude using the interpreter version
"""
def
__init__
(
self
)
->
None
:
"""
Constructor of the class
"""
s
uper
().
__init__
()
s
elf
.
maude
=
Maude
()
def
_get_parameter_constraints
(
self
,
model
)
->
list
[
str
]:
"""
Get the initial constraints of parameters
...
...
@@ -440,3 +383,38 @@ class InterpreterParser(Parser):
"""
return
textwrap
.
dedent
(
model_str
).
strip
()
def
parse_file
(
self
,
filename
:
str
)
->
str
:
"""
Parse an Imitator file into a Maude model
Parameters
----------
filename : str
Imitator file
sync_product : bool
Computes the synchronisation product of the automata
Returns
-------
str
"""
fs_in
=
antlr4
.
FileStream
(
filename
,
encoding
=
"
utf8
"
)
# lexer
lexer
=
ImitatorLexer
(
fs_in
)
stream
=
antlr4
.
CommonTokenStream
(
lexer
)
# parser
parser
=
ImitatorParser
(
stream
)
tree
=
parser
.
main
()
# evaluator
visitor
=
MyVisitor
()
model
=
visitor
.
visit
(
tree
)
# parse to Maude
output
=
self
.
to_maude
(
model
)
return
output
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