Skip to content

asmeralt/dsl_compilers_design

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

A baseline project for "Design Compilers for DSL" course

Python example for ANTLR can be found here

Requirements

MacOSX

  1. Install brew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Install antlr4 tool brew install antlr
  3. Create python virtual environment
  4. Install antlr4 python interface pip install -r requirements.txt

Windows

  1. Install WSL and Ubuntu distro
    1. How to turn on Hyper Visor video
    2. Move WSL installation to non-system drive wsl --manage distro --move new-location where distro = Ubuntu and new-location = D:\wsl\
    3. How to reset user password
      1. Start Ubuntu terminal in as root user wsl -d Ubuntu -u root
      2. Reset password for your user passwd {username}
      3. Enter new password and confirm it. Note: in Unix like systems passwords typed in terminal are not visible
  2. Install VS Code and recommended for this project extentions
    1. Install WSL extention for VS Code
    2. In bottom left corner select Open a Remote Window button and restart VS Code in WSL mode
  3. Run Ubuntu terminal from start menu or in VS Code
  4. Update system packages sudo apt update && sudo apt upgrade -y
  5. Install python3 sudo apt install python3 python3-pip python3-venv
  6. Install antlr4 sudo apt install antlr4

Windows (simplified)

  1. Install python3 from official website without Admin Privileges and/or adding to Path
  2. Install VS Code and recommended for this project extentions
  3. In VS Code open any file with .py extention and in bottom right corner select correct python interpreter installed on previous step
  4. Run file with Run button in right top corner
  5. If needed specify default Terminal application by pressing F1, typing Terminal: Select Default Profile and choosing Command Prompt (cmd.exe)
  6. Install ANTLR4
    1. Install ANTLR4 with pip install antlr4-tools
    2. (Alternatively) Get Java for Windows and add java executables & ANTLR4 jar in PATH variable

Usage

ANTLR Calculator Example

  1. Enter folder cd antlr4_calculator
  2. Run antlr tool
antlr -Dlanguage=Python3 -visitor Expr.g4  
  1. Execute Driver.py script
    1. CLI command
    python3 Driver.py --file input.txt --worker visitor
    1. VS Code Run & Debug config ANTLR Calculator Example

Labs

Run unit tests from VS Code Testing tab

Substrings

  1. Run on config form VS Code Run & Debug tab
    1. Naive Substring
    2. KMP Substring

About

A practical course to DSL compilers design in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published