-
Notifications
You must be signed in to change notification settings - Fork 0
Directions
GCC/G++ and make are required to run this program. They should be installed already on most Linux Distributions. If they are not:
sudo apt install make gcc
Flex and Bison are the main programs that generate the Lexical Analyzer and the Bottom Up Parser. To install these on Linux run:
sudo apt install flex bison
Then download the project files from GitHub in the terminal by running:
git clone https://github.com/iagrant/CS460TEAM
Once all of the files have downloaded, cd into the folder called src that you cloned the files into and run:
make
This will build all of the files that are needed to run the compiler.
After the make command has been run, the binary is called fcc.
-
-i <inputfile>(Required) [This option specifies the input file that will be compiled.] -
-o <outputfile>(Optional) [This option specifies a file that the debug output will be placed in. If none is specified, then the compiler defaults to output.txt] -
-d[This option runs all of the debug options that are included with the compiler.] -
-dl[This option outputs all of the tokens that Flex finds in the source code to the terminal.] -
-dp[This option outputs all of the productions that Yacc uses when it is parsing the source code to the terminal.] -
-ds[This option outputs all of the contents of the Symbol Table to the terminal.] -
-dg[This option outputs all of the code to make a Graphviz representation of the AST.]
After the compiler has been run:
cd outputspimload "output.s"load "print.asm"run
These options allow certain places in the source code to have debugging options enabled and then disabled later in the code. They work by putting the flag on a line of source code to turn on that option and then placing another flag on a different line of source code to turn off the options.
-
!!dl[This option outputs all of the tokens that Flex finds in the source code to the terminal.] -
!!dp[This option outputs all of the productions that Yacc uses when it is parsing the source code to the terminal.] -
!!ds[This option outputs all of the contents of the Symbol Table to the terminal.]
This example has an input file called foo.c and an output file called fooOuput.txt
./fcc -i foo.c -o fooOuput.txt
This example has an input file called bar.c and prints out all of the tokens that are matched.
./fcc -i bar.c -dl
This example has an input file called foo.c and prints out all productions and the contents of the symbol table.
./fcc -i foo.c -dp -ds
This example shows how to use GraphViz output option
./fcc -i foo.c -dg
In order to view the graph representation for the AST run:
make graph
This command will output a file named ASTnode.png. Open this file to view the graph representation.