Tslator is a compiler for the TSLANG programming language, developed as part of the Compiler Design course at Babol Noshirvani University of Technology. TesLang is a simple C-like educational language featuring basic types, user-defined functions, arrays, conditionals, loops, and string handling.
Instructor and Developer of TSLANG: Dr. Gholami Rudi
TesLang supports the following data types:
int: Integer valuesvector: Arrays of integersstr: String literalsmstr: Multi-line stringsbool: Boolean values (true,false)
| File/Folder | Description |
|---|---|
lexer.py |
Lexical analyzer built with PLY |
parser.py |
Parser using TesLang grammar rules |
AST.py |
Abstract Syntax Tree node classes |
SymbolTable.py |
Symbol management, scoping, and type checking |
SemanticAnalyzer.py |
Performs semantic analysis and type validation |
IRGenerator.py |
Intermediate Representation (IR) code generation |
main.py |
Entry point of the compiler |
This compiler was developed in three main phases:
- Token recognition for all TesLang keywords and operators
- Support for nested comments (
</ ... />) - Error reporting for malformed tokens
- PLY-based parser using a hand-written BNF grammar
- Construction of the Abstract Syntax Tree (AST)
- Symbol table construction with scoped entries
- Type checking and semantic validation (e.g., return consistency, redefinition, undeclared use)
- Emits low-level IR resembling assembly
- Register allocation for variables and temporaries
- Correct return handling and expression evaluation
This project is licensed under the MIT License.