Project: Implementation of Program and Statement Kernels
Objectives
- Familiarity with writing a kernel class for a new type and its
kernel operations (
ProgramusingMapandStatement). - Familiarity with writing a kernel class for a new type and its
kernel operations (
StatementusingTree). - Familiarity with alternative ways of testing software components.
The Problem
The problem is to complete and carefully test implementations of the
constructor and kernel methods defined in interfaces ProgramKernel and
StatementKernel. These are the core components in the BL compiler.
Setup
Only one member of the team should follow the steps to set up an Eclipse project for this assignment. The project should then be shared with the rest of the team by using the Subversion version control system as learned in the Version Control With Subversion lab.
To get started, import the project for this assignment,
ProgramAndStatement, from the ProgramAndStatement.zip file available
at this link. If you don't remember how to do
this, see these Setup
instructions
from an earlier project.
Method
-
Start by implementing
ProgramKernel. Carefully review theProgram2.javaskeleton in thesrcfolder. Pay particular attention to the representation (the private instance variables), the convention, and the correspondence. AStringis used to represent the program name, aMap<String, Statement>is used to represent the program context, and aStatementis used to represent the program body. Complete the bodies of the private methodcreateNewRepand the kernel methods (setName,name,newContext,swapContext,newBody, andswapBody). IncreateNewRep, make sure you useStatement1from the component library and notStatement2from this project (otherwise nothing will work until you have a complete and correct implementation ofStatement2). -
Testing of
ProgramKernelis kind of tricky because of the challenge of constructingProgramvalues to test the component. We provide two different testing set-ups. Note that the example test inputs/cases provided are just for illustration purposes and are not meant as a complete test fixture. It is up to you to design appropriate additional inputs and test cases to thoroughly test your implementation.- In the
srcfolder, carefully review the test program forProgram2calledProgramTesterand make sure you understand what it does. Design appropriate BL programs meant to exercise your implementation, save them in thedatafolder and use them as input to the test program. - In the
testfolder, carefully review the provided JUnit test fixtureProgramTest(andProgram2Test). Remember that the provided test input (in thedatafolder) and test cases are just meant to be examples of how to set up a JUnit test fixture for theProgram2component. Add appropriate additional inputs (in thedatafolder) and test cases to thoroughly test your kernel implementation.
Once you are confident that your implementation of
Program2is correct, you can move on to the next part of this project. - In the
-
The next step is to implement
StatementKernel. Carefully review theStatement2.javaskeleton in thesrcfolder. Pay particular attention to the representation (the private instance variable), the convention, and the correspondence. The statement is represented by aTree<StatementLabel>whereStatementLabelis a nested class obviously representing a statement label. Note the three constructors provided in the nested class. Complete the bodies of the private methodcreateNewRepand the kernel methods (kind,addToBlock,removeFromBlock,lengthOfBlock,assembleIfElse,disassembleIfElse,assembleWhile,disassembleWhile,assembleCall, anddisassembleCall). Code for the kernel methodsassembleIfanddisassembleIfis provided as a guide. Make sure you understand each line of code in these methods before you attempt to complete the others. -
Testing
StatementKernelpresents challenges similar to testingProgramKerneland the set-up is similar too. Again, it is up to you to design appropriate additional inputs and test cases to thoroughly test your implementation.- In the
srcfolder, carefully review the test program forStatement2calledStatementTesterand make sure you understand what it does. It is similar to theProgramTesterprogram but reads a sequence of BL statements instead of a complete BL program. Design appropriate BL statements meant to exercise your implementation, save them in thedatafolder and use them as input to the test program. - In the
testfolder, carefully review the provided JUnit test fixtureStatementTest(andStatement2Test). Remember that the provided test input (in thedatafolder) and test cases are just meant to be examples of how to set up a JUnit test fixture for theStatement2component. Add appropriate additional inputs (in thedatafolder) and test cases to thoroughly test your kernel implementation.
Once you are confident that your implementation of
Statement2is correct, you are done with the project. - In the
-
When you and your teammate(s) are done with the project, decide who is going to submit your solution. That team member should select the Eclipse project
ProgramAndStatement(not just some of the files, but the whole project) containing the complete group submission, create a zip archive of it, and submit the zip archive to the Carmen dropbox for this project, as described in Submitting a Project. Note that you will only be allowed one submission per group, that is, your group can submit as many times as you want, but only the last submission will be on Carmen and will be graded. Under no circumstance will teammates be allowed to submit separate solutions. Make sure that you and your partner agree on what should be submitted.