From 621a7863cb27e4ca4643729596b40f4ef805ca4f Mon Sep 17 00:00:00 2001 From: theo <2022xmm3@kuas.ac.jp> Date: Thu, 13 Oct 2022 16:22:32 +0900 Subject: [PATCH] Added some test files --- tests-parsimony/001.c | 14 ++++++++++++++ tests-parsimony/002.c | 5 +++++ tests-parsimony/003.c | 1 + tests-parsimony/004.c | 9 +++++++++ tests-parsimony/tmp.c | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+) create mode 100644 tests-parsimony/001.c create mode 100644 tests-parsimony/002.c create mode 100644 tests-parsimony/003.c create mode 100644 tests-parsimony/004.c create mode 100644 tests-parsimony/tmp.c diff --git a/tests-parsimony/001.c b/tests-parsimony/001.c new file mode 100644 index 0000000..ed38619 --- /dev/null +++ b/tests-parsimony/001.c @@ -0,0 +1,14 @@ +@{ 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")); +char *foos[] = { "FOO", "BAR", "BAZ" }; diff --git a/tests-parsimony/002.c b/tests-parsimony/002.c new file mode 100644 index 0000000..0f40d3e --- /dev/null +++ b/tests-parsimony/002.c @@ -0,0 +1,5 @@ +@(a = `constant 10) + +int q = @(`constant 10); + +int w = @(a); diff --git a/tests-parsimony/003.c b/tests-parsimony/003.c new file mode 100644 index 0000000..70c77e3 --- /dev/null +++ b/tests-parsimony/003.c @@ -0,0 +1 @@ +int i = @({ __proto__: Token, text: "14" }); diff --git a/tests-parsimony/004.c b/tests-parsimony/004.c new file mode 100644 index 0000000..d24dca4 --- /dev/null +++ b/tests-parsimony/004.c @@ -0,0 +1,9 @@ +@{if (1) print("yo");} + +int main(){ + if (1) { + return 0; + } else { + return 1; + } +} diff --git a/tests-parsimony/tmp.c b/tests-parsimony/tmp.c new file mode 100644 index 0000000..b035305 --- /dev/null +++ b/tests-parsimony/tmp.c @@ -0,0 +1,37 @@ +@{ + + // 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"));