diff --git a/tests/array/array.e b/tests/array/array.e index 991bb56e38b916487dfc4f610031b68cb7038c5f..3617f797c2ef2e3c0c11dc9c5c67f8dcf3e8b42d 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 0000000000000000000000000000000000000000..61b83a85dd0aeeb0ff59aaeb795875114625cdf7 --- /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 0000000000000000000000000000000000000000..61b83a85dd0aeeb0ff59aaeb795875114625cdf7 --- /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 0000000000000000000000000000000000000000..472e69b5d3ba5acd455927bc861f79f7235a093a --- /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 5261405bfcb7029bae32090f64040327bfaa78bc..e5d62947c4c4f1761ebe7407eb26e11cc5f15e4d 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 0000000000000000000000000000000000000000..46eb758a30a5a05a4aed05c3fb6599f4445a5a08 --- /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 0000000000000000000000000000000000000000..46eb758a30a5a05a4aed05c3fb6599f4445a5a08 --- /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 0000000000000000000000000000000000000000..828b548a9e54df1376dc4fda16c747f52629985a --- /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 b13de33d2569d489f21db1fb0c28fce1ab242617..e63c576a4ad0a2eff3a33100544a77e2c6e20557 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 0000000000000000000000000000000000000000..2bd92018d953185fdf4602de6784eb8d56ae2f3c --- /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 0000000000000000000000000000000000000000..2bd92018d953185fdf4602de6784eb8d56ae2f3c --- /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 0000000000000000000000000000000000000000..2b275af2969d6c5dba28bfb6af539a2de7bdf921 --- /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 1ac9e501e1e2606b6eccacdc6d944ba161fb070a..bebd09a2489efcb74401c1b5a7208ede44d35a0f 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 0000000000000000000000000000000000000000..ff173ecdb8373e909da3d38e30940db4a55a4f2d --- /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 0000000000000000000000000000000000000000..ff173ecdb8373e909da3d38e30940db4a55a4f2d --- /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 0000000000000000000000000000000000000000..29192015aa8028937fe08c33f0c0162e42b2a14b --- /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 c8f42dfffc18d3727faf23c68428946d34ceddc9..9d0eff9c28a715c9458ce84c960b18ad081148fd 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 0000000000000000000000000000000000000000..bd654bf2fc45c712f7557bcc0dda4a86cc94a4ff --- /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 0000000000000000000000000000000000000000..bd654bf2fc45c712f7557bcc0dda4a86cc94a4ff --- /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 0000000000000000000000000000000000000000..d7168b157831414121db4466aa676bfbcf0f9f24 --- /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 0000000000000000000000000000000000000000..f28c3d354c19b88c5063634ef470148f7bf18852 --- /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 0000000000000000000000000000000000000000..8858d4cccf47c58c61f15b14873ea04ff1793568 --- /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 0000000000000000000000000000000000000000..8858d4cccf47c58c61f15b14873ea04ff1793568 --- /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 0000000000000000000000000000000000000000..1566d173fdc41a967b051fd8f02525da716c01e2 --- /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 d169ba75903a4acf43a00d69d93697a5c5ba49fe..2b86a5a790b84294d8dd1073fc4a2172a1ff9fd4 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 0000000000000000000000000000000000000000..5e0e1d8e95659264ba481f9f8365906d19a91516 --- /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 0000000000000000000000000000000000000000..5e0e1d8e95659264ba481f9f8365906d19a91516 --- /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 0000000000000000000000000000000000000000..aa6f81eaa86e76a2bcf656db8fde7e0e357f667d --- /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 e76ae273be5c5c199533f3c8827369027d78597d..70cbf87a4d22df020c98d9c0f395fa5bed1dcdaa 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 0000000000000000000000000000000000000000..016d6cd30c8fc3fd3f0ef57bfe183aa6023661fa --- /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 0000000000000000000000000000000000000000..016d6cd30c8fc3fd3f0ef57bfe183aa6023661fa --- /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 0000000000000000000000000000000000000000..c8ddec75638f834c5c254903cc233a2fe7dc07e5 --- /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 9f656e5e2aa0b83ba25fbe022d08fa70d28c8e59..e4c8bcdee358f8983895ce659e46686add1ea9a1 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 0000000000000000000000000000000000000000..30828c15056b7ce6e95653abc818578558480a3e --- /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 0000000000000000000000000000000000000000..30828c15056b7ce6e95653abc818578558480a3e --- /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 0000000000000000000000000000000000000000..23154b3ff6ab075e332a475f9419f3bd735c2877 --- /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 a8375fd22ea25f50d1261fef7d3e0883e34a1dc2..f07a34616b54d86d533fa7820c7452b2814a8525 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 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /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 0000000000000000000000000000000000000000..91ce1a2bdbf38470155456d0bd691bff3912e2c6 --- /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 0000000000000000000000000000000000000000..22ef58f57df64dd0be8b134421daa329570864fb --- /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 0000000000000000000000000000000000000000..af07a81a761bee6b52012a6bd49cce46a9fb6576 --- /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 0000000000000000000000000000000000000000..2e9bfe9b00974ddaaaf41c927a37b8892553413d --- /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 0000000000000000000000000000000000000000..2e9bfe9b00974ddaaaf41c927a37b8892553413d --- /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 0000000000000000000000000000000000000000..62903ca1a3fe44f477850dbf377c06897158bf1f --- /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 a0f4f9a279d1d8b843075d004d8db23436b231cf..1a6c1b9aa3147f57e6413afb9ddc2aa0b3a961cc 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 0000000000000000000000000000000000000000..f027ba59b2dfd707cb7cb2669cdd6f2d58f96637 --- /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 0000000000000000000000000000000000000000..f027ba59b2dfd707cb7cb2669cdd6f2d58f96637 --- /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 0000000000000000000000000000000000000000..4a97a5c738b64559c9cff1565da33518f0138bea --- /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 ad699aef000b6b2042a6a7b26fbb600c2524cc76..e1ae73543d9b7632f87fc0de3eb26cfbb38f39d5 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 0000000000000000000000000000000000000000..f027ba59b2dfd707cb7cb2669cdd6f2d58f96637 --- /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 0000000000000000000000000000000000000000..f027ba59b2dfd707cb7cb2669cdd6f2d58f96637 --- /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 0000000000000000000000000000000000000000..09bd6dbdfd4d99d34c4ee41db289a258e15b9e04 --- /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