-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCUTE.PY
More file actions
executable file
·92 lines (83 loc) · 2.11 KB
/
CUTE.PY
File metadata and controls
executable file
·92 lines (83 loc) · 2.11 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
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
#!/usr/bin/python
import sys
import os
namestr = 'CUTEBASIC'
version = '2.0a'
keywords = {
'lang' : 'shorthand',
'dialects' : 'none',
'use' : 'use',
'def' : 'def',
'bef' : 'bef',
'aft' : 'aft',
'ret' : 'ret',
'opt' : 'opt',
'newline' : 'newline',
'0+' : '0+',
'1+' : '1+',
'choose' : 'choose',
'incl' : 'incl',
'name' : 'name',
'none' : 'none',
'asm' : 'asm',
'asmstart' : 'asmstart',
'cbstart' : 'cbstart',
'asmend' : 'asmend',
'cbend' : 'cbend',
'start' : 'start',
'end' : 'end',
'var' : 'var',
'stmt' : 'stmt',
'ig' : 'ig',
'exit' : 'exit',
'let' : 'let',
'=' : '=',
'is' : 'is',
'if' : 'if',
'elif' : 'elif',
'else' : 'else',
'endif' : 'endif',
'while' : 'while',
'endwhile' : 'endwhile',
'breakloop' : 'breakloop',
'breakif' : 'breakif',
'lbl' : 'lbl',
'goto' : 'goto'
}
useage = {
'def' : {
'bef' : ['none'],
'aft' : [
'newline', 'use', 'stmt',
'newline', 'bef', '1+', 'var',
'newline', 'aft', '1+', 'var',
'newline', 'ret', '1+', 'var',
'newline', 'choose', 'asmstart', 'cutestart'
'newline', '1+', 'stmt',
'newline', 'choose', 'asmend', 'cuteend'
],
'ret' : ['none'],
'use' : ""
}
}
if __name__ == "__main__":
if len(sys.argv) > 1:
with open(sys.argv[1]) as f:
for line in f:
replaces = line.split()
if len(replaces) > 1:
if keywords.get(replaces[0].strip()) != None:
if replaces[0].strip() == 'lang' or replaces[0].strip() == 'dialects':
keywords[replaces[0].strip()] = replaces[1].strip()
else:
keywords[replaces[1].strip()] = replaces[0].strip()
keywords[replaces[0].strip()] = replaces[1].strip()
if len(replaces) > 2:
if keywords.get(replaces[2].strip()) == 'use':
if useage.get(replaces[0].strip()) == None:
useage[replaces[0].strip()] = {'bef' : [], 'aft' : [], 'ret' : [], 'use': "" }
useage[replaces[0].strip()]['use'] = " ".join(replaces[3:])
print namestr + " " + version + " for " + keywords['lang'],
if keywords['dialects'] != "":
print "- " + keywords['dialects']
def printuseage( key ):