adokitkat / vut-fit-vypa

Project for VYPa (Compiler Construction) class at VUT/BUT FIT

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VYPa 2022

Simplified project structure:

├── doc                        Documentation files
│   └── ...
├── tests                      Test files
│   └── ...
├── vypa_compiler              Compiler source files
│   ├── generated
│   │   └── ...
│   ├── internals
│   │   ├── _ast.py            Abstract syntax tree implementation
│   │   ├── _code_templates.py Instruction templates
│   │   ├── _codegen.py        Code generation implementation
│   │   ├── _instructions.py   Target instructions
│   │   ├── _lexer.py          Lexer implementation
│   │   ├── _model.py          Symbol table, semantics, etc.
│   │   ├── _parser.py         Parser implementation
│   │   └── _utils.py          Utility functions
│   └── compiler.py            Main source file
│
├── .gitignore
├── LICENSE
├── Makefile                   Makefile script
├── README.md
├── requirements.txt           Pip dependencies
├── setup.py                   Setup script 
└── vypcomp                    Complier executable

Getting started

Setup

Initialize the project before running:

make

Running the compiler

vypcomp SOURCE_FILE [OUTPUT_FILE]

Default output file name is out.vc.

Progress

Compiler stages

  • Lexical analysis
    • Source code lexemes to tokens
  • Syntax analysis
  • Semantic analysis
  • Construct AST
  • Target code generation (partially)

Features / Other

  • Symbol table, variables
  • Operator precedence
  • If-Else
  • While
  • Functions
  • Built-in Functions
    • Print
    • Cast INT STRING
    • ...
  • OOP
    • Classes, objects
    • Inheritance

Etc.

About

Project for VYPa (Compiler Construction) class at VUT/BUT FIT

License:MIT License


Languages

Language:Python 99.3%Language:Makefile 0.5%Language:Shell 0.2%