-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwoof.py
executable file
·50 lines (38 loc) · 1022 Bytes
/
woof.py
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
#!/usr/bin/env python3
import argparse
import os
from antlr4 import FileStream
from src.engine.engine import Engine
parser = argparse.ArgumentParser(description='Woof: An interpreter for Datalog with Well Founded semantics.')
parser.add_argument(
'file',
metavar='F',
type=str,
help='Woof Datalog program file'
)
parser.add_argument(
'--print',
action='store_true',
required=False,
default=False,
dest='print',
help='Print true and unknown facts to stdout'
)
parser.add_argument(
'--output',
type=str,
required=False,
default=None,
dest='output_dir',
help='If specified, true and unknown facts will be output in the directory',
)
args = parser.parse_args()
if __name__ == '__main__':
engine = Engine(FileStream(args.file))
engine.run()
if args.print:
engine.print_all()
if args.output_dir:
if not os.path.exists(args.output_dir):
os.makedirs(args.output_dir)
engine.output_all(args.output_dir)