-
Notifications
You must be signed in to change notification settings - Fork 2
Scopes
Nikitin Ilya edited this page Apr 29, 2020
·
7 revisions
Scope is one of the most important and useful expressions in language. It is used as a body for classes, functions/lambdas, loops, and can appear in macros.
It has 3 valid syntax descriptions (styles):
- Indentation style
class Example
fn a
for x in [1..10]
print(x)
This style is commonly used to specify blocks of almost all expressions, and it's a most preferred style. Also, this style does not work, if scope is enclosed in any type of brackets.
- Braces style
print-cube = collection.map(fn (x) {
r = x * x * x;
print(r);
return r
})
This style is mainly used to denote body of multiline anonymous functions. Second case is usage in place, where indentation is not allowed For example, as above, or inside a code quote:
macro x ('cool-loop')
return {{
while true {
print("😎")
}
}}
- One-line style
let x = fn (x): print(x)
This compact style is used to specify small scope with only 1 expression.
Expressions
Public compiler interface
-
Units & Modules- TODO -
Compilerclass
Backend
- Lexer (Tokenizer)
- Syntax tree
- Traversing