-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.moon
58 lines (42 loc) · 1.22 KB
/
example.moon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// line comment
/*
block comment
hey, I can write here
*/
include "another_file.moon" // include file
include "specific_func_file.moon" specific_func,factorial // import just specific_func,factorial functions
import example.other aspecific_func // import aspecific_func from example.other module
import std.io println,printf
#def PREVARIABLE 3.14
const varinreadonlymemory = 55
struct foobar<foo, bar>
#ifdef PREVARIABLE:
print("Yey")
prinln ", defined!"
#if defined PREVARIABLE || defined(PREVARIABLE) {
print("Yey")
prinln ", defined!"
}
#else: error("Not defined!")
#if (PREVARIABLE == 3.14) : println "Equal!"
global program_ended
println program_ended
local example_ended = false
println "Hello world in Moon!"
println "Hello
separated"
println `Hello raw literal
also separated string!`
example_function(): print "This is an example"
example_function
def complex_function(...) {
print '-' // puts '-' char
println $1 $2 $3 // print argument 1, 2 and 3
println ... // print all arguments
println `${PREVARIABLE}: ${example_ended}` // Output should be: 3.14: false
}
def foovar;
example_ended = true // redefine a variable
label endlbl // record the instruction line
println("End!");
goto endlbl // goto instruction line