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