1 | from asdl import pybase
|
2 |
|
3 | option_t = int # type alias for integer
|
4 |
|
5 | class option_i(object):
|
6 | errexit = 1
|
7 | nounset = 2
|
8 | pipefail = 3
|
9 | inherit_errexit = 4
|
10 | nullglob = 5
|
11 | verbose_errexit = 6
|
12 | noexec = 7
|
13 | xtrace = 8
|
14 | verbose = 9
|
15 | noglob = 10
|
16 | noclobber = 11
|
17 | errtrace = 12
|
18 | posix = 13
|
19 | vi = 14
|
20 | emacs = 15
|
21 | interactive = 16
|
22 | hashall = 17
|
23 | lastpipe = 18
|
24 | failglob = 19
|
25 | extglob = 20
|
26 | nocasematch = 21
|
27 | dotglob = 22
|
28 | eval_unsafe_arith = 23
|
29 | ignore_flags_not_impl = 24
|
30 | ignore_shopt_not_impl = 25
|
31 | _allow_command_sub = 26
|
32 | _allow_process_sub = 27
|
33 | dynamic_scope = 28
|
34 | redefine_const = 29
|
35 | redefine_source = 30
|
36 | _running_trap = 31
|
37 | _running_hay = 32
|
38 | _no_debug_trap = 33
|
39 | _no_err_trap = 34
|
40 | strict_parse_slice = 35
|
41 | strict_argv = 36
|
42 | strict_arith = 37
|
43 | strict_array = 38
|
44 | strict_control_flow = 39
|
45 | strict_errexit = 40
|
46 | strict_nameref = 41
|
47 | strict_word_eval = 42
|
48 | strict_tilde = 43
|
49 | strict_glob = 44
|
50 | parse_at = 45
|
51 | parse_proc = 46
|
52 | parse_func = 47
|
53 | parse_brace = 48
|
54 | parse_bracket = 49
|
55 | parse_equals = 50
|
56 | parse_paren = 51
|
57 | parse_ysh_string = 52
|
58 | parse_triple_quote = 53
|
59 | simple_word_eval = 54
|
60 | dashglob = 55
|
61 | command_sub_errexit = 56
|
62 | process_sub_fail = 57
|
63 | xtrace_rich = 58
|
64 | xtrace_details = 59
|
65 | sigpipe_status_ok = 60
|
66 | env_obj = 61
|
67 | parse_at_all = 62
|
68 | parse_backslash = 63
|
69 | parse_backticks = 64
|
70 | parse_dollar = 65
|
71 | parse_ignored = 66
|
72 | parse_sh_arith = 67
|
73 | parse_dparen = 68
|
74 | parse_dbracket = 69
|
75 | parse_bare_word = 70
|
76 | no_exported = 71
|
77 | no_init_globals = 72
|
78 | simple_echo = 73
|
79 | simple_eval_builtin = 74
|
80 | simple_test_builtin = 75
|
81 | expand_aliases = 76
|
82 | progcomp = 77
|
83 | histappend = 78
|
84 | hostcomplete = 79
|
85 | cmdhist = 80
|
86 | assoc_expand_once = 81
|
87 | autocd = 82
|
88 | cdable_vars = 83
|
89 | cdspell = 84
|
90 | checkhash = 85
|
91 | checkjobs = 86
|
92 | checkwinsize = 87
|
93 | complete_fullquote = 88
|
94 | direxpand = 89
|
95 | dirspell = 90
|
96 | execfail = 91
|
97 | extdebug = 92
|
98 | extquote = 93
|
99 | force_fignore = 94
|
100 | globasciiranges = 95
|
101 | globstar = 96
|
102 | gnu_errfmt = 97
|
103 | histreedit = 98
|
104 | histverify = 99
|
105 | huponexit = 100
|
106 | interactive_comments = 101
|
107 | lithist = 102
|
108 | localvar_inherit = 103
|
109 | localvar_unset = 104
|
110 | login_shell = 105
|
111 | mailwarn = 106
|
112 | no_empty_cmd_completion = 107
|
113 | nocaseglob = 108
|
114 | progcomp_alias = 109
|
115 | promptvars = 110
|
116 | restricted_shell = 111
|
117 | shift_verbose = 112
|
118 | sourcepath = 113
|
119 | xpg_echo = 114
|
120 | ARRAY_SIZE = 115
|
121 |
|
122 | _option_str = {
|
123 | 1: 'errexit',
|
124 | 2: 'nounset',
|
125 | 3: 'pipefail',
|
126 | 4: 'inherit_errexit',
|
127 | 5: 'nullglob',
|
128 | 6: 'verbose_errexit',
|
129 | 7: 'noexec',
|
130 | 8: 'xtrace',
|
131 | 9: 'verbose',
|
132 | 10: 'noglob',
|
133 | 11: 'noclobber',
|
134 | 12: 'errtrace',
|
135 | 13: 'posix',
|
136 | 14: 'vi',
|
137 | 15: 'emacs',
|
138 | 16: 'interactive',
|
139 | 17: 'hashall',
|
140 | 18: 'lastpipe',
|
141 | 19: 'failglob',
|
142 | 20: 'extglob',
|
143 | 21: 'nocasematch',
|
144 | 22: 'dotglob',
|
145 | 23: 'eval_unsafe_arith',
|
146 | 24: 'ignore_flags_not_impl',
|
147 | 25: 'ignore_shopt_not_impl',
|
148 | 26: '_allow_command_sub',
|
149 | 27: '_allow_process_sub',
|
150 | 28: 'dynamic_scope',
|
151 | 29: 'redefine_const',
|
152 | 30: 'redefine_source',
|
153 | 31: '_running_trap',
|
154 | 32: '_running_hay',
|
155 | 33: '_no_debug_trap',
|
156 | 34: '_no_err_trap',
|
157 | 35: 'strict_parse_slice',
|
158 | 36: 'strict_argv',
|
159 | 37: 'strict_arith',
|
160 | 38: 'strict_array',
|
161 | 39: 'strict_control_flow',
|
162 | 40: 'strict_errexit',
|
163 | 41: 'strict_nameref',
|
164 | 42: 'strict_word_eval',
|
165 | 43: 'strict_tilde',
|
166 | 44: 'strict_glob',
|
167 | 45: 'parse_at',
|
168 | 46: 'parse_proc',
|
169 | 47: 'parse_func',
|
170 | 48: 'parse_brace',
|
171 | 49: 'parse_bracket',
|
172 | 50: 'parse_equals',
|
173 | 51: 'parse_paren',
|
174 | 52: 'parse_ysh_string',
|
175 | 53: 'parse_triple_quote',
|
176 | 54: 'simple_word_eval',
|
177 | 55: 'dashglob',
|
178 | 56: 'command_sub_errexit',
|
179 | 57: 'process_sub_fail',
|
180 | 58: 'xtrace_rich',
|
181 | 59: 'xtrace_details',
|
182 | 60: 'sigpipe_status_ok',
|
183 | 61: 'env_obj',
|
184 | 62: 'parse_at_all',
|
185 | 63: 'parse_backslash',
|
186 | 64: 'parse_backticks',
|
187 | 65: 'parse_dollar',
|
188 | 66: 'parse_ignored',
|
189 | 67: 'parse_sh_arith',
|
190 | 68: 'parse_dparen',
|
191 | 69: 'parse_dbracket',
|
192 | 70: 'parse_bare_word',
|
193 | 71: 'no_exported',
|
194 | 72: 'no_init_globals',
|
195 | 73: 'simple_echo',
|
196 | 74: 'simple_eval_builtin',
|
197 | 75: 'simple_test_builtin',
|
198 | 76: 'expand_aliases',
|
199 | 77: 'progcomp',
|
200 | 78: 'histappend',
|
201 | 79: 'hostcomplete',
|
202 | 80: 'cmdhist',
|
203 | 81: 'assoc_expand_once',
|
204 | 82: 'autocd',
|
205 | 83: 'cdable_vars',
|
206 | 84: 'cdspell',
|
207 | 85: 'checkhash',
|
208 | 86: 'checkjobs',
|
209 | 87: 'checkwinsize',
|
210 | 88: 'complete_fullquote',
|
211 | 89: 'direxpand',
|
212 | 90: 'dirspell',
|
213 | 91: 'execfail',
|
214 | 92: 'extdebug',
|
215 | 93: 'extquote',
|
216 | 94: 'force_fignore',
|
217 | 95: 'globasciiranges',
|
218 | 96: 'globstar',
|
219 | 97: 'gnu_errfmt',
|
220 | 98: 'histreedit',
|
221 | 99: 'histverify',
|
222 | 100: 'huponexit',
|
223 | 101: 'interactive_comments',
|
224 | 102: 'lithist',
|
225 | 103: 'localvar_inherit',
|
226 | 104: 'localvar_unset',
|
227 | 105: 'login_shell',
|
228 | 106: 'mailwarn',
|
229 | 107: 'no_empty_cmd_completion',
|
230 | 108: 'nocaseglob',
|
231 | 109: 'progcomp_alias',
|
232 | 110: 'promptvars',
|
233 | 111: 'restricted_shell',
|
234 | 112: 'shift_verbose',
|
235 | 113: 'sourcepath',
|
236 | 114: 'xpg_echo',
|
237 | }
|
238 |
|
239 | def option_str(val, dot=True):
|
240 | # type: (option_t, bool) -> str
|
241 | v = _option_str[val]
|
242 | if dot:
|
243 | return "option.%s" % v
|
244 | else:
|
245 | return v
|
246 |
|
247 | builtin_t = int # type alias for integer
|
248 |
|
249 | class builtin_i(object):
|
250 | colon = 1
|
251 | dot = 2
|
252 | exec_ = 3
|
253 | eval = 4
|
254 | set = 5
|
255 | shift = 6
|
256 | times = 7
|
257 | trap = 8
|
258 | unset = 9
|
259 | readonly = 10
|
260 | local = 11
|
261 | declare = 12
|
262 | typeset = 13
|
263 | export_ = 14
|
264 | extern_ = 15
|
265 | true_ = 16
|
266 | false_ = 17
|
267 | try_ = 18
|
268 | assert_ = 19
|
269 | read = 20
|
270 | echo = 21
|
271 | printf = 22
|
272 | mapfile = 23
|
273 | readarray = 24
|
274 | cd = 25
|
275 | pushd = 26
|
276 | popd = 27
|
277 | dirs = 28
|
278 | pwd = 29
|
279 | source = 30
|
280 | umask = 31
|
281 | ulimit = 32
|
282 | wait = 33
|
283 | jobs = 34
|
284 | fg = 35
|
285 | bg = 36
|
286 | shopt = 37
|
287 | complete = 38
|
288 | compgen = 39
|
289 | compopt = 40
|
290 | compadjust = 41
|
291 | compexport = 42
|
292 | getopts = 43
|
293 | builtin = 44
|
294 | command = 45
|
295 | type = 46
|
296 | hash = 47
|
297 | help = 48
|
298 | history = 49
|
299 | alias = 50
|
300 | unalias = 51
|
301 | bind = 52
|
302 | append = 53
|
303 | write = 54
|
304 | json = 55
|
305 | json8 = 56
|
306 | pp = 57
|
307 | hay = 58
|
308 | haynode = 59
|
309 | use = 60
|
310 | error = 61
|
311 | failed = 62
|
312 | fork = 63
|
313 | forkwait = 64
|
314 | redir = 65
|
315 | fopen = 66
|
316 | shvar = 67
|
317 | ctx = 68
|
318 | invoke = 69
|
319 | runproc = 70
|
320 | boolstatus = 71
|
321 | test = 72
|
322 | bracket = 73
|
323 | push_registers = 74
|
324 | source_guard = 75
|
325 | is_main = 76
|
326 | cat = 77
|
327 | ARRAY_SIZE = 78
|
328 |
|
329 | _builtin_str = {
|
330 | 1: 'colon',
|
331 | 2: 'dot',
|
332 | 3: 'exec_',
|
333 | 4: 'eval',
|
334 | 5: 'set',
|
335 | 6: 'shift',
|
336 | 7: 'times',
|
337 | 8: 'trap',
|
338 | 9: 'unset',
|
339 | 10: 'readonly',
|
340 | 11: 'local',
|
341 | 12: 'declare',
|
342 | 13: 'typeset',
|
343 | 14: 'export_',
|
344 | 15: 'extern_',
|
345 | 16: 'true_',
|
346 | 17: 'false_',
|
347 | 18: 'try_',
|
348 | 19: 'assert_',
|
349 | 20: 'read',
|
350 | 21: 'echo',
|
351 | 22: 'printf',
|
352 | 23: 'mapfile',
|
353 | 24: 'readarray',
|
354 | 25: 'cd',
|
355 | 26: 'pushd',
|
356 | 27: 'popd',
|
357 | 28: 'dirs',
|
358 | 29: 'pwd',
|
359 | 30: 'source',
|
360 | 31: 'umask',
|
361 | 32: 'ulimit',
|
362 | 33: 'wait',
|
363 | 34: 'jobs',
|
364 | 35: 'fg',
|
365 | 36: 'bg',
|
366 | 37: 'shopt',
|
367 | 38: 'complete',
|
368 | 39: 'compgen',
|
369 | 40: 'compopt',
|
370 | 41: 'compadjust',
|
371 | 42: 'compexport',
|
372 | 43: 'getopts',
|
373 | 44: 'builtin',
|
374 | 45: 'command',
|
375 | 46: 'type',
|
376 | 47: 'hash',
|
377 | 48: 'help',
|
378 | 49: 'history',
|
379 | 50: 'alias',
|
380 | 51: 'unalias',
|
381 | 52: 'bind',
|
382 | 53: 'append',
|
383 | 54: 'write',
|
384 | 55: 'json',
|
385 | 56: 'json8',
|
386 | 57: 'pp',
|
387 | 58: 'hay',
|
388 | 59: 'haynode',
|
389 | 60: 'use',
|
390 | 61: 'error',
|
391 | 62: 'failed',
|
392 | 63: 'fork',
|
393 | 64: 'forkwait',
|
394 | 65: 'redir',
|
395 | 66: 'fopen',
|
396 | 67: 'shvar',
|
397 | 68: 'ctx',
|
398 | 69: 'invoke',
|
399 | 70: 'runproc',
|
400 | 71: 'boolstatus',
|
401 | 72: 'test',
|
402 | 73: 'bracket',
|
403 | 74: 'push_registers',
|
404 | 75: 'source_guard',
|
405 | 76: 'is_main',
|
406 | 77: 'cat',
|
407 | }
|
408 |
|
409 | def builtin_str(val, dot=True):
|
410 | # type: (builtin_t, bool) -> str
|
411 | v = _builtin_str[val]
|
412 | if dot:
|
413 | return "builtin.%s" % v
|
414 | else:
|
415 | return v
|
416 |
|