-
Notifications
You must be signed in to change notification settings - Fork 1
/
mptc
executable file
·59 lines (50 loc) · 2.36 KB
/
mptc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
import sys
from os.path import abspath
from parser.parser import Parser
from codegen.codegen import CodeGenCpp
import argparse
def main(args):
parser = Parser()
ast, mpt = parser.parse_path(args.input_mpt)
#mpt.todot()
# print(ast.pretty())
codegen = CodeGenCpp(args)
codegen.generate(mpt)
def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument('inputs', nargs='+', help='Input files (.mpt, .src, additional C++ files')
parser.add_argument('--out-dir', action='store', default="/tmp/mpt", help='Output directory (default: /tmp/mpt)')
parser.add_argument('--build-type', action='store', help='Force build type for the CMake project')
parser.add_argument('--debug', action='store_true', help='Debugging mode')
parser.add_argument('--exit-on-error', action='store_true', help='Stop when a violation is found')
parser.add_argument('--verbose', '-v', action='store_true', help='Print more messages')
parser.add_argument('--stats', action='store_true', help='Gather statistics')
parser.add_argument('-D', action='append', default=[], help='Additional CMake definitions')
parser.add_argument('--reduction', action='append', default=[], choices=["symmetry", "reflexivity"],
help='Do not process pairs reflexive and symmetric pairs of traces')
parser.add_argument('--overwrite-default', action='append', default=[],
help="Do not generate the default version of the given file, its replacement is assumed to be "
"provided as an additional source.")
args = parser.parse_args()
args.input_mpt = None
args.cpp_files = []
args.sources_def = None
args.cmake_defs = args.D
for fl in args.inputs:
if fl.endswith(".mpt"):
if args.input_mpt:
raise RuntimeError("Multiple .mpt files given")
args.input_mpt = fl
elif fl.endswith(".cpp") or fl.endswith(".h") or\
fl.endswith(".hpp") or fl.endswith(".cxx") or fl.endswith("cc"):
args.cpp_files.append(abspath(fl))
elif fl.endswith(".src"):
if args.sources_def:
raise RuntimeError("Multiple .src files given")
args.sources_def = fl
print(args)
return args
if __name__ == "__main__":
args = parse_arguments()
main(args)