Skip to content

Remembering my university course "Programming Languages and Translation Methods"

Notifications You must be signed in to change notification settings

forsaken1/simple-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Compiler

Rewrite my old compiler https://github.com/forsaken1/compiler

Grammar: C lang (cutted), based on https://www.lysator.liu.se/c/ANSI-C-grammar-y.html

Status: syntax analysis

Todo

  1. lexical analysis

  2. syntax analysis

  3. semantic analysis

  4. code generation

  5. optimization

  6. code-not-shitication

Installation

brew install crystal-lang
git clone git@github.com:forsaken1/simple-compiler.git
cd simple-compiler

crystal build simple-compiler.cr         # build compiler
./simple-compiler path/to/file.txt       # compile file without optimization
./simple-compiler -s path/to/file.txt    # returns list of tokens (scanner)
./simple-compiler -p path/to/file.txt    # returns syntax tree (parser)
./simple-compiler -g path/to/file.txt    # returns assembler code (generator)
./simple-compiler -o path/to/file.txt    # compile file with optimization
./simple-compiler -g -o path/to/file.txt # returns assembler code with optimization

crystal tester.cr # run all tests (don't work without simple-compiler)

About

Remembering my university course "Programming Languages and Translation Methods"

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published