Skip to content

Commit

Permalink
refactor: ast structure changed return is inside statement list, upda…
Browse files Browse the repository at this point in the history
…te generated test
  • Loading branch information
zestones committed Dec 30, 2024
1 parent ff181b1 commit f929ae1
Show file tree
Hide file tree
Showing 57 changed files with 60 additions and 7,625 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ Root of the AST:
+------------------------------------------------------------------------+
Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 12, Decl Idx: 12 -- Lexeme: 'test'
│ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_FLOAT_LITERAL, Lexico Idx: 13, Decl Idx: -1 -- Lexeme: '1.0'
│ ├── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_FLOAT_LITERAL, Lexico Idx: 13, Decl Idx: -1 -- Lexeme: '1.0'
+------------------------------------------------------------------------+


Expand All @@ -236,7 +237,8 @@ Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 14, Decl Idx: 14 -- Lexeme: 'main'
│ ├── A_PARAMETER_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_PARAMETER, Lexico Idx: 15, Decl Idx: 15 -- Lexeme: 'a'
│ └── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 16, Decl Idx: -1 -- Lexeme: '0'
│ └── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_INTEGER_LITERAL, Lexico Idx: 16, Decl Idx: -1 -- Lexeme: '0'
+------------------------------------------------------------------------+

Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ Root of the AST:
│ │ │ │ ├── A_MUL_OP, Lexico Idx: -1, Decl Idx: -1
│ │ │ │ │ ├── A_IDENTIFIER, Lexico Idx: 4, Decl Idx: 500 -- Lexeme: 'a'
│ │ │ │ │ └── A_INTEGER_LITERAL, Lexico Idx: 24, Decl Idx: -1 -- Lexeme: '2'
│ └── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_IDENTIFIER, Lexico Idx: 4, Decl Idx: 500 -- Lexeme: 'a'
└── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_IDENTIFIER, Lexico Idx: 4, Decl Idx: 500 -- Lexeme: 'a'
+------------------------------------------------------------------------+


Expand All @@ -289,7 +289,7 @@ Root of the AST:
│ │ │ │ ├── A_DIV_OP, Lexico Idx: -1, Decl Idx: -1
│ │ │ │ │ ├── A_IDENTIFIER, Lexico Idx: 26, Decl Idx: 26 -- Lexeme: 'g'
│ │ │ │ │ └── A_INTEGER_LITERAL, Lexico Idx: 24, Decl Idx: -1 -- Lexeme: '2'
│ └── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_IDENTIFIER, Lexico Idx: 26, Decl Idx: 26 -- Lexeme: 'g'
└── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_IDENTIFIER, Lexico Idx: 26, Decl Idx: 26 -- Lexeme: 'g'
+------------------------------------------------------------------------+

Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ Root of the AST:
│ ├── A_PARAMETER_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_PARAMETER, Lexico Idx: 19, Decl Idx: 19 -- Lexeme: 'a'
│ │ └── A_PARAMETER, Lexico Idx: 20, Decl Idx: 20 -- Lexeme: 'b'
│ └── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 21, Decl Idx: -1 -- Lexeme: '0'
│ └── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_INTEGER_LITERAL, Lexico Idx: 21, Decl Idx: -1 -- Lexeme: '0'
+------------------------------------------------------------------------+

Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ Root of the AST:
+------------------------------------------------------------------------+
Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 5, Decl Idx: 5 -- Lexeme: 'one_int'
│ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 6, Decl Idx: -1 -- Lexeme: '1'
│ ├── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_INTEGER_LITERAL, Lexico Idx: 6, Decl Idx: -1 -- Lexeme: '1'
+------------------------------------------------------------------------+


Expand All @@ -157,8 +158,9 @@ Root of the AST:
+------------------------------------------------------------------------+
Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 7, Decl Idx: 7 -- Lexeme: 'one_float'
│ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_FLOAT_LITERAL, Lexico Idx: 8, Decl Idx: -1 -- Lexeme: '1.0'
│ ├── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_FLOAT_LITERAL, Lexico Idx: 8, Decl Idx: -1 -- Lexeme: '1.0'
+------------------------------------------------------------------------+


Expand All @@ -170,7 +172,8 @@ Root of the AST:
│ ├── A_PARAMETER_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_PARAMETER, Lexico Idx: 10, Decl Idx: 10 -- Lexeme: 'a'
│ │ └── A_PARAMETER, Lexico Idx: 11, Decl Idx: 11 -- Lexeme: 'b'
│ └── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 12, Decl Idx: -1 -- Lexeme: '0'
│ └── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_INTEGER_LITERAL, Lexico Idx: 12, Decl Idx: -1 -- Lexeme: '0'
+------------------------------------------------------------------------+

Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ Root of the AST:
│ ├── A_PARAMETER_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_PARAMETER, Lexico Idx: 16, Decl Idx: 16 -- Lexeme: 'a'
│ │ └── A_PARAMETER, Lexico Idx: 17, Decl Idx: 17 -- Lexeme: 'b'
│ └── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 18, Decl Idx: -1 -- Lexeme: '0'
│ └── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_INTEGER_LITERAL, Lexico Idx: 18, Decl Idx: -1 -- Lexeme: '0'
+------------------------------------------------------------------------+

Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ Root of the AST:
+------------------------------------------------------------------------+
Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 6, Decl Idx: 6 -- Lexeme: 'test2'
│ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 7, Decl Idx: -1 -- Lexeme: '1'
│ ├── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_INTEGER_LITERAL, Lexico Idx: 7, Decl Idx: -1 -- Lexeme: '1'
+------------------------------------------------------------------------+


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ Root of the AST:
│ ├── A_PARAMETER_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_PARAMETER, Lexico Idx: 16, Decl Idx: 16 -- Lexeme: 'a'
│ │ └── A_PARAMETER, Lexico Idx: 17, Decl Idx: 17 -- Lexeme: 'b'
│ └── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 18, Decl Idx: -1 -- Lexeme: '0'
│ └── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_INTEGER_LITERAL, Lexico Idx: 18, Decl Idx: -1 -- Lexeme: '0'
+------------------------------------------------------------------------+

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Type Error] Type mismatch for function return value at example/compilation/errors/semantic/func_proc/prototype/prototype.txt:17:2.
[Type Error] Type mismatch for function return value at example/compilation/errors/semantic/func_proc/prototype/prototype.txt:16:23.
Function returned value has type 'float', but it should be of type 'int'.
Ensure the function return type matches the expected type.

