--- layout: default title: Grammar --- ## Specification ```rust content: expr* expr: high_expr | low_expr mod_expr: expr* high_expr: export_def | annotation_def export_def: "export" ~ expr annotation_def: "@" ~ expr low_expr: class_def | fn_def | data_def | var_def | mut_redef | mod_expr | scope_def | if_block | loop_block | unary_op | binary_op scope_def: anon_scope_def | unsafe_scope_def var_def: "var_kw" ~ expr ~ "=" ~ expr unary_op: ident ~ unary_operator binary_op: expr ~ binary_operator ~ expr ``` ## Notes How would one parse a rei input? With prei, the tool automatically assigns naming schemes to each file and adds its associated mod name. Then it combines everything into a singular file `build/project.rei`, and reads that as an input to reic. Reic parses in a recursive manner from the first expr, which is deemed to be the root mod content expression. We always expect a rei file to start with a `mod` expr. Then a list of general `expr`. The root mod expr is always shown on the IDE and can be hidden. Note, thats just how a `.rei` file works, it always starts with a mod expr. If you dont want to use reic and prei, you can do whatever you want. `expr` are general bodies of content that have a start and an end. Expressions are meant to define and run logic. An expression always evaluates to a value. Trivial expressions evaluate to `()` empty. Non trivial expressions evaluate to a non `()` empty value. All values returned from an expression can be assigned through variable definition and redefinition. A const variable can only be defined, not redefined. It must also be defined at construction. A static variable exists for the duration of the program's execution, and would be placed in the .bss or .data segments like a const var. Unlike a const var, a static variable can be mutated and assigned at runtime. Rei uses a special mutex to handle mutations of global statics. A let variable can be defined at anytime and can be shadowed. It cant be redefined however. A mut variable is a let variable but is able to be defined. It can also be borrowed mutably, unlike let or const variables. A variable shadow is simply another `var_def` that shadows the prev var. An anonymous function definition is simply a var_def. An anonymous scope def is simply an unlabelled mod_expr (anon_scope_def). The thing wit h rei is you can script very easily.