Skip to content

Latest commit

 

History

History
75 lines (45 loc) · 2.29 KB

README.md

File metadata and controls

75 lines (45 loc) · 2.29 KB

no-tiger

Not Ordinary Tiger Language

Build Status

Introduction

no-tiger is the course project for Compiler, Zhejiang University, Spring 2019.

Reference

  1. ANSI-C-grammar-lex

  2. ANSI-C-grammar-yacc

  3. FLEX AND BISON IN C++ best workable example

  4. compiler2018_big_picture slides from Lequn Chen, TA from SJTU (now PhD at UW)

Prerequisite

  • Flex: 2.5.37 (different version may cause UB)
  • Bison: 3.0.4 (for Bison version >= 3.0.4, remove sed command in build.sh since move semantics is already supported)
  • GCC: 7.3.0

For macOS

You can easily install the newest Bison throwgh homebrew. However, currently for Flex version >= 2.6, there exist some reference problems. Thus, we use the version 2.5.37 to develop and test. You might download the source from here and compile it yourself.

What needs to be pointed out is that macOS has a default Flex (2.5.35) and a default Bison (2.3), and they may cause some conflicts with your manual installed versions. Thus, you should export the new ones' path into ~/.bash_profile to make them available. Type in these in terminal:

echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile

Build

git clone --recursive [url]
sh build.sh

Visualization

Our compiler can dump AST in XML format. The provided python script can help visualize the AST

python tools/visualize.py input.xml

Roadmap

  • C++ style Flex/Bison generated scanner/parser

  • support main (at exp1.c)

  • Support basic control flow: if while for break continue

  • Support function definition

  • Support expressions

  • XML AST format output

  • LLVM codegen

  • Support builtin array

  • Support builtin I/O functions

Built With

  • cxxopts - Lightweight C++ command line option parser