A compiler-like tool that translates pseudocode into executable code (or another target language) by implementing formal grammar-based analysis. The project follows a classic multi-stage translation pipeline: lexical, syntactic, and semantic analysis, followed by code generation.
- Lexical Analysis: Tokenizes input using finite automata and regular grammars.
- Syntax Analysis: Parses tokens via context-free grammar (CFG) rules.
- Semantic Analysis: Validates variable declarations, type consistency, and operator compatibility.
- GUI Client: Interactive interface for input and visualization (built with Tkinter).
- REST API: Optional server mode (Flask) for remote processing.
code-analyzer/
├── core/ # Backend and Analysis Core
│ ├── app.py # Flask REST API
│ ├── lexer.py # Lexical analyzer (finite automata)
│ ├── syntax_analyzer.py # CFG-based parser
│ ├── semantic_analyzer.py # Type/scope validation
│ ├── Dockerfile # Containerization
│ ├── pyproject.toml
│ └── requirements.txt # Python dependencies
│
├── client/ # Frontend (GUI)
│ ├── main.py # Tkinter-based interface
│ ├── pyproject.toml
│ └── requirements.txt # Client dependencies
│
├── grammar/ # Formal grammar specs
│ └── README.md
│
└── tests/ # Unit/integration tests
├── test_lexer.py # Lexer test cases
└── test_parser.py # Syntax/semantic tests- Python 3.11+
- pip
- Docker
- Clone the repository:
git clone https://github.com/Nikindrik/Ossa.git cd Ossa
...
- Launch
client/main.py. - Input pseudocode in the text area.
- Click Analyze to view tokens, parse trees, and translated output.
curl -X POST -H "Content-Type: text/plain" --data-binary @input.pseudo http://localhost:5000/analyze- Lexical Rules: Defined as regex patterns (e.g.,
IDENTIFIER = [a-zA-Z_][a-zA-Z0-9_]*). - Syntax Rules: Context-free grammar (BNF format) for statement/expression parsing.
- Semantic Checks: Type inference, variable scoping, and operator validation.
See grammar/ directory for details.
MIT License. See LICENSE for details.