-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmc.py
More file actions
52 lines (40 loc) · 1.24 KB
/
smc.py
File metadata and controls
52 lines (40 loc) · 1.24 KB
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
import logging.config
import os
from stack_machine.driver import Driver
from stack_machine.setup_logger import setup_logger
from optparse import OptionParser
from optparse_mooi import CompactColorHelpFormatter
logger = logging.getLogger(__name__)
BASE_DIR = os.path.dirname(__file__)
def main():
parser = OptionParser(
formatter=CompactColorHelpFormatter(),
usage="usage: python ./%prog [options] filename",
version="%prog 0.1"
)
parser.add_option(
"-o", "--output",
action="store",
dest="output_file",
default=None,
help="File name for executable code",
)
parser.add_option(
"-k", "--keep-ir",
action="store_true",
dest="keep",
default=False,
help="Keep intermediate files"
)
(options, args) = parser.parse_args()
if len(args) != 1:
parser.error("wrong option. Check --help option")
input_file_name = args[0]
output_file_name = options.output_file
if not output_file_name:
output_file_name = input_file_name.split('.')[0] + ".out"
setup_logger(BASE_DIR)
driver = Driver(BASE_DIR, input_file_name, output_file_name, options.keep)
driver.compile()
if __name__ == "__main__":
main()