Expand Down Expand Up @@ -106,8 +106,9 @@ Root of the AST:
+------------------------------------------------------------------------+
Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 4, Decl Idx: 4 -- Lexeme: 'zero'
│ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_FLOAT_LITERAL, Lexico Idx: 5, Decl Idx: -1 -- Lexeme: '0.0'
│ ├── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_FLOAT_LITERAL, Lexico Idx: 5, Decl Idx: -1 -- Lexeme: '0.0'
+------------------------------------------------------------------------+


Expand All @@ -118,8 +119,9 @@ Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 6, Decl Idx: 6 -- Lexeme: 'one'
│ ├── A_PARAMETER_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_PARAMETER, Lexico Idx: 7, Decl Idx: 7 -- Lexeme: 'x'
│ └── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_IDENTIFIER, Lexico Idx: 7, Decl Idx: 7 -- Lexeme: 'x'
│ └── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_IDENTIFIER, Lexico Idx: 7, Decl Idx: 7 -- Lexeme: 'x'
+------------------------------------------------------------------------+


Expand All @@ -136,9 +138,9 @@ Root of the AST:
│ │ ├── A_ASSIGNMENT_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_VARIABLE_ASSIGNMENT, Lexico Idx: 7, Decl Idx: 500 -- Lexeme: 'x'
│ │ │ │ ├── A_FLOAT_LITERAL, Lexico Idx: 10, Decl Idx: -1 -- Lexeme: '45.0'
│ └── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_ADD_OP, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_IDENTIFIER, Lexico Idx: 7, Decl Idx: 500 -- Lexeme: 'x'
│ │ │ └── A_FUNC_PROC_CALL_STATEMENT, Lexico Idx: 4, Decl Idx: 4 -- Lexeme: 'zero'
└── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_ADD_OP, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_IDENTIFIER, Lexico Idx: 7, Decl Idx: 500 -- Lexeme: 'x'
│ │ │ └── A_FUNC_PROC_CALL_STATEMENT, Lexico Idx: 4, Decl Idx: 4 -- Lexeme: 'zero'
+------------------------------------------------------------------------+

Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ Root of the AST:
+------------------------------------------------------------------------+
Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 4, Decl Idx: 4 -- Lexeme: 'main'
│ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 5, Decl Idx: -1 -- Lexeme: '0'
│ ├── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_INTEGER_LITERAL, Lexico Idx: 5, Decl Idx: -1 -- Lexeme: '0'
+------------------------------------------------------------------------+


Expand All @@ -102,8 +103,9 @@ Root of the AST:
+------------------------------------------------------------------------+
Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 4, Decl Idx: 500 -- Lexeme: 'main'
│ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 5, Decl Idx: -1 -- Lexeme: '0'
│ ├── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_INTEGER_LITERAL, Lexico Idx: 5, Decl Idx: -1 -- Lexeme: '0'
+------------------------------------------------------------------------+


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ Root of the AST:
│ ├── A_PARAMETER_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_PARAMETER, Lexico Idx: 15, Decl Idx: 15 -- Lexeme: 'a'
│ │ └── A_PARAMETER, Lexico Idx: 16, Decl Idx: 16 -- Lexeme: 'b'
│ └── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 17, Decl Idx: -1 -- Lexeme: '0'
│ └── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_INTEGER_LITERAL, Lexico Idx: 17, Decl Idx: -1 -- Lexeme: '0'
+------------------------------------------------------------------------+

Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 8, Decl Idx: 8 -- Lexeme: 'my_func'
│ ├── A_DECLARATION_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_VARIABLE_DECLARATION, Lexico Idx: 9, Decl Idx: 9 -- Lexeme: 'x'
│ └── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_IDENTIFIER, Lexico Idx: 9, Decl Idx: 9 -- Lexeme: 'x'
│ └── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_IDENTIFIER, Lexico Idx: 9, Decl Idx: 9 -- Lexeme: 'x'
+------------------------------------------------------------------------+


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ Root of the AST:
+------------------------------------------------------------------------+
Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 22, Decl Idx: 22 -- Lexeme: 'test'
│ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 14, Decl Idx: -1 -- Lexeme: '1'
│ ├── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_INTEGER_LITERAL, Lexico Idx: 14, Decl Idx: -1 -- Lexeme: '1'
+------------------------------------------------------------------------+


Expand All @@ -275,7 +276,8 @@ Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 23, Decl Idx: 23 -- Lexeme: 'main'
│ ├── A_PARAMETER_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_PARAMETER, Lexico Idx: 24, Decl Idx: 24 -- Lexeme: 'a'
│ └── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 25, Decl Idx: -1 -- Lexeme: '0'
│ └── A_STATEMENT_LIST, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ │ ├── A_INTEGER_LITERAL, Lexico Idx: 25, Decl Idx: -1 -- Lexeme: '0'
+------------------------------------------------------------------------+

95 changes: 0 additions & 95 deletions example/compilation/.out/expected_outputs/lexical/unknow_char.out

This file was deleted.

Loading

0 comments on commit f929ae1

Please sign in to comment.