category | total lines | num files |
mycpp Translator | 6,668 | 15 |
mycpp Test Data | 4,065 | 46 |
Zephyr ASDL | 3,273 | 11 |
pgen2 Parser Generator | 1,854 | 8 |
Other Code Generators | 3,030 | 11 |
Yaks | 510 | 4 |
Hand-written C++ Code | 3,403 | 29 |
Garbage-Collected Runtime | 5,066 | 24 |
Unit tests in C++ | 7,584 | 25 |
Incremental C++ Build | 3,432 | 19 |
OSH (and common libraries) | 42,423 | 81 |
YSH | 9,009 | 24 |
Data Languages | 2,798 | 11 |
Tools | 1,330 | 5 |
Spec Tests | 52,049 | 182 |
Gold Tests | 2,775 | 27 |
Generated C++ Code | 117,402 | 41 |
The README for oilshell/oil has another overview of the repository.
This prototype uses the MyPy frontend to translate statically-typed Python to C++. The generated code calls a small runtime which implements things like List[T], Dict[K, V], and Python's len().
mycpp/compare_pairs.py 60 mycpp/const_pass.py 532 mycpp/control_flow_pass.py 348 mycpp/cppgen_pass.py 3,084 mycpp/crash.py 38 mycpp/debug_pass.py 465 mycpp/format_strings.py 114 mycpp/ir_pass.py 99 mycpp/mops.py 203 mycpp/mycpp_main.py 401 mycpp/mylib.py 524 mycpp/pass_state.py 446 mycpp/util.py 112 mycpp/visitor.py 242 6,668 lines in 15 files
Small Python examples that translate to C++, compile, and run.
mycpp/examples/__init__.py 0 mycpp/examples/asdl_generated.py 65 mycpp/examples/cartesian.py 78 mycpp/examples/cgi.py 62 mycpp/examples/classes.py 298 mycpp/examples/containers.py 254 mycpp/examples/control_flow.py 113 mycpp/examples/escape.py 70 mycpp/examples/fib_iter.py 53 mycpp/examples/fib_recursive.py 49 mycpp/examples/files.py 64 mycpp/examples/invalid_condition.py 31 mycpp/examples/invalid_default_args.py 44 mycpp/examples/invalid_except.py 38 mycpp/examples/invalid_format_args.py 15 mycpp/examples/invalid_format_strings.py 20 mycpp/examples/invalid_global.py 18 mycpp/examples/invalid_print.py 13 mycpp/examples/invalid_python.py 61 mycpp/examples/invalid_switch.py 84 mycpp/examples/invalid_try_else.py 38 mycpp/examples/invalid_types.py 31 mycpp/examples/invalid_types_2.py 31 mycpp/examples/length.py 109 mycpp/examples/lexer_main.py 47 mycpp/examples/loops.py 177 mycpp/examples/modules.py 81 mycpp/examples/parse.py 271 mycpp/examples/pgen2_demo.py 106 mycpp/examples/scoped_resource.py 221 mycpp/examples/test_arith_ops.py 45 mycpp/examples/test_cast.py 208 mycpp/examples/test_classes_gc.py 212 mycpp/examples/test_conditional.py 66 mycpp/examples/test_default_args.py 75 mycpp/examples/test_globals.py 62 mycpp/examples/test_hoist.py 61 mycpp/examples/test_integers.py 74 mycpp/examples/test_io_os_error.py 131 mycpp/examples/test_iterators.py 101 mycpp/examples/test_small_str.py 33 mycpp/examples/test_strings.py 272 mycpp/examples/test_switch.py 80 mycpp/examples/tuple_return_value.py 54 mycpp/examples/varargs.py 49 4,065 lines in 46 files
A DSL for algebraic data types, borrowed from Python. Oils is the most strongly typed Bourne shell implementation!
asdl/asdl_main.py 299 asdl/ast.py 238 asdl/format.py 518 asdl/front_end.py 516 asdl/gen_cpp.py 826 asdl/gen_python.py 611 asdl/pybase.py 51 asdl/runtime.py 67 asdl/util.py 11 asdl/visitor.py 136 3,273 lines in 11 files
An LL(1) parser generator used to parse YSH expressions. Also borrowed from CPython.
pgen2/driver.py 101 pgen2/grammar.py 303 pgen2/parse.py 225 pgen2/pgen.py 430 pgen2/pnode.py 67 pgen2/token.py 149 pgen2/tokenize.py 579 1,854 lines in 8 files
In order to make Oils statically typed, we had to abandon Python reflection and use C++ source code generation instead. The lexer, flag definitions, and constants can be easily compiled to C++.
core/optview_gen.py 94 cpp/embedded_file_gen.py 66 doctools/help_gen.py 658 frontend/consts_gen.py 641 frontend/flag_gen.py 532 frontend/lexer_gen.py 496 frontend/option_gen.py 94 frontend/signal_gen.py 105 osh/arith_parse_gen.py 100 ysh/grammar_gen.py 244 3,030 lines in 11 files
Experimental replacement for mycpp
yaks/gen_cpp.py 104 yaks/transform.py 250 yaks/yaks_main.py 156 510 lines in 4 files
Includes OS bindings. Small C++ files like cpp/osh_arith_parse.{cc,h} correspond to larger Python files like osh/arith_parse.py.
cpp/core.cc 418 cpp/core.h 274 cpp/data_lang.cc 271 cpp/data_lang.h 34 cpp/embedded_file.h 18 cpp/fanos.cc 57 cpp/fanos.h 18 cpp/fanos_shared.h 49 cpp/frontend_flag_spec.cc 231 cpp/frontend_flag_spec.h 151 cpp/frontend_match.cc 142 cpp/frontend_match.h 90 cpp/frontend_pyreadline.cc 336 cpp/frontend_pyreadline.h 73 cpp/libc.cc 241 cpp/libc.h 38 cpp/osh.cc 161 cpp/osh.h 50 cpp/osh_tdop.cc 16 cpp/osh_tdop.h 52 cpp/pgen2.cc 44 cpp/pgen2.h 85 cpp/preamble.h 48 cpp/pylib.cc 58 cpp/pylib.h 22 cpp/stdlib.cc 245 cpp/stdlib.h 170 cpp/translation_stubs.h 11 3,403 lines in 29 files
Uses a fork-friendly Mark-Sweep collector.
mycpp/common.h 92 mycpp/comparators.h 90 mycpp/gc_alloc.h 256 mycpp/gc_builtins.cc 456 mycpp/gc_builtins.h 175 mycpp/gc_dict.h 471 mycpp/gc_list.h 524 mycpp/gc_mops.cc 58 mycpp/gc_mops.h 125 mycpp/gc_mylib.cc 302 mycpp/gc_mylib.h 381 mycpp/gc_obj.h 179 mycpp/gc_slab.h 58 mycpp/gc_str.cc 645 mycpp/gc_str.h 219 mycpp/gc_tuple.h 149 mycpp/hash.cc 45 mycpp/hash.h 22 mycpp/mark_sweep_heap.cc 438 mycpp/mark_sweep_heap.h 294 mycpp/probes.h 39 mycpp/runtime.h 24 mycpp/test_common.h 24 5,066 lines in 24 files
The goal is to make the spec tests pass, but unit tests are helpful too.
cpp/core_test.cc 417 cpp/data_lang_test.cc 178 cpp/data_race_test.cc 206 cpp/frontend_flag_spec_test.cc 154 cpp/frontend_match_test.cc 87 cpp/libc_test.cc 403 cpp/obj_layout_test.cc 212 cpp/osh_test.cc 50 cpp/pylib_test.cc 52 cpp/stdlib_test.cc 158 cpp/unicode_test.cc 71 mycpp/bump_leak_heap_test.cc 62 mycpp/float_test.cc 150 mycpp/gc_builtins_test.cc 447 mycpp/gc_dict_test.cc 745 mycpp/gc_heap_test.cc 479 mycpp/gc_list_test.cc 491 mycpp/gc_mops_test.cc 104 mycpp/gc_mylib_test.cc 327 mycpp/gc_str_test.cc 1,558 mycpp/gc_stress_test.cc 222 mycpp/gc_tuple_test.cc 139 mycpp/mark_sweep_heap_test.cc 370 mycpp/small_str_test.cc 502 7,584 lines in 25 files
NINJA-config.sh 137 asdl/NINJA_subgraph.py 56 bin/NINJA_subgraph.py 122 build/ninja-rules-cpp.sh 367 build/ninja-rules-py.sh 349 build/ninja_lib.py 518 build/ninja_lib_test.py 253 build/ninja_main.py 431 core/NINJA_subgraph.py 58 cpp/NINJA_subgraph.py 223 data_lang/NINJA_subgraph.py 67 frontend/NINJA_subgraph.py 175 mycpp/NINJA_subgraph.py 418 osh/NINJA_subgraph.py 32 pea/NINJA_subgraph.py 19 prebuilt/NINJA_subgraph.py 75 yaks/NINJA_subgraph.py 93 ysh/NINJA_subgraph.py 39 3,432 lines in 19 files
This is the input to the translators, written in statically-typed Python. Note that bash is at least 140K lines of code, and OSH implements a large part of bash and more.
bin/oils_for_unix.py 198 builtin/assign_osh.py 577 builtin/bracket_osh.py 285 builtin/completion_osh.py 514 builtin/dirs_osh.py 349 builtin/io_osh.py 183 builtin/meta_osh.py 480 builtin/misc_osh.py 115 builtin/printf_osh.py 541 builtin/process_osh.py 598 builtin/pure_osh.py 490 builtin/read_osh.py 521 builtin/readline_osh.py 142 builtin/trap_osh.py 274 core/alloc.py 320 core/ansi.py 14 core/comp_ui.py 578 core/completion.py 1,516 core/dev.py 766 core/error.py 344 core/executor.py 714 core/main_loop.py 402 core/num.py 99 core/optview.py 58 core/process.py 1,952 core/pyos.py 397 core/pyutil.py 214 core/runtime.asdl 173 core/shell.py 1,139 core/state.py 2,452 core/ui.py 537 core/util.py 168 core/value.asdl 175 core/vm.py 338 frontend/args.py 669 frontend/builtin_def.py 163 frontend/consts.py 383 frontend/flag_def.py 538 frontend/flag_spec.py 349 frontend/flag_util.py 69 frontend/id_kind_def.py 798 frontend/lexer.py 451 frontend/lexer_def.py 1,116 frontend/location.py 571 frontend/match.py 292 frontend/option_def.py 410 frontend/parse_lib.py 405 frontend/py_readline.py 104 frontend/reader.py 256 frontend/signal_def.py 94 frontend/syntax.asdl 653 frontend/syntax_abbrev.py 140 frontend/typed_args.py 589 frontend/types.asdl 61 osh/arith_parse.py 197 osh/bool_parse.py 272 osh/bool_stat.py 135 osh/braces.py 539 osh/cmd_eval.py 2,174 osh/cmd_parse.py 2,824 osh/glob_.py 494 osh/history.py 193 osh/prompt.py 373 osh/sh_expr_eval.py 1,205 osh/split.py 311 osh/string_ops.py 545 osh/tdop.py 342 osh/word_.py 805 osh/word_compile.py 310 osh/word_eval.py 2,438 osh/word_parse.py 2,218 pyext/fanos.c 119 pyext/fastfunc.c 133 pyext/fastfunc.pyi 11 pyext/fastlex.c 351 pyext/fastlex.pyi 19 pyext/libc.c 421 pyext/libc.pyi 18 pyext/line_input.pyi 32 pyext/posix_.pyi 210 42,423 lines in 81 files
Expression grammar, parser, evaluator, etc.
builtin/completion_ysh.py 69 builtin/error_ysh.py 224 builtin/func_eggex.py 186 builtin/func_hay.py 150 builtin/func_misc.py 754 builtin/hay_ysh.py 431 builtin/io_ysh.py 244 builtin/json_ysh.py 139 builtin/meta_ysh.py 101 builtin/method_dict.py 45 builtin/method_io.py 87 builtin/method_list.py 100 builtin/method_other.py 32 builtin/method_str.py 514 builtin/module_ysh.py 120 builtin/pure_ysh.py 270 ysh/expr_eval.py 1,424 ysh/expr_parse.py 378 ysh/expr_to_ast.py 1,708 ysh/func_proc.py 571 ysh/grammar.pgen2 538 ysh/regex_translate.py 393 ysh/val_ops.py 531 9,009 lines in 24 files
JSON, J8 Notation, ...
data_lang/nil8.asdl 31 data_lang/pretty.asdl 29 data_lang/j8.py 1,240 data_lang/j8_lite.py 46 data_lang/pretty.py 692 data_lang/pyj8.py 27 data_lang/j8.h 314 data_lang/j8_libc.c 221 data_lang/j8_libc.h 28 data_lang/utf8.h 170 2,798 lines in 11 files
tools/deps.py 149 tools/fmt.py 25 tools/readlink.py 31 tools/ysh_ify.py 1,125 1,330 lines in 5 files
A comprehensive test suite that compares OSH against other shells. If OSH passes these tests in BOTH Python and C++, it means that the translation works.
spec/TODO-deprecate.test.sh 80 spec/alias.test.sh 571 spec/append.test.sh 303 spec/arith-context.test.sh 216 spec/arith.test.sh 875 spec/array-basic.test.sh 45 spec/array-compat.test.sh 189 spec/array.test.sh 803 spec/assign-deferred.test.sh 105 spec/assign-dialects.test.sh 61 spec/assign-extended.test.sh 857 spec/assign.test.sh 674 spec/assoc-zsh.test.sh 53 spec/assoc.test.sh 797 spec/background.test.sh 184 spec/ble-features.test.sh 645 spec/ble-idioms.test.sh 355 spec/blog-other1.test.sh 57 spec/blog1.test.sh 95 spec/blog2.test.sh 60 spec/brace-expansion.test.sh 502 spec/bugs.test.sh 390 spec/builtin-bash.test.sh 192 spec/builtin-bracket.test.sh 581 spec/builtin-cd.test.sh 304 spec/builtin-completion.test.sh 596 spec/builtin-dirs.test.sh 238 spec/builtin-echo.test.sh 248 spec/builtin-eval-source.test.sh 249 spec/builtin-getopts.test.sh 347 spec/builtin-history.test.sh 198 spec/builtin-meta.test.sh 607 spec/builtin-misc.test.sh 161 spec/builtin-printf.test.sh 1,100 spec/builtin-process.test.sh 588 spec/builtin-read.test.sh 770 spec/builtin-special.test.sh 141 spec/builtin-times.test.sh 15 spec/builtin-trap-bash.test.sh 657 spec/builtin-trap-err.test.sh 647 spec/builtin-trap.test.sh 247 spec/builtin-type-bash.test.sh 326 spec/builtin-type.test.sh 117 spec/builtin-vars.test.sh 707 spec/case_.test.sh 199 spec/command-parsing.test.sh 63 spec/command-sub.test.sh 285 spec/command_.test.sh 194 spec/comments.test.sh 11 spec/dbracket.test.sh 438 spec/dparen.test.sh 205 spec/empty-bodies.test.sh 24 spec/errexit-osh.test.sh 758 spec/errexit.test.sh 532 spec/exit-status.test.sh 280 spec/explore-parsing.test.sh 42 spec/extglob-files.test.sh 384 spec/extglob-match.test.sh 400 spec/fatal-errors.test.sh 186 spec/for-expr.test.sh 173 spec/func-parsing.test.sh 105 spec/glob.test.sh 388 spec/globignore.test.sh 159 spec/hay-isolation.test.sh 169 spec/hay-meta.test.sh 200 spec/hay.test.sh 699 spec/here-doc.test.sh 370 spec/if_.test.sh 56 spec/interactive-parse.test.sh 37 spec/interactive.test.sh 343 spec/introspect.test.sh 287 spec/let.test.sh 23 spec/loop.test.sh 474 spec/nameref.test.sh 637 spec/nix-idioms.test.sh 196 spec/nocasematch-match.test.sh 71 spec/nul-bytes.test.sh 158 spec/parse-errors.test.sh 226 spec/pipeline.test.sh 197 spec/posix.test.sh 153 spec/process-sub.test.sh 204 spec/prompt.test.sh 253 spec/quote.test.sh 230 spec/redirect-command.test.sh 306 spec/redirect-multi.test.sh 308 spec/redirect.test.sh 485 spec/regex.test.sh 631 spec/serialize.test.sh 230 spec/sh-func.test.sh 152 spec/sh-options.test.sh 746 spec/sh-usage.test.sh 94 spec/shell-grammar.test.sh 206 spec/smoke.test.sh 126 spec/strict-options.test.sh 277 spec/subshell.test.sh 23 spec/tilde.test.sh 184 spec/toysh-posix.test.sh 344 spec/toysh.test.sh 143 spec/type-compat.test.sh 159 spec/unicode.test.sh 196 spec/var-num.test.sh 43 spec/var-op-bash.test.sh 397 spec/var-op-len.test.sh 219 spec/var-op-patsub.test.sh 413 spec/var-op-slice.test.sh 403 spec/var-op-strip.test.sh 357 spec/var-op-test.test.sh 520 spec/var-ref.test.sh 509 spec/var-sub-quote.test.sh 312 spec/var-sub.test.sh 60 spec/vars-bash.test.sh 30 spec/vars-special.test.sh 634 spec/whitespace.test.sh 114 spec/word-eval.test.sh 62 spec/word-split.test.sh 421 spec/xtrace.test.sh 361 spec/ysh-assign.test.sh 402 spec/ysh-augmented.test.sh 245 spec/ysh-bin.test.sh 19 spec/ysh-blocks.test.sh 407 spec/ysh-bugs.test.sh 199 spec/ysh-builtin-ctx.test.sh 168 spec/ysh-builtin-error.test.sh 264 spec/ysh-builtin-eval.test.sh 99 spec/ysh-builtin-help.test.sh 99 spec/ysh-builtin-meta.test.sh 220 spec/ysh-builtin-module.test.sh 38 spec/ysh-builtin-process.test.sh 85 spec/ysh-builtin-shopt.test.sh 180 spec/ysh-builtins.test.sh 537 spec/ysh-case.test.sh 245 spec/ysh-cmd-lang.test.sh 54 spec/ysh-command-sub.test.sh 147 spec/ysh-completion.test.sh 204 spec/ysh-convert.test.sh 171 spec/ysh-demo.test.sh 59 spec/ysh-dev.test.sh 164 spec/ysh-dict.test.sh 91 spec/ysh-expr-arith.test.sh 369 spec/ysh-expr-bool.test.sh 181 spec/ysh-expr-compare.test.sh 382 spec/ysh-expr-sub.test.sh 42 spec/ysh-expr.test.sh 720 spec/ysh-for.test.sh 192 spec/ysh-func-builtin.test.sh 103 spec/ysh-func.test.sh 535 spec/ysh-funcs-external.test.sh 86 spec/ysh-int-float.test.sh 116 spec/ysh-interactive.test.sh 37 spec/ysh-json.test.sh 1,080 spec/ysh-keywords.test.sh 37 spec/ysh-list.test.sh 97 spec/ysh-methods.test.sh 490 spec/ysh-multiline.test.sh 179 spec/ysh-options-assign.test.sh 106 spec/ysh-options.test.sh 811 spec/ysh-place.test.sh 136 spec/ysh-printing.test.sh 128 spec/ysh-proc.test.sh 453 spec/ysh-prompt.test.sh 133 spec/ysh-regex-api.test.sh 829 spec/ysh-regex.test.sh 711 spec/ysh-reserved.test.sh 48 spec/ysh-scope.test.sh 766 spec/ysh-slice-range.test.sh 209 spec/ysh-source.test.sh 29 spec/ysh-special-vars.test.sh 50 spec/ysh-stdlib-2.test.sh 158 spec/ysh-stdlib-args.test.sh 333 spec/ysh-stdlib-testing.test.sh 125 spec/ysh-stdlib.test.sh 160 spec/ysh-string.test.sh 491 spec/ysh-tuple.test.sh 28 spec/ysh-unicode.test.sh 184 spec/ysh-usage.test.sh 47 spec/ysh-user-feedback.test.sh 141 spec/ysh-var-sub.test.sh 45 spec/ysh-with-sh.test.sh 221 spec/ysh-word-eval.test.sh 145 spec/ysh-xtrace.test.sh 547 spec/zsh-idioms.test.sh 45 52,049 lines in 182 files
Another suite that tests shells "from the outside". Instead of making explicit assertions, we verify that OSH behaves like bash.
test/gold/abuild.sh 9 test/gold/and-or.sh 27 test/gold/autoconf-backtick.sh 50 test/gold/big-here-doc.sh 1,531 test/gold/case-in-subshell.sh 37 test/gold/char-class.sh 33 test/gold/command-sub-2.sh 12 test/gold/command-sub.sh 39 test/gold/comments.sh 22 test/gold/complex-here-docs.sh 192 test/gold/configure-bug.sh 13 test/gold/de1.sh 24 test/gold/declare.sh 28 test/gold/dollar-sq.sh 42 test/gold/echo-e.sh 36 test/gold/errexit-confusion.sh 139 test/gold/errexit.sh 121 test/gold/export.sh 65 test/gold/glob.sh 26 test/gold/lineno.sh 23 test/gold/nix.sh 32 test/gold/readlink.sh 61 test/gold/readonly.sh 24 test/gold/scope.sh 126 test/gold/strip-op-char-class.sh 6 test/gold/word-eval.sh 57 2,775 lines in 27 files
mycpp generates the big file _gen/bin/oils-for-unix.mycpp.cc. Other programs like Zephyr ASDL and re2c generate other files.
_gen/_tmp/match.re2c-input.h 1,277 _gen/asdl/hnode.asdl.h 197 _gen/bin/oils_for_unix.mycpp.cc 56,230 _gen/bin/oils_for_unix.mycpp.h 5 _gen/bin/text_files.cc 1,811 _gen/core/optview.h 126 _gen/core/runtime.asdl.cc 1,258 _gen/core/runtime.asdl.h 1,012 _gen/core/value.asdl.cc 1,253 _gen/core/value.asdl.h 1,043 _gen/cpp/build_stamp.cc 1 _gen/cpp/build_stamp.h 1 _gen/data_lang/nil8.asdl.cc 253 _gen/data_lang/nil8.asdl.h 229 _gen/data_lang/pretty.asdl.cc 256 _gen/data_lang/pretty.asdl.h 263 _gen/frontend/arg_types.cc 596 _gen/frontend/arg_types.h 796 _gen/frontend/consts.cc 1,766 _gen/frontend/consts.h 56 _gen/frontend/help_meta.cc 440 _gen/frontend/help_meta.h 6 _gen/frontend/id_kind.asdl.cc 915 _gen/frontend/id_kind.asdl.h 470 _gen/frontend/id_kind.asdl_c.h 402 _gen/frontend/match.re2c.h 24,285 _gen/frontend/option.asdl.h 209 _gen/frontend/signal.cc 205 _gen/frontend/signal.h 16 _gen/frontend/syntax.asdl.cc 6,172 _gen/frontend/syntax.asdl.h 5,389 _gen/frontend/types.asdl.h 87 _gen/frontend/types.asdl_c.h 47 _gen/osh/arith_parse.cc 129 _gen/yaks/yaks.asdl.cc 1,187 _gen/yaks/yaks.asdl.h 1,034 _gen/yaks/yaks_main.mycpp.cc 3,348 _gen/yaks/yaks_main.mycpp.h 5 _gen/ysh/grammar_nt.h 76 _gen/ysh/grammar_tables.cc 4,551 117,402 lines in 41 files