/compilers.cpp

Playing with JFlex, Cup, Java, and C++

Primary LanguageJavaMIT LicenseMIT

C++ Compiler Project

This is just a project to exercise the concepts and theory of compilers. As you might guess, this is a C++ compiler and it will be built using JFlex and Cup. Because we don't have access to the official C++ Standard, we decided to follow this specifiation.

Tools

JFlex 1.5###

JFlex is a scanner generator. JFlex reads a lexical specification and outputs java sources for the generated scanner. If you don't have experience with JFlex, access the official website and try it! See the README file for more information and examples.

CUP 11a

CUP is a LALR (lookahead-LR method) parser generator. CUP reads a syntacitc specification and outputs the java sources for the generated parser. If you dont't have experience with CUP, access the manual for more information.

Building the Project

  • First, make sure you have Ant installed in your computer.
  • By this moment, you just need to run ant on the project's root directory.

Extending the Grammar

The Lexical and Syntax Analyzers must be extended together. It is extremely important to follow these guidelines:

  • After modifying lexical.flex and/or parser.cup, run ant compile.
  • Resolve Warnings before pushing (or create a remote branch for fixing and open an issue in the repository).
  • Implement grammar rules one by one.
  • Add NOT IMPLEMENTED on rules not implemented.