@ -0,0 +1,7 @@ | |||||
enum foo { FOO, BAR, BAZ }; | |||||
char *x[] = {"X","Y","Z"}; | |||||
int i = 42; | |||||
char *c = "42"; | |||||
int i = 14; | |||||
char *foos[] = { "FOO", "BAR", "BAZ" }; |
@ -0,0 +1,19 @@ | |||||
@{ | |||||
newObject(type, fields) { fields.__proto__ = type; fields } | |||||
newCint(text) { newObject(C_int, { text: text }) } | |||||
newCstring(text) { newObject(C_stringLiteral, { text: "\""+text+"\"" }) } | |||||
newCinitializer(list) { { __proto__: C_initializer, leftCurly: lcurly, initList: list, rightCurly: rcurly } } | |||||
newToken(text) { { __proto__: Token, text: text } } | |||||
comma = newToken(","); | |||||
lcurly = newToken("{"); | |||||
rcurly = newToken("}"); | |||||
nil; | |||||
} | |||||
enum foo { FOO, BAR, BAZ }; | |||||
char *x[] = @(newCinitializer([newCstring("X"), comma, newCstring("Y"), comma, newCstring("Z")])); | |||||
int i = @(newCint("42")); | |||||
char *c = @(newCstring("42")); | |||||
int i = @({ __proto__: Token, text: "14" }); | |||||
char *foos[] = { "FOO", "BAR", "BAZ" }; |
@ -0,0 +1,6 @@ | |||||
char t = 10; | |||||
int i = 2; | |||||
int q = 10; | |||||
int k = (1,2,"stringy thingy",21<<1); | |||||
int i = (1,2,"string",21<<1); | |||||
int w = 10; |
@ -0,0 +1,17 @@ | |||||
@{ | |||||
saved = `expression (1,2,"string",21<<1); | |||||
first = `constant 2; | |||||
nil; | |||||
} | |||||
@{ | |||||
second = `constant 10; | |||||
nil; | |||||
} | |||||
char t = @(`constant @second); | |||||
int i = @first; | |||||
int q = @(`constant 10); | |||||
int k = @(`expression (1,2,"stringy thingy",21<<1)); | |||||
int i = @saved; | |||||
int w = @second; |
@ -0,0 +1,6 @@ | |||||
int main() | |||||
{ | |||||
for (int i = 0; i < 10; ++i) printf("%d\n", i);for (int i = 0; i < 10; ++i) printf("%d\n", i);; | |||||
for (int i = 0; i < 10; ++i) printf("%d\n", i);while (i < 10) { printf("%d\n", i); ++il; }; | |||||
return 0; | |||||
} |
@ -0,0 +1,35 @@ | |||||
@{import("../src/parsimonyLibrary/boot.mc");} | |||||
@{ | |||||
nTimes = `constant 10; | |||||
forLoop = `statement for (int i = 0; i < 10; ++i) printf("%d\n", i);; | |||||
whileLoop = `statement while (i < 10) { printf("%d\n", i); ++il; }; | |||||
useForLoop = 1; | |||||
nil; | |||||
} | |||||
int main() | |||||
{ | |||||
@{ | |||||
l = {}; | |||||
append(l, forLoop); | |||||
if (useForLoop) { | |||||
append(l, forLoop); | |||||
} else { | |||||
append(l, whileLoop); | |||||
} | |||||
l; | |||||
}; | |||||
@{ | |||||
l = {}; | |||||
useForLoop = 0; | |||||
append(l, forLoop); | |||||
if (useForLoop) { | |||||
append(l, forLoop); | |||||
} else { | |||||
append(l, whileLoop); | |||||
} | |||||
l; | |||||
}; | |||||
return 0; | |||||
} |
@ -0,0 +1,8 @@ | |||||
int x = 2 * 21; | |||||
int main() { | |||||
int i = 2 * 21; | |||||
int y = 2 * 10; | |||||
int a = 2 * 21; | |||||
return 0; | |||||
} |
@ -0,0 +1,18 @@ | |||||
@{ | |||||
num = `constant 21; | |||||
test = `expression 2 * 10; | |||||
nil; | |||||
} | |||||
int x = @{`expression 2 * @num;}; | |||||
int main() { | |||||
int i = @(`expression 2 * @num); | |||||
int y = @test; | |||||
int a = @{ | |||||
num = `constant 21; | |||||
test = 2; | |||||
`expression 2 * @num; | |||||
}; | |||||
return 0; | |||||
} |
@ -0,0 +1,5 @@ | |||||
int a = 5;int b = 2;int main() { | |||||
int c = 5;int d = 2;for(int i =0; i < 10; i++) { | |||||
a = 2; | |||||
}; | |||||
} |
@ -0,0 +1,22 @@ | |||||
@{import("../src/parsimonyLibrary/boot.mc");} | |||||
@{ | |||||
l = {}; | |||||
append(l, `declaration int a = 5;); | |||||
append(l, `declaration int b = 2;); | |||||
l; | |||||
} | |||||
int main() { | |||||
@{ | |||||
l = {}; | |||||
a = (`declaration int a = 2;); | |||||
append(l, `declaration int c = 5;); | |||||
b = 5; | |||||
append(l, `declaration int d = 2;); | |||||
append(l, `statement for(int i =0; i < 10; i++) { | |||||
a = 2; | |||||
}); | |||||
l; | |||||
}; | |||||
} |
@ -0,0 +1,12 @@ | |||||
int a = 5;int a = 5;; | |||||
int a = 5;; | |||||
int abc = 2;; | |||||
int main() { | |||||
int a = 5;; | |||||
int b = 0; | |||||
int c = 0;int d = 5;int d = 5;; | |||||
int e = 0; | |||||
return 0; | |||||
} |
@ -0,0 +1,36 @@ | |||||
@{import("../src/parsimonyLibrary/boot.mc");} | |||||
@{ | |||||
l = {}; | |||||
append(l, `declaration int a = 5;); | |||||
a = (`declaration int a = 5;); | |||||
append(l, `declaration int a = 5;); | |||||
l; | |||||
}; | |||||
@a; | |||||
@{ | |||||
t = `constant 2; | |||||
nil; | |||||
} | |||||
@(`declaration int abc = @t;); | |||||
int main() { | |||||
@a; | |||||
int b = 0; | |||||
@{ | |||||
l = {}; | |||||
append(l, `declaration int c = 0;); | |||||
x = (`declaration int d = 5;); | |||||
append(l, x); | |||||
if (1) { | |||||
if (1) { | |||||
x = (`declaration int d = 5;); | |||||
append(l, x); | |||||
} | |||||
} | |||||
l; | |||||
}; | |||||
int e = 0; | |||||
return 0; | |||||
} |
@ -0,0 +1,3 @@ | |||||
int a = 0;int b = 0;int c = 0;; | |||||
int b = 0;; |
@ -0,0 +1,16 @@ | |||||
@{import("../src/parsimonyLibrary/boot.mc");} | |||||
@{ | |||||
l = {}; | |||||
append(l, `declaration int a = 0;); | |||||
a = (`declaration int b = 0;); | |||||
append(l, a); | |||||
if (1) { | |||||
append(l, `declaration int c = 0;); | |||||
} else { | |||||
append(l, `declaration int c = 1;); | |||||
} | |||||
l; | |||||
}; | |||||
@a; |
@ -0,0 +1 @@ | |||||
int x; |
@ -0,0 +1,6 @@ | |||||
@{ | |||||
f(n) { | |||||
`declaration int @@(n);; | |||||
} | |||||
f("x"); | |||||
} |
@ -0,0 +1,8 @@ | |||||
x = 1, y = 2, z = 3 | |||||
x = 1, y = 2, z = 3 | |||||
x = 1, y = 3, z = null | |||||
x = 1, y = null, z = 3 | |||||
x = 3, y = null, z = 1 | |||||
x = 3, y = 1, z = null | |||||
x = null, y = 1, z = 3 | |||||
x = null, y = 3, z = 1 |
@ -0,0 +1,15 @@ | |||||
@{ | |||||
f(x, y, z) { | |||||
print("x = ", x, ", y = ", y, ", z = ", z, "\n"); | |||||
nil; | |||||
} | |||||
f(1, 2, 3); | |||||
f(x:1, y:2, z:3); | |||||
f(x:1, y:3); | |||||
f(x:1, z:3); | |||||
f(z:1,x:3); | |||||
f(y:1,x:3); | |||||
f(y:1,z:3); | |||||
f(z:1,y:3); | |||||
} |
@ -0,0 +1,8 @@ | |||||
enum foo { A, B, C }; | |||||
enum oof { A, B, C }; | |||||
char *a[] = { "A""B""C"}; | |||||
char *b[] = { "A", "B", "C"}; | |||||
char *c[] = { "A", "B", "C"}; |
@ -0,0 +1,20 @@ | |||||
@{import("../src/parsimonyLibrary/boot.mc");} | |||||
enum foo { A, B, C }; | |||||
enum oof { A, B, C }; | |||||
@{ | |||||
isEnum(x) { x.__proto__ == C_enum } | |||||
notToken(x) { x.__proto__ != Token } | |||||
to_C_string(x) {{ __proto__: C_string, value: "\"" + string(x.name.identifier) + "\"" }} | |||||
a = map(to_C_string, select(isEnum, program.enums.foo.enumList)); | |||||
b = map(to_C_string, program.enums.foo.enumList, notToken); | |||||
c = map(to_C_string, program.enums.foo.enumList, isEnum); | |||||
nil; | |||||
} | |||||
char *a[] = { @a }; | |||||
char *b[] = { @b }; | |||||
char *c[] = { @c }; |