Coder Social home page Coder Social logo

erfaniaa / compilers-course-project Goto Github PK

View Code? Open in Web Editor NEW
8.0 5.0 0.0 700 KB

Converting a pseudo-C source code to a pseudo-assembly code

License: GNU General Public License v3.0

Python 97.59% C 2.41%
compilers cpp python3 lalr-parser lark-parser grammar parser

compilers-course-project's Introduction

Compilers Course Project

Converting a pseudo C source code to a pseudo assembly code

For more information, read the PDF files which are located in this repository (they're in Persian language).

Dependencies

pip3 install -r requirements.txt

Usage

python3 run.py input_file_name.c

Sample input (pseudo C source code):

Check out sample.c in the repository (to see the language features).

python3 run.py sample.c

Sample output (pseudo assembly codes):

No syntax errors
line number 0: jmp 15 
line number 1: mov 0 #0 
line number 2: pop 10000 
line number 3: mov 4 #47 
line number 4: push 4 
line number 5: jmp 10000 
line number 6: push #0 
line number 7: jmp 10000 
line number 8: pop 4 
line number 9: pop 10000 
line number 10: add 4 #47 4 
...

Notes

  • This project was done by Ali Mirjahani and Erfan Alimohammadi in 2019 for the Shahid Beheshti University Compilers Course project.
  • You can modify the codes and produce your own programming language. There are not much hard-codes, so editing the language grammar would be easy. Grammar rules files have ".in" extension in the repository.
  • There are no switch-case statements in the scanner finite-state machine part. Just draw your DFA graph on a paper, and enter the graph nodes and edges in the scanner; it will work for you! So, modifying scanner DFA (adding and removing edges) doesn't take time from you.
  • This project uses a LL(1) parser (which is implemented by us) and a LALR parser (which is lark-parser, for parsing the boolean expressions). It switches between these two parsers, according to its state.

compilers-course-project's People

Contributors

erfaniaa avatar alimirjahani avatar

Stargazers

Arjun Menon avatar Friedhold Matz avatar shadow avatar Typical Engineer avatar Saman Khamesian avatar Sina Sheikholeslami avatar Roozbeh Sharifnasab avatar  avatar

Watchers

Friedhold Matz avatar  avatar Roozbeh Sharifnasab avatar  avatar  avatar

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.