Infix to Postfix (in2post) Exercise
COP-3402
Table of Contents
1. Overview
In this project you will create an infix-to-postfix translator using the ANTLR parsing framework for C++.
2. Project setup and usage
The project has three required files:
| File | Description |
|---|---|
| Arithmetic.g4 | The grammar file |
| in2post.cpp | The translator program |
| Makefile | The build script |
You only need these three files in your repo. Be sure that all three files are in the root of your git repository. Do not submit any compiled files, binaries, jar files, etc.
2.1. in2post.cpp
Hand-type by yourself the in2post.cpp program shown in the image below. Receiving a copy of the text of this program or copying in any other way besides personally typing it out yourself is unauthorized assistance. Note that the symbol endl is the word end followed by the letter l, as in "end line".
2.2. Setup
mkdir -p ~/cop3402fall25/in2post cd ~/cop3402fall25/in2post wget https://www.cs.ucf.edu/~gazzillo/teaching/cop3402fall25/files/Arithmetic.g4 wget https://www.cs.ucf.edu/~gazzillo/teaching/cop3402fall25/files/Makefile
2.3. Compiling
To build your project, run make
make
If you see the following warnings, you can ignore them:
g++ -I /usr/include/antlr4-runtime -c ArithmeticBaseListener.cpp
In file included from /usr/include/antlr4-runtime/atn/PredictionContext.h:10,
from /usr/include/antlr4-runtime/LexerInterpreter.h:9,
from /usr/include/antlr4-runtime/antlr4-runtime.h:32,
from ArithmeticBaseListener.h:7,
from ArithmeticBaseListener.cpp:5:
/usr/include/antlr4-runtime/atn/ATNState.h:73:26: warning: type attributes ignored after type is already defined [-Wattributes]
73 | class ANTLR4CPP_PUBLIC ATN;
2.4. Running
echo "1+2" | ./in2post
Here are several example runs of the translator:
$ echo "1+2" | ./in2post 12+ $ echo "1+2*3" | ./in2post 123*+ $ echo "1+2*3+4" | ./in2post 123*+4+
3. Submitting your project
3.1. git setup
Be sure to complete the vc exercise before attempting this project.
Create a new local repository, following the directions in the git exercise (including running git push --set-upstream submission master in the last step). Instead of using hello, set the local and remote repository URLs to be the following locations:
| Local repository | ~/cop3402fall25/in2post |
| Remote repository | gitolite3@eustis3.eecs.ucf.edu:cop3402/$USER/in2post |
3.2. Commands to setup your repo
These steps only setup the repo, do not submit your code, and assume you have already completed the vc exercise. Consult that exercise for specifics on validating each step and submitting your code.
mkdir -p ~/cop3402fall25/in2post cd ~/cop3402fall25/in2post git init echo "in2post project" > README.md git add README.md git commit README.md # Enter a commit message in the editor that pops up git remote add submission gitolite3@eustis3.eecs.ucf.edu:cop3402/$USER/in2post git push --set-upstream submission master
3.3. Adding, commit, and pushing your project files
See the hello project for instructions on using git to submit your project.
3.4. Self-check
See the hello project for instructions on cloning a project from the grading server.
4. Grading schema
| Criterion | Points |
|---|---|
| The git repo exists | 1 |
| The repo contains the three required files | 1 |
| The program builds | 1 |
| The program runs correctly | 1 |
| TOTAL | 4 |