OILS / _devbuild / gen / option_asdl.py View on Github | oils.pub

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