ChocoPy Compiler By Bill Sun
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
sunyinqi0508 24eda2a724
Merge pull request #4 from ldXiao/pa3grade
3 years ago
pa1-tests disclose hiden tests 3 years ago
pa2-tests pa2grade 3 years ago
pa3-tests test kit 3 years ago
src cleanup 3 years ago
web Classes/Objects/Methods 3 years ago
.gitignore Added more default functions 3 years ago
LICENSE Initial commit 3 years ago
README.md Initial commit 3 years ago
WORKLOG.md Update WORKLOG.md 3 years ago
build.sh added test scripts 3 years ago
chocopy-ref.jar Initial commit 3 years ago
full_test.sh Merged in pa2 and updated test scripts 3 years ago
generate_assembly_r.sh added test scripts 3 years ago
generate_assembly_s.sh added test scripts 3 years ago
grade.md fin 3 years ago
pom.xml Initial commit 3 years ago
run_r.sh added test scripts 3 years ago
run_s.sh added test scripts 3 years ago
test_benchmarks.sh Merged in pa2 and updated test scripts 3 years ago
test_gen.sh Final bug fixes. 3 years ago
test_py_file.sh Added student test cases 3 years ago
test_sample.sh Merged in pa2 and updated test scripts 3 years ago
test_student_contributed.sh Added test scripts 3 years ago

README.md

NYU Compiler Construction CSCI-GA.2130/Spring 2021: Programming Assignment 3

This assignment is adapted from https://github.com/cs164berkeley/pa3-chocopy-code-generation with the authors' permission.

See the PA3 document on Piazza for a detailed specification.

Quickstart

Run the following commands to compile your code generator and run the tests:

mvn clean package
java -cp "chocopy-ref.jar:target/assignment.jar" chocopy.ChocoPy \
  --pass=..s --test --run --dir src/test/data/pa3/sample/

The dots in --pass make the compiler skip parsing and semantic analysis and go straight to code generation. --pass=..s uses your (s for student) generator to generate code from an annotated AST (the .ast.typed files under src/test/data/pa3/sample/). With the starter code, only one test should pass. Your main objective is to build a code generator that passes all the provided tests.

--pass=..r uses the reference (r for reference) generator, which should pass all tests.

In addition to running in test mode with --test, you can also observe the actual output of your (or reference) generator with:

java -cp "chocopy-ref.jar:target/assignment.jar" chocopy.ChocoPy \
  --pass=..s src/test/data/pa3/sample/op_add.py.ast.typed

You can also run all passes on the original .py file:

java -cp "chocopy-ref.jar:target/assignment.jar" chocopy.ChocoPy \
  --pass=rrr src/test/data/pa3/sample/op_add.py

Once you merge your semantic analysis code from assignment 2, you should be able to use --pass=sss.

Generating vs Running

The above should be familiar from previous assignments. A new aspect of PA3 is the distinction between generating and running the code.

The following outputs the generated RISC-V assembly (with the usual option to save to a file with --out):

java -cp "chocopy-ref.jar:target/assignment.jar" chocopy.ChocoPy \
  --pass=rrr src/test/data/pa3/sample/op_add.py

The following (note the --run option) generates the assembly and then runs it on the bundled RISC-V emulator:

java -cp "chocopy-ref.jar:target/assignment.jar" chocopy.ChocoPy \
  --pass=rrr --run src/test/data/pa3/sample/op_add.py