C compiler with embedded metalanguage.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

48 lines
869 B

@{import("boot.mc");}
@{
toChar(foo) {
"\"type :"+foo+"\"";
}
p2(foo) {
foo * foo;
}
c = ["earth", "sky", "water"];
isSky(x) { x == "sky" }
c = reject(isSky, c);
nil;
}
@{
print(map(p2, [100, 2, 3]));
nil;
}
@{
print(map(toChar, c));
nil;
}
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) + "\"" }}
// to_C_string(properties.enums.foo.enumList[?].name.identifier);
a = map(to_C_string, select(isEnum, properties.enums.foo.enumList));
b = map(to_C_string, properties.enums.foo.enumList, notToken);
c = map(to_C_string, properties.enums.foo.enumList, isEnum);
nil;
}
char *a[] = { @a };
char *b[] = { @b };
char *c[] = { @c };