Skip to content

Commit

Permalink
Revert "4 handle boolean expression with arithmetic operation"
Browse files Browse the repository at this point in the history
  • Loading branch information
zestones authored Dec 30, 2024
1 parent d4d2166 commit 5a8f663
Show file tree
Hide file tree
Showing 128 changed files with 7,900 additions and 3,080 deletions.
39 changes: 0 additions & 39 deletions .vscode/launch.json

This file was deleted.

34 changes: 24 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
{
"files.associations": {
"*.rmd": "markdown",
"address_calculation.h": "c",
"stack_management.h": "c",
"variable_manager.h": "c",
"cstdlib": "c",
"execution.h": "c",
"region_table.h": "c",
"vm_cell.h": "c",
"stdio.h": "c",
"representation_table.h": "c",
"lexeme_table.h": "c",
"utility.h": "c",
"expression.h": "c",
"stdlib.h": "c",
"execution.h": "c",
"interpreter.h": "c",
"stack.h": "c",
"stack_management.h": "c",
"ast.h": "c",
"table_printer.h": "c",
"system_error": "c",
"array": "c",
"functional": "c",
"tuple": "c",
"type_traits": "c",
"utility": "c",
"compare": "c",
"utils.h": "c",
"region_table.h": "c",
"address_calculation.h": "c",
"type_inference.h": "c",
"representation_table.h": "c",
"formatting.h": "c",
"stdlib.h": "c"
"condition.h": "c",
"procedure.h": "c",
"format_specifiers.h": "c",
"cstdlib": "c"
}
}
16 changes: 0 additions & 16 deletions .vscode/tasks.json

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ clean: simple-clean
rm -f *.exe $(BIN_DIR)/*.tab.c $(BIN_DIR)/*.tab.h $(BIN_DIR)/lex.yy.c && \
rm -rf tests/**/__pycache__
rm -rf ./.pytest_cache/
rm -f log.txt
rm -f log.txt *.a
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,3 @@ Address of $S[3].f$:
$$
\text{Address} = 2000 + (3 \cdot 12) + 4 = 2040
$$

### Notes:

- **Dynamic**: Refers to the function frame index of the caller.
- **Static**: Refers to the frame index of the parent.
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,8 @@ Root of the AST:
+------------------------------------------------------------------------+
Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 12, Decl Idx: 12 -- Lexeme: 'test'
│ ├── 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'
│ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_FLOAT_LITERAL, Lexico Idx: 13, Decl Idx: -1 -- Lexeme: '1.0'
+------------------------------------------------------------------------+


Expand All @@ -237,8 +236,7 @@ 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_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'
│ └── 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,8 +226,7 @@ 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_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'
│ └── 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,9 +147,8 @@ Root of the AST:
+------------------------------------------------------------------------+
Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 5, Decl Idx: 5 -- Lexeme: 'one_int'
│ ├── 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'
│ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 6, Decl Idx: -1 -- Lexeme: '1'
+------------------------------------------------------------------------+


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


Expand All @@ -172,8 +170,7 @@ 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_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'
│ └── 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,8 +196,7 @@ 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_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'
│ └── 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,9 +167,8 @@ Root of the AST:
+------------------------------------------------------------------------+
Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 6, Decl Idx: 6 -- Lexeme: 'test2'
│ ├── 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'
│ ├── 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,8 +177,7 @@ 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_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'
│ └── 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:16:23.
[Type Error] Type mismatch for function return value at example/compilation/errors/semantic/func_proc/prototype/prototype.txt:17:2.
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,9 +106,8 @@ Root of the AST:
+------------------------------------------------------------------------+
Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 4, Decl Idx: 4 -- Lexeme: 'zero'
│ ├── 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'
│ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_FLOAT_LITERAL, Lexico Idx: 5, Decl Idx: -1 -- Lexeme: '0.0'
+------------------------------------------------------------------------+


Expand All @@ -119,9 +118,8 @@ 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_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'
│ └── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_IDENTIFIER, Lexico Idx: 7, Decl Idx: 7 -- Lexeme: 'x'
+------------------------------------------------------------------------+


Expand All @@ -138,9 +136,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,9 +92,8 @@ Root of the AST:
+------------------------------------------------------------------------+
Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 4, Decl Idx: 4 -- Lexeme: 'main'
│ ├── 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'
│ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 5, Decl Idx: -1 -- Lexeme: '0'
+------------------------------------------------------------------------+


Expand All @@ -103,9 +102,8 @@ Root of the AST:
+------------------------------------------------------------------------+
Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 4, Decl Idx: 500 -- Lexeme: 'main'
│ ├── 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'
│ ├── 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,8 +220,7 @@ 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_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'
│ └── 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,9 +120,8 @@ 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_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'
│ └── 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,9 +263,8 @@ Root of the AST:
+------------------------------------------------------------------------+
Root of the AST:
├── A_FUNCTION_DECLARATION, Lexico Idx: 22, Decl Idx: 22 -- Lexeme: 'test'
│ ├── 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'
│ ├── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 14, Decl Idx: -1 -- Lexeme: '1'
+------------------------------------------------------------------------+


Expand All @@ -276,8 +275,7 @@ 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_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'
│ └── A_RETURN_STATEMENT, Lexico Idx: -1, Decl Idx: -1
│ │ ├── A_INTEGER_LITERAL, Lexico Idx: 25, Decl Idx: -1 -- Lexeme: '0'
+------------------------------------------------------------------------+

Loading

0 comments on commit 5a8f663

Please sign in to comment.