-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.py
114 lines (89 loc) · 3.38 KB
/
main.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import sys
import yaml
import re
from typing import (
Optional,
List,
cast
)
from sigmaF.repl import (
start_repl,
read_module
)
_SIGMAF_: str = """
. .
d888888o. 8 8888 ,o888888o. ,8. ,8. .8. 8 8888888888
.`8888:' `88. 8 8888 8888 `88. ,888. ,888. .888. 8 8888
8.`8888. Y8 8 8888 ,8 8888 `8. .`8888. .`8888. :88888. 8 8888
`8.`8888. 8 8888 88 8888 ,8.`8888. ,8.`8888. . `88888. 8 8888
`8.`8888. 8 8888 88 8888 ,8'8.`8888,8^8.`8888. .8. `88888. 8 888888888888
`8.`8888. 8 8888 88 8888 ,8' `8.`8888' `8.`8888. .8`8. `88888. 8 8888
`8.`8888. 8 8888 88 8888 8888888 ,8' `8.`88' `8.`8888. .8' `8. `88888. 8 8888
8b `8.`8888. 8 8888 `8 8888 .8',8' `8.`' `8.`8888. .8' `8. `88888. 8 8888
`8b. ;8.`8888 8 8888 8888 ,88',8' `8 `8.`8888. .888888888. `88888. 8 8888
`Y8888P ,88P' 8 8888 `8888888P' ,8' ` `8.`8888. .8' `8. `88888. 8 8888
"""
def show_cover(version):
global _SIGMAF_
print('-'*106)
print(
f'\n\nWelcome to SigmaF v{version}, the Program Language of the future for the Programming Functional and a lot more\n\n{_SIGMAF_}')
print('-'*106)
def show_head(version):
print(f'SigmaF v{version} | Exit: exit() | Update: update()')
def get_configs():
with open('configs.yaml', 'r') as fin:
configs = yaml.load(fin, Loader=yaml.FullLoader)
return dict(configs)
def presentation_config(configs, params, exe_file=False):
version = configs['version']
if not params is None:
if exe_file:
if '-cover' in params:
show_cover(version)
return
show_head(version)
else:
if not '-ncover' in params:
show_cover(version)
return
show_head(version)
else:
if exe_file:
show_head(version)
else:
show_cover(version)
def main(path=None, params=None) -> None:
configs = get_configs()
if not params is None and '-version' in params:
version = configs['version']
print(f'SigmaF v{version}')
return
if path is None:
presentation_config(configs, params, exe_file=False)
start_repl()
elif not path is None:
presentation_config(configs, params, exe_file=True)
src = read_module(path)
if not src is None:
start_repl(src, path)
def filter_path_params(args):
path = list(filter(lambda s: not re.match('(\S+?\.sf$)', s) is None, args))
params = list(filter(lambda s: s.startswith('-'), args))
if len(path) > 0:
path = path[0]
else:
path = None
if len(params) == 0:
params = None
return path, params
if __name__ == '__main__':
args: List[str] = sys.argv
if len(args) > 1:
path, params = filter_path_params(args)
else:
path, params = None, None
try:
main(path, params)
except KeyboardInterrupt:
print('\n↳ Good bye \n')