Skip to content

Nikindrik/Ossa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ossa

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.


Features

  • 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.

🛠️ Project Structure

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

Installation

Prerequisites

  • Python 3.11+
  • pip
  • Docker

Steps

  1. Clone the repository:
    git clone https://github.com/Nikindrik/Ossa.git
    cd Ossa

...


Usage

GUI Mode

  1. Launch client/main.py.
  2. Input pseudocode in the text area.
  3. Click Analyze to view tokens, parse trees, and translated output.

CLI/API Mode

curl -X POST -H "Content-Type: text/plain" --data-binary @input.pseudo http://localhost:5000/analyze

📜 Grammar Specifications

  • 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.


📄 License

MIT License. See LICENSE for details.

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors