Git Product home page Git Product logo

refined_c_compiler's Introduction

Refined C Compiler

A new language compiler defined by grammar in guidebook of Compiling Principle in Njtech University. For detailed instructions, please read the pdf file in ./doc

What is it?

A homework made for handling Compiler Principle courses. This project is using lex and yacc, also known as flex and bison. If there is anyone taking this course in Njtech University, this might help you A LOT.

How to use it?

  1. Download and install your own flex, bison and makefile environment, as all of them are the basic tools for cooking the whole project. As for how to achieve that, you should search for it in yourself.
  2. git clone https://github.com/Autokaka/refined_c_compiler.git
  3. In termial, input:
    • make to compile the compiler. The build files shall be generated “build” directory in your project root directory.
    • make demo to compile and run an example file to help you understand how to use this simple compiler.
    • make clean to clean the generated files and build files.
  4. if you don’t have Makefile environment, you can run these commands in the root directory of your project in terminal:
    • ./make_all.sh to compile the compiler. The build files shall be generated “build” directory in your project root directory.
    • ./make_demo.sh to compile and run an example file to help you understand how to use this simple compiler.
    • ./make_clean.sh to clean the generated files and build files.

What’s more

  1. If you need to know the detailed technique about how the script take effect, you can see all of them in make_all.sh, make_clean.sh and make_demo.sh. Talk is cheap in learning new things, you should always read the code :)

  2. Please notice that the “C” here does not mean that c/c++ language. The language itself has its own rules. The format of your code should follow the definition in ./doc/编译原理上机实验指导书.pdf and ./doc/修改好的LL(1)文法.md

  3. The whole project is built under the following environment. If you have problem in running scripts, please check if you meet the requirements below:

    • OS: Mac OS Catalina 10.15.5

    • Tools:

      flex 2.5.35 Apple(flex-32)

      bison (GNU Bison) 2.3

      Apple clang version 11.0.3 (clang-1103.0.32.62) Target: x86_64-apple-darwin19.5.0 Thread model: posix

  4. Here is the tutorial about how to install lex and yacc: https://www.youtube.com/watch?v=8EO5Y7KhoeU. It is a Youtube link, if you are in a country that cannot access foreign website, please use a VPN first.

refined_c_compiler's People

Contributors

autokaka avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sho94os

refined_c_compiler's Issues

syntax error

You've really done an awesome work! I do a black box test in a incremental way, and it seems that there is something wrong with if and while statement. The screenshots are as below.
1
2
3
4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.