Code Monkey home page Code Monkey logo

cool-compiler's Introduction

Cool compiler

An implementation of the "Classroom Object-Oriented Language" compiler for Compilers course in Shoubra Faculty of Engineering.
The files in this directory can get pretty messy, so here is a basic tour:

Cool Lexer

This directory contains the classes and code for Lexical Analyzer phase.

Cool Parser

This directory contains the classes and code for Parese Tree phase.

Requirements

  1. Install intelliJ IDEA.
  2. Install ANTLRv4. Please follow the quickstart guide here, or you can simply install ANTLR from IDEA's plugin manager.
  3. Import antlr runtime jar.
  4. To connect intellij with ANTRL see this video.
  5. Use your terminal to run the program.

Phase 1 : Lexer analyzer

  • First, create the Token file which contains all the tokens we want to compile and its possible values.
  • Press right click and click generate Antlr Recognizer.
  • Second, Create controller.java that will test the cool input using tokens and generated files
  • Pass the test cases files named (good.cl or bad.cl) as an argument to main.
  • If there are no errors, the program will output a sequence of tokens in a file called good.cl-lex, otherwise it will report errors with their line numbers.

Phase 2 : Parse Tree

  • First, create the Token file which contains all the tokens we want to compile and its possible values.
  • Create the grammer file and import the token file in it and put all the cool relues
  • Press right click and click generate Antlr Recognizer.
  • Create the ParseErrorListener class in which you can listen for sentax error
  • Create controller.java that will test the cool input using tokens and generated files
  • Pass the test cases files named (good.cl or bad.cl) as an argument to main.
  • If there are no errors, the program will output a sequence of tokens in a file called good.cl-lex and will write the parse tree in the good-cst file
  • Otherwise it will report errors with their line numbers .

cool-compiler's People

Contributors

mhmedwagih1324 avatar omarkhaledabdlhafez avatar ismail-mahmoud avatar raafatabualazm 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.