Skip to content

Latest commit

 

History

History
109 lines (89 loc) · 4.87 KB

File metadata and controls

109 lines (89 loc) · 4.87 KB

Study Guide

If you want to learn Bang language, first you need to be familiar with the logical exported syntax of Mindustry logical editor

You also need to have the ability to manually write its exported syntax outside the logic editor

If you are not familiar with the syntax exported by the logic editor, here is a tutorial written in Chinese, and you may be able to find more suitable resources than it

If you meet the above conditions, then you only need to start reading from Learning Tutorial

Deprecated reading index

The following is the recommended reading order

value.mdtlbl
mult_line_string.mdtlbl
dexp.mdtlbl
print.mdtlbl
op.mdtlbl
op_expr.mdtlbl
control.mdtlbl
control_plus.mdtlbl
control_block.mdtlbl
cmps.mdtlbl
insert_sort.mdtlbl
switch.mdtlbl
const.mdtlbl
inline_block.mdtlbl
take.mdtlbl
compiling_eval.mdtlbl
cmp_deps.mdtlbl
switch_append.mdtlbl
switch_catch.mdtlbl
take2.mdtlbl
gswitch.mdtlbl
mul_takes_and_consts.mdtlbl
cmper.mdtlbl
setres.mdtlbl
consted_dexp.mdtlbl
quick_dexp_take.mdtlbl
value_bind.mdtlbl
dexp_binder.mdtlbl
closured_value.mdtlbl
caller.mdtlbl
match.mdtlbl
const_match.mdtlbl
builtin_functions.mdtlbl
value_bind_ref.mdtlbl

If it is not listed in the above list, you can watch it yourself after reading the above content. The reading order can refer to the file creation order

There is also a reference manual, You can read together with the above content

[!WARNING] The version of the reference manual mentioned above is completely outdated. It may be useful for beginners, but advanced usage cannot constitute a language reference for use

And the tutorial directory mentioned above is iterated step by step from ancient versions, and its style is very unsuitable for learning

If you have any questions, it is recommended to ask directly in the issues and discussions

Recommended examples

There are some large and advanced complex examples that can be used as references or pasted into your code for quick and convenient use

  • std Some of the more general and large tools
  • for_each Exquisite for-each implementation
  • function.mdtlbl Quickly generate non recursive functions
  • stack.mdtlbl Packaging a stack to simplify common stack operations
  • count_loop.mdtlbl Generate loop expansion for dynamic count
  • timeit.mdtlbl Test execution lines to measure performance
  • sync.mdtlbl Mutex lock, for shared mutable data of multiple processor block

Simple Attempt

If you feel that Bang language is too complex or does not require the capabilities it provides, you can try some of the additional features of this compiler

About Logical Language

  • Rename label: mindustry_logic_bang_lang in
  • Convert absolute address into label: mindustry_logic_bang_lang i
  • Some simplify variable check: mindustry_logic_bang_lang l
  • Extract and build op statements: mindustry_logic_bang_lang b

About Paren Language

This is a lightweight logical language extension, that only provides the feature of embedding multiple statement return values into variables

A simplified version similar to DExp in Bang

The variable name starting with $ in parentheses will be treated as the return variable of the current parentheses.

If the variable name is empty, a new anonymous variable will be created

For more examples, please refer to mini_paren.logic

Compile it using mindustry_logic_bang_lang p