Giter Club home page Giter Club logo

while-compiler's Introduction

Compiler Project

This project encompasses various phases of a compiler, each residing in its respective directory.

Project Contributors

Presented by:

A big thank you to these amazing contributors for their dedication and hard work! ๐Ÿš€โœจ

Directory Structure

01Lexical/

Contains the implementation of the lexical analysis phase of the compiler.

  • File: lexical.cpp
    • Reads the input.c file and generates tokens.
    • Tokens are written to output.txt.
    • Performs bracket matching using the chck_brakects function.

02SyntaxTree/

Houses the syntax tree generation phase of the compiler.

  • Files:
    • SyntaxPhase.cpp: Parses While.c and generates a syntax tree.
    • SyntaxPhase.hpp: Contains functions for parsing different code structures.

03LRParser/

Encompasses the LR parsing phase of the compiler.

  • File: shiftreduce.cpp
    • Reads input.c and rules.txt.
    • Performs shift-reduce parsing and writes the output to Output.txt.
    • Utilizes a set of production rules defined in rules.txt.

How to Run

To execute specific phases of the compiler:

  • Navigate to the relevant directory (e.g., 01Lexical/, 02SyntaxTree/, or 03LRParser/).
  • Compile and run the corresponding source file (e.g., lexical.cpp, SyntaxPhase.cpp, or shiftreduce.cpp).

For example:

cd Compiler/01Lexical/
g++ lexical.cpp -o lexicalAnalyzer
./lexicalAnalyzer

Dependencies

  • C++ compiler for compiling the source files.
  • Input files such as input.c, While.c, and rules.txt as required by specific phases.

Additional Notes

  • The lexical analysis phase checks for balanced brackets using the chck_brakects function.
  • The LR parsing phase utilizes a set of production rules defined in rules.txt.

Feel free to explore each directory for detailed implementation and outputs. For any questions or issues, refer to the specific README within each directory.

Happy compiling!

while-compiler's People

Contributors

omarahmed-a avatar

Watchers

 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.