forked from paulwratt/bas-2.5-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.py
196 lines (190 loc) · 8.02 KB
/
temp.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import re
code = r'''
table[]=
{
/* 0 */ {(const char*)0,-1},
/* T_ACCESS_READ */ {"access read",1},
/* T_ACCESS_READ_WRITE */ {"access read write",1},
/* T_ACCESS_WRITE */ {"access write",1},
/* T_AND */ {"and",1},
/* T_AS */ {"as",1},
/* T_CALL */ {"call",1},
/* T_CASEELSE */ {"case else",1},
/* T_CASEVALUE */ {"case",1},
/* T_CHANNEL */ {"#",0},
/* T_CHDIR */ {"chdir",1},
/* T_CLEAR */ {"clear",1},
/* T_CLOSE */ {"close",1},
/* T_CLS */ {"cls",1},
/* T_COLON */ {":",1},
/* T_COLOR */ {"color",1},
/* T_COMMA */ {",",0},
/* T_CON */ {"con",0},
/* T_COPY */ {"copy",1},
/* T_CP */ {")",0},
/* T_DATA */ {"data",1},
/* T_DATAINPUT */ {(const char*)0,0},
/* T_DEC */ {"dec",1},
/* T_DEFDBL */ {"defdbl",1},
/* T_DEFFN */ {"def",1},
/* T_DEFINT */ {"defint",1},
/* T_DEFPROC */ {"def",1},
/* T_DEFSTR */ {"defstr",1},
/* T_DELETE */ {"delete",1},
/* T_DIM */ {"dim",1},
/* T_DISPLAY */ {"display",1},
/* T_DIV */ {"/",0},
/* T_DO */ {"do",1},
/* T_DOUNTIL */ {"do until",1},
/* T_DOWHILE */ {"do while",1},
/* T_EDIT */ {"edit",1},
/* T_ELSE */ {"else",1},
/* T_ELSEIFELSE */ {"elseif",1},
/* T_ELSEIFIF */ {(const char*)0,0},
/* T_END */ {"end",1},
/* T_ENDFN */ {"end function",1},
/* T_ENDIF */ {"end if",1},
/* T_ENDPROC */ {"end proc",1},
/* T_ENDSELECT */ {"end select",1},
/* T_ENVIRON */ {"environ",1},
/* T_EOL */ {"\n",0},
/* T_EQ */ {"=",0},
/* T_EQV */ {"eqv",0},
/* T_ERASE */ {"erase",1},
/* T_EXITDO */ {"exit do",1},
/* T_EXITFOR */ {"exit for",1},
/* T_FIELD */ {"field",1},
/* T_FNEND */ {"fnend",1},
/* T_FNEXIT */ {"exit function",1},
/* T_FNRETURN */ {"fnreturn",1},
/* T_FOR */ {"for",1},
/* T_FOR_INPUT */ {"for input",1},
/* T_FOR_OUTPUT */ {"for output",1},
/* T_FOR_APPEND */ {"for append",1},
/* T_FOR_RANDOM */ {"for random",1},
/* T_FOR_BINARY */ {"for binary",1},
/* T_FUNCTION */ {"function",1},
/* T_GE */ {">=",0},
/* T_GET */ {"get",1},
/* T_GOSUB */ {"gosub",1},
/* T_GOTO */ {"goto",1},
/* T_GT */ {">",0},
/* T_HEXINTEGER */ {(const char*)0,0},
/* T_OCTINTEGER */ {(const char*)0,0},
/* T_IDENTIFIER */ {(const char*)0,0},
/* T_IDIV */ {"\\",0},
/* T_IDN */ {"idn",0},
/* T_IF */ {"if",1},
/* T_IMAGE */ {"image",1},
/* T_IMP */ {"imp",0},
/* T_INC */ {"inc",1},
/* T_INPUT */ {"input",1},
/* T_INTEGER */ {(const char*)0,0},
/* T_INV */ {"inv",0},
/* T_IS */ {"is",1},
/* T_JUNK */ {(const char*)0,0},
/* T_KILL */ {"kill",1},
/* T_LE */ {"<=",0},
/* T_LET */ {"let",1},
/* T_LINEINPUT */ {"line input",1},
/* T_LIST */ {"list",1},
/* T_LLIST */ {"llist",1},
/* T_LOAD */ {"load",1},
/* T_LOCAL */ {"local",1},
/* T_LOCATE */ {"locate",1},
/* T_LOCK */ {"lock",1},
/* T_LOCK_READ */ {"lock read",1},
/* T_LOCK_WRITE */ {"lock write",1},
/* T_LOOP */ {"loop",1},
/* T_LOOPUNTIL */ {"loop until",1},
/* T_LPRINT */ {"lprint",1},
/* T_LSET */ {"lset",1},
/* T_LT */ {"<",0},
/* T_MAT */ {"mat",1},
/* T_MATINPUT */ {"mat input",1},
/* T_MATPRINT */ {"mat print",1},
/* T_MATREAD */ {"mat read",1},
/* T_MATREDIM */ {"mat redim",1},
/* T_MATWRITE */ {"mat write",1},
/* T_MERGE */ {"merge",1},
/* T_MINUS */ {"-",0},
/* T_MKDIR */ {"mkdir",1},
/* T_MOD */ {"mod",0},
/* T_MULT */ {"*",0},
/* T_NAME */ {"name",1},
/* T_NE */ {"<>",0},
/* T_NEW */ {"new",1},
/* T_NEXT */ {"next",1},
/* T_NOT */ {"not",0},
/* T_ON */ {"on",1},
/* T_ONERROR */ {"on error",1},
/* T_ONERRORGOTO0 */ {"on error goto 0",1},
/* T_ONERROROFF */ {"on error off",1},
/* T_OP */ {"(",0},
/* T_OPEN */ {"open",1},
/* T_OPTIONBASE */ {"option base",1},
/* T_OPTIONRUN */ {"option run",1},
/* T_OPTIONSTOP */ {"option stop",1},
/* T_OR */ {"or",1},
/* T_OUT */ {"out",1},
/* T_PLUS */ {"+",0},
/* T_POKE */ {"poke",1},
/* T_POW */ {"^",0},
/* T_PRINT */ {"print",1},
/* T_PUT */ {"put",1},
/* T_QUOTE */ {(const char*)0,1},
/* T_RANDOMIZE */ {"randomize",1},
/* T_READ */ {"read",1},
/* T_REAL */ {(const char*)0,0},
/* T_REM */ {(const char*)0,1},
/* T_RENAME */ {"rename",1},
/* T_RENUM */ {"renum",1},
/* T_REPEAT */ {"repeat",1},
/* T_RESTORE */ {"restore",1},
/* T_RESUME */ {"resume",1},
/* T_RETURN */ {"return",1},
/* T_RSET */ {"rset",1},
/* T_RUN */ {"run",1},
/* T_SAVE */ {"save",1},
/* T_SELECTCASE */ {"select case",1},
/* T_SEMICOLON */ {";",0},
/* T_SHARED */ {"shared",1},
/* T_SHELL */ {"shell",1},
/* T_SLEEP */ {"sleep",1},
/* T_SPC */ {"spc",0},
/* T_STEP */ {"step",1},
/* T_STOP */ {"stop",1},
/* T_STRING */ {(const char*)0,0},
/* T_SUB */ {"sub",1},
/* T_SUBEND */ {"subend",1},
/* T_SUBEXIT */ {"subexit",1},
/* T_SWAP */ {"swap",1},
/* T_SYSTEM */ {"system",1},
/* T_TAB */ {"tab",0},
/* T_THEN */ {"then",1},
/* T_TO */ {"to",1},
/* T_TRN */ {"trn",0},
/* T_TROFF */ {"troff",1},
/* T_TRON */ {"tron",1},
/* T_TRUNCATE */ {"truncate",1},
/* T_UNLOCK */ {"unlock",1},
/* T_UNNUM */ {"unnum",1},
/* T_UNNUMBERED */ {"",0},
/* T_UNTIL */ {"until",1},
/* T_USING */ {"using",0},
/* T_WAIT */ {"wait",1},
/* T_WEND */ {"wend",1},
/* T_WHILE */ {"while",1},
/* T_WIDTH */ {"width",1},
/* T_WRITE */ {"write",1},
/* T_XOR */ {"xor",0},
/* T_XREF */ {"xref",0},
/* T_ZER */ {"zer",0},
/* T_ZONE */ {"zone",1},
};
'''
pattern = re.compile(r'"(.*?)"', re.MULTILINE | re.DOTALL)
def upper(match):
return '"' + match.group(1).upper() + '"'
modified_code = pattern.sub(upper, code)
print(modified_code)