CS451/651 Project 3 (Parsing) Swami Iyer
Ob jectives.
1. Support long and double basic types.
2. Support operators.
3. Support conditional expression and switch statement. 4. Support do-while and for statements.
5. Support exception handlers.
6. Support interface type declaration.
In this project, you will only be supporting the parsing of the above programming constructs and their representations in the abstract syntax tree (AST). To compile (just parse for now) your j– programs, you need to run the j– command as follows:
$ $j/j–/bin/j– -p P.java
which will only parse P.java and print the AST for the program in XML format. Note.
- Consult Appendix C of our text for the grammar (ie, formal specification) for each new construct you will be supporting in j–.
- The AST shown (as XML) for each problem is only a suggestion as to what the AST ought to look like once the syntactic constructs for that problem are implemented in j–. You are not expected to produce exactly the same AST, but just something similar. The autograder will not match your AST against ours for correctness, but instead will test if your parser parses our pass tests without errors and our fail tests with suitable error messages.
Problem 1. (Long and Double Basic Types) Add support for the long and double basic types.
$ $j/j–/bin/j– -p tests/BasicTypes.java <?xml version=”1.0″ encoding=”utf-8″?> |
<JCompilationUnit line=”1″> |
<Imports > |
<Import name=”java.lang.Long”/> <Import name=”java.lang.System”/> |
</Imports> <TypeDeclarations > |
<JClassDeclaration line=”5″ name=”BasicTypes” super=”java.lang.Object”> <Modifiers > |
<Modifier name=”public”/> </Modifiers > |
<ClassBlock > |
<Modifiers > |
<Modifier name=”static”/> </Modifiers > |
<FormalParameters > |
</FormalParameters > <Body> |
<JBlock line=”6″> <JVariableDeclaration > |
<Modifiers > </Modifiers > |
<VariableDeclarators > |
<Initializer > |
1 of 15
CS451/651 Project 3 (Parsing) Swami Iyer
<Arguments > |
<Argument > <JArrayExpression > |
<TheArray > |
</TheArray> <IndexExpression > |
<JLiteralInt line=”7″ type=”” value=”0″/> </IndexExpression > |
</JArrayExpression > </Argument> |
</Arguments > </JMessageExpression > |
</Initializer > </JVariableDeclarator > |
</VariableDeclarators > </JVariableDeclaration > |
<JVariableDeclaration > <Modifiers > |
</Modifiers > <VariableDeclarators > |
<JVariableDeclarator line=”8″ name=”b” type=”long”> <Initializer > |
<JMessageExpression line=”8″ name=”parseLong”> <Arguments > |
<Argument > <JArrayExpression > |
<TheArray > |
</TheArray> <IndexExpression > |
<JLiteralInt line=”8″ type=”” value=”1″/> </IndexExpression > |
</JArrayExpression > </Argument> |
</Arguments > </JMessageExpression > |
</Initializer > </JVariableDeclarator > |
</VariableDeclarators > </JVariableDeclaration > |
<JStatementExpression line=”9″> <JMessageExpression line=”9″ name=”println”> |
<Arguments > <Argument > |
<JBinaryExpression line=”9″ type=”” operator=”*”> <Lhs> |
<JBinaryExpression line=”9″ type=”” operator=”*”> <Lhs> |
<JLiteralDouble line=”9″ type=”” value=”3.14159D”/> </Lhs> |
<Rhs> |
</Rhs> </JBinaryExpression > |
</Lhs> <Rhs> |
<JVariable name=”a”/> </Rhs> |
</JBinaryExpression > |
</Argument> </Arguments > |
</JMessageExpression > </JStatementExpression > |
<JStatementExpression line=”10″> <JMessageExpression line=”10″ name=”println”> |
<Arguments > <Argument > |
2 of 15
CS451/651 Project 3 (Parsing) Swami Iyer
<JBinaryExpression line=”10″ type=”” operator=”*”> |
<Lhs> |
</Lhs> <Rhs> |
<JBinaryExpression line=”10″ type=”” operator=”+”> <Lhs> |
<JVariable name=”b”/> </Lhs> |
<Rhs> |
</Rhs> </JBinaryExpression > |
</Rhs> </JBinaryExpression > |
</Argument> </Arguments > |
</JMessageExpression > </JStatementExpression > |
</JBlock> </Body> |
</JMethodDeclaration > </ClassBlock > |
</JClassDeclaration > </TypeDeclarations > |
</JCompilationUnit > |
Problem 2. (Operators) Add support for the following operators, obeying precedence rules (see Appendix C).
~ != / /= -= |
++ — *= % %= >> >>= >>> >>>= >= |
<< <<= < ^ ^= | |= || & &= |
$ $j/j–/bin/j– -p tests/Operators.java <?xml version=”1.0″ encoding=”utf-8″?> |
<JCompilationUnit line=”1″> |
<Imports > |
</Imports> <TypeDeclarations > |
<JClassDeclaration line=”3″ name=”Operators” super=”java.lang.Object”> <Modifiers > |
<Modifier name=”public”/> </Modifiers > |
<ClassBlock > |
<Modifiers > |
<Modifier name=”static”/> </Modifiers > |
<FormalParameters > |
</FormalParameters > <Body> |
<JBlock line=”4″> <JStatementExpression line=”5″> |
<JMessageExpression line=”5″ name=”println”> <Arguments > |
<Argument > |
<Lhs> |
<Lhs> |
3 of 15
CS451/651 Project 3 (Parsing) Swami Iyer
<Operand > |
<JLiteralTrue line=”5″ type=””/> </Operand> |
</JUnaryExpression > </Lhs> |
<Rhs> |
</Rhs> </JBinaryExpression > |
</Lhs> <Rhs> |
<JLiteralFalse line=”5″ type=””/> </Rhs> |
</JBinaryExpression > </Argument> |
</Arguments > </JMessageExpression > |
</JStatementExpression > <JStatementExpression line=”6″> |
<JMessageExpression line=”6″ name=”println”> <Arguments > |
<Argument > |
<Lhs> |
</Lhs> <Rhs> |
<JLiteralFalse line=”6″ type=””/> </Rhs> |
</JBinaryExpression > </Argument> |
</Arguments > </JMessageExpression > |
</JStatementExpression > <JVariableDeclaration > |
<Modifiers > </Modifiers > |
<VariableDeclarators > |
<Initializer > |
</Initializer > </JVariableDeclarator > |
</VariableDeclarators > </JVariableDeclaration > |
<JStatementExpression line=”8″> |
<Lhs> |
</Lhs> <Rhs> |
<JLiteralInt line=”8″ type=”” value=”2″/> </Rhs> |
</JBinaryExpression > </JStatementExpression > |
<JStatementExpression line=”9″> |
<Lhs> |
</Lhs> |
<Rhs> |
</Rhs> </JBinaryExpression > |
</JStatementExpression > <JStatementExpression line=”10″> |
<JBinaryExpression line=”10″ type=”” operator=”/=”> <Lhs> |
4 of 15
CS451/651 Project 3 (Parsing) Swami Iyer
<JVariable name=”x”/> |
</Lhs> <Rhs> |
<JLiteralInt line=”10″ type=”” value=”10″/> </Rhs> |
</JBinaryExpression > </JStatementExpression > |
<JStatementExpression line=”11″> |
<Lhs> |
</Lhs> <Rhs> |
<JLiteralInt line=”11″ type=”” value=”3″/> </Rhs> |
</JBinaryExpression > </JStatementExpression > |
<JStatementExpression line=”12″> <JMessageExpression line=”12″ name=”println”> |
<Arguments > <Argument > |
<JUnaryExpression line=”12″ type=”” operator=”post++”> <Operand > |
<JVariable name=”x”/> </Operand> |
</JUnaryExpression > </Argument> |
</Arguments > </JMessageExpression > |
</JStatementExpression > <JStatementExpression line=”13″> |
<JMessageExpression line=”13″ name=”println”> <Arguments > |
<Argument > |
<Operand > |
</Operand> </JUnaryExpression > |
</Argument> </Arguments > |
</JMessageExpression > </JStatementExpression > |
<JStatementExpression line=”14″> |
<Lhs> |
</Lhs> <Rhs> |
<JLiteralInt line=”14″ type=”” value=”1″/> </Rhs> |
</JBinaryExpression > </JStatementExpression > |
<JStatementExpression line=”15″> |
<Lhs> |
</Lhs> <Rhs> |
<JLiteralInt line=”15″ type=”” value=”2″/> |
</Rhs> </JBinaryExpression > |
</JStatementExpression > <JStatementExpression line=”16″> |
<JBinaryExpression line=”16″ type=”” operator=”<<=”> <Lhs> |
<JVariable name=”x”/> </Lhs> |
5 of 15
CS451/651 Project 3 (Parsing) Swami Iyer
<Rhs> |
<JLiteralInt line=”16″ type=”” value=”3″/> </Rhs> |
</JBinaryExpression > </JStatementExpression > |
<JStatementExpression line=”17″> |
<Lhs> |
</Lhs> <Rhs> |
<JLiteralInt line=”17″ type=”” value=”2″/> </Rhs> |
</JBinaryExpression > </JStatementExpression > |
<JStatementExpression line=”18″> |
<Lhs> |
</Lhs> <Rhs> |
<JLiteralInt line=”18″ type=”” value=”4″/> </Rhs> |
</JBinaryExpression > </JStatementExpression > |
<JStatementExpression line=”19″> |
<Lhs> |
</Lhs> <Rhs> |
<JLiteralInt line=”19″ type=”” value=”8″/> </Rhs> |
</JBinaryExpression > </JStatementExpression > |
<JStatementExpression line=”20″> <JMessageExpression line=”20″ name=”println”> |
<Arguments > <Argument > |
<JBinaryExpression line=”20″ type=”” operator=”<”> <Lhs> |
<JVariable name=”x”/> </Lhs> |
<Rhs> |
</Rhs> </JBinaryExpression > |
</Argument> </Arguments > |
</JMessageExpression > </JStatementExpression > |
<JStatementExpression line=”21″> <JMessageExpression line=”21″ name=”println”> |
<Arguments > <Argument > |
<JBinaryExpression line=”21″ type=”” operator=”>=”> <Lhs> |
<JVariable name=”x”/> </Lhs> |
<Rhs> |
<JLiteralInt line=”21″ type=”” value=”50″/> </Rhs> |
</JBinaryExpression > </Argument> |
</Arguments > </JMessageExpression > |
</JStatementExpression > </JBlock> |
6 of 15
CS451/651 Project 3 (Parsing) Swami Iyer
</Body> |
</JMethodDeclaration > </ClassBlock > |
</JClassDeclaration > </TypeDeclarations > |
</JCompilationUnit > |
Problem 3. (Conditional Expression) Add support for conditional expression (e1 ? e2 : e3).
$ $j/j–bin/j– -p tests/ConditionalExpression.java |
<?xml version=”1.0″ encoding=”utf-8″?> <JCompilationUnit line=”1″> |
<Source fileName=”tests/ConditionalExpression.java”/> <Imports > |
<Import name=”java.lang.Integer”/> <Import name=”java.lang.System”/> |
</Imports> <TypeDeclarations > |
<JClassDeclaration line=”4″ name=”ConditionalExpression” super=”java.lang.Object”> |
<Modifiers > |
</Modifiers > <ClassBlock > |
<JMethodDeclaration line=”5″ name=”main” returnType=”void”> <Modifiers > |
<Modifier name=”public”/> <Modifier name=”static”/> |
</Modifiers > <FormalParameters > |
<JFormalParameter line=”5″ name=”args” type=”String[]”/> </FormalParameters > |
<Body> |
<JVariableDeclaration > <Modifiers > |
</Modifiers > <VariableDeclarators > |
<JVariableDeclarator line=”6″ name=”x” type=”int”> <Initializer > |
<JMessageExpression line=”6″ name=”parseInt”> <Arguments > |
<Argument > <JArrayExpression > |
<TheArray > |
</TheArray> <IndexExpression > |
<JLiteralInt line=”6″ type=”” value=”0″/> </IndexExpression > |
</JArrayExpression > </Argument> |
</Arguments > </JMessageExpression > |
</Initializer > </JVariableDeclarator > |
</VariableDeclarators > </JVariableDeclaration > |
<JStatementExpression line=”7″> <JMessageExpression line=”7″ name=”println”> |
<Arguments > <Argument > |
<JConditionalExpression line=”7″ type=”” operator=”?”> <TestExpression > |
<JBinaryExpression line=”7″ type=”” operator=”==”> <Lhs> |
<JBinaryExpression line=”7″ type=”” operator=”%”> <Lhs> |
7 of 15
CS451/651 Project 3 (Parsing) Swami Iyer
<JVariable name=”x”/> |
</Lhs> <Rhs> |
<JLiteralInt line=”7″ type=”” value=”2″/> </Rhs> |
</JBinaryExpression > </Lhs> |
<Rhs> |
</Rhs> </JBinaryExpression > |
</TestExpression > <TrueClause > |
<JLiteralString line=”7″ type=”” value=”"even"”/> </TrueClause > |
<FalseClause > |
</FalseClause > </JConditionalExpression > |
</Argument> </Arguments > |
</JMessageExpression > </JStatementExpression > |
</JBlock> </Body> |
</JMethodDeclaration > </ClassBlock > |
</JClassDeclaration > </TypeDeclarations > |
</JCompilationUnit > |
Problem 4. (Switch Statement) Add support for a switch statement.
$ $j/j–/bin/j– -p tests/SwitchStatement.java <?xml version=”1.0″ encoding=”utf-8″?> |
<JCompilationUnit line=”1″> |
<Imports > |
<Import name=”java.lang.System”/> </Imports> |
<TypeDeclarations > |
<Modifiers > |
</Modifiers > <ClassBlock > |
<JMethodDeclaration line=”5″ name=”main” returnType=”void”> <Modifiers > |
<Modifier name=”public”/> <Modifier name=”static”/> |
</Modifiers > <FormalParameters > |
<JFormalParameter line=”5″ name=”args” type=”String[]”/> </FormalParameters > |
<Body> |
<JSwitchStatement line=”6″> <TestExpression > |
<JMessageExpression line=”6″ name=”parseInt”> <Arguments > |
<Argument > <JArrayExpression > |
<TheArray > |
</TheArray> <IndexExpression > |
8 of 15
CS451/651 Project 3 (Parsing) Swami Iyer
<JLiteralInt line=”6″ type=”” value=”0″/> |
</IndexExpression > </JArrayExpression > |
</Argument> </Arguments > |
</JMessageExpression > </TestExpression > |
<SwitchBlockStatementGroup > <CaseLabel > |
<JLiteralInt line=”7″ type=”” value=”1″/> </CaseLabel > |
<CaseLabel > |
</CaseLabel > <CaseLabel > |
<JLiteralInt line=”9″ type=”” value=”3″/> </CaseLabel > |
<CaseLabel > |
</CaseLabel > <CaseLabel > |
<JLiteralInt line=”11″ type=”” value=”5″/> </CaseLabel > |
<Body> |
<JMessageExpression line=”12″ name=”println”> <Arguments > |
<Argument > |
</Argument> </Arguments > |
</JMessageExpression > </JStatementExpression > |
</Body> <Body> |
<JBreakStatement line=”13″> </JBreakStatement > |
</Body> </SwitchBlockStatementGroup > |
<SwitchBlockStatementGroup > <CaseLabel > |
<JLiteralInt line=”14″ type=”” value=”6″/> </CaseLabel > |
<CaseLabel > |
</CaseLabel > <CaseLabel > |
<JLiteralInt line=”16″ type=”” value=”8″/> </CaseLabel > |
<Body> |
<JMessageExpression line=”17″ name=”println”> <Arguments > |
<Argument > |
</Argument> </Arguments > |
</JMessageExpression > </JStatementExpression > |
</Body> |
<Body> |
</JBreakStatement > </Body> |
</SwitchBlockStatementGroup > <SwitchBlockStatementGroup > |
<CaseLabel > |
9 of 15
CS451/651 Project 3 (Parsing) Swami Iyer
</CaseLabel > |
<CaseLabel > |
</CaseLabel > <CaseLabel > |
<JLiteralInt line=”21″ type=”” value=”11″/> </CaseLabel > |
<CaseLabel > |
</CaseLabel > <Body> |
<JStatementExpression line=”23″> <JMessageExpression line=”23″ name=”println”> |
<Arguments > <Argument > |
<JLiteralString line=”23″ type=”” value=”"Fall"”/> </Argument> |
</Arguments > </JMessageExpression > |
</JStatementExpression > </Body> |
<Body> |
</JBreakStatement > </Body> |
</SwitchBlockStatementGroup > <SwitchBlockStatementGroup > |
<DefaultLabel/> <Body> |
<JStatementExpression line=”26″> <JMessageExpression line=”26″ name=”println”> |
<Arguments > <Argument > |
<JLiteralString line=”26″ type=”” value=”"Error!"”/> </Argument> |
</Arguments > </JMessageExpression > |
</JStatementExpression > </Body> |
</SwitchBlockStatementGroup > </JSwitchStatement > |
</JBlock> </Body> |
</JMethodDeclaration > </ClassBlock > |
</JClassDeclaration > </TypeDeclarations > |
</JCompilationUnit > |
Problem 5. (Do-while Statement) Add support for a do-while statement.
$ $j/j–/bin/j– -p tests/DoWhileStatement.java <?xml version=”1.0″ encoding=”utf-8″?> |
<JCompilationUnit line=”1″> |
<Imports > |
</Imports> <TypeDeclarations > |
<JClassDeclaration line=”3″ name=”DoWhileStatement” super=”java.lang.Object”> <Modifiers > |
<Modifier name=”public”/> </Modifiers > |
<ClassBlock > |
<Modifiers > |
10 of 15
CS451/651 Project 3 (Parsing) Swami Iyer
<Modifier name=”static”/> |
</Modifiers > <FormalParameters > |
<JFormalParameter line=”4″ name=”args” type=”String[]”/> </FormalParameters > |
<Body> |
<JVariableDeclaration > <Modifiers > |
</Modifiers > <VariableDeclarators > |
<JVariableDeclarator line=”5″ name=”i” type=”int”> <Initializer > |
<JLiteralInt line=”5″ type=”” value=”0″/> </Initializer > |
</JVariableDeclarator > |
<Initializer > |
</Initializer > </JVariableDeclarator > |
</VariableDeclarators > </JVariableDeclaration > |
<JDoWhileStatement line=”6″> <Body> |
<JBlock line=”6″> <JStatementExpression line=”7″> |
<JBinaryExpression line=”7″ type=”” operator=”+=”> <Lhs> |
<JVariable name=”sum”/> </Lhs> |
<Rhs> |
<Operand > |
</Operand> </JUnaryExpression > |
</Rhs> </JBinaryExpression > |
</JStatementExpression > </JBlock> |
</Body> <TestExpression > |
<JBinaryExpression line=”8″ type=”” operator=”<=”> <Lhs> |
<JVariable name=”i”/> </Lhs> |
<Rhs> |
</Rhs> </JBinaryExpression > |
</TestExpression > </JDoWhileStatement > |
<JStatementExpression line=”9″> <JMessageExpression line=”9″ name=”println”> |
<Arguments > <Argument > |
<JVariable name=”sum”/> </Argument> |
</Arguments > |
</JMessageExpression > </JStatementExpression > |
</JBlock> </Body> |
</JMethodDeclaration > </ClassBlock > |
</JClassDeclaration > </TypeDeclarations > |
11 of 15
CS451/651 Project 3 (Parsing) Swami Iyer
</JCompilationUnit >
Problem 6. (For Statement) Add support for a for statement.
$ $j/j–/bin/j– -p tests/ForStatement.java <?xml version=”1.0″ encoding=”utf-8″?> |
<JCompilationUnit line=”1″> |
<Imports > |
</Imports> <TypeDeclarations > |
<JClassDeclaration line=”3″ name=”ForStatement” super=”java.lang.Object”> <Modifiers > |
<Modifier name=”public”/> </Modifiers > |
<ClassBlock > |
<Modifiers > |
<Modifier name=”public”/> <Modifier name=”static”/> |
</Modifiers > <FormalParameters > |
<JFormalParameter line=”4″ name=”args” type=”String[]”/> </FormalParameters > |
<Body> |
<JVariableDeclaration > <Modifiers > |
</Modifiers > <VariableDeclarators > |
<JVariableDeclarator line=”5″ name=”sum” type=”int”> <Initializer > |
<JLiteralInt line=”5″ type=”” value=”0″/> </Initializer > |
</JVariableDeclarator > </VariableDeclarators > |
</JVariableDeclaration > <JForStatement line=”6″> |
<InitialExpression > <JVariableDeclaration > |
<Modifiers > </Modifiers > |
<VariableDeclarators > |
<Initializer > |
</Initializer > </JVariableDeclarator > |
</VariableDeclarators > </JVariableDeclaration > |
</InitialExpression > <TestExpression > |
<JBinaryExpression line=”6″ type=”” operator=”<=”> <Lhs> |
<JVariable name=”i”/> </Lhs> |
<Rhs> |
</Rhs> </JBinaryExpression > |
</TestExpression > <UpdateExpression > |
<JStatementExpression line=”6″> |
<Operand > |
12 of 15
CS451/651 Project 3 (Parsing) Swami Iyer
</Operand> |
</JUnaryExpression > </JStatementExpression > |
</UpdateExpression > <Statement > |
<JBlock line=”6″> <JStatementExpression line=”7″> |
<JBinaryExpression line=”7″ type=”” operator=”+=”> <Lhs> |
<JVariable name=”sum”/> </Lhs> |
<Rhs> |
</Rhs> </JBinaryExpression > |
</JStatementExpression > </JBlock> |
</Statement > </JForStatement > |
<JStatementExpression line=”9″> <JMessageExpression line=”9″ name=”println”> |
<Arguments > <Argument > |
<JVariable name=”sum”/> </Argument> |
</Arguments > </JMessageExpression > |
</JStatementExpression > </JBlock> |
</Body> </JMethodDeclaration > |
</ClassBlock > </JClassDeclaration > |
</TypeDeclarations > </JCompilationUnit > |
Problem 7. (Exception Handlers) Add support for exception handling, which involves supporting the try, catch, finally, throw, and throws clauses.
$ $j/j–/bin/j– -p tests/ExceptionHandlers.java <?xml version=”1.0″ encoding=”utf-8″?> |
<JCompilationUnit line=”1″> |
<Imports > </Imports> |
<TypeDeclarations > |
<Modifiers > |
</Modifiers > <ClassBlock > |
<JMethodDeclaration line=”2″ name=”f” returnType=”void”> <Modifiers > |
<Modifier name=”private”/> <Modifier name=”static”/> |
</Modifiers > <FormalParameters > |
</FormalParameters > <Exceptions > |
<Exception type=”Exception1″/> <Exception type=”Exception2″/> |
</Exceptions > <Body> |
<JBlock line=”2″> <JThrowStatement line=”3″> |
<JNewOp line=”3″ type=”Exception1″/> <Arguments > |
13 of 15
CS451/651 Project 3 (Parsing) Swami Iyer
</Arguments > |
</JNewOp> </JThrowStatement > |
</JBlock> </Body> |
</JMethodDeclaration > |
<Modifiers > |
<Modifier name=”static”/> </Modifiers > |
<FormalParameters > |
</FormalParameters > <Body> |
<JBlock line=”6″> <JTryCatchFinallyStatement line=”7″> |
<TryBlock > |
<JStatementExpression line=”8″> <JMessageExpression line=”8″ name=”f”> |
<Arguments > </Arguments > |
</JMessageExpression > </JStatementExpression > |
</JBlock> </TryBlock > |
<CatchBlock > |
<JBlock line=”10″> <JEmptyStatement line=”10″/> |
</JBlock> </CatchBlock > |
<CatchBlock > |
<JBlock line=”11″> <JEmptyStatement line=”11″/> |
</JBlock> </CatchBlock > |
<FinallyBlock > <JBlock line=”12″> |
<JEmptyStatement line=”12″/> </JBlock> |
</FinallyBlock > </JTryCatchFinallyStatement > |
</JBlock> </Body> |
</JMethodDeclaration > </ClassBlock > |
</JClassDeclaration > </TypeDeclarations > |
</JCompilationUnit > |
Problem 8. (Interface Type Declaration) Implement support for interface declaration.
$ $j/j–/bin/j– -p tests/Interface.java <?xml version=”1.0″ encoding=”utf-8″?> |
<JCompilationUnit line=”1″> |
<Imports > </Imports> |
<TypeDeclarations > |
<Modifiers > </Modifiers > |
<InterfaceBlock > |
14 of 15
CS451/651 Project 3 (Parsing) Swami Iyer
<Modifiers > |
<Modifier name=”public”/> </Modifiers > |
<FormalParameters > |
</FormalParameters > </JMethodDeclaration > |
</InterfaceBlock > </JInterfaceDeclaration > |
<JClassDeclaration line=”5″ name=”B” super=”java.lang.Object”> <Modifiers > |
<Modifier name=”public”/> </Modifiers > |
<Implements > |
</Implements > <ClassBlock > |
<JMethodDeclaration line=”6″ name=”f” returnType=”int”> <Modifiers > |
<Modifier name=”public”/> </Modifiers > |
<FormalParameters > |
</FormalParameters > <Body> |
<JBlock line=”6″> <JReturnStatement line=”7″> |
<JBinaryExpression line=”7″ type=”” operator=”*”> <Lhs> |
<JVariable name=”x”/> </Lhs> |
<Rhs> |
</Rhs> </JBinaryExpression > |
</JReturnStatement > </JBlock> |
</Body> </JMethodDeclaration > |
</ClassBlock > </JClassDeclaration > |
</TypeDeclarations > </JCompilationUnit > |
Files to Submit
1. j–.tar.gz (j– source tree as a single gzip file) 2. report.txt (project report)
Before you submit:
• Make sure you create the gzip file j–.tar.gz such that it only includes the source files and not the binaries, which can be done on the terminal as follows:
• Make sure your report isn’t too verbose, doesn’t contain lines that exceed 80 characters, and doesn’t contain spelling/grammatical mistakes
$ cd $j/j– |
$ ant clean $ cd .. |
$ tar -cvf j–.tar j–/* $ gzip j–.tar |
15 of 15