From bb0708d4d6395c706ec6466b9ab464d4eac9274b Mon Sep 17 00:00:00 2001 From: Pierre Wilke <pierre.wilke@centralesupelec.fr> Date: Wed, 1 Apr 2020 14:14:36 +0200 Subject: [PATCH] fix tests --- tests/array/array.e | 2 +- tests/array/array.e.expect_14_12_3_8_12 | 1 + tests/array/array.e.expect_1_2_3 | 1 + tests/array/array.e.expect_lexer | 38 +++ tests/array/array2.e | 2 +- tests/array/array2.e.expect_14_12_3_8_12 | 1 + tests/array/array2.e.expect_1_2_3 | 1 + tests/array/array2.e.expect_lexer | 74 ++++ tests/array/array_pass.e | 10 +- tests/array/array_pass.e.expect_14_12_3_8_12 | 1 + tests/array/array_pass.e.expect_1_2_3 | 1 + tests/array/array_pass.e.expect_lexer | 51 +++ tests/array/array_sum.e | 2 +- tests/array/array_sum.e.expect_14_12_3_8_12 | 1 + tests/array/array_sum.e.expect_1_2_3 | 1 + tests/array/array_sum.e.expect_lexer | 38 +++ tests/array/sort.e | 60 ++-- tests/array/sort.e.expect_14_12_3_8_12 | 1 + tests/array/sort.e.expect_1_2_3 | 1 + tests/array/sort.e.expect_lexer | 322 ++++++++++++++++++ tests/array/structtab.e | 10 + tests/array/structtab.e.expect_14_12_3_8_12 | 1 + tests/array/structtab.e.expect_1_2_3 | 1 + tests/array/structtab.e.expect_lexer | 55 +++ tests/array/swap.e | 33 +- tests/array/swap.e.expect_14_12_3_8_12 | 1 + tests/array/swap.e.expect_1_2_3 | 1 + tests/array/swap.e.expect_lexer | 98 ++++++ tests/globals/glob.e | 2 +- tests/globals/glob.e.expect_14_12_3_8_12 | 1 + tests/globals/glob.e.expect_1_2_3 | 1 + tests/globals/glob.e.expect_lexer | 15 + tests/globals/globarray.e | 2 +- tests/globals/globarray.e.expect_14_12_3_8_12 | 1 + tests/globals/globarray.e.expect_1_2_3 | 1 + tests/globals/globarray.e.expect_lexer | 89 +++++ tests/globals/globtab.e | 2 +- tests/globals/globtab.e.expect_14_12_3_8_12 | 1 + tests/globals/globtab.e.expect_1_2_3 | 1 + tests/globals/globtab.e.expect_lexer | 76 +++++ tests/structs/point.e | 26 ++ tests/structs/point.e.expect_14_12_3_8_12 | 1 + tests/structs/point.e.expect_1_2_3 | 1 + tests/structs/point.e.expect_lexer | 131 +++++++ tests/structs/struct.e | 2 +- tests/structs/struct.e.expect_14_12_3_8_12 | 1 + tests/structs/struct.e.expect_1_2_3 | 1 + tests/structs/struct.e.expect_lexer | 45 +++ tests/structs/struct2.e | 2 +- tests/structs/struct2.e.expect_14_12_3_8_12 | 1 + tests/structs/struct2.e.expect_1_2_3 | 1 + tests/structs/struct2.e.expect_lexer | 61 ++++ 52 files changed, 1205 insertions(+), 69 deletions(-) create mode 100644 tests/array/array.e.expect_14_12_3_8_12 create mode 100644 tests/array/array.e.expect_1_2_3 create mode 100644 tests/array/array.e.expect_lexer create mode 100644 tests/array/array2.e.expect_14_12_3_8_12 create mode 100644 tests/array/array2.e.expect_1_2_3 create mode 100644 tests/array/array2.e.expect_lexer create mode 100644 tests/array/array_pass.e.expect_14_12_3_8_12 create mode 100644 tests/array/array_pass.e.expect_1_2_3 create mode 100644 tests/array/array_pass.e.expect_lexer create mode 100644 tests/array/array_sum.e.expect_14_12_3_8_12 create mode 100644 tests/array/array_sum.e.expect_1_2_3 create mode 100644 tests/array/array_sum.e.expect_lexer create mode 100644 tests/array/sort.e.expect_14_12_3_8_12 create mode 100644 tests/array/sort.e.expect_1_2_3 create mode 100644 tests/array/sort.e.expect_lexer create mode 100644 tests/array/structtab.e create mode 100644 tests/array/structtab.e.expect_14_12_3_8_12 create mode 100644 tests/array/structtab.e.expect_1_2_3 create mode 100644 tests/array/structtab.e.expect_lexer create mode 100644 tests/array/swap.e.expect_14_12_3_8_12 create mode 100644 tests/array/swap.e.expect_1_2_3 create mode 100644 tests/array/swap.e.expect_lexer create mode 100644 tests/globals/glob.e.expect_14_12_3_8_12 create mode 100644 tests/globals/glob.e.expect_1_2_3 create mode 100644 tests/globals/glob.e.expect_lexer create mode 100644 tests/globals/globarray.e.expect_14_12_3_8_12 create mode 100644 tests/globals/globarray.e.expect_1_2_3 create mode 100644 tests/globals/globarray.e.expect_lexer create mode 100644 tests/globals/globtab.e.expect_14_12_3_8_12 create mode 100644 tests/globals/globtab.e.expect_1_2_3 create mode 100644 tests/globals/globtab.e.expect_lexer create mode 100644 tests/structs/point.e create mode 100644 tests/structs/point.e.expect_14_12_3_8_12 create mode 100644 tests/structs/point.e.expect_1_2_3 create mode 100644 tests/structs/point.e.expect_lexer create mode 100644 tests/structs/struct.e.expect_14_12_3_8_12 create mode 100644 tests/structs/struct.e.expect_1_2_3 create mode 100644 tests/structs/struct.e.expect_lexer create mode 100644 tests/structs/struct2.e.expect_14_12_3_8_12 create mode 100644 tests/structs/struct2.e.expect_1_2_3 create mode 100644 tests/structs/struct2.e.expect_lexer diff --git a/tests/array/array.e b/tests/array/array.e index 991bb56..3617f79 100644 --- a/tests/array/array.e +++ b/tests/array/array.e @@ -1,4 +1,4 @@ -int main(int argc,char* argv[]){ +int main(){ int t[10]; t[0] = 5; t[1] = 3 + t[0]; diff --git a/tests/array/array.e.expect_14_12_3_8_12 b/tests/array/array.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..61b83a8 --- /dev/null +++ b/tests/array/array.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 8} \ No newline at end of file diff --git a/tests/array/array.e.expect_1_2_3 b/tests/array/array.e.expect_1_2_3 new file mode 100644 index 0000000..61b83a8 --- /dev/null +++ b/tests/array/array.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 8} \ No newline at end of file diff --git a/tests/array/array.e.expect_lexer b/tests/array/array.e.expect_lexer new file mode 100644 index 0000000..472e69b --- /dev/null +++ b/tests/array/array.e.expect_lexer @@ -0,0 +1,38 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(10) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(3) +SYM_PLUS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/array/array2.e b/tests/array/array2.e index 5261405..e5d6294 100644 --- a/tests/array/array2.e +++ b/tests/array/array2.e @@ -1,4 +1,4 @@ -int main(int argc,char* argv[]){ +int main(){ int t[10]; int i = 0; while(i < 10){ diff --git a/tests/array/array2.e.expect_14_12_3_8_12 b/tests/array/array2.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..46eb758 --- /dev/null +++ b/tests/array/array2.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 45} \ No newline at end of file diff --git a/tests/array/array2.e.expect_1_2_3 b/tests/array/array2.e.expect_1_2_3 new file mode 100644 index 0000000..46eb758 --- /dev/null +++ b/tests/array/array2.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 45} \ No newline at end of file diff --git a/tests/array/array2.e.expect_lexer b/tests/array/array2.e.expect_lexer new file mode 100644 index 0000000..828b548 --- /dev/null +++ b/tests/array/array2.e.expect_lexer @@ -0,0 +1,74 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(10) +SYM_RBRACKET +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(10) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(sum) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(10) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(sum) +SYM_ASSIGN +SYM_IDENTIFIER(sum) +SYM_PLUS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(sum) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/array/array_pass.e b/tests/array/array_pass.e index b13de33..e63c576 100644 --- a/tests/array/array_pass.e +++ b/tests/array/array_pass.e @@ -1,9 +1,9 @@ -int main(int argc,char* argv[]){ - int t[3]; - int x = f(t,5); - return t[1]; -} int f(int* a, int i){ a[1] = i; return 0; } +int main(){ + int t[3]; + int x = f(t,5); + return t[1]; +} diff --git a/tests/array/array_pass.e.expect_14_12_3_8_12 b/tests/array/array_pass.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..2bd9201 --- /dev/null +++ b/tests/array/array_pass.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 5} \ No newline at end of file diff --git a/tests/array/array_pass.e.expect_1_2_3 b/tests/array/array_pass.e.expect_1_2_3 new file mode 100644 index 0000000..2bd9201 --- /dev/null +++ b/tests/array/array_pass.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 5} \ No newline at end of file diff --git a/tests/array/array_pass.e.expect_lexer b/tests/array/array_pass.e.expect_lexer new file mode 100644 index 0000000..2b275af --- /dev/null +++ b/tests/array/array_pass.e.expect_lexer @@ -0,0 +1,51 @@ +SYM_INT +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INT +SYM_ASTERISK +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(i) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(a) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(3) +SYM_RBRACKET +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_INTEGER(5) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/array/array_sum.e b/tests/array/array_sum.e index 1ac9e50..bebd09a 100644 --- a/tests/array/array_sum.e +++ b/tests/array/array_sum.e @@ -1,4 +1,4 @@ -int main(int argc,char* argv[]){ +int main(){ int t[2]; t[0] = 1; t[1] = 2; diff --git a/tests/array/array_sum.e.expect_14_12_3_8_12 b/tests/array/array_sum.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..ff173ec --- /dev/null +++ b/tests/array/array_sum.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/array/array_sum.e.expect_1_2_3 b/tests/array/array_sum.e.expect_1_2_3 new file mode 100644 index 0000000..ff173ec --- /dev/null +++ b/tests/array/array_sum.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/array/array_sum.e.expect_lexer b/tests/array/array_sum.e.expect_lexer new file mode 100644 index 0000000..2919201 --- /dev/null +++ b/tests/array/array_sum.e.expect_lexer @@ -0,0 +1,38 @@ +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(2) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_PLUS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/array/sort.e b/tests/array/sort.e index c8f42df..9d0eff9 100644 --- a/tests/array/sort.e +++ b/tests/array/sort.e @@ -1,36 +1,6 @@ -int main(int argc,char* argv[]){ - int a = atoi(argv[1]); - int b = atoi(argv[2]); - int t[10]; - t[0] = 5; - t[1] = 7; - t[2] = 3; - t[3] = 8; - t[4] = 11; - t[5] = 1; - t[6] = 4; - t[7] = 7; - t[8] = 2; - t[9] = 9; - sort(t,0,9); - int i = 0; - while(i < 10){ - print(t[i]); - i = i + 1; - } - return 0; -} -int sort(int* t, int begin, int end){ - if (begin < end){ - int pivot = begin; - pivot = partition(t, begin, end, pivot); - sort(t, begin, pivot-1); - sort(t, pivot+1, end); - } -} int swap(int* t ,int i,int j){ -int tmp = t[i]; + int tmp = t[i]; t[i] = t[j]; t[j] = tmp; return 0; @@ -49,3 +19,31 @@ int partition(int* t, int begin, int end, int pivot){ swap(t, end, j); return j; } +int sort(int* t, int begin, int end){ + if (begin < end){ + int pivot = begin; + pivot = partition(t, begin, end, pivot); + sort(t, begin, pivot-1); + sort(t, pivot+1, end); + } +} +int main(){ + int t[10]; + t[0] = 5; + t[1] = 7; + t[2] = 3; + t[3] = 8; + t[4] = 11; + t[5] = 1; + t[6] = 4; + t[7] = 7; + t[8] = 2; + t[9] = 9; + sort(t,0,9); + int i = 0; + while(i < 10){ + print(t[i]); + i = i + 1; + } + return 0; +} diff --git a/tests/array/sort.e.expect_14_12_3_8_12 b/tests/array/sort.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..bd654bf --- /dev/null +++ b/tests/array/sort.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "1\n2\n3\n4\n5\n7\n7\n8\n9\n11\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/array/sort.e.expect_1_2_3 b/tests/array/sort.e.expect_1_2_3 new file mode 100644 index 0000000..bd654bf --- /dev/null +++ b/tests/array/sort.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "1\n2\n3\n4\n5\n7\n7\n8\n9\n11\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/array/sort.e.expect_lexer b/tests/array/sort.e.expect_lexer new file mode 100644 index 0000000..d7168b1 --- /dev/null +++ b/tests/array/sort.e.expect_lexer @@ -0,0 +1,322 @@ +SYM_INT +SYM_IDENTIFIER(swap) +SYM_LPARENTHESIS +SYM_INT +SYM_ASTERISK +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(i) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(j) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(tmp) +SYM_ASSIGN +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_ASSIGN +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(j) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(j) +SYM_RBRACKET +SYM_ASSIGN +SYM_IDENTIFIER(tmp) +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(partition) +SYM_LPARENTHESIS +SYM_INT +SYM_ASTERISK +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(begin) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(end) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(pivot) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(swap) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_IDENTIFIER(pivot) +SYM_COMMA +SYM_IDENTIFIER(end) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(j) +SYM_ASSIGN +SYM_IDENTIFIER(begin) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(begin) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LEQ +SYM_IDENTIFIER(end) +SYM_MINUS +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_LEQ +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(end) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(swap) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_IDENTIFIER(i) +SYM_COMMA +SYM_IDENTIFIER(j) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(j) +SYM_ASSIGN +SYM_IDENTIFIER(j) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(swap) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_IDENTIFIER(end) +SYM_COMMA +SYM_IDENTIFIER(j) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(j) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(sort) +SYM_LPARENTHESIS +SYM_INT +SYM_ASTERISK +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(begin) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(end) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(begin) +SYM_LT +SYM_IDENTIFIER(end) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(pivot) +SYM_ASSIGN +SYM_IDENTIFIER(begin) +SYM_SEMICOLON +SYM_IDENTIFIER(pivot) +SYM_ASSIGN +SYM_IDENTIFIER(partition) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_IDENTIFIER(begin) +SYM_COMMA +SYM_IDENTIFIER(end) +SYM_COMMA +SYM_IDENTIFIER(pivot) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(sort) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_IDENTIFIER(begin) +SYM_COMMA +SYM_IDENTIFIER(pivot) +SYM_MINUS +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(sort) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_IDENTIFIER(pivot) +SYM_PLUS +SYM_INTEGER(1) +SYM_COMMA +SYM_IDENTIFIER(end) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(10) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(7) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(2) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(3) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(8) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(4) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(11) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(5) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(6) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(4) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(7) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(7) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(8) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(9) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(9) +SYM_SEMICOLON +SYM_IDENTIFIER(sort) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_INTEGER(0) +SYM_COMMA +SYM_INTEGER(9) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(10) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/array/structtab.e b/tests/array/structtab.e new file mode 100644 index 0000000..f28c3d3 --- /dev/null +++ b/tests/array/structtab.e @@ -0,0 +1,10 @@ +struct S { + int t[4]; +}; + +int main(){ + struct S s; + (s.t)[0] = 1; + print_int((s.t)[0]); + return (s.t)[0]; +} diff --git a/tests/array/structtab.e.expect_14_12_3_8_12 b/tests/array/structtab.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..8858d4c --- /dev/null +++ b/tests/array/structtab.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "1", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/array/structtab.e.expect_1_2_3 b/tests/array/structtab.e.expect_1_2_3 new file mode 100644 index 0000000..8858d4c --- /dev/null +++ b/tests/array/structtab.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "1", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/array/structtab.e.expect_lexer b/tests/array/structtab.e.expect_lexer new file mode 100644 index 0000000..1566d17 --- /dev/null +++ b/tests/array/structtab.e.expect_lexer @@ -0,0 +1,55 @@ +SYM_STRUCT +SYM_IDENTIFIER(S) +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(4) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RBRACE +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_STRUCT +SYM_IDENTIFIER(S) +SYM_IDENTIFIER(s) +SYM_SEMICOLON +SYM_LPARENTHESIS +SYM_IDENTIFIER(s) +SYM_POINT +SYM_IDENTIFIER(t) +SYM_RPARENTHESIS +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_IDENTIFIER(print_int) +SYM_LPARENTHESIS +SYM_LPARENTHESIS +SYM_IDENTIFIER(s) +SYM_POINT +SYM_IDENTIFIER(t) +SYM_RPARENTHESIS +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(s) +SYM_POINT +SYM_IDENTIFIER(t) +SYM_RPARENTHESIS +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/array/swap.e b/tests/array/swap.e index d169ba7..2b86a5a 100644 --- a/tests/array/swap.e +++ b/tests/array/swap.e @@ -1,32 +1,15 @@ -int main(int argc,char* argv[]){ - int t[10]; - t[0] = 5; - t[1] = 12; - partition(t,0,1,0); - print(t[0]); - print(t[0]); - print(t[1]); - return 0; -} int swap(int* t,int i,int j){ int tmp = t[i]; t[i] = t[j]; t[j] = tmp; return 0; } -int partition(int* t, int begin, int end, int pivot){ - swap(t, pivot, end); - int j = begin; - int i = begin; - while(i <= end - 1){ - if(t[i] <= t[end]){ - swap(t, i, j); - j = j + 1; - } else { - } - i = i + 1; - } - swap(t, end, j); - return j; +int main(){ + int t[10]; + t[0] = 5; + t[1] = 12; + swap(t,0,1); + print(t[0]); + print(t[1]); + return 0; } - diff --git a/tests/array/swap.e.expect_14_12_3_8_12 b/tests/array/swap.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..5e0e1d8 --- /dev/null +++ b/tests/array/swap.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "12\n5\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/array/swap.e.expect_1_2_3 b/tests/array/swap.e.expect_1_2_3 new file mode 100644 index 0000000..5e0e1d8 --- /dev/null +++ b/tests/array/swap.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "12\n5\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/array/swap.e.expect_lexer b/tests/array/swap.e.expect_lexer new file mode 100644 index 0000000..aa6f81e --- /dev/null +++ b/tests/array/swap.e.expect_lexer @@ -0,0 +1,98 @@ +SYM_INT +SYM_IDENTIFIER(swap) +SYM_LPARENTHESIS +SYM_INT +SYM_ASTERISK +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(i) +SYM_COMMA +SYM_INT +SYM_IDENTIFIER(j) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(tmp) +SYM_ASSIGN +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_ASSIGN +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(j) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_IDENTIFIER(j) +SYM_RBRACKET +SYM_ASSIGN +SYM_IDENTIFIER(tmp) +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(10) +SYM_RBRACKET +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_IDENTIFIER(swap) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_INTEGER(0) +SYM_COMMA +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(0) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(t) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/globals/glob.e b/tests/globals/glob.e index e76ae27..70cbf87 100644 --- a/tests/globals/glob.e +++ b/tests/globals/glob.e @@ -1,6 +1,6 @@ int i = 37; -int main(int argc, char** argv){ +int main(){ return i; } diff --git a/tests/globals/glob.e.expect_14_12_3_8_12 b/tests/globals/glob.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..016d6cd --- /dev/null +++ b/tests/globals/glob.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 37} \ No newline at end of file diff --git a/tests/globals/glob.e.expect_1_2_3 b/tests/globals/glob.e.expect_1_2_3 new file mode 100644 index 0000000..016d6cd --- /dev/null +++ b/tests/globals/glob.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 37} \ No newline at end of file diff --git a/tests/globals/glob.e.expect_lexer b/tests/globals/glob.e.expect_lexer new file mode 100644 index 0000000..c8ddec7 --- /dev/null +++ b/tests/globals/glob.e.expect_lexer @@ -0,0 +1,15 @@ +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(37) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/globals/globarray.e b/tests/globals/globarray.e index 9f656e5..e4c8bcd 100644 --- a/tests/globals/globarray.e +++ b/tests/globals/globarray.e @@ -2,7 +2,7 @@ int max = 20; int objs[20]; -int main(int argc, char** argv){ +int main(){ int i = 0; int sum = 0; while (i < max){ diff --git a/tests/globals/globarray.e.expect_14_12_3_8_12 b/tests/globals/globarray.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..30828c1 --- /dev/null +++ b/tests/globals/globarray.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "0\n0\n1\n3\n6\n10\n15\n21\n28\n36\n45\n55\n66\n78\n91\n105\n120\n136\n153\n171\n", "error": null, "retval": 171} \ No newline at end of file diff --git a/tests/globals/globarray.e.expect_1_2_3 b/tests/globals/globarray.e.expect_1_2_3 new file mode 100644 index 0000000..30828c1 --- /dev/null +++ b/tests/globals/globarray.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "0\n0\n1\n3\n6\n10\n15\n21\n28\n36\n45\n55\n66\n78\n91\n105\n120\n136\n153\n171\n", "error": null, "retval": 171} \ No newline at end of file diff --git a/tests/globals/globarray.e.expect_lexer b/tests/globals/globarray.e.expect_lexer new file mode 100644 index 0000000..23154b3 --- /dev/null +++ b/tests/globals/globarray.e.expect_lexer @@ -0,0 +1,89 @@ +SYM_INT +SYM_IDENTIFIER(max) +SYM_ASSIGN +SYM_INTEGER(20) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_INTEGER(20) +SYM_RBRACKET +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(sum) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_IDENTIFIER(max) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_ASSIGN +SYM_IDENTIFIER(sum) +SYM_SEMICOLON +SYM_IDENTIFIER(sum) +SYM_ASSIGN +SYM_IDENTIFIER(sum) +SYM_PLUS +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_IDENTIFIER(max) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_IDENTIFIER(max) +SYM_MINUS +SYM_INTEGER(1) +SYM_RBRACKET +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/globals/globtab.e b/tests/globals/globtab.e index a8375fd..f07a346 100644 --- a/tests/globals/globtab.e +++ b/tests/globals/globtab.e @@ -6,7 +6,7 @@ struct my_struct { struct my_struct objs[2]; -int main(int argc, char** argv){ +int main(){ int i = 0; while (i < 2){ (objs[i]).x = i; diff --git a/tests/globals/globtab.e.expect_14_12_3_8_12 b/tests/globals/globtab.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..91ce1a2 --- /dev/null +++ b/tests/globals/globtab.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/globals/globtab.e.expect_1_2_3 b/tests/globals/globtab.e.expect_1_2_3 new file mode 100644 index 0000000..91ce1a2 --- /dev/null +++ b/tests/globals/globtab.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/globals/globtab.e.expect_lexer b/tests/globals/globtab.e.expect_lexer new file mode 100644 index 0000000..22ef58f --- /dev/null +++ b/tests/globals/globtab.e.expect_lexer @@ -0,0 +1,76 @@ +SYM_STRUCT +SYM_IDENTIFIER(my_struct) +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_SEMICOLON +SYM_STRUCT +SYM_IDENTIFIER(my_struct) +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_INTEGER(2) +SYM_RBRACKET +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_WHILE +SYM_LPARENTHESIS +SYM_IDENTIFIER(i) +SYM_LT +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_LPARENTHESIS +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_LPARENTHESIS +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_IDENTIFIER(i) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_SEMICOLON +SYM_IDENTIFIER(i) +SYM_ASSIGN +SYM_IDENTIFIER(i) +SYM_PLUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(objs) +SYM_LBRACKET +SYM_INTEGER(1) +SYM_RBRACKET +SYM_RPARENTHESIS +SYM_POINT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/structs/point.e b/tests/structs/point.e new file mode 100644 index 0000000..af07a81 --- /dev/null +++ b/tests/structs/point.e @@ -0,0 +1,26 @@ +struct point { + int x; + int y; +}; + +int scalar_product(struct point p1, struct point p2){ + return p1.x * p2.x + p1.y * p2.y; +} + +int orthogonal(struct point p1, struct point p2){ + return p1.x * p2.y - p1.y * p2.x; +} + + +int main(){ + struct point p1; + struct point p2; + p1.x = 3; + p1.y = 3; + p2.x = -5; + p2.y = 4; + + print(scalar_product(p1,p2)); + return (orthogonal(p1,p2)); +} + diff --git a/tests/structs/point.e.expect_14_12_3_8_12 b/tests/structs/point.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..2e9bfe9 --- /dev/null +++ b/tests/structs/point.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "-3\n", "error": null, "retval": 27} \ No newline at end of file diff --git a/tests/structs/point.e.expect_1_2_3 b/tests/structs/point.e.expect_1_2_3 new file mode 100644 index 0000000..2e9bfe9 --- /dev/null +++ b/tests/structs/point.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "-3\n", "error": null, "retval": 27} \ No newline at end of file diff --git a/tests/structs/point.e.expect_lexer b/tests/structs/point.e.expect_lexer new file mode 100644 index 0000000..62903ca --- /dev/null +++ b/tests/structs/point.e.expect_lexer @@ -0,0 +1,131 @@ +SYM_STRUCT +SYM_IDENTIFIER(point) +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(scalar_product) +SYM_LPARENTHESIS +SYM_STRUCT +SYM_IDENTIFIER(point) +SYM_IDENTIFIER(p1) +SYM_COMMA +SYM_STRUCT +SYM_IDENTIFIER(point) +SYM_IDENTIFIER(p2) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(p1) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASTERISK +SYM_IDENTIFIER(p2) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(p1) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASTERISK +SYM_IDENTIFIER(p2) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(orthogonal) +SYM_LPARENTHESIS +SYM_STRUCT +SYM_IDENTIFIER(point) +SYM_IDENTIFIER(p1) +SYM_COMMA +SYM_STRUCT +SYM_IDENTIFIER(point) +SYM_IDENTIFIER(p2) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(p1) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASTERISK +SYM_IDENTIFIER(p2) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_MINUS +SYM_IDENTIFIER(p1) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASTERISK +SYM_IDENTIFIER(p2) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_STRUCT +SYM_IDENTIFIER(point) +SYM_IDENTIFIER(p1) +SYM_SEMICOLON +SYM_STRUCT +SYM_IDENTIFIER(point) +SYM_IDENTIFIER(p2) +SYM_SEMICOLON +SYM_IDENTIFIER(p1) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_IDENTIFIER(p1) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_IDENTIFIER(p2) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_MINUS +SYM_INTEGER(5) +SYM_SEMICOLON +SYM_IDENTIFIER(p2) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(4) +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(scalar_product) +SYM_LPARENTHESIS +SYM_IDENTIFIER(p1) +SYM_COMMA +SYM_IDENTIFIER(p2) +SYM_RPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(orthogonal) +SYM_LPARENTHESIS +SYM_IDENTIFIER(p1) +SYM_COMMA +SYM_IDENTIFIER(p2) +SYM_RPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/structs/struct.e b/tests/structs/struct.e index a0f4f9a..1a6c1b9 100644 --- a/tests/structs/struct.e +++ b/tests/structs/struct.e @@ -3,7 +3,7 @@ struct mastruct { int y; }; -int main(int argc,char* argv[]){ +int main(){ struct mastruct S; S.x = 12; S.y = 3; diff --git a/tests/structs/struct.e.expect_14_12_3_8_12 b/tests/structs/struct.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..f027ba5 --- /dev/null +++ b/tests/structs/struct.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 15} \ No newline at end of file diff --git a/tests/structs/struct.e.expect_1_2_3 b/tests/structs/struct.e.expect_1_2_3 new file mode 100644 index 0000000..f027ba5 --- /dev/null +++ b/tests/structs/struct.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 15} \ No newline at end of file diff --git a/tests/structs/struct.e.expect_lexer b/tests/structs/struct.e.expect_lexer new file mode 100644 index 0000000..4a97a5c --- /dev/null +++ b/tests/structs/struct.e.expect_lexer @@ -0,0 +1,45 @@ +SYM_STRUCT +SYM_IDENTIFIER(mastruct) +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_STRUCT +SYM_IDENTIFIER(mastruct) +SYM_IDENTIFIER(S) +SYM_SEMICOLON +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/structs/struct2.e b/tests/structs/struct2.e index ad699ae..e1ae735 100644 --- a/tests/structs/struct2.e +++ b/tests/structs/struct2.e @@ -3,7 +3,7 @@ struct mastruct { int y; }; -int main(int argc,char* argv[]){ +int main(){ struct mastruct S; struct mastruct T; S.x = 12; diff --git a/tests/structs/struct2.e.expect_14_12_3_8_12 b/tests/structs/struct2.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..f027ba5 --- /dev/null +++ b/tests/structs/struct2.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 15} \ No newline at end of file diff --git a/tests/structs/struct2.e.expect_1_2_3 b/tests/structs/struct2.e.expect_1_2_3 new file mode 100644 index 0000000..f027ba5 --- /dev/null +++ b/tests/structs/struct2.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 15} \ No newline at end of file diff --git a/tests/structs/struct2.e.expect_lexer b/tests/structs/struct2.e.expect_lexer new file mode 100644 index 0000000..09bd6db --- /dev/null +++ b/tests/structs/struct2.e.expect_lexer @@ -0,0 +1,61 @@ +SYM_STRUCT +SYM_IDENTIFIER(mastruct) +SYM_LBRACE +SYM_INT +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(y) +SYM_SEMICOLON +SYM_RBRACE +SYM_SEMICOLON +SYM_INT +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_STRUCT +SYM_IDENTIFIER(mastruct) +SYM_IDENTIFIER(S) +SYM_SEMICOLON +SYM_STRUCT +SYM_IDENTIFIER(mastruct) +SYM_IDENTIFIER(T) +SYM_SEMICOLON +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(12) +SYM_SEMICOLON +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_IDENTIFIER(T) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_INTEGER(14) +SYM_SEMICOLON +SYM_IDENTIFIER(T) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_ASSIGN +SYM_INTEGER(15) +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(S) +SYM_POINT +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF -- GitLab