Giter Site home page Giter Site logo

anycc's Introduction

AnyCC Compiler Project Readme

The AnyCC Compiler is a project aimed at creating a compiler for a custom programming language. The compiler consists of various components, including a Lex, Parser, and Symbol Table. This README provides an overview of the entire project, including how to build and use the compiler.

Authors

Documentation

Project Structure

The project is organized into the following main components

  • The Lex Component is a component responsible for scanning the source code and generating tokens.

  • The Parser Component is a component responsible for parsing the tokens and building the syntax tree.

  • The Symbol Table Component is a component responsible for managing information about tokens encountered during lexical analysis.

  • Tests Using Google Test

    • Unit Tests for public methods if it is not a simple getter/setter and not complex.
    • Integration Tests for public methods when needed.

Notes

  • The project is not fully tested, but I tried to test as much as I can.
  • Analyzer sometimes shifts the column number, but it is not a big problem and doesn't show up in important places.

Building and Running

Prerequisites

Ensure you have the necessary dependencies installed on your system

  • C++ compiler (supporting C++17)
  • CMake

Build Steps

  1. Clone the repository

    git clone <repository_url>
    cd anycc
  2. Create a build directory and navigate into it

    mkdir build
    cd build
  3. Generate build files with CMake

    • On Linux
      cmake -G "Unix Makefiles" ..
    • On Windows
      cmake -G "MinGW Makefiles" ..
      or
      cmake -G "Visual Studio 17 2022" ..
  4. Build the project

    cmake --build .

Running the Compiler

The AnyCC Compiler takes three command-line arguments: <rules_file_name>, <cfg_file_name>, and <program_file_name>. These arguments specify the files containing lexical rules, context-free grammar rules, and the program to be compiled, respectively.

anycc <rules_file_name> <cfg_file_name> <program_file_name>

Output

Upon successful execution, the compiler will generate an output folder containing various artifacts which includes

  • Symbol Table in .md format.
  • NFA Graph in .dot, csv, and md formats.
  • DFA Graph in .dot, csv, and md formats.
  • Minimized DFA Graph in .dot, csv, and md formats.
  • tokens.txt file containing the tokens generated by the lexer if getAllTokensAndCreateOutputFile() is called.
  • First and Follow sets in .md format.
  • LL(1) Parsing Table in .md format.
  • Left most derivation in .md format.
  • Predictive Parsing Table in .md format.

Example

Here is an example of how to use the AnyCC Compiler

anycc ../input/rules.txt ../input/CFG.txt ../input/program.txt

This example assumes that lex_rules.txt contains lexical rules, cfg_rules.txt contains context-free grammar rules, and source_code.txt contains the program source code.

Enjoy using the AnyCC Compiler!

anycc's People

Contributors

abdelrahmanmosly avatar ahmedelsa3eed avatar bazina avatar muhammadkotb avatar

Stargazers

 avatar  avatar  avatar

anycc's Issues

Repackaging

Symbol Table class needs to be moved from the Lex folder to another general folder as it is used in both lex and parser.

Start Symbol

We should assume that the first non-terminal in the grammar is the start symbol is better than setting it as hard coded constant.

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.