├── bolt ├── py.typed ├── contrib │ └── __init__.py ├── resources │ └── __init__.py ├── __init__.py └── plugin.py ├── tests ├── __init__.py ├── snapshots │ ├── bolt__parse_100__1.txt │ ├── bolt__parse_136__1.txt │ ├── bolt__parse_137__1.txt │ ├── bolt__parse_163__1.txt │ ├── bolt__parse_166__1.txt │ ├── bolt__parse_274__1.txt │ ├── bolt__parse_280__1.txt │ ├── bolt__parse_362__1.txt │ ├── bolt__parse_366__1.txt │ ├── bolt__parse_73__0.txt │ ├── bolt__parse_74__0.txt │ ├── bolt__parse_307__0.txt │ ├── bolt__parse_59__0.txt │ ├── bolt__parse_27__0.txt │ ├── bolt__parse_155__0.txt │ ├── bolt__parse_157__0.txt │ ├── bolt__parse_187__0.txt │ ├── bolt__parse_257__0.txt │ ├── bolt__parse_306__0.txt │ ├── bolt__parse_325__0.txt │ ├── sandbox__run_8__0.txt │ ├── bolt__parse_115__0.txt │ ├── bolt__parse_18__0.txt │ ├── bolt__parse_213__0.txt │ ├── bolt__parse_242__0.txt │ ├── bolt__parse_361__0.txt │ ├── bolt__parse_52__0.txt │ ├── bolt__parse_60__0.txt │ ├── bolt__parse_177__0.txt │ ├── bolt__parse_28__0.txt │ ├── bolt__parse_31__0.txt │ ├── bolt__parse_58__0.txt │ ├── bolt__parse_116__0.txt │ ├── bolt__parse_121__0.txt │ ├── bolt__parse_122__0.txt │ ├── bolt__parse_214__0.txt │ ├── bolt__parse_172__0.txt │ ├── bolt__parse_40__0.txt │ ├── bolt__parse_75__0.txt │ ├── bolt__parse_123__0.txt │ ├── bolt__parse_277__0.txt │ ├── bolt__parse_61__0.txt │ ├── bolt__parse_85__0.txt │ ├── bolt__parse_178__0.txt │ ├── bolt__parse_179__0.txt │ ├── bolt__parse_188__0.txt │ ├── bolt__parse_232__0.txt │ ├── sandbox__run_0__0.txt │ ├── bolt__parse_173__0.txt │ ├── bolt__parse_204__0.txt │ ├── bolt__parse_339__0.txt │ ├── bolt__parse_38__0.txt │ ├── bolt__parse_76__0.txt │ ├── bolt__parse_124__0.txt │ ├── bolt__parse_30__0.txt │ ├── bolt__parse_310__0.txt │ ├── bolt__parse_119__0.txt │ ├── bolt__parse_190__0.txt │ ├── bolt__parse_256__0.txt │ ├── bolt__parse_39__0.txt │ ├── bolt__parse_158__0.txt │ ├── bolt__parse_260__0.txt │ ├── bolt__parse_311__0.txt │ ├── bolt__parse_54__0.txt │ ├── bolt__parse_56__0.txt │ ├── bolt__parse_296__0.txt │ ├── bolt__parse_308__0.txt │ ├── bolt__parse_159__0.txt │ ├── bolt__parse_19__0.txt │ ├── bolt__parse_266__0.txt │ ├── bolt__parse_298__0.txt │ ├── bolt__parse_348__0.txt │ ├── sandbox__run_7__0.txt │ ├── bolt__parse_189__0.txt │ ├── bolt__parse_326__0.txt │ ├── bolt__parse_347__0.txt │ ├── bolt__parse_272__0.txt │ ├── bolt__parse_295__0.txt │ ├── bolt__parse_300__0.txt │ ├── sandbox__run_5__0.txt │ ├── bolt__parse_297__0.txt │ ├── bolt__parse_48__0.txt │ ├── sandbox__run_4__0.txt │ ├── bolt__parse_299__0.txt │ ├── bolt__parse_180__0.txt │ ├── bolt__parse_261__0.txt │ ├── bolt__parse_302__0.txt │ ├── bolt__parse_304__0.txt │ ├── bolt__parse_364__0.txt │ ├── sandbox__run_1__0.txt │ ├── bolt__parse_146__0.txt │ ├── bolt__parse_191__0.txt │ ├── bolt__parse_212__0.txt │ ├── bolt__parse_301__0.txt │ ├── bolt__parse_303__0.txt │ ├── bolt__parse_349__0.txt │ ├── sandbox__run_6__0.txt │ ├── bolt__parse_148__0.txt │ ├── bolt__parse_267__0.txt │ ├── bolt__parse_252__0.txt │ ├── bolt__parse_88__0.txt │ ├── bolt__parse_240__0.txt │ ├── bolt__parse_86__0.txt │ ├── sandbox__run_3__0.txt │ ├── bolt__parse_147__0.txt │ ├── bolt__parse_149__0.txt │ ├── bolt__parse_253__0.txt │ ├── bolt__parse_258__0.txt │ ├── bolt__parse_350__0.txt │ ├── bolt__parse_351__0.txt │ ├── bolt__parse_224__0.txt │ ├── bolt__parse_271__0.txt │ ├── bolt__parse_90__0.txt │ ├── sandbox__run_2__0.txt │ ├── bolt__parse_183__0.txt │ ├── bolt__parse_125__0.txt │ ├── bolt__parse_269__0.txt │ ├── bolt__parse_342__0.txt │ ├── bolt__parse_79__0.txt │ ├── bolt__parse_236__0.txt │ ├── bolt__parse_225__0.txt │ ├── bolt__parse_368__0.txt │ ├── bolt__parse_335__0.txt │ ├── bolt__parse_353__0.txt │ ├── bolt__parse_37__0.txt │ ├── bolt__parse_268__0.txt │ ├── bolt__parse_230__0.txt │ ├── bolt__parse_358__0.txt │ ├── bolt__parse_78__0.txt │ ├── bolt__parse_222__0.txt │ ├── bolt__parse_36__0.txt │ ├── bolt__parse_223__0.txt │ ├── bolt__parse_309__0.txt │ ├── bolt__parse_83__0.txt │ ├── bolt__parse_305__0.txt │ ├── bolt__parse_312__0.txt │ ├── bolt__parse_99__0.txt │ ├── examples__build_bolt_lazy__0.pack.md │ ├── bolt__parse_195__0.txt │ ├── examples__build_bolt_memo2__0.pack.md │ ├── examples__build_bolt_circular__0.pack.md │ ├── examples__build_bolt_shadow_global__0.pack.md │ ├── bolt__parse_200__0.txt │ ├── bolt__parse_98__0.txt │ ├── examples__build_bolt_order__0.pack.md │ ├── examples__build_bolt_function_signature__0.pack.md │ ├── bolt__parse_270__0.txt │ ├── bolt__parse_352__0.txt │ ├── examples__build_bolt_assets__0.pack.md │ ├── examples__build_bolt_strip_final_newline__0.pack.md │ ├── examples__build_bolt_memo4__0.pack.md │ ├── bolt__parse_237__0.txt │ ├── examples__build_bolt_memo3__0.pack.md │ ├── examples__build_bolt_custom_provider__0.pack.md │ ├── examples__build_bolt_json__0.pack.md │ ├── examples__build_bolt_defer__0.pack.md │ ├── examples__build_bolt_1_20__0.pack.md │ ├── examples__build_bolt_lectern_prelude__0.pack.md │ ├── examples__build_bolt_docstring__0.pack.md │ ├── examples__build_bolt_overlay__0.pack.md │ ├── examples__build_bolt_merge__0.pack.md │ ├── bolt__parse_80__0.txt │ ├── bolt__parse_24__1.txt │ ├── bolt__parse_21__1.txt │ ├── bolt__parse_237__1.txt │ ├── bolt__parse_25__1.txt │ ├── bolt__parse_320__1.txt │ ├── bolt__parse_0__1.txt │ ├── bolt__parse_181__1.txt │ ├── bolt__parse_22__1.txt │ ├── bolt__parse_1__1.txt │ ├── bolt__parse_23__1.txt │ ├── bolt__parse_29__1.txt │ ├── bolt__parse_2__1.txt │ ├── bolt__parse_321__1.txt │ ├── bolt__parse_330__1.txt │ ├── bolt__parse_331__1.txt │ ├── bolt__parse_4__1.txt │ ├── bolt__parse_120__1.txt │ ├── bolt__parse_246__1.txt │ ├── bolt__parse_26__1.txt │ ├── bolt__parse_283__1.txt │ ├── bolt__parse_284__1.txt │ ├── bolt__parse_3__1.txt │ ├── bolt__parse_105__1.txt │ ├── bolt__parse_288__1.txt │ ├── bolt__parse_84__1.txt │ ├── bolt__parse_0__0.txt │ ├── bolt__parse_217__1.txt │ ├── bolt__parse_24__0.txt │ ├── bolt__parse_1__0.txt │ ├── bolt__parse_241__1.txt │ ├── bolt__parse_291__1.txt │ ├── bolt__parse_29__0.txt │ ├── bolt__parse_322__1.txt │ ├── bolt__parse_332__1.txt │ ├── bolt__parse_336__1.txt │ ├── bolt__parse_131__1.txt │ ├── bolt__parse_21__0.txt │ ├── bolt__parse_243__1.txt │ ├── bolt__parse_244__1.txt │ ├── bolt__parse_25__0.txt │ ├── bolt__parse_2__0.txt │ ├── bolt__parse_4__0.txt │ ├── bolt__parse_112__1.txt │ ├── bolt__parse_113__1.txt │ ├── bolt__parse_114__1.txt │ ├── bolt__parse_181__0.txt │ ├── bolt__parse_182__1.txt │ ├── bolt__parse_371__1.txt │ ├── bolt__parse_154__1.txt │ ├── bolt__parse_320__0.txt │ ├── bolt__parse_22__0.txt │ ├── bolt__parse_249__1.txt │ ├── bolt__parse_333__1.txt │ ├── bolt__parse_3__0.txt │ ├── bolt__parse_110__1.txt │ ├── bolt__parse_23__0.txt │ ├── bolt__parse_247__1.txt │ ├── bolt__parse_145__1.txt │ ├── bolt__parse_321__0.txt │ ├── bolt__parse_329__1.txt │ ├── examples__build_bolt_macro_perf__0.pack.md │ ├── bolt__parse_330__0.txt │ ├── bolt__parse_5__1.txt │ ├── bolt__parse_6__1.txt │ ├── bolt__parse_238__1.txt │ ├── bolt__parse_331__0.txt │ ├── examples__build_bolt_compile_cached__0.pack.md │ ├── bolt__parse_26__0.txt │ ├── bolt__parse_324__1.txt │ ├── bolt__parse_91__1.txt │ ├── bolt__parse_327__1.txt │ ├── bolt__parse_337__1.txt │ ├── bolt__parse_359__0.txt │ ├── bolt__parse_105__0.txt │ ├── bolt__parse_254__1.txt │ ├── bolt__parse_32__1.txt │ ├── bolt__parse_9__1.txt │ ├── bolt__parse_156__1.txt │ ├── bolt__parse_185__1.txt │ ├── bolt__parse_239__1.txt │ ├── bolt__parse_47__1.txt │ ├── bolt__parse_108__1.txt │ ├── bolt__parse_250__1.txt │ ├── bolt__parse_109__1.txt │ ├── bolt__parse_233__1.txt │ ├── bolt__parse_322__0.txt │ ├── bolt__parse_323__1.txt │ ├── bolt__parse_338__1.txt │ ├── bolt__parse_234__1.txt │ ├── examples__build_bolt_type_annotations__0.pack.md │ ├── bolt__parse_7__1.txt │ ├── bolt__parse_8__1.txt │ ├── examples__build_bolt_generated__0.pack.md │ ├── bolt__parse_15__1.txt │ ├── bolt__parse_69__1.txt │ ├── bolt__parse_49__1.txt │ ├── bolt__parse_106__1.txt │ ├── bolt__parse_359__1.txt │ ├── bolt__parse_87__1.txt │ ├── bolt__parse_107__1.txt │ ├── examples__build_bolt_class__0.pack.md │ ├── bolt__parse_367__1.txt │ ├── bolt__parse_65__1.txt │ ├── bolt__parse_369__1.txt │ ├── bolt__parse_50__1.txt │ ├── bolt__parse_10__1.txt │ ├── bolt__parse_111__1.txt │ ├── bolt__parse_11__1.txt │ ├── bolt__parse_33__1.txt │ ├── bolt__parse_357__1.txt │ ├── bolt__parse_71__1.txt │ ├── bolt__parse_372__1.txt │ ├── bolt__parse_92__1.txt │ ├── bolt__parse_93__1.txt │ ├── bolt__parse_262__1.txt │ ├── bolt__parse_285__1.txt │ ├── bolt__parse_286__1.txt │ ├── bolt__parse_287__1.txt │ ├── bolt__parse_13__1.txt │ ├── bolt__parse_14__1.txt │ ├── bolt__parse_160__1.txt │ ├── examples__build_bolt_overgen__0.pack.md │ ├── bolt__parse_150__1.txt │ ├── bolt__parse_360__1.txt │ ├── bolt__parse_12__1.txt │ ├── bolt__parse_66__1.txt │ ├── bolt__parse_248__1.txt │ ├── bolt__parse_100__0.txt │ ├── bolt__parse_340__1.txt │ ├── bolt__parse_67__1.txt │ ├── examples__build_bolt_debug__0.pack.md │ ├── bolt__parse_208__1.txt │ └── bolt__parse_65__0.txt ├── test_spec.py ├── conftest.py ├── resources │ └── sandbox_examples.mcfunction └── test_examples.py ├── examples ├── bolt_flat │ ├── demo │ │ ├── __init__.py │ │ ├── math.py │ │ └── main.bolt │ └── beet.yml ├── bolt_sample_ui │ ├── sample_ui │ │ ├── __init__.py │ │ ├── modules │ │ │ └── main.bolt │ │ ├── resources.py │ │ └── generate.py │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ └── ui_screens │ │ └── foo.xml ├── bolt_basic │ ├── random_data.json │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ ├── functions │ │ ├── utils.mcfunction │ │ ├── import_a.mcfunction │ │ ├── import_b.mcfunction │ │ └── thing.mcfunction │ │ └── modules │ │ └── utils.bolt ├── bolt_overlay │ ├── src │ │ ├── data │ │ │ └── demo │ │ │ │ ├── modules │ │ │ │ └── vars.bolt │ │ │ │ └── functions │ │ │ │ └── foo.mcfunction │ │ └── dummy_overlay │ │ │ └── data │ │ │ └── demo │ │ │ └── functions │ │ │ └── foo.mcfunction │ └── beet.yml ├── bolt_prelude │ └── src │ │ └── data │ │ ├── demo │ │ ├── functions │ │ │ ├── bar.mcfunction │ │ │ └── foo.mcfunction │ │ └── modules │ │ │ ├── macros.bolt │ │ │ ├── prelude.bolt │ │ │ └── other.bolt │ │ └── no_idea │ │ └── modules │ │ ├── bbb.bolt │ │ ├── aaa.bolt │ │ └── prelude.bolt ├── bolt_compile_cached │ ├── src │ │ └── data │ │ │ └── demo │ │ │ └── functions │ │ │ └── foo.mcfunction │ ├── cached │ │ └── slow.mcfunction │ ├── beet.yml │ └── compile_cached.py ├── bolt_lazy │ ├── src │ │ └── data │ │ │ └── demo │ │ │ └── modules │ │ │ ├── foo.bolt │ │ │ ├── hello1.lazy.bolt │ │ │ └── hello2.lazy.bolt │ └── beet.yml ├── bolt_generated │ ├── src │ │ └── data │ │ │ └── demo │ │ │ └── functions │ │ │ └── foo.mcfunction │ ├── beet.yml │ └── demo.py ├── bolt_shadow_global │ ├── src │ │ └── data │ │ │ └── demo │ │ │ └── functions │ │ │ └── foo.mcfunction │ ├── beet.yml │ └── demo.py ├── bolt_custom_provider │ ├── src │ │ └── data │ │ │ └── demo │ │ │ ├── custom │ │ │ └── stuff.bolt │ │ │ └── functions │ │ │ └── foo.mcfunction │ ├── beet.yml │ └── custom_provider.py ├── bolt_debug │ ├── src │ │ └── data │ │ │ └── demo │ │ │ └── functions │ │ │ ├── bar.mcfunction │ │ │ └── foo.mcfunction │ └── beet.yml ├── bolt_assets │ ├── src │ │ └── assets │ │ │ └── demo │ │ │ └── modules │ │ │ └── foo.bolt │ └── beet.yml ├── bolt_1_20 │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ └── functions │ │ └── foo.mcfunction ├── bolt_chicken │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ ├── functions │ │ └── chicken.mcfunction │ │ └── modules │ │ └── utils.bolt ├── bolt_class │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ └── functions │ │ └── pydantic.mcfunction ├── bolt_defer │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ └── functions │ │ └── foo.mcfunction ├── bolt_loop │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ └── functions │ │ └── init.mcfunction ├── bolt_macro │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ └── functions │ │ └── bar.mcfunction ├── bolt_memo2 │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ └── functions │ │ └── foo.mcfunction ├── bolt_memo3 │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ └── functions │ │ └── foo.mcfunction ├── bolt_memo4 │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ └── functions │ │ └── foo.mcfunction ├── bolt_merge │ ├── pack_1 │ │ └── data │ │ │ └── pack_1 │ │ │ └── functions │ │ │ ├── bob.mcfunction │ │ │ └── utils.mcfunction │ ├── pack_2 │ │ └── data │ │ │ └── pack_2 │ │ │ └── functions │ │ │ └── carol.mcfunction │ └── beet.yml ├── bolt_nesting │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ └── functions │ │ └── foo.mcfunction ├── bolt_strip_final_newline │ ├── src │ │ └── data │ │ │ └── demo │ │ │ └── functions │ │ │ └── foo.mcfunction │ └── beet.yml ├── bolt_summon │ └── beet.yml ├── bolt_chained_comp │ └── beet.yml ├── bolt_circular │ ├── src │ │ ├── bar.bolt │ │ ├── foo.bolt │ │ └── main.bolt │ └── beet.yml ├── bolt_docstring │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ └── functions │ │ └── foo.mcfunction ├── bolt_macro_perf │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ └── functions │ │ ├── export.mcfunction │ │ ├── func1.mcfunction │ │ ├── func2.mcfunction │ │ └── lib.mcfunction ├── bolt_order │ ├── src │ │ └── data │ │ │ └── hello │ │ │ └── modules │ │ │ ├── entry_point.bolt │ │ │ └── main.bolt │ └── beet.yml ├── bolt_proc_macro │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ └── functions │ │ └── foo.mcfunction ├── bolt_nested_location │ ├── beet.yml │ └── src │ │ └── data │ │ └── demo │ │ └── functions │ │ └── foo.mcfunction ├── bolt_type_annotations │ └── beet.yml ├── bolt_overgen │ ├── src │ │ └── data │ │ │ └── demo │ │ │ ├── functions │ │ │ └── foo.mcfunction │ │ │ └── overgen │ │ │ └── stuff.bolt │ └── beet.yml ├── bolt_json │ ├── beet.yml │ └── src │ │ └── data │ │ └── minecraft │ │ └── tags │ │ └── functions │ │ └── load.json ├── bolt_patchers │ ├── src │ │ └── data │ │ │ ├── minecraft │ │ │ └── recipes │ │ │ │ ├── tipped_arrow.json │ │ │ │ ├── spectral_arrow.json │ │ │ │ └── arrow.json │ │ │ └── demo │ │ │ ├── functions │ │ │ └── foo.mcfunction │ │ │ └── patchers │ │ │ └── arrow_recipes.bolt │ └── beet.yml ├── bolt_too_many_statically_nested_blocks │ └── beet.yml ├── bolt_function_signature │ ├── beet.yml │ └── foo.mcfunction ├── bolt_lectern_prelude │ ├── beet.yml │ └── source.txt └── bolt_memo │ ├── src │ └── data │ │ └── demo │ │ └── functions │ │ ├── foo.mcfunction │ │ └── vars.mcfunction │ └── beet.yml ├── .github ├── FUNDING.yml └── dependabot.yml ├── typings └── pathspec.py ├── .vscode ├── extensions.json └── settings.json ├── package.json └── setup.py /bolt/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bolt/contrib/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bolt/resources/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/bolt_flat/demo/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: 2 | - vberlier 3 | -------------------------------------------------------------------------------- /examples/bolt_sample_ui/sample_ui/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/bolt_basic/random_data.json: -------------------------------------------------------------------------------- 1 | { 2 | "value": 42 3 | } 4 | -------------------------------------------------------------------------------- /examples/bolt_overlay/src/data/demo/modules/vars.bolt: -------------------------------------------------------------------------------- 1 | stuff = 123 2 | -------------------------------------------------------------------------------- /typings/pathspec.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | PathSpec = Any 4 | -------------------------------------------------------------------------------- /examples/bolt_prelude/src/data/demo/functions/bar.mcfunction: -------------------------------------------------------------------------------- 1 | dump_ast() 2 | -------------------------------------------------------------------------------- /examples/bolt_compile_cached/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | say hello 2 | -------------------------------------------------------------------------------- /examples/bolt_lazy/src/data/demo/modules/foo.bolt: -------------------------------------------------------------------------------- 1 | import ./hello1.lazy as _ 2 | -------------------------------------------------------------------------------- /examples/bolt_flat/demo/math.py: -------------------------------------------------------------------------------- 1 | def add(a: int, b: int) -> int: 2 | return a + b 3 | -------------------------------------------------------------------------------- /examples/bolt_generated/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | a = 123 2 | say a 3 | -------------------------------------------------------------------------------- /examples/bolt_shadow_global/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | say max(1, 2, 3) 2 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_100__1.txt: -------------------------------------------------------------------------------- 1 | # Nothing 2 | --- 3 | output = None 4 | --- 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_136__1.txt: -------------------------------------------------------------------------------- 1 | # Nothing 2 | --- 3 | output = None 4 | --- 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_137__1.txt: -------------------------------------------------------------------------------- 1 | # Nothing 2 | --- 3 | output = None 4 | --- 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_163__1.txt: -------------------------------------------------------------------------------- 1 | # Nothing 2 | --- 3 | output = None 4 | --- 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_166__1.txt: -------------------------------------------------------------------------------- 1 | # Nothing 2 | --- 3 | output = None 4 | --- 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_274__1.txt: -------------------------------------------------------------------------------- 1 | # Nothing 2 | --- 3 | output = None 4 | --- 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_280__1.txt: -------------------------------------------------------------------------------- 1 | # Nothing 2 | --- 3 | output = None 4 | --- 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_362__1.txt: -------------------------------------------------------------------------------- 1 | # Nothing 2 | --- 3 | output = None 4 | --- 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_366__1.txt: -------------------------------------------------------------------------------- 1 | # Nothing 2 | --- 3 | output = None 4 | --- 5 | -------------------------------------------------------------------------------- /examples/bolt_prelude/src/data/no_idea/modules/bbb.bolt: -------------------------------------------------------------------------------- 1 | def okok(): 2 | say ok ok 3 | -------------------------------------------------------------------------------- /examples/bolt_custom_provider/src/data/demo/custom/stuff.bolt: -------------------------------------------------------------------------------- 1 | function ~/abc: 2 | say 123 3 | -------------------------------------------------------------------------------- /examples/bolt_debug/src/data/demo/functions/bar.mcfunction: -------------------------------------------------------------------------------- 1 | say hello without anything fancy 2 | -------------------------------------------------------------------------------- /examples/bolt_lazy/src/data/demo/modules/hello1.lazy.bolt: -------------------------------------------------------------------------------- 1 | function ./hello1: 2 | say hello1 3 | -------------------------------------------------------------------------------- /examples/bolt_lazy/src/data/demo/modules/hello2.lazy.bolt: -------------------------------------------------------------------------------- 1 | function ./hello2: 2 | say hello2 3 | -------------------------------------------------------------------------------- /examples/bolt_assets/src/assets/demo/modules/foo.bolt: -------------------------------------------------------------------------------- 1 | model minecraft:block/stone {"parent": "block/cube"} 2 | -------------------------------------------------------------------------------- /examples/bolt_compile_cached/cached/slow.mcfunction: -------------------------------------------------------------------------------- 1 | for i in range(10): 2 | say f"something slow {i}" 3 | -------------------------------------------------------------------------------- /examples/bolt_overlay/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | from ./vars import stuff 2 | say f"my {stuff}" 3 | -------------------------------------------------------------------------------- /examples/bolt_1_20/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_basic/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: [src] 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_basic/src/data/demo/functions/utils.mcfunction: -------------------------------------------------------------------------------- 1 | say this doesn't conflict with the demo:utils module 2 | -------------------------------------------------------------------------------- /examples/bolt_chicken/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: [src] 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_class/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_debug/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | def say_hello(): 2 | say hello 3 | 4 | say_hello() 5 | -------------------------------------------------------------------------------- /examples/bolt_defer/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_loop/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_macro/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_memo2/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_memo3/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_memo4/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_merge/pack_1/data/pack_1/functions/bob.mcfunction: -------------------------------------------------------------------------------- 1 | from pack_1:utils import hello 2 | hello("Bob") 3 | -------------------------------------------------------------------------------- /examples/bolt_nesting/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_overlay/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_strip_final_newline/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | scoreboard players operation foo set = bar set -------------------------------------------------------------------------------- /examples/bolt_summon/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_chained_comp/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_circular/src/bar.bolt: -------------------------------------------------------------------------------- 1 | import ./foo as foo 2 | 3 | VALUE = 33 4 | 5 | def b(): 6 | return foo.VALUE 7 | -------------------------------------------------------------------------------- /examples/bolt_circular/src/foo.bolt: -------------------------------------------------------------------------------- 1 | import ./bar as bar 2 | 3 | VALUE = 42 4 | 5 | def a(): 6 | return bar.VALUE 7 | -------------------------------------------------------------------------------- /examples/bolt_docstring/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_macro_perf/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_merge/pack_2/data/pack_2/functions/carol.mcfunction: -------------------------------------------------------------------------------- 1 | from pack_1:utils import hello 2 | hello("Carol") 3 | -------------------------------------------------------------------------------- /examples/bolt_order/src/data/hello/modules/entry_point.bolt: -------------------------------------------------------------------------------- 1 | from hello:main import i_run_last 2 | 3 | i_run_last() 4 | -------------------------------------------------------------------------------- /examples/bolt_proc_macro/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_nested_location/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_type_annotations/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_generated/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: [src] 5 | pipeline: 6 | - demo 7 | - mecha 8 | -------------------------------------------------------------------------------- /examples/bolt_memo2/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | say ok 2 | memo: 3 | append function __name__: 4 | say wat 5 | -------------------------------------------------------------------------------- /examples/bolt_overgen/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | value = "abc" 2 | print(value) 3 | say this should be left untouched 4 | -------------------------------------------------------------------------------- /examples/bolt_overlay/src/dummy_overlay/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | from ./vars import stuff 2 | say (1 + 2) 3 | say stuff 4 | -------------------------------------------------------------------------------- /examples/bolt_strip_final_newline/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_debug/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt.contrib.debug_codegen 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /examples/bolt_merge/pack_1/data/pack_1/functions/utils.mcfunction: -------------------------------------------------------------------------------- 1 | def hello(name): 2 | say f"Hello, {name}!" 3 | hello("Alice") 4 | -------------------------------------------------------------------------------- /examples/bolt_shadow_global/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | - demo 4 | data_pack: 5 | load: [src] 6 | pipeline: 7 | - mecha 8 | -------------------------------------------------------------------------------- /examples/bolt_circular/src/main.bolt: -------------------------------------------------------------------------------- 1 | from ./foo import a 2 | from ./bar import b 3 | 4 | function ./thing: 5 | say a() 6 | say b() 7 | -------------------------------------------------------------------------------- /examples/bolt_custom_provider/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | value = 123 2 | print(value) 3 | say this should be left untouched 4 | -------------------------------------------------------------------------------- /examples/bolt_compile_cached/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | - compile_cached 8 | -------------------------------------------------------------------------------- /examples/bolt_json/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - mecha.contrib.json_files 3 | - bolt 4 | data_pack: 5 | load: "src" 6 | pipeline: 7 | - mecha 8 | -------------------------------------------------------------------------------- /examples/bolt_prelude/src/data/demo/modules/macros.bolt: -------------------------------------------------------------------------------- 1 | macro greet name=brigadier:string{"type": "word"}: 2 | say f"hello {name.value}" 3 | -------------------------------------------------------------------------------- /examples/bolt_sample_ui/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - sample_ui.resources 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - sample_ui.generate 7 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_73__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected brace '(' but got newline '\n'. 2 | # line 1, column 6 3 | # 1 | def f 4 | def f 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_74__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected colon but reached end of file. 2 | # line 1, column 8 3 | # 1 | def f() 4 | def f() 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_307__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected non-empty block. 2 | # line 1, column 5 3 | # 1 | memo: 4 | # : ^ 5 | memo: 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_59__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Can only use "break" in loops. 2 | # line 1, column 1 3 | # 1 | break 4 | # : ^^^^^ 5 | break 6 | -------------------------------------------------------------------------------- /examples/bolt_patchers/src/data/minecraft/recipes/tipped_arrow.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_special_tippedarrow", 3 | "category": "misc" 4 | } 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_27__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Invalid escape sequence \". 2 | # line 1, column 5 3 | # 1 | 'abc\"' 4 | # : ^^ 5 | 'abc\"' 6 | -------------------------------------------------------------------------------- /examples/bolt_json/src/data/minecraft/tags/functions/load.json: -------------------------------------------------------------------------------- 1 | name = demo:foo 2 | 3 | { 4 | "values": [name] 5 | } 6 | 7 | function name: 8 | say hello 9 | -------------------------------------------------------------------------------- /examples/bolt_too_many_statically_nested_blocks/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt.contrib.debug_codegen 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_155__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Dict unpacking not allowed. 2 | # line 1, column 2 3 | # 1 | [**"abc"] 4 | # : ^^^^^^^ 5 | [**"abc"] 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_157__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR List unpacking not allowed. 2 | # line 1, column 2 3 | # 1 | {*{1: 1}} 4 | # : ^^^^^^^ 5 | {*{1: 1}} 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_187__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "x" is not defined. 2 | # line 1, column 8 3 | # 1 | global x 4 | # : ^ 5 | global x 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_257__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Can't apply decorator to nothing. 2 | # line 1, column 1 3 | # 1 | @print 4 | # : ^^^^^^ 5 | @print 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_306__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected assignment, colon or identifier but got newline '\n'. 2 | # line 1, column 5 3 | # 1 | memo 4 | memo 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_325__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Trailing input following final expression. 2 | # line 1, column 3 3 | # 1 | """ 4 | # : ^ 5 | """ 6 | -------------------------------------------------------------------------------- /tests/snapshots/sandbox__run_8__0.txt: -------------------------------------------------------------------------------- 1 | open("/etc/passwd") 2 | --- 3 | Reported 1 error. 4 | 5 | File "demo:foo", line 1, column 1: Identifier "open" is not defined. -------------------------------------------------------------------------------- /examples/bolt_chicken/src/data/demo/functions/chicken.mcfunction: -------------------------------------------------------------------------------- 1 | from ./utils import summon_chicken_army 2 | 3 | say Go forth, my minions! 4 | summon_chicken_army(16) 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_115__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected quote but got brace '}'. 2 | # line 1, column 8 3 | # 1 | yo = f"}" 4 | # : ^ 5 | yo = f"}" 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_18__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Trailing input following final expression. 2 | # line 1, column 4 3 | # 1 | 64 §§§ 4 | # : ^^^ 5 | 64 §§§ 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_213__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected non-empty block. 2 | # line 1, column 10 3 | # 1 | with None: 4 | # : ^ 5 | with None: 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_242__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "r" is not defined. 2 | # line 1, column 7 3 | # 1 | foo = r"\" 4 | # : ^ 5 | foo = r"\" 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_361__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Trailing input following final expression. 2 | # line 1, column 4 3 | # 1 | ~/ ~/ 4 | # : ^^ 5 | ~/ ~/ 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_52__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "foo" is not defined. 2 | # line 1, column 7 3 | # 1 | foo = foo 4 | # : ^^^ 5 | foo = foo 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_60__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Can only use "continue" in loops. 2 | # line 1, column 1 3 | # 1 | continue 4 | # : ^^^^^^^^ 5 | continue 6 | -------------------------------------------------------------------------------- /examples/bolt_assets/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | resource_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | meta: 8 | bolt: 9 | entrypoint: "*" 10 | -------------------------------------------------------------------------------- /examples/bolt_custom_provider/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - custom_provider 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | - custom_provider.remove_custom_modules 8 | -------------------------------------------------------------------------------- /examples/bolt_function_signature/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: 5 | data/demo/functions/foo.mcfunction: "foo.mcfunction" 6 | pipeline: 7 | - mecha 8 | -------------------------------------------------------------------------------- /examples/bolt_loop/src/data/demo/functions/init.mcfunction: -------------------------------------------------------------------------------- 1 | append function_tag minecraft:load { 2 | "values": [__name__] 3 | } 4 | 5 | scoreboard objectives add global dummy 6 | -------------------------------------------------------------------------------- /examples/bolt_prelude/src/data/no_idea/modules/aaa.bolt: -------------------------------------------------------------------------------- 1 | from ./bbb import okok 2 | from demo:macros import greet 3 | 4 | def alright_then(): 5 | okok() 6 | greet steve 7 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_177__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected colon but got newline '\n'. 2 | # line 1, column 25 3 | # 1 | append function demo:foo 4 | append function demo:foo 5 | -------------------------------------------------------------------------------- /examples/bolt_order/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | meta: 8 | bolt: 9 | entrypoint: hello:entry_point 10 | -------------------------------------------------------------------------------- /examples/bolt_overgen/src/data/demo/overgen/stuff.bolt: -------------------------------------------------------------------------------- 1 | declare_overlay_formats( 2 | min_inclusive=18, 3 | max_inclusive=19, 4 | ) 5 | 6 | function ./foo: 7 | say stuff 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_28__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Trailing input following final expression. 2 | # line 1, column 7 3 | # 1 | "hey" "hey" 4 | # : ^^^^^ 5 | "hey" "hey" 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_31__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "foo" is not defined. 2 | # line 1, column 11 3 | # 1 | "hello" + foo 4 | # : ^^^ 5 | "hello" + foo 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_58__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "the" is not defined. 2 | # line 1, column 7 3 | # 1 | wat = the = "f" 4 | # : ^^^ 5 | wat = the = "f" 6 | -------------------------------------------------------------------------------- /examples/bolt_merge/beet.yml: -------------------------------------------------------------------------------- 1 | data_pack: 2 | load: ["pack_1", "pack_2"] 3 | require: 4 | - bolt 5 | - mecha.contrib.messages 6 | - beet.contrib.auto_yaml 7 | pipeline: 8 | - mecha 9 | -------------------------------------------------------------------------------- /examples/bolt_patchers/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt.contrib.sandbox 3 | - patchers.define_custom_resources 4 | data_pack: 5 | load: "src" 6 | pipeline: 7 | - patchers.process_files 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_116__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Invalid escape sequence \e. 2 | # line 1, column 14 3 | # 1 | yo = f'thing \e' 4 | # : ^^ 5 | yo = f'thing \e' 6 | -------------------------------------------------------------------------------- /examples/bolt_memo3/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | n = 5 2 | execute function ~/{n}: 3 | say 1 4 | memo n: 5 | say 2 6 | append function ~/: 7 | say 3 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_121__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Can't import "demo:foo" without alias. 2 | # line 1, column 8 3 | # 1 | import demo:foo 4 | # : ^^^^^^^^ 5 | import demo:foo 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_122__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Can't import "demo:thing" without alias. 2 | # line 1, column 8 3 | # 1 | import ./thing 4 | # : ^^^^^^^ 5 | import ./thing 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_214__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected identifier but got invalid ':'. 2 | # line 1, column 13 3 | # 1 | with None as: 4 | # : ^ 5 | with None as: 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_172__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Can only delete variables, attributes, or subscripted items. 2 | # line 1, column 5 3 | # 1 | del 1 + 1 4 | # : ^^^^^ 5 | del 1 + 1 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_40__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected non-empty block. 2 | # line 1, column 8 3 | # 1 | if True: 4 | # : ^ 5 | # 2 | say hello 6 | if True: 7 | say hello 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_75__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected non-empty block. 2 | # line 1, column 8 3 | # 1 | def f(): 4 | # : ^ 5 | # 2 | say yolo 6 | def f(): 7 | say yolo 8 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-python.python", 4 | "ms-python.vscode-pylance", 5 | "ms-python.black-formatter", 6 | "tamasfe.even-better-toml" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /examples/bolt_circular/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: 5 | data/demo/modules: src 6 | pipeline: 7 | - mecha 8 | meta: 9 | bolt: 10 | entrypoint: "demo:main" 11 | -------------------------------------------------------------------------------- /examples/bolt_lazy/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: "src" 5 | pipeline: 6 | - mecha 7 | meta: 8 | bolt: 9 | entrypoint: 10 | - "*" 11 | - "!*.lazy" 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "watch": "poetry run pyright -w", 4 | "check": "poetry run pyright" 5 | }, 6 | "devDependencies": { 7 | "pyright": "^1.1.293" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_123__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Invalid module location "wat/is/that". 2 | # line 1, column 8 3 | # 1 | import wat/is/that 4 | # : ^^^^^^^^^^^ 5 | import wat/is/that 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_277__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected call expression on builtin "hex". 2 | # line 1, column 10 3 | # 1 | time set hex.time 4 | # : ^^^^^^^^ 5 | time set hex.time 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_61__0.txt: -------------------------------------------------------------------------------- 1 | if true: 2 | #>ERROR Can only use "break" in loops. 3 | # line 2, column 5 4 | # 1 | if true: 5 | # 2 | break 6 | # : ^^^^^ 7 | break 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_85__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Statement "return" is not allowed in this context. 2 | # line 1, column 1 3 | # 1 | return "hello" 4 | # : ^^^^^^^^^^^^^^ 5 | return "hello" 6 | -------------------------------------------------------------------------------- /examples/bolt_flat/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | data_pack: 4 | load: 5 | data/demo/modules: "@demo" 6 | pipeline: 7 | - mecha 8 | meta: 9 | bolt: 10 | entrypoint: "demo:main" 11 | -------------------------------------------------------------------------------- /examples/bolt_order/src/data/hello/modules/main.bolt: -------------------------------------------------------------------------------- 1 | def i_run_last(): 2 | print(2) 3 | append function hello:world: 4 | say second 5 | 6 | print(1) 7 | append function hello:world: 8 | say first 9 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_178__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected assignment, identifier, nested_location or resource_location but got newline '\n'. 2 | # line 1, column 13 3 | # 1 | function_tag 4 | function_tag 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_179__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected identifier, nested_location or resource_location but got newline '\n'. 2 | # line 1, column 19 3 | # 1 | merge function_tag 4 | merge function_tag 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_188__0.txt: -------------------------------------------------------------------------------- 1 | x = 1 2 | #>ERROR Can't make local identifier "x" global. 3 | # line 2, column 8 4 | # 1 | x = 1 5 | # 2 | global x 6 | # : ^ 7 | global x 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_232__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Forbidden literal "macro". 2 | # line 1, column 7 3 | # 1 | macro macro: 4 | # : ^^^^^ 5 | # 2 | pass 6 | macro macro: 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/sandbox__run_0__0.txt: -------------------------------------------------------------------------------- 1 | import sys 2 | --- 3 | Traceback (most recent call last): 4 | File "demo:foo", line 1, in demo:foo 5 | bolt.contrib.sandbox.SecurityError: Access forbidden module 'sys'. 6 | -------------------------------------------------------------------------------- /examples/bolt_class/src/data/demo/functions/pydantic.mcfunction: -------------------------------------------------------------------------------- 1 | from pydantic.v1 import BaseModel 2 | 3 | class Model(BaseModel, frozen=True): 4 | a: int 5 | b: str 6 | 7 | say Model(a="123", b="123").json() 8 | -------------------------------------------------------------------------------- /examples/bolt_lectern_prelude/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt 3 | pipeline: 4 | - lectern 5 | - mecha 6 | meta: 7 | lectern: 8 | load: "source.txt" 9 | bolt: 10 | prelude: "demo:prelude" 11 | -------------------------------------------------------------------------------- /examples/bolt_macro_perf/src/data/demo/functions/export.mcfunction: -------------------------------------------------------------------------------- 1 | # Importing macros doesn't cause a command tree update when there is no code below 2 | 3 | from ./lib import foo1, foo2 4 | from ./lib import foo3 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_173__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected non-empty block. 2 | # line 1, column 26 3 | # 1 | execute function demo:foo: 4 | # : ^ 5 | execute function demo:foo: 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_204__0.txt: -------------------------------------------------------------------------------- 1 | "hey" 2 | #>ERROR Invalid indent following final expression. 3 | # line 2, column 5 4 | # 1 | "hey" 5 | # 2 | "hey" 6 | # : ^^^^^ 7 | "hey" 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_339__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "doesnotexist" is not defined. 2 | # line 1, column 6 3 | # 1 | foo: doesnotexist = 123 4 | # : ^^^^^^^^^^^^ 5 | foo: doesnotexist = 123 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_38__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected bracket '[', curly '{', docstring, ellipsis, false, identifier or 16 other tokens but reached end of file. 2 | # line 1, column 3 3 | # 1 | if 4 | if 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_76__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "a" is not defined. 2 | # line 1, column 9 3 | # 1 | def f(a=a): 4 | # : ^ 5 | # 2 | say wat 6 | def f(a=a): 7 | say wat 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_124__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Invalid module location "wat/is/that". 2 | # line 1, column 6 3 | # 1 | from wat/is/that import foo 4 | # : ^^^^^^^^^^^ 5 | from wat/is/that import foo 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_30__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "foo" is not defined. 2 | # line 1, column 1 3 | # 1 | foo 4 | # : ^^^ 5 | # Notes: 6 | # - Expected assignment but got newline '\n'. 7 | foo 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_310__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "foo" is not defined. 2 | # line 1, column 10 3 | # 1 | memo foo=foo: 4 | # : ^^^ 5 | # 2 | pass 6 | memo foo=foo: 7 | pass 8 | -------------------------------------------------------------------------------- /examples/bolt_prelude/src/data/demo/modules/prelude.bolt: -------------------------------------------------------------------------------- 1 | from ./macros import greet 2 | from ./other import CALAMAR, dump_ast 3 | 4 | macro !!!: 5 | say !!! 6 | 7 | def anonymous() -> str: 8 | return "anonymous" 9 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_119__0.txt: -------------------------------------------------------------------------------- 1 | if True: 2 | #>ERROR Statement "yield" is not allowed in this context. 3 | # line 2, column 5 4 | # 1 | if True: 5 | # 2 | yield 6 | # : ^^^^^ 7 | yield 8 | -------------------------------------------------------------------------------- /examples/bolt_shadow_global/demo.py: -------------------------------------------------------------------------------- 1 | from beet import Context 2 | 3 | from bolt import Runtime 4 | 5 | 6 | def beet_default(ctx: Context): 7 | runtime = ctx.inject(Runtime) 8 | runtime.expose("max", lambda *args: args) 9 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # This is a shim to allow GitHub to detect the package. The build is done with poetry. 4 | 5 | import setuptools 6 | 7 | if __name__ == "__main__": 8 | setuptools.setup(name="bolt") 9 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_190__0.txt: -------------------------------------------------------------------------------- 1 | def f(x): 2 | #>ERROR Can't make local identifier "x" global. 3 | # line 2, column 12 4 | # 1 | def f(x): 5 | # 2 | global x 6 | # : ^ 7 | global x 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_256__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Decorators can only be applied to functions or classes. 2 | # line 1, column 1 3 | # 1 | @print 4 | # : ^^^^^^ 5 | # 2 | foo = "bar" 6 | @print 7 | foo = "bar" 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_39__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected bracket '[', curly '{', docstring, ellipsis, false, identifier or 5 other tokens but got newline '\n'. 2 | # line 1, column 12 3 | # 1 | if True and 4 | if True and 5 | -------------------------------------------------------------------------------- /examples/bolt_prelude/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | !!! 2 | greet anonymous() 3 | summon CALAMAR 4 | CALAMAR = None 5 | 6 | !!! 7 | alright_then() 8 | what about minecraft:becomeduck 9 | 10 | !!! 11 | dump_ast() 12 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_158__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "foo" is not defined. 2 | # line 1, column 1 3 | # 1 | foo.bar = 1 4 | # : ^^^ 5 | # Notes: 6 | # - Expected assignment but got literal '.bar'. 7 | foo.bar = 1 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_260__0.txt: -------------------------------------------------------------------------------- 1 | class Foo: 2 | #>ERROR Statement "return" is not allowed in this context. 3 | # line 2, column 5 4 | # 1 | class Foo: 5 | # 2 | return 6 | # : ^^^^^^ 7 | return 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_311__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected assignment, colon or identifier but got literal '{}'. 2 | # line 1, column 6 3 | # 1 | memo {}: 4 | # : ^^ 5 | # 2 | pass 6 | memo {}: 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_54__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "foo" is not defined. 2 | # line 1, column 12 3 | # 1 | for foo in foo: 4 | # : ^^^ 5 | # 2 | foo = foo 6 | for foo in foo: 7 | foo = foo 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_56__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "foo" is not defined. 2 | # line 1, column 1 3 | # 1 | foo += "hey" 4 | # : ^^^ 5 | # Notes: 6 | # - Expected assignment but got literal '+='. 7 | foo += "hey" 8 | -------------------------------------------------------------------------------- /examples/bolt_lectern_prelude/source.txt: -------------------------------------------------------------------------------- 1 | @module demo:prelude 2 | stuff = 123 3 | 4 | @function demo:foo 5 | say stuff 6 | 7 | @overlay dummy 8 | @module demo:prelude 9 | stuff = 456 10 | 11 | @function demo:foo 12 | say stuff 13 | -------------------------------------------------------------------------------- /examples/bolt_prelude/src/data/no_idea/modules/prelude.bolt: -------------------------------------------------------------------------------- 1 | from ./aaa import alright_then 2 | 3 | macro what about(stream): 4 | from mecha import delegate 5 | node = delegate("resource_location", stream) 6 | say repr(node) 7 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_296__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected at least one named argument after bare variadic marker. 2 | # line 1, column 7 3 | # 1 | def g(*): 4 | # : ^ 5 | # 2 | pass 6 | def g(*): 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_308__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected assignment, colon or identifier but got literal '123'. 2 | # line 1, column 6 3 | # 1 | memo 123: 4 | # : ^^^ 5 | # 2 | pass 6 | memo 123: 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_159__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "foo" is not defined. 2 | # line 1, column 1 3 | # 1 | foo().bar = 1 4 | # : ^^^ 5 | # Notes: 6 | # - Expected assignment but got literal '().bar'. 7 | foo().bar = 1 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_19__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected bracket '[', curly '{', docstring, ellipsis, false, identifier or 5 other tokens but got literal '%3'. 2 | # line 1, column 6 3 | # 1 | 17 % %3 4 | # : ^^ 5 | 17 % %3 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_266__0.txt: -------------------------------------------------------------------------------- 1 | if 0: 2 | #>ERROR Import statement can only appear directly at scope level. 3 | # line 2, column 5 4 | # 1 | if 0: 5 | # 2 | import math 6 | # : ^^^^^^^^^^^ 7 | import math 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_298__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Positional marker can not appear after variadic arguments. 2 | # line 1, column 10 3 | # 1 | def g(*, /): 4 | # : ^ 5 | # 2 | pass 6 | def g(*, /): 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_348__0.txt: -------------------------------------------------------------------------------- 1 | for i in range(10): 2 | memo: 3 | #>ERROR Can only use "break" in loops. 4 | # line 3, column 9 5 | # 2 | memo: 6 | # 3 | break 7 | # : ^^^^^ 8 | break 9 | -------------------------------------------------------------------------------- /tests/snapshots/sandbox__run_7__0.txt: -------------------------------------------------------------------------------- 1 | say __name__.format() 2 | --- 3 | Traceback (most recent call last): 4 | File "demo:foo", line 1, in demo:foo 5 | bolt.contrib.sandbox.SecurityError: Access forbidden attribute 'format' of . 6 | -------------------------------------------------------------------------------- /examples/bolt_macro_perf/src/data/demo/functions/func1.mcfunction: -------------------------------------------------------------------------------- 1 | # Importing multiple macros in a row will update the command tree in a single batch 2 | 3 | from ./lib import foo1, foo2 4 | from ./lib import foo3 5 | 6 | foo1 7 | foo2 8 | foo3 9 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_189__0.txt: -------------------------------------------------------------------------------- 1 | x = 1 2 | def f(): 3 | #>ERROR Identifier "xx" is not defined. Did you mean "x"? 4 | # line 3, column 12 5 | # 2 | def f(): 6 | # 3 | global xx 7 | # : ^^ 8 | global xx 9 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_326__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Trailing input following final expression. 2 | # line 1, column 9 3 | # 1 | foo = """ 4 | # : ^ 5 | # 2 | This is a docstring. 6 | foo = """ 7 | This is a docstring. 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_347__0.txt: -------------------------------------------------------------------------------- 1 | for i in range(10): 2 | def f(): 3 | #>ERROR Can only use "break" in loops. 4 | # line 3, column 9 5 | # 2 | def f(): 6 | # 3 | break 7 | # : ^^^^^ 8 | break 9 | -------------------------------------------------------------------------------- /examples/bolt_macro_perf/src/data/demo/functions/func2.mcfunction: -------------------------------------------------------------------------------- 1 | # If multiple scopes end up using the same set of macros they will share the same underlying command spec 2 | 3 | from ./export import foo1, foo2, foo3 4 | 5 | foo1 6 | foo2 7 | foo3 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_272__0.txt: -------------------------------------------------------------------------------- 1 | class B: 2 | #>ERROR Import statement can only appear directly at scope level. 3 | # line 2, column 5 4 | # 1 | class B: 5 | # 2 | import math 6 | # : ^^^^^^^^^^^ 7 | import math 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_295__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Positional marker can not appear directly at the beginning of the argument list. 2 | # line 1, column 7 3 | # 1 | def g(/): 4 | # : ^ 5 | # 2 | pass 6 | def g(/): 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_300__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected at least one named argument after bare variadic marker. 2 | # line 1, column 12 3 | # 1 | def g(foo, *): 4 | # : ^ 5 | # 2 | pass 6 | def g(foo, *): 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/sandbox__run_5__0.txt: -------------------------------------------------------------------------------- 1 | "a{0.__class__}b".format(42) 2 | --- 3 | Traceback (most recent call last): 4 | File "demo:foo", line 1, in demo:foo 5 | bolt.contrib.sandbox.SecurityError: Access forbidden attribute 'format' of . 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_297__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Positional marker can not appear directly at the beginning of the argument list. 2 | # line 1, column 7 3 | # 1 | def g(/, *): 4 | # : ^ 5 | # 2 | pass 6 | def g(/, *): 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_48__0.txt: -------------------------------------------------------------------------------- 1 | 1 * 2 2 | #>ERROR Expected bracket '[', curly '{', decorator, docstring, ellipsis, false or 188 other tokens but got literal '*'. 3 | # line 2, column 1 4 | # 1 | 1 * 2 5 | # 2 | * 3 6 | # : ^ 7 | * 3 8 | -------------------------------------------------------------------------------- /tests/snapshots/sandbox__run_4__0.txt: -------------------------------------------------------------------------------- 1 | print(f'foo {str.__name__} bar') 2 | --- 3 | Traceback (most recent call last): 4 | File "demo:foo", line 1, in demo:foo 5 | bolt.contrib.sandbox.SecurityError: Access forbidden attribute '__name__' of . 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_299__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Positional marker can not appear directly at the beginning of the argument list. 2 | # line 1, column 7 3 | # 1 | def g(/, foo): 4 | # : ^ 5 | # 2 | pass 6 | def g(/, foo): 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_180__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected bracket '[', curly '{', false, identifier, null, number, string or true but reached end of file. 2 | # line 1, column 34 3 | # 1 | merge function_tag minecraft:tick 4 | merge function_tag minecraft:tick 5 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_261__0.txt: -------------------------------------------------------------------------------- 1 | def f(): 2 | class Foo: 3 | #>ERROR Statement "return" is not allowed in this context. 4 | # line 3, column 9 5 | # 2 | class Foo: 6 | # 3 | return 7 | # : ^^^^^^ 8 | return 9 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_302__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Positional marker already present in function signature. 2 | # line 1, column 20 3 | # 1 | def g(foo, /, bar, /): 4 | # : ^ 5 | # 2 | pass 6 | def g(foo, /, bar, /): 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_304__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Argument without default can not appear after arguments with default values. 2 | # line 1, column 12 3 | # 1 | def g(a=1, b): 4 | # : ^ 5 | # 2 | pass 6 | def g(a=1, b): 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_364__0.txt: -------------------------------------------------------------------------------- 1 | x = ./foo 2 | #>ERROR Expected bracket '[', curly '{', false, identifier, null, number, string or true but reached end of file. 3 | # line 2, column 14 4 | # 1 | x = ./foo 5 | # 2 | predicate x[] 6 | predicate x[] 7 | -------------------------------------------------------------------------------- /tests/snapshots/sandbox__run_1__0.txt: -------------------------------------------------------------------------------- 1 | def f(): 2 | pass 3 | f.__code__ 4 | --- 5 | Traceback (most recent call last): 6 | File "demo:foo", line 3, in demo:foo 7 | bolt.contrib.sandbox.SecurityError: Access forbidden attribute '__code__' of . 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_146__0.txt: -------------------------------------------------------------------------------- 1 | def f(): 2 | pass 3 | #>ERROR Positional argument not allowed after keyword arguments. 4 | # line 3, column 18 5 | # 2 | pass 6 | # 3 | f(1, 2, thing=3, 4) 7 | # : ^ 8 | f(1, 2, thing=3, 4) 9 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_191__0.txt: -------------------------------------------------------------------------------- 1 | x = 1 2 | def f(): 3 | global x 4 | #>ERROR Can't make global identifier "x" nonlocal. 5 | # line 4, column 14 6 | # 3 | global x 7 | # 4 | nonlocal x 8 | # : ^ 9 | nonlocal x 10 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_212__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected bracket '[', curly '{', docstring, ellipsis, false, identifier or 8 other tokens but got invalid ':'. 2 | # line 1, column 5 3 | # 1 | with: 4 | # : ^ 5 | # 2 | pass 6 | with: 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_301__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Variadic keyword arguments should not be followed by anything. 2 | # line 1, column 17 3 | # 1 | def g(**kwargs, foo): 4 | # : ^^^ 5 | # 2 | pass 6 | def g(**kwargs, foo): 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_303__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Variadic arguments already specified. 2 | # line 1, column 24 3 | # 1 | def g(foo, *args, bar, *args): 4 | # : ^ 5 | # 2 | pass 6 | def g(foo, *args, bar, *args): 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_349__0.txt: -------------------------------------------------------------------------------- 1 | def f(): 2 | memo: 3 | #>ERROR Statement "return" is not allowed in this context. 4 | # line 3, column 9 5 | # 2 | memo: 6 | # 3 | return 9999 7 | # : ^^^^^^^^^^^ 8 | return 9999 9 | -------------------------------------------------------------------------------- /tests/snapshots/sandbox__run_6__0.txt: -------------------------------------------------------------------------------- 1 | foo = "a{x.__class__}b".format_map({"x":42}) 2 | --- 3 | Traceback (most recent call last): 4 | File "demo:foo", line 1, in demo:foo 5 | bolt.contrib.sandbox.SecurityError: Access forbidden attribute 'format_map' of . 6 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | updates: 4 | - package-ecosystem: "pip" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | 9 | - package-ecosystem: "npm" 10 | directory: "/" 11 | schedule: 12 | interval: "weekly" 13 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_148__0.txt: -------------------------------------------------------------------------------- 1 | def f(): 2 | pass 3 | #>ERROR List unpacking not allowed after keyword arguments. 4 | # line 3, column 18 5 | # 2 | pass 6 | # 3 | f(1, 2, thing=3, *[4]) 7 | # : ^^^^ 8 | f(1, 2, thing=3, *[4]) 9 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_267__0.txt: -------------------------------------------------------------------------------- 1 | def f(): 2 | if 0: 3 | #>ERROR Import statement can only appear directly at scope level. 4 | # line 3, column 9 5 | # 2 | if 0: 6 | # 3 | import this 7 | # : ^^^^^^^^^^^ 8 | import this 9 | -------------------------------------------------------------------------------- /examples/bolt_1_20/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | def f(): 2 | execute if entity @e[type=pig] run return 123 3 | n = 77 4 | execute return n 5 | return 99999 6 | 7 | say f() 8 | 9 | execute function ./thing: 10 | return 42 11 | 12 | return 0 13 | -------------------------------------------------------------------------------- /examples/bolt_memo4/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | def stuff(): 2 | memo: 3 | append function __name__: 4 | say something 5 | 6 | say before 7 | stuff() 8 | stuff() 9 | say after 10 | 11 | function ./bar: 12 | say bop 13 | stuff() 14 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_252__0.txt: -------------------------------------------------------------------------------- 1 | class Foo: 2 | #>ERROR Identifier "Foo" is not defined. 3 | # line 2, column 5 4 | # 1 | class Foo: 5 | # 2 | Foo() 6 | # : ^^^ 7 | # Notes: 8 | # - Expected assignment but got literal '()'. 9 | Foo() 10 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_88__0.txt: -------------------------------------------------------------------------------- 1 | def f(): 2 | foo = 0 3 | #>ERROR Identifier "foo" is not defined. 4 | # line 3, column 3 5 | # 2 | foo = 0 6 | # 3 | f(foo) 7 | # : ^^^ 8 | # Notes: 9 | # - Expected equal but got brace ')'. 10 | f(foo) 11 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_240__0.txt: -------------------------------------------------------------------------------- 1 | foo = { 2 | a: 1, 3 | #>ERROR Forbidden dynamic key in dict without quotes. 4 | # line 3, column 5 5 | # 2 | a: 1, 6 | # 3 | "b" + "c": 2 7 | # : ^^^^^^^^^ 8 | # 4 | } 9 | "b" + "c": 2 10 | } 11 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_86__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "foo" is not defined. 2 | # line 1, column 8 3 | # 1 | return foo 4 | # : ^^^ 5 | # Notes: 6 | # - Expected colon, eof, literal 'fail', literal 'run', newline or number but got literal 'foo'. 7 | return foo 8 | -------------------------------------------------------------------------------- /tests/snapshots/sandbox__run_3__0.txt: -------------------------------------------------------------------------------- 1 | say ctx.data.functions.setdefault("demo:foo") 2 | --- 3 | Traceback (most recent call last): 4 | File "demo:foo", line 1, in demo:foo 5 | bolt.contrib.sandbox.SecurityError: Access forbidden attribute 'data' of . 6 | -------------------------------------------------------------------------------- /tests/test_spec.py: -------------------------------------------------------------------------------- 1 | from beet import Context 2 | from mecha import Mecha 3 | from pytest_insta import SnapshotFixture 4 | 5 | 6 | def test_prototypes(snapshot: SnapshotFixture, ctx: Context): 7 | mc = ctx.inject(Mecha) 8 | assert snapshot("json") == list(sorted(mc.spec.prototypes)) 9 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_147__0.txt: -------------------------------------------------------------------------------- 1 | def f(): 2 | pass 3 | #>ERROR Positional argument not allowed after keyword arguments. 4 | # line 3, column 25 5 | # 2 | pass 6 | # 3 | f(1, 2, **{"thing": 3}, 4) 7 | # : ^ 8 | f(1, 2, **{"thing": 3}, 4) 9 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_149__0.txt: -------------------------------------------------------------------------------- 1 | def f(): 2 | pass 3 | #>ERROR List unpacking not allowed after keyword arguments. 4 | # line 3, column 25 5 | # 2 | pass 6 | # 3 | f(1, 2, **{"thing": 3}, *[4]) 7 | # : ^^^^ 8 | f(1, 2, **{"thing": 3}, *[4]) 9 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_253__0.txt: -------------------------------------------------------------------------------- 1 | class Foo: 2 | bar = 2 3 | #>ERROR Identifier "bar" is not defined. 4 | # line 3, column 7 5 | # 2 | bar = 2 6 | # 3 | print(bar) 7 | # : ^^^ 8 | # Notes: 9 | # - Expected equal but got brace ')'. 10 | print(bar) 11 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_258__0.txt: -------------------------------------------------------------------------------- 1 | if True: 2 | #>ERROR Can't apply decorator to nothing. 3 | # line 2, column 5 4 | # 1 | if True: 5 | # 2 | @print 6 | # : ^^^^^^ 7 | # 3 | class A: 8 | # 4 | pass 9 | @print 10 | class A: 11 | pass 12 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_350__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Unexpected macro argument after subcommand. 2 | # line 1, column 30 3 | # 1 | macro hello thing=subcommand after: 4 | # : ^^^^^ 5 | # 2 | pass 6 | macro hello thing=subcommand after: 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_351__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Interpolation disabled. 2 | # line 1, column 42 3 | # 1 | macro hello thing=subcommand{"redirect": ] 4 | # : ^ 5 | # 2 | pass 6 | macro hello thing=subcommand{"redirect": ] 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_224__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Specifying a tag is not allowed '#brigadier:integer'. 2 | # line 1, column 15 3 | # 1 | macro foo bar=#brigadier:integer: 4 | # : ^^^^^^^^^^^^^^^^^^ 5 | # 2 | pass 6 | macro foo bar=#brigadier:integer: 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_271__0.txt: -------------------------------------------------------------------------------- 1 | class A: 2 | #>ERROR Macro definition can only appear directly at scope level. 3 | # line 2, column 5 4 | # 1 | class A: 5 | # 2 | macro foo: 6 | # : ^^^^^^^^^ 7 | # 3 | pass 8 | macro foo: 9 | pass 10 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_90__0.txt: -------------------------------------------------------------------------------- 1 | def f(x): 2 | #>ERROR Identifier "xx" is not defined. Did you mean "x"? 3 | # line 2, column 16 4 | # 1 | def f(x): 5 | # 2 | tellraw @a xx 6 | # : ^^ 7 | # 3 | f("thing") 8 | tellraw @a xx 9 | f("thing") 10 | -------------------------------------------------------------------------------- /tests/snapshots/sandbox__run_2__0.txt: -------------------------------------------------------------------------------- 1 | def hello(): 2 | return "world" 3 | say hello.__name__.capitalize() 4 | --- 5 | Traceback (most recent call last): 6 | File "demo:foo", line 3, in demo:foo 7 | bolt.contrib.sandbox.SecurityError: Access forbidden attribute '__name__' of . 8 | -------------------------------------------------------------------------------- /examples/bolt_overgen/beet.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - bolt.contrib.sandbox 3 | - overgen.define_custom_resources 4 | - overgen.define_compilation_unit_providers 5 | - overgen.define_module_globals 6 | data_pack: 7 | load: "src" 8 | pipeline: 9 | - mecha 10 | - overgen.remove_custom_resources 11 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_183__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected identifier but got literal 'class'. 2 | # line 1, column 5 3 | # 1 | for class in "abc": 4 | # : ^^^^^ 5 | # 2 | scoreboard objectives add class dummy 6 | for class in "abc": 7 | scoreboard objectives add class dummy 8 | -------------------------------------------------------------------------------- /examples/bolt_macro_perf/src/data/demo/functions/lib.mcfunction: -------------------------------------------------------------------------------- 1 | # Defining multiple macros in a row will update the command tree in a single batch 2 | 3 | macro foo1: 4 | say foo1 5 | 6 | macro foo2: 7 | say foo2 8 | 9 | macro foo3: 10 | say foo3 11 | 12 | macro foo4: 13 | say foo4 14 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_125__0.txt: -------------------------------------------------------------------------------- 1 | import math 2 | #>ERROR Identifier "mah" is not defined. Did you mean "math"? 3 | # line 2, column 1 4 | # 1 | import math 5 | # 2 | mah.sin(1) 6 | # : ^^^ 7 | # Notes: 8 | # - Expected assignment but got literal '.sin(1)'. 9 | mah.sin(1) 10 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_269__0.txt: -------------------------------------------------------------------------------- 1 | if "beans": 2 | #>ERROR Macro definition can only appear directly at scope level. 3 | # line 2, column 5 4 | # 1 | if "beans": 5 | # 2 | macro beans: 6 | # : ^^^^^^^^^^^ 7 | # 3 | pass 8 | macro beans: 9 | pass 10 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_342__0.txt: -------------------------------------------------------------------------------- 1 | uwu = 0 2 | def f(): 3 | global uwu 4 | memo: 5 | #>ERROR Binding to global variable "uwu" is not allowed in this context. 6 | # line 5, column 9 7 | # 4 | memo: 8 | # 5 | uwu = 9 9 | # : ^^^ 10 | uwu = 9 11 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_79__0.txt: -------------------------------------------------------------------------------- 1 | def f(a, b): 2 | def g(c): 3 | a + b 4 | #>ERROR Identifier "c" is not defined. 5 | # line 4, column 7 6 | # 3 | a + b 7 | # 4 | f(c) 8 | # : ^ 9 | # Notes: 10 | # - Expected equal but got brace ')'. 11 | f(c) 12 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_236__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Proc macro "foo" contains non-literal match. 2 | # line 1, column 11 3 | # 1 | macro foo message=minecraft:message(stream): 4 | # : ^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | # 2 | pass 6 | macro foo message=minecraft:message(stream): 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_225__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Unrecognized argument parser "brigadier:does_not_exist". 2 | # line 1, column 15 3 | # 1 | macro foo bar=brigadier:does_not_exist: 4 | # : ^^^^^^^^^^^^^^^^^^^^^^^^ 5 | # 2 | pass 6 | macro foo bar=brigadier:does_not_exist: 7 | pass 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_368__0.txt: -------------------------------------------------------------------------------- 1 | class A: 2 | pass 3 | #>ERROR Base class not allowed after keyword argument "foo". 4 | # line 3, column 19 5 | # 2 | pass 6 | # 3 | class B(foo=True, A): 7 | # : ^ 8 | # 4 | pass 9 | class B(foo=True, A): 10 | pass 11 | -------------------------------------------------------------------------------- /examples/bolt_prelude/src/data/demo/modules/other.bolt: -------------------------------------------------------------------------------- 1 | from bolt import Runtime 2 | 3 | CALAMAR = minecraft:squid 4 | 5 | def dump_ast(): 6 | runtime = ctx.inject(Runtime) 7 | function generate_path(): 8 | for line in runtime.modules.current.ast.dump().splitlines(): 9 | raw f"# {line}" 10 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_335__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "f" is not defined. 2 | # line 1, column 38 3 | # 1 | def f(a: int, b: int = f(a - 1), *c: f) -> int: 4 | # : ^ 5 | # 2 | return a + b 6 | def f(a: int, b: int = f(a - 1), *c: f) -> int: 7 | return a + b 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_353__0.txt: -------------------------------------------------------------------------------- 1 | macro hello thing=subcommand: 2 | pass 3 | #>ERROR Can't use if as a subcommand. 4 | # line 3, column 7 5 | # 2 | pass 6 | # 3 | hello if True: 7 | # : ^^^^^^^^ 8 | # 4 | pass 9 | # : ^^^^ 10 | hello if True: 11 | pass 12 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_37__0.txt: -------------------------------------------------------------------------------- 1 | if True: 2 | say hello 3 | a = 1 4 | #>ERROR Conditional branch must be part of an if statement. 5 | # line 4, column 1 6 | # 2 | say hello 7 | # 3 | a = 1 8 | # 4 | else: 9 | # : ^^^^^ 10 | # 5 | say hello 11 | else: 12 | say hello 13 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_268__0.txt: -------------------------------------------------------------------------------- 1 | for i in range(10): 2 | if i % 2 == 0: 3 | #>ERROR Import statement can only appear directly at scope level. 4 | # line 3, column 9 5 | # 2 | if i % 2 == 0: 6 | # 3 | from math import sin 7 | # : ^^^^^^^^^^^^^^^^^^^^ 8 | from math import sin 9 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_230__0.txt: -------------------------------------------------------------------------------- 1 | macro foo: 2 | pass 3 | #>ERROR Expected colon, literal 'advancement', literal 'align', literal 'anchored', literal 'append', literal 'as' or 158 other tokens but got literal 'foo'. 4 | # line 3, column 7 5 | # 2 | pass 6 | # 3 | as @p foo 7 | # : ^^^ 8 | as @p foo 9 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_358__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected literal 'advancement', literal 'align', literal 'anchored', literal 'append', literal 'as', literal 'at' or 175 other tokens but got literal '"not'. 2 | # line 1, column 13 3 | # 1 | execute run "not docstring" 4 | # : ^^^^ 5 | execute run "not docstring" 6 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_78__0.txt: -------------------------------------------------------------------------------- 1 | def f(a, b): 2 | def g(c): 3 | a + b 4 | c 5 | #>ERROR Identifier "g" is not defined. 6 | # line 5, column 1 7 | # 3 | a + b 8 | # 4 | c 9 | # 5 | g() 10 | # : ^ 11 | # Notes: 12 | # - Expected assignment but got literal '()'. 13 | g() 14 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_222__0.txt: -------------------------------------------------------------------------------- 1 | def thing(): 2 | macro bar: 3 | pass 4 | bar 5 | #>ERROR Identifier "bar" is not defined. 6 | # line 5, column 1 7 | # 3 | pass 8 | # 4 | bar 9 | # 5 | bar 10 | # : ^^^ 11 | # Notes: 12 | # - Expected assignment but got newline '\n'. 13 | bar 14 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_36__0.txt: -------------------------------------------------------------------------------- 1 | if True: 2 | say hello 3 | elif True or False: 4 | say hello 5 | #>ERROR Expected colon but got literal '"blah"'. 6 | # line 5, column 6 7 | # 4 | say hello 8 | # 5 | else "blah": 9 | # : ^^^^^^ 10 | # 6 | say hello 11 | else "blah": 12 | say hello 13 | -------------------------------------------------------------------------------- /bolt/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.49.2" 2 | 3 | 4 | from .ast import * 5 | from .codegen import * 6 | from .emit import * 7 | from .helpers import * 8 | from .loop_info import * 9 | from .memo import * 10 | from .module import * 11 | from .parse import * 12 | from .plugin import * 13 | from .runtime import * 14 | from .semantics import * 15 | -------------------------------------------------------------------------------- /examples/bolt_patchers/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | say this is not compiled 2 | 3 | value = 123 4 | print(value) 5 | 6 | # As long as you don't mc.compile(ctx.data) or include "mecha" in the pipeline 7 | # you can leverage mecha's compiler and the bolt runtime for other purposes 8 | # without affecting function files in the output pack. 9 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_223__0.txt: -------------------------------------------------------------------------------- 1 | macro foo: 2 | macro bar: 3 | foo 4 | bar 5 | def thing(): 6 | #>ERROR Identifier "bar" is not defined. 7 | # line 6, column 5 8 | # 5 | def thing(): 9 | # 6 | bar 10 | # : ^^^ 11 | # Notes: 12 | # - Expected assignment but got newline '\n'. 13 | bar 14 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_309__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Identifier "foo" is not defined. 2 | # line 1, column 6 3 | # 1 | memo foo: 4 | # : ^^^ 5 | # 2 | pass 6 | # Notes: 7 | # - Expected bracket '[', curly '{', docstring, ellipsis, false, identifier or 5 other tokens but got newline '\n'. 8 | memo foo: 9 | pass 10 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_83__0.txt: -------------------------------------------------------------------------------- 1 | def foo(): 2 | bar() + thing 3 | def bar(): 4 | #>ERROR Identifier "thin" is not defined. Did you mean "thing"? 5 | # line 4, column 13 6 | # 3 | def bar(): 7 | # 4 | foo() + thin 8 | # : ^^^^ 9 | # 5 | thing = bar() 10 | foo() + thin 11 | thing = bar() 12 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_305__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected literal 'advancement', literal 'align', literal 'anchored', literal 'append', literal 'as', literal 'at' or 175 other tokens but got literal 'foo'. 2 | # line 1, column 11 3 | # 1 | as @a run foo = "bar" 4 | # : ^^^ 5 | # 2 | say foo 6 | as @a run foo = "bar" 7 | say foo 8 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_312__0.txt: -------------------------------------------------------------------------------- 1 | memo something=123: 2 | #>ERROR Identifier "somethig" is not defined. Did you mean "something"? 3 | # line 2, column 11 4 | # 1 | memo something=123: 5 | # 2 | print(somethig) 6 | # : ^^^^^^^^ 7 | # Notes: 8 | # - Expected equal but got brace ')'. 9 | print(somethig) 10 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_99__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected colon, literal 'advancement', literal 'align', literal 'anchored', literal 'append', literal 'as' or 158 other tokens but got literal 'for'. 2 | # line 1, column 7 3 | # 1 | at @s for i in "foo": 4 | # : ^^^ 5 | # 2 | say yolo 6 | at @s for i in "foo": 7 | say yolo 8 | -------------------------------------------------------------------------------- /tests/snapshots/examples__build_bolt_lazy__0.pack.md: -------------------------------------------------------------------------------- 1 | # Lectern snapshot 2 | 3 | ## Data pack 4 | 5 | `@data_pack pack.mcmeta` 6 | 7 | ```json 8 | { 9 | "pack": { 10 | "pack_format": 48, 11 | "description": "" 12 | } 13 | } 14 | ``` 15 | 16 | ### demo 17 | 18 | `@function demo:hello1` 19 | 20 | ```mcfunction 21 | say hello1 22 | ``` 23 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_195__0.txt: -------------------------------------------------------------------------------- 1 | for i in range(3): 2 | #>ERROR Identifier "parent" is not defined. Did you mean "print"? 3 | # line 2, column 5 4 | # 1 | for i in range(3): 5 | # 2 | parent[i] = f"param{i}" 6 | # : ^^^^^^ 7 | # Notes: 8 | # - Expected assignment but got literal '[i]'. 9 | parent[i] = f"param{i}" 10 | -------------------------------------------------------------------------------- /tests/snapshots/examples__build_bolt_memo2__0.pack.md: -------------------------------------------------------------------------------- 1 | # Lectern snapshot 2 | 3 | ## Data pack 4 | 5 | `@data_pack pack.mcmeta` 6 | 7 | ```json 8 | { 9 | "pack": { 10 | "pack_format": 48, 11 | "description": "" 12 | } 13 | } 14 | ``` 15 | 16 | ### demo 17 | 18 | `@function demo:foo` 19 | 20 | ```mcfunction 21 | say ok 22 | say wat 23 | ``` 24 | -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from beet import run_beet 3 | 4 | 5 | @pytest.fixture(scope="session") 6 | def ctx(): 7 | with run_beet({"require": ["bolt"]}) as ctx: 8 | yield ctx 9 | 10 | 11 | @pytest.fixture(scope="session") 12 | def ctx_sandbox(): 13 | with run_beet({"require": ["bolt.contrib.sandbox"]}) as ctx: 14 | yield ctx 15 | -------------------------------------------------------------------------------- /tests/snapshots/examples__build_bolt_circular__0.pack.md: -------------------------------------------------------------------------------- 1 | # Lectern snapshot 2 | 3 | ## Data pack 4 | 5 | `@data_pack pack.mcmeta` 6 | 7 | ```json 8 | { 9 | "pack": { 10 | "pack_format": 48, 11 | "description": "" 12 | } 13 | } 14 | ``` 15 | 16 | ### demo 17 | 18 | `@function demo:thing` 19 | 20 | ```mcfunction 21 | say 33 22 | say 42 23 | ``` 24 | -------------------------------------------------------------------------------- /tests/snapshots/examples__build_bolt_shadow_global__0.pack.md: -------------------------------------------------------------------------------- 1 | # Lectern snapshot 2 | 3 | ## Data pack 4 | 5 | `@data_pack pack.mcmeta` 6 | 7 | ```json 8 | { 9 | "pack": { 10 | "pack_format": 48, 11 | "description": "" 12 | } 13 | } 14 | ``` 15 | 16 | ### demo 17 | 18 | `@function demo:foo` 19 | 20 | ```mcfunction 21 | say (1, 2, 3) 22 | ``` 23 | -------------------------------------------------------------------------------- /examples/bolt_sample_ui/sample_ui/modules/main.bolt: -------------------------------------------------------------------------------- 1 | import xml.etree.ElementTree as ET 2 | 3 | for name, content in ctx.meta.sample_ui.all_screens.items(): 4 | parser = ET.XMLPullParser(["start", "end"]) 5 | parser.feed(content) 6 | 7 | function name: 8 | for event, elem in parser.read_events(): 9 | say (event, elem.tag, elem.attrib) 10 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_200__0.txt: -------------------------------------------------------------------------------- 1 | a = 1 2 | def f(): 3 | #>ERROR Identifier "a" is not defined. 4 | # line 3, column 5 5 | # 2 | def f(): 6 | # 3 | a += 1 7 | # : ^ 8 | # Notes: 9 | # - Use "global a" or "nonlocal a" to mutate the variable defined in outer scope. 10 | # - Expected assignment but got literal '+='. 11 | a += 1 12 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_98__0.txt: -------------------------------------------------------------------------------- 1 | #>ERROR Expected literal 'biome', literal 'block', literal 'blocks', literal 'data', literal 'dimension', literal 'entity' or 5 other tokens but got literal '"foo"'. 2 | # line 1, column 10 3 | # 1 | at @s if "foo" == "bar": 4 | # : ^^^^^ 5 | # 2 | say yolo 6 | at @s if "foo" == "bar": 7 | say yolo 8 | -------------------------------------------------------------------------------- /tests/snapshots/examples__build_bolt_order__0.pack.md: -------------------------------------------------------------------------------- 1 | # Lectern snapshot 2 | 3 | ## Data pack 4 | 5 | `@data_pack pack.mcmeta` 6 | 7 | ```json 8 | { 9 | "pack": { 10 | "pack_format": 48, 11 | "description": "" 12 | } 13 | } 14 | ``` 15 | 16 | ### hello 17 | 18 | `@function hello:world` 19 | 20 | ```mcfunction 21 | say first 22 | say second 23 | ``` 24 | -------------------------------------------------------------------------------- /tests/snapshots/examples__build_bolt_function_signature__0.pack.md: -------------------------------------------------------------------------------- 1 | # Lectern snapshot 2 | 3 | ## Data pack 4 | 5 | `@data_pack pack.mcmeta` 6 | 7 | ```json 8 | { 9 | "pack": { 10 | "pack_format": 48, 11 | "description": "" 12 | } 13 | } 14 | ``` 15 | 16 | ### demo 17 | 18 | `@function(strip_final_newline) demo:foo` 19 | 20 | ```mcfunction 21 | 22 | ``` 23 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_270__0.txt: -------------------------------------------------------------------------------- 1 | for bean in "beans": 2 | if bean: 3 | #>ERROR Macro definition can only appear directly at scope level. 4 | # line 3, column 9 5 | # 2 | if bean: 6 | # 3 | macro jelly bean(stream): 7 | # : ^^^^^^^^^^^ 8 | # 4 | pass 9 | macro jelly bean(stream): 10 | pass 11 | -------------------------------------------------------------------------------- /tests/snapshots/bolt__parse_352__0.txt: -------------------------------------------------------------------------------- 1 | macro hello thing=subcommand: 2 | pass 3 | #>ERROR Expected assignment, literal 'advancement', literal 'align', literal 'anchored', literal 'append', literal 'as' or 177 other tokens but got literal 'print(123)'. 4 | # line 3, column 7 5 | # 2 | pass 6 | # 3 | hello print(123) 7 | # : ^^^^^^^^^^ 8 | hello print(123) 9 | -------------------------------------------------------------------------------- /examples/bolt_sample_ui/sample_ui/resources.py: -------------------------------------------------------------------------------- 1 | from typing import ClassVar 2 | 3 | from beet import Context, NamespaceFileScope, TextFileBase 4 | 5 | 6 | class UiScreen(TextFileBase[str]): 7 | scope: ClassVar[NamespaceFileScope] = ("ui_screens",) 8 | extension: ClassVar[str] = ".xml" 9 | 10 | 11 | def beet_default(ctx: Context): 12 | ctx.data.extend_namespace.append(UiScreen) 13 | -------------------------------------------------------------------------------- /tests/snapshots/examples__build_bolt_assets__0.pack.md: -------------------------------------------------------------------------------- 1 | # Lectern snapshot 2 | 3 | ## Resource pack 4 | 5 | `@resource_pack pack.mcmeta` 6 | 7 | ```json 8 | { 9 | "pack": { 10 | "pack_format": 34, 11 | "description": "" 12 | } 13 | } 14 | ``` 15 | 16 | ### minecraft 17 | 18 | `@model minecraft:block/stone` 19 | 20 | ```json 21 | { 22 | "parent": "block/cube" 23 | } 24 | ``` 25 | -------------------------------------------------------------------------------- /tests/snapshots/examples__build_bolt_strip_final_newline__0.pack.md: -------------------------------------------------------------------------------- 1 | # Lectern snapshot 2 | 3 | ## Data pack 4 | 5 | `@data_pack pack.mcmeta` 6 | 7 | ```json 8 | { 9 | "pack": { 10 | "pack_format": 48, 11 | "description": "" 12 | } 13 | } 14 | ``` 15 | 16 | ### demo 17 | 18 | `@function demo:foo` 19 | 20 | ```mcfunction 21 | scoreboard players operation foo set = bar set 22 | ``` 23 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "python.languageServer": "Pylance", 3 | "[python]": { 4 | "editor.tabSize": 4, 5 | "editor.formatOnSave": true, 6 | "editor.formatOnType": false, 7 | "editor.formatOnPaste": false, 8 | "editor.codeActionsOnSave": { 9 | "source.organizeImports": "explicit" 10 | }, 11 | "editor.defaultFormatter": "ms-python.black-formatter" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/bolt_basic/src/data/demo/functions/import_a.mcfunction: -------------------------------------------------------------------------------- 1 | from bolt import Runtime 2 | 3 | runtime = ctx.inject(Runtime) 4 | 5 | foo = 42 6 | 7 | def callback(): 8 | return foo 9 | 10 | def loga(f): 11 | runtime.modules.current.namespace["bar"] *= 2 12 | say __name__ 13 | say runtime.modules.current_path 14 | say f() 15 | 16 | from ./import_b import logb 17 | 18 | logb(callback) 19 | -------------------------------------------------------------------------------- /examples/bolt_basic/src/data/demo/functions/import_b.mcfunction: -------------------------------------------------------------------------------- 1 | from bolt import Runtime 2 | 3 | runtime = ctx.inject(Runtime) 4 | 5 | bar = 7 6 | 7 | def callback(): 8 | return bar 9 | 10 | def logb(f): 11 | runtime.modules.current.namespace["foo"] *= 2 12 | say __name__ 13 | say runtime.modules.current_path 14 | say f() 15 | 16 | from ./import_a import loga 17 | 18 | loga(callback) 19 | -------------------------------------------------------------------------------- /examples/bolt_memo/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | memo: 2 | pass 3 | 4 | bop = 123 5 | memo bop, foo=bop, foo: 6 | thing = foo 7 | function ./ayy: 8 | say thing 9 | say foo 10 | 11 | a = (1, 2) 12 | a = (a, a) 13 | a = (a, a) 14 | 15 | memo a, a: 16 | say a 17 | 18 | say wat 19 | 20 | a = 1 21 | b = 2 22 | memo a, b: 23 | say (a + b) 24 | memo b: 25 | say b 26 | -------------------------------------------------------------------------------- /examples/bolt_nested_location/src/data/demo/functions/foo.mcfunction: -------------------------------------------------------------------------------- 1 | execute function ~/thing1: 2 | as @a function ~/thing2: 3 | function ~/thing{3:03}/hello 4 | say ~/thing{123456789:x}/hello 5 | 6 | schedule function ~/blob 2s append: 7 | say (~/, ~/../{~/[:3]}) 8 | 9 | function ./welp: 10 | if predicate ~/ say yes 11 | 12 | function ~/{"":_<2} 13 | function ~/foo{"bar":_^5} 14 | -------------------------------------------------------------------------------- /tests/snapshots/examples__build_bolt_memo4__0.pack.md: -------------------------------------------------------------------------------- 1 | # Lectern snapshot 2 | 3 | ## Data pack 4 | 5 | `@data_pack pack.mcmeta` 6 | 7 | ```json 8 | { 9 | "pack": { 10 | "pack_format": 48, 11 | "description": "" 12 | } 13 | } 14 | ``` 15 | 16 | ### demo 17 | 18 | `@function demo:foo` 19 | 20 | ```mcfunction 21 | say something 22 | ``` 23 | 24 | `@function demo:bar` 25 | 26 | ```mcfunction 27 | say bop 28 | ``` 29 | -------------------------------------------------------------------------------- /examples/bolt_sample_ui/src/data/demo/ui_screens/foo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |