Commit Graph

5 Commits

Author SHA1 Message Date
Arkaprabha Chakraborty
dee7372ae4 Add build directory to .gitignore
Changes made in .gitignore:
- Add 'build/' to exclude generated build files.
2024-01-22 07:09:30 +05:30
Arkaprabha Chakraborty
69bc5b4aa1 Create ast.cxx for AST implementation and tests
Commit details:
- Add new file ast.cxx with ASTNode, Identifier, Divide, Multiply, Subtract, Power classes.
- Include necessary headers and static initialization of variableTable in Identifier class.
- Add a test function runTest() for evaluating a complex expression.
- Add printHelpMessage() function for displaying program usage.
- Update main function to handle "--run-test" argument.
2024-01-22 07:07:30 +05:30
Arkaprabha Chakraborty
7b5eb1e26d Rename main.cxx to ast.hxx
Commit details:
- Rename main.cxx to src/ast.hxx to better reflect its content.
- Update include statements in the renamed file.
- Remove unnecessary include <cstring> statement from ast.hxx.
- Remove redundant implementation of Power::evaluate() in ast.hxx.
2024-01-22 07:06:48 +05:30
Arkaprabha Chakraborty
6c313ae3dd Refactor AST Node Hierarchy and Enable Test Execution
Commit details:
- Refactor the Abstract Syntax Tree (AST) node hierarchy in `main.cxx` for improved memory management and ownership semantics.
- Introduce smart pointers (`std::unique_ptr`) for managing ownership of AST nodes, eliminating manual memory management.
- Add getter functions to access operands in Unary and Binary nodes.
- Implemente functions to release ownership of operands in Unary and Binary nodes.
- Replace manual deletion of operands in the destructor with default virtual destructors for Unary and Binary nodes.
- Add a conditional compilation block (`#ifdef ENABLE_TESTS`) to enable testing functionality.
- Create a test expression in the `runTest` function to evaluate a complex mathematical expression.
- Enable test execution using the `--run-test` command-line option.
- Provide a help message for the main program, outlining available options.
2024-01-22 07:00:48 +05:30
Arkaprabha Chakraborty
49617b7822 Initial commit 2024-01-20 07:34:29 +05:30