Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pranavsuriya-sr/tccdtest
https://github.com/pranavsuriya-sr/tccdtest
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/pranavsuriya-sr/tccdtest
- Owner: pranavsuriya-sr
- Created: 2024-10-13T13:28:35.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-21T05:56:44.000Z (3 months ago)
- Last Synced: 2024-10-21T08:43:59.651Z (3 months ago)
- Language: Python
- Homepage: https://tccdproj.streamlit.app/
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Simple C++ Compiler Simulation with Parse Tree Visualization
This is a basic C++ Compiler Simulation built using **Streamlit** for the user interface and **Anytree** for visualizing the parse tree. The program performs lexical analysis, syntax analysis, and semantic analysis on simple C++ code snippets, and generates a binary-like parse tree in the terminal.
## Features
- **Lexical Analysis**: Converts the input C++ code into a sequence of tokens (keywords, operators, identifiers, literals, etc.).
- **Syntax Analysis**: Validates the structure of the input code based on predefined rules (e.g., assignment statements, loops).
- **Semantic Analysis**: Ensures that the input code is semantically correct (e.g., correct variable types and assignments).
- **Parse Tree Visualization**: Displays a binary-like parse tree structure based on the code's tokens and syntactic structure.## How It Works
### 1. Lexical Analysis
The input code is broken into lexemes, and each lexeme is classified into a token type (e.g., `KEYWORD`, `ASSIGNMENT_OPERATOR`, `IDENTIFIER`, `INTEGER_LITERAL`, etc.).### 2. Syntax Analysis
Checks the sequence of tokens against C++ syntax rules, such as variable declarations, assignments, and loops.### 3. Semantic Analysis
Verifies the semantic correctness, such as ensuring the correct type of values being assigned to variables (e.g., integer to `int`).### 4. Parse Tree
Generates and visualizes a parse tree representing the structure of the code. The tree is shown as a text-based hierarchical tree in the Streamlit app.## Example
Input Code:
```cpp
int x = 5;