UP | HOME

Calc Project
COP-3402

Overview

In this project you will hand-copy a simple calculator program written using the ANTLR parser generator. As with all programming projects, it will be submitted via git.

Setup the repo

  1. ssh into eustis, replacing NID with your UCF NID.

    ssh NID@eustis.eecs.ucf.edu
    
  2. Clone the calc project starter repo

    git clone https://www.cs.ucf.edu/~gazzillo/teaching/cop3402fall24/repos/calc.git/
    
  3. Enter the repo

    cd calc/
    
  4. Add the URL of your personal remote repository, replacing NID with your UCF NID.

    git remote add submission gitolite3@eustis3.eecs.ucf.edu:cop3402/NID/calc
    
  5. Synchronize your local repo with the remote eustis3 repo.

    git push --set-upstream submission master
    

    You only need to do this once. Use git commit and git push regularly to keep the remote repo up to date.

Implementation

Inside your repo, create and hand-type by yourself in either emacs or vim the following files. The relative path of the file in your repo and an image of the text of the file are given. Be sure to commit and push your new files.

grammar/Arithmetic.g4

Arithmetic.g4.png

calc/Calc.py

Calc.py.png

Building and testing

  1. Install the pipenv tool, which will use to setup our python development environment. This only ever needs to be done once on eustis.

    pip3 install --user pipenv
    

    If you receive a warning about a managed python installation, then double-check that you are on eustis.

  2. Then create the development environment. This creates an "editable" installation of your project, so that you can modify its source and rerun without having to reinstall the project.

    pipenv install -e ./
    

    If you can't run pipenv, trying logging out and back in again to eustis.

  3. Enter your pipenv development environment. Do this everytime you log in to eustis to work on your project.

    pipenv shell
    

    Double-check that you are in the environment. Your prompt should look something like this:

    (calc) NID@net1547:~/calc$
    
  1. Get ANTLR and build the parser.

    make -C grammar/
    
  2. Test your implementation by running the calculator.

    python3 calc/Calc.py << EOT
    a := 2
    x := a + 2
    y := 3
    z := x % y
    EOT
    
  3. Exit the pipenv environment.

    Double-check that you are in the environment. Your prompt should look something like this:

    (calc) NID@net1547:~/calc$
    

    Leave the environment with exit:

    exit
    

Submitting your project

Stage, commit, and push to the grading server

Once you have set up the repo, all you need to do is use git add, git commit, and git push to stage, commit, and sync your repo to the grading git server.

Be sure to only submit the files necessary for the project, i.e., calc/Calc.py and grammar/Arithmetic.g4. Use a .gitignore file if you like to make it easier to validate this.

Self-check

You can check that you've submitted correctly by cloning, building, and testing your repo.

cd ~
git clone gitolite3@eustis3.eecs.ucf.edu:cop3402/NID/calc calc_new
cd calc_new
pipenv install -e ./
pipenv shell
make -C grammar/
python3 calc/Calc.py << EOT
a := 2
x := a + 2
y := 3
z := x % y
EOT

What should be the correct output, i.e., assignments of the variables, for these arithmetic operations?

(Only if instructed) Updating from the start repo

If the original repo gets updated after you have already started implementing your project, you can get those updates by pulling. Otherwise, you will never need to do this step. Be sure to commit any changes you have made before proceeding.

git pull origin master --rebase
git push -f

If you encounter a conflict, it may be that you modified some files from the original repo that didn't need to be modified. Come to office hours if you need help resolving the conflict.

Troubleshooting

  • If you make a mistake in typing the URL, you can remove the submission remote and try the add step again:

    git remote rm submission
    git remote add submission gitolite3@eustis3.eecs.ucf.edu:cop3402/NID/calc  # replace NID with yours
    
  • Do not try creating a new repo if you make a mistake. You will not be able to push the new repo to gitolite3, since there already is one there. You can always make new changes and commit them to fix mistakes.
  • If in self-check calc_new already exists, just use a fresh directory name.
  • If you add a file that you do not want in the repo, e.g., the calc program binary, then you can remove it with

    git rm calc
    git commit
    # enter the commit message
    git push # to record the change in the remote grading repo
    
  • The program must be run inside of the pipenv environment. You can see that you have successfully entered the environment because your prompt is prefixed with (calc), e.g.,

    (calc) NID@net1547:~/calc$
    

    You can exit the environment with exit.

Grading schema

Criterion Points
The git repo exists 1
The repo contains only the required files 1
grammar/Arithmetic.g4 is hand-typed correctly 1
calc/Calc.py is hand-typed correctly 1
The calculator runs the given example correctly 1
The calculator runs new example inputs correctly 1
TOTAL 6

Author: Paul Gazzillo

Created: 2024-10-23 Wed 23:33

Validate