-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.monarch
101 lines (73 loc) · 1.26 KB
/
test.monarch
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//x = 4 + 5 - 6;
//x = a && b ? c ? d : e : f && f0 ? g && g0 : h && h0;
/*
x = y = 10;
x *= 2;
y /= 2;
print x;
print y;
*/
//x = 1 + 2 * 3 + 1;
//print x;
/*
x = 11;
if ( x < 10 )
{
x = 0;
}
else
{
x = 20;
}
*/
//x = true ? 10 : 20;
//do { --x; }
//while (x > 5);
//while (x > 5) { --x; }
/*
for (x = 0; x < 10; ++x)
{
if (x < 3)
continue;
print x;
if (x == 5)
break;
}
*/
// to support nested functions (references to outer vars),
// we will need to package them in a struct and pass in a pointer
// to the inner function(s) - similar to the 'this' pointer for members.
// this might require a first pass to collect up all vars for a given
// scope so we can identify which need to be specially packaged.
//x = 100;
/*
test = function Test()
{
print 200;
};
test();
*/
/*
myarray = [ 99, 20 ];
x = true ? 10 : 20;
myarray[0] = x;
print myarray[0];
*/
/*
print x; // x should not exist in this scope (only assignments/lvalues should create vars?)
if (x > 0)
if (x > 100)
x = 200;
else
x = 300;
print x;
*/
test = function(x)
{
print x;
};
test(99);
// - need support for functions and arrays so we can keep old tests around and ensure they don't break.
// todo:
// index into arrays (auto-size?)
// allow += operator on arrays? (to push_back)