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.
 
 
 

15 lines
684 B

@{ newObject(type, fields) { fields.__proto__ = type; fields }
newCint(text) { newObject(C_int, { text: text }) }
newCstring(text) { newObject(C_string, { 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("}");
}
enum foo { FOO, BAR, BAZ };
char *x[] = @(newCinitializer([newCstring("X"), comma, newCstring("Y")]));
int i = @(newCint("42"));
int i = @({ __proto__: Token, text: "14" });
char *foos[] = { "FOO", "BAR", "BAZ" };