This project is a compiler for the Flux Control Language, defined on the file fcl.pdf.
FCL compiler uses ANTLR4 to generate a top-down using the Visitor design pattern.
Ubuntu has ANTLR4 in its default repositories. To install it, just run:
sudo apt-get install antlr4
Make sure to install the version 4.5.1 of the library. Otherwise you must download and replace the lib/antlr-4.5.1-complete.jar file yourself, as this project has not been developed with Maven or Gradle. If you want to convert this project into a Maven project, you are welcome to make a pull request!
Obs: you are only required to generate the parser if the file FCL.g4 has been modified. This repository already includes the parser for the current grammar of the language.
By default ANTLR4 generates a parser using a Listener design pattern. In this project we opted for using a Visitor design pattern, as it is considerably easier to visualize. For ANTLR4 to generate the parser using the Visitor design pattern, just run it as it follows:
antlr4 -no-listener -visitor -o src/com/fcl/compiler/antlr4/ grammar/FCL.g4
The following files should be generated in the directory src/com/fcl/compiler/antlr4:
FCLBaseListener.java
FCLBaseVisitor.java
FCLLexer.java
FCLParser.java
FCLVisitor.java
FCL.tokens
FCLLexer.tokens
In which FCLVisitor.java is the interface to be implemented in the file src/com/fcl/compiler/FCLVisitorImpl.java
The files generated by ANTLR4 do not include the package to which they belong. We must prepend the package declaration ourselves:
package com.fcl.compiler.antlr4;
That being done, just open the Eclipse project and compile it.