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.
 
 
 

37 regels
1.2 KiB

@{
// File used only for rule creation help
newObject(type, fields) { fields.__proto__ = type; fields }
newCint(text) { newObject(C_int, { text: text }) }
newCstring(text) { newObject(C_string, { text: "\""+text+"\"" }) }
newCinitializer(list) { newObject(C_initializer, { leftCurly: lcurly, initList: list, rightCurly: rcurly }) }
//newCif(list) { newObject(C_if, {ifTok: iftok, lParen: lpar, condition: , oop rParen, oop consequent }) }
newCexpression() {}
//newCcondition() { newObject(C_conditional, {logicalOrExpression, question, expression, colon, conditionalExpression}) }
//newCbinary() { newObject() }
//newCcast() { newObject(C_cast, { lParen: lpar, typeName, rParen: rpar, expression }) }
//newCdeclaration() { newObject(C_declaration, {specifiers, declarators, semicolon: semicolon }) }
newCstatement() {}
newToken(text) { { __proto__: Token, text: text } }
comma = newToken(",");
semicolon = newToken(";");
lcurly = newToken("{");
rcurly = newToken("}");
lpar = newToken("(");
rpar = newToken(")");
iftok = newToken("if");
}
char *x[] = @(newCinitializer([newCstring("X"), comma, newCstring("Y")]));
int i = @(newCint("42"));