1
Fork 0

Finished regression testing for PA3

master
Joshua Potter 2014-04-07 20:06:13 -04:00
parent 3517e9648c
commit 5580416065
388 changed files with 1491 additions and 3676 deletions

View File

@ -14,6 +14,7 @@ public class Analyzer implements Visitor<IdentificationTable, Type> {
private MethodDecl mainMethod = null;
private ClassDecl currentClassDecl = null;
private MethodDecl currentMethodDecl = null;
private VarDecl currentVarDecl = null;
private IdentificationTable table = new IdentificationTable();
// Keep track of all predefined names to handle
@ -125,6 +126,8 @@ public class Analyzer implements Visitor<IdentificationTable, Type> {
// Must check that the type of the field can be identified
if (!table.classExists(fd.type)) {
Reporter.report(ErrorType.UNDECLARED_TYPE, fd.type, null);
} else if(fd.type.typeKind == TypeKind.VOID) {
Reporter.report(ErrorType.VOID_TYPE, fd.type, null);
}
return fd.type;
@ -169,6 +172,8 @@ public class Analyzer implements Visitor<IdentificationTable, Type> {
arg.setDeclarationAtScope(pd);
if (!table.classExists(pd.type)) {
Reporter.report(ErrorType.UNDECLARED_TYPE, pd.type, null);
} else if(pd.type.typeKind == TypeKind.VOID) {
Reporter.report(ErrorType.VOID_TYPE, pd.type, null);
}
return pd.type;
@ -178,6 +183,8 @@ public class Analyzer implements Visitor<IdentificationTable, Type> {
arg.setDeclarationAtScope(decl);
if (!table.classExists(decl.type)) {
Reporter.report(ErrorType.UNDECLARED_TYPE, decl.type, null);
} else if(decl.type.typeKind == TypeKind.VOID) {
Reporter.report(ErrorType.VOID_TYPE, decl.type, null);
}
return decl.type;
@ -221,20 +228,33 @@ public class Analyzer implements Visitor<IdentificationTable, Type> {
return null;
}
// The stmt of the vardecl may not refer to the variable itself so we check the stmt first
// The stmt of the vardecl may not refer to the variable itself
public Type visitVardeclStmt(VarDeclStmt stmt, IdentificationTable arg) {
Type initExpType = stmt.initExp.visit(this, arg);
Type varDeclType = stmt.varDecl.visit(this, arg);
currentVarDecl = stmt.varDecl;
Type initExpType = stmt.initExp.visit(this, arg);
IdentificationTable.match(varDeclType, initExpType, true);
currentVarDecl = null;
// Can't have a class reference as the sole rhs
if(stmt.initExp instanceof RefExpr && initExpType.typeKind == TypeKind.CLASS) {
RefExpr re = (RefExpr)stmt.initExp;
Declaration decl = table.getDeclarationAtScope(re.ref.decl.name);
if(decl != null) Reporter.report(ErrorType.CLASS_IDENTIFER, stmt, null);
}
return varDeclType;
}
public Type visitAssignStmt(AssignStmt stmt, IdentificationTable arg) {
Type valType = stmt.val.visit(this, arg);
Type refType = stmt.ref.visit(this, arg);
Type valType = stmt.val.visit(this, arg);
IdentificationTable.match(valType, refType, true);
if(stmt.ref.decl instanceof MethodDecl)
Reporter.report(ErrorType.FUNCTION_ASSIGNMENT, stmt.ref.decl, null);
return refType;
}
@ -242,15 +262,18 @@ public class Analyzer implements Visitor<IdentificationTable, Type> {
Type methodType = stmt.methodRef.visit(this, arg);
// Check that parameter count is correct and each type is correct
MethodDecl decl = (MethodDecl) stmt.methodRef.decl;
if (decl.parameterDeclList.size() != stmt.argList.size()) {
Reporter.report(ErrorType.INVALID_PARAM_COUNT, stmt, decl);
} else {
for (int i = 0; i < stmt.argList.size(); i++) {
Type exprType = stmt.argList.get(i).visit(this, arg);
Type pdType = decl.parameterDeclList.get(i).type;
IdentificationTable.match(pdType, exprType, true);
if(methodType.typeKind != TypeKind.ERROR) {
// Check that parameter count is correct and each type is correct
MethodDecl decl = (MethodDecl) stmt.methodRef.decl;
if (decl.parameterDeclList.size() != stmt.argList.size()) {
Reporter.report(ErrorType.INVALID_PARAM_COUNT, stmt, decl);
} else {
for (int i = 0; i < stmt.argList.size(); i++) {
Type exprType = stmt.argList.get(i).visit(this, arg);
Type pdType = decl.parameterDeclList.get(i).type;
IdentificationTable.match(pdType, exprType, true);
}
}
}
@ -424,8 +447,8 @@ public class Analyzer implements Visitor<IdentificationTable, Type> {
return new BaseType(TypeKind.ERROR, ref.id.posn);
}
// If the qualifed ref is a class declaration, members must be static
else if(qualified instanceof ClassDecl) {
// If the qualifed ref is a class declaration, members must be static (must check for 'this')
else if(qualified instanceof ClassDecl && !(ref.ref instanceof ThisRef)) {
if(!md.isStatic) {
Reporter.report(ErrorType.STATIC, md, ref.id);
return new BaseType(TypeKind.ERROR, ref.id.posn);
@ -453,7 +476,7 @@ public class Analyzer implements Visitor<IdentificationTable, Type> {
public Type visitIndexedRef(IndexedRef ref, IdentificationTable arg) {
Type refType = ref.ref.visit(this, arg);
ArrayType refType = (ArrayType) ref.ref.visit(this, arg);
// Make sure index is an integer
Type indexExprType = ref.indexExpr.visit(this, arg);
@ -462,7 +485,7 @@ public class Analyzer implements Visitor<IdentificationTable, Type> {
}
ref.decl = ref.ref.decl;
return refType;
return refType.eltType;
}
public Type visitIdRef(IdRef ref, IdentificationTable arg) {
@ -490,6 +513,12 @@ public class Analyzer implements Visitor<IdentificationTable, Type> {
public Type visitIdentifier(Identifier id, IdentificationTable arg) {
// Must check identifier is not of the same type being declared
if(currentVarDecl != null && currentVarDecl.name.equals(id.spelling)) {
Reporter.report(ErrorType.VARDECL_USED, id, currentVarDecl);
return new BaseType(TypeKind.ERROR, id.posn);
}
// Check if identifier can be found in current scope
Declaration decl = arg.getDeclarationAtScope(id.spelling);
if (decl != null) { id.decl = decl; return decl.type; }

View File

@ -4,7 +4,11 @@ import miniJava.AbstractSyntaxTrees.*;
enum ErrorType {
THIS,
VOID_TYPE,
CLASS_IDENTIFER,
VARDECL_USED,
NONFUNCTION_CALL,
FUNCTION_ASSIGNMENT,
UNDEFINED,
STATIC,
VISIBILITY,
@ -68,12 +72,30 @@ public class Reporter {
break;
}
// Can't use a class as an identifier solely
case CLASS_IDENTIFER: {
emit("Cannot use class identifier by outside of a qualified reference at " + a1.posn);
break;
}
// Cannot have a parameter of type void
case VOID_TYPE: {
emit("Cannot have a parameter of type void at " + a1.posn);
break;
}
// Attempting to call a non function as a function
case NONFUNCTION_CALL: {
emit("Not a valid function call at " + a1.posn);
break;
}
// Cannot assign a value to a function
case FUNCTION_ASSIGNMENT: {
emit("Cannot assign a value to a function at " + a1.posn);
break;
}
// Tried accessing a non-static member from a static method
case STATIC: {
MemberDecl md = (MemberDecl) a1;
@ -162,6 +184,12 @@ public class Reporter {
emit("Index expression is not of type int " + a1.posn);
break;
}
// A variable declaration identifier was used in a var decl statement
case VARDECL_USED: {
emit("Identifier at " + a1.posn + " cannot refer to the variable declaration at " + a2.posn);
break;
}
}
error = true;

View File

@ -1,40 +0,0 @@
Program ::= (ClassDeclaration)* eot
ClassDeclaration ::=
class id {
(Declarators id (; | MethodDeclaration))*
}
MethodDeclaration ::=
(ParameterList?) {
Statement* (return Expression ;)?
}
Declarators ::= (public | private)? static? Type
Type ::= boolean | void | int ([])? | id ([])?
ParameterList ::= Type id (, Type id)*
ArgumentList ::= Expression (, Expression)*
Reference ::= BaseRef (. id ([ Expression])?)*
BaseRef ::= this | id ([ Expression])?
Statement ::=
{Statement*}
| Type id = Expression;
| Reference = Expression;
| Reference ( ArgumentList? );
| if (Expression) Statement (else Statement)?
| while (Expression) Statement
Expression ::=
Reference ((ArgumentList?))?
| unop Expression
| Expression binop Expression
| ( Expression )
| num | true | false
| new (id() | int [ Expression ] | id [ Expression ] )

View File

@ -1,50 +0,0 @@
Program ::= (ClassDeclaration)* eot
ClassDeclaration ::=
class id {
(Declarators id (; | MethodDeclaration))*
}
MethodDeclaration ::=
(ParameterList?) {
Statement* (return Expression ;)?
}
Declarators ::= (public | private)? static? Type
Type ::= boolean | void | int ([])? | id ([])?
ParameterList ::= Type id (, Type id)*
ArgumentList ::= Expression (, Expression)*
Reference ::= BaseRef (. id ([ Expression])?)*
BaseRef ::= this | id ([ Expression])?
Statement ::=
{Statement*}
| Type id = Expression;
| Reference = Expression;
| Reference ( ArgumentList? );
| if (Expression) Statement (else Statement)?
| while (Expression) Statement
Expression ::=
num | true | false
| ( Expression )
| new (id() | int [ Expression ] | id [ Expression ] )
| Reference ((ArgumentList?))?
| DExpression
DExpression ::= CExpression (|| CExpression)*
CExpression ::= EExpression (&& EExpression)*
EExpression ::= RExpression ((==|!=) RExpression)*
RExpression ::= AExpression ((<=|<|>|>=) AExpression)*
AExpression ::= MExpression ((+|-) MExpression)*
MExpression ::= Expression ((*|/) Expression)*

View File

@ -1,71 +0,0 @@
package tester;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/* Automated regression tester for Checkpoint 1 tests
* Created by Max Beckman-Harned
* Put your tests in "tests/pa1_tests" folder in your Eclipse workspace directory
*/
public class Checkpoint1 {
static ExecutorService threadPool = Executors.newCachedThreadPool();
public static void main(String[] args) throws IOException, InterruptedException {
File testDir = new File(System.getProperty("java.class.path") + "/../tests/pa1_tests");
System.out.println(testDir.getAbsolutePath());
int failures = 0;
for (File x : testDir.listFiles()) {
int returnCode = runTest(x);
if (x.getName().indexOf("pass") != -1) {
if (returnCode == 0)
System.out.println(x.getName() + " passed successfully!");
else {
failures++;
System.err.println(x.getName()
+ " failed but should have passed!");
}
} else {
if (returnCode == 4)
System.out.println(x.getName() + " failed successfully!");
else {
System.err.println(x.getName() + " did not fail properly!");
failures++;
}
}
}
System.out.println(failures + " failures in all.");
}
private static int runTest(File x) throws IOException, InterruptedException {
ProcessBuilder pb = new ProcessBuilder("java", "miniJava.Compiler", x.getPath()).directory(new File(System.getProperty("java.class.path")));
Process p = pb.start();
threadPool.execute(new ProcessOutputter(p.getInputStream(), false));
p.waitFor();
return p.exitValue();
}
static class ProcessOutputter implements Runnable {
private Scanner processOutput;
private boolean output;
public ProcessOutputter(InputStream _processStream, boolean _output) {
processOutput = new Scanner(_processStream);
output = _output;
}
@Override
public void run() {
while(processOutput.hasNextLine()) {
String line = processOutput.nextLine();
if (output)
System.out.println(line);
}
}
}
}

View File

@ -3,50 +3,34 @@ package tester;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.FileInputStream;
import java.util.Scanner;
/* Automated regression tester for Checkpoint 2 tests
/* Automated regression tester for Checkpoint 3 tests
* Created by Max Beckman-Harned
* Put your tests in "tests/pa2_tests" folder in your Eclipse workspace directory
* Put your tests in "tests/pa3_tests" folder in your Eclipse workspace directory
* If you preface your error messages / exceptions with ERROR or *** then they will be displayed if they appear during processing
*/
public class Checkpoint2 {
public class Checkpoint3 {
private static class ReturnInfo {
int returnCode;
String ast;
public ReturnInfo(int _returnCode, String _ast) {
returnCode = _returnCode;
ast = _ast;
}
}
public static void main(String[] args) throws IOException, InterruptedException {
File testDir = new File(System.getProperty("java.class.path")
+ "/../tests/pa2_tests");
+ "/../tests/pa3_tests");
int failures = 0;
for (File x : testDir.listFiles()) {
if (x.getName().endsWith("out") || x.getName().startsWith("."))
if (x.getName().endsWith("out") || x.getName().startsWith(".") || x.getName().endsWith("mJAM") || x.getName().endsWith("asm"))
continue;
ReturnInfo info = runTest(x);
int returnCode = info.returnCode;
String ast = info.ast;
int returnCode = runTest(x);
if (x.getName().indexOf("pass") != -1) {
if (returnCode == 0) {
String actualAST = getAST(new FileInputStream(x.getPath() + ".out"));
if (actualAST.equals(ast))
System.out.println(x.getName() + " parsed successfully and has a correct AST!");
else {
System.err.println(x.getName() + " parsed successfully but has an incorrect AST!");
failures++;
}
System.out.println(x.getName() + " processed successfully!");
}
else {
failures++;
System.err.println(x.getName()
+ " failed to be parsed!");
+ " failed to be processed!");
}
} else {
if (returnCode == 4)
@ -60,39 +44,30 @@ public class Checkpoint2 {
System.out.println(failures + " failures in all.");
}
private static ReturnInfo runTest(File x) throws IOException, InterruptedException {
private static int runTest(File x) throws IOException, InterruptedException {
ProcessBuilder pb = new ProcessBuilder("java", "miniJava.Compiler", x.getPath()).directory(new File(System.getProperty("java.class.path")));
pb.redirectErrorStream(true);
Process p = pb.start();
String ast = getAST(p.getInputStream());
processStream(p.getInputStream());
p.waitFor();
int exitValue = p.exitValue();
return new ReturnInfo(exitValue, ast);
return exitValue;
}
public static String getAST(InputStream stream) {
public static void processStream(InputStream stream) {
Scanner scan = new Scanner(stream);
String ast = null;
while (scan.hasNextLine()) {
String line = scan.nextLine();
if (line.equals("======= AST Display =========================")) {
line = scan.nextLine();
while(scan.hasNext() && !line.equals("=============================================")) {
ast += line + "\n";
line = scan.nextLine();
}
}
if (line.startsWith("*** "))
System.out.println(line);
if (line.startsWith("ERROR")) {
System.out.println(line);
while(scan.hasNext())
System.out.println(scan.next());
//while(scan.hasNext())
//System.out.println(scan.next());
}
}
scan.close();
return ast;
}
}

View File

@ -0,0 +1,13 @@
/*** F02 is invalid qualified reference
* COMP 520
* Identification
*/
class fail61 {
public static void main(String[] args) {
F02 c = F02;
}
}
class F02 {
public int x;
}

View File

@ -1,2 +0,0 @@
// PA1 lex id fail
class _id {}

View File

@ -1,2 +0,0 @@
// PA1 lex id fail
class boolean {}

View File

@ -1,2 +0,0 @@
// PA1 parse fail
class Foo {}.

View File

@ -1,2 +0,0 @@
// PA1 lex id fail
class true {}

View File

@ -1,2 +0,0 @@
// PA1 lex comment fail
class id {} /* unterminated

View File

@ -1,3 +0,0 @@
// PA1 lex comment fail
class /* /* nested */ */ id {}

View File

@ -1,2 +0,0 @@
// PA1 lex ill char fail
class NonTokens{} #

View File

@ -1,7 +0,0 @@
// PA1 lex binop fail
class id {
void p(){
int x = 1 &| 0;
}
}

View File

@ -1,7 +0,0 @@
// PA1 lex binop fail
class id {
void p(){
x = 1 + 2*3 = 4;
}
}

View File

@ -1,7 +0,0 @@
// PA1 lex/parse binop fail
class id {
void p(){
int x = 1 >> 0;
}
}

View File

@ -1,7 +0,0 @@
// PA1 lex binop fail
class id {
void p(){
while ( 1 > = 0) {}
}
}

View File

@ -1,5 +0,0 @@
// PA1 lex trailing start char fail
class Almost {
public static void main (String [] args) {
} // nothing follows next slash
} /

View File

@ -1,5 +0,0 @@
// PA1 lex comment fail
class IllegalComment {
public static void main (String [] args) {
} // nothing follows final *
}/* ****

View File

@ -1,6 +0,0 @@
// PA1 parse field decl fail
class id {
static private Type x;
}

View File

@ -1,6 +0,0 @@
// PA1 parse field decl fail
class id {
public private static Type x;
}

View File

@ -1,6 +0,0 @@
// PA1 parse field decl fail
class id {
int x = 3;
}

View File

@ -1,6 +0,0 @@
// PA1 parse field decl fail
class id {
void int x;
}

View File

@ -1,6 +0,0 @@
// PA1 parse field decl fail
class id {
public [] String x;
}

View File

@ -1,6 +0,0 @@
// PA1 parse field decl fail
class id {
public void [] x;
}

View File

@ -1,8 +0,0 @@
// PA1 parse local decl fail
class id {
void foo() {
Nonesuch x[2] = 3;
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse local decl fail
class id {
public void f(){
Ref [] x(33);
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse local decl fail
class id {
public void f(){
int x;
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse local decl fail
class id {
public void f(){
Foo x;
}
}

View File

@ -1,6 +0,0 @@
// PA1 parse local decl fail
class idfail {
public void foo () {
int [] x[3] = null;
}
}

View File

@ -1,6 +0,0 @@
// PA1 parse local decl fail
class LValueFail {
void foo () {
true = false;
}
}

View File

@ -1,6 +0,0 @@
// PA1 parse expr fail
class NonTokens{
int main () {
return a++b;
}
}

View File

@ -1,6 +0,0 @@
// PA1 parse expr fail
class NonTokens{
int main () {
return;
}
}

View File

@ -1,6 +0,0 @@
// PA1 parse expr fail
class IllegalExpressions {
void main () {
z = a+!=b;
}
}

View File

@ -1,6 +0,0 @@
// PA1 parse stmt fail
class IllegalStmt {
void main () {
this;
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse expr fail
class IllegalExpressions {
static void foo (int a) {
if (a = a) {
a = a;
}
}
}

View File

@ -1,6 +0,0 @@
// PA1 parse unop fail
class IllegalExpressions {
void foo() {
z = a!b;
}
}

View File

@ -1,6 +0,0 @@
// PA1 parse ref fail
class IllegalExpressions {
void foo () {
a [b] [c] = d; // not ok
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse method fail
class IllegalExpressions {
void foo () {
if (x != 0)
return x;
return y;
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse refs fail
class Test {
void p() {
A a [17] = 23;
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse decl fail
class Test {
void p() {
boolean [] a = b;
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse call fail
class Test {
void p(int a, boolean b) {
int p(a,b);
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse decl fail
class Test {
void p(int a) {
Test [ ] x.y = a;
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse assign fail
class Test {
void p(int a) {
Test [ ] = a * 3;
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse call fail
class Test {
void p(int a) {
c.p(2,3)[3] = 4;
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse assign fail
class Test {
void p(int a) {
that.this = 4;
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse assign fail
class Test {
void p() {
x.y() = z;
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse decl fail
class Test {
void p() {
c [] d b = new int[4];
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse new fail
class Test {
void p() {
x = new Foo(10);
}
}

View File

@ -1,2 +0,0 @@
class id {}

View File

@ -1,3 +0,0 @@
// PA1 lex id pass
class id {}

View File

@ -1,3 +0,0 @@
// PA1 lex id pass
class id_ {}

View File

@ -1,3 +0,0 @@
// PA1 lex id pass
class id_0_1__{}

View File

@ -1,3 +0,0 @@
// PA1 lex id pass
class Class{}

View File

@ -1,3 +0,0 @@
// PA1 lex comment pass
class // comment $$ followed by \r\n
id {}

View File

@ -1,2 +0,0 @@
// PA1 lex comment pass
class id {} // trailing comment terminated by \r\n

View File

@ -1,3 +0,0 @@
// PA1 lex comment pass
class /* comment */ id {}

View File

@ -1,3 +0,0 @@
// PA1 lex comment pass
class /**/ id {}

View File

@ -1,3 +0,0 @@
// PA1 lex comment pass
class /*/**/ id {}

View File

@ -1,3 +0,0 @@
// PA1 lex comment pass
class /*/$*/ id {}

View File

@ -1,8 +0,0 @@
// PA1 lex unop pass
class id {
void p(){
int x = - b;
boolean y = !y;
}
}

View File

@ -1,7 +0,0 @@
// PA1 lex unop pass
class id {
void p(){
boolean x = !!!!!b;
}
}

View File

@ -1,7 +0,0 @@
// PA1 lex unop pass
class id {
void p(){
boolean x = 10 >- b;
}
}

View File

@ -1,7 +0,0 @@
// PA1 lex binop pass
class id {
void p(){
int x = 1 + 2 * 3 / 4 > 5 >= 6 < 7 <= 8 != 9 && 0 || 1;
}
}

View File

@ -1,7 +0,0 @@
// PA1 lex binop pass
class id {
void p(){
boolean x = true && false || x;
}
}

View File

@ -1,7 +0,0 @@
// PA1 lex unop pass
class id {
void p(){
int y = --y;
}
}

View File

@ -1,7 +0,0 @@
// PA1 lex unop pass
class id {
void p(){
int x = b - - b;
}
}

View File

@ -1,7 +0,0 @@
// PA1 lex unop pass
class id {
void p(){
int x = b - - - -b;
}
}

View File

@ -1,12 +0,0 @@
// PA1 lex whitespace including tab
class Test {
/* multiple comments between
*/
// tokens
/**//* is OK */
}

View File

@ -1,3 +0,0 @@
// PA1 lex comment pass
class // comment followed by \n only
id {}

View File

@ -1,3 +0,0 @@
// PA1 lex comment pass
class // comment followed by \r only
id {}

View File

@ -1,2 +0,0 @@
// PA1 lex comment pass
class id {} // trailing comment terminated by \r

View File

@ -1,2 +0,0 @@
// PA1 lex comment pass
class id {} // trailing comment terminated by \n

View File

@ -1,2 +0,0 @@
// PA1 lex comment pass
class id {} // unterminated comment - no trailing \r\n

View File

@ -1,2 +0,0 @@
// PA1 lex comment pass
class id {} /* no trailing \r\n */

View File

@ -1,5 +0,0 @@
// PA1 parse field decl pass
class id {
public static Type x;
}

View File

@ -1,5 +0,0 @@
// PA1 parse field decl pass
class id {
private static Type x;
}

View File

@ -1,5 +0,0 @@
// PA1 parse field decl pass
class id {
static Type x;
}

View File

@ -1,5 +0,0 @@
// PA1 parse field decl pass
class id {
Type x;
}

View File

@ -1,5 +0,0 @@
// PA1 parse field decl pass
class id {
int x;
}

View File

@ -1,5 +0,0 @@
// PA1 parse field decl pass
class id {
int[] x;
}

View File

@ -1,5 +0,0 @@
// PA1 parse field decl pass
class id {
static void x;
}

View File

@ -1,5 +0,0 @@
// PA1 parse method decl pass
class id {
public static void main(String[] args){}
}

View File

@ -1,5 +0,0 @@
// PA1 parse method decl pass
class id {
private int f(int x, boolean b) {return 3;}
}

View File

@ -1,9 +0,0 @@
// PA1 parse classdecls pass
class MainClass {
public static void main (String [] args) {}
}
class OfItsOwn {
int A_01;
} // class OfItsOwn

View File

@ -1,20 +0,0 @@
// PA1 parse identifiers pass
class Keywords {
// minijava keywords are lower case only
void p() {
int format = while_1;
int Int = New;
For = Class;
FOR = RETURN;
}
public int declare () {
boolean iF = true;
boolean Then = false;
boolean else1 = false;
if (true == false) { else1 = iF == Then; }
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse new pass
class MainClass {
public static void main (String [] args) {
SecondSubClass newobj = new SecondSubClass ();
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse new pass
class Foo {
void bar() {
int[] newarr = new int[20];
}
}

View File

@ -1,23 +0,0 @@
// PA1 parse methods pass
class MainClass {
public static void main (String [] args) {
}
}
class SuperClass
{
public void setWorth (int worth){
integer = worth;
}
public int getWorth (){
return this.integer;
}
public void setTruth (boolean truth){
bool = truth;
}
public int getTruth (){
return this.bool;
}
}

View File

@ -1,21 +0,0 @@
// PA1 parse parse pass
class MainClass {
public static void main (String [] args) {
SecondSubClass newobj = new SecondSubClass ();
}
}
class SuperClass
{
private void fillup (boolean open, int [] jar, int marble, int upto) {
int index = 0;
if (open == true) {
while ( index < upto ) {
ownjar [index] = jar [index];
jar [index] = marble;
} // while
} // if
} // fillup
} // class SuperClass

View File

@ -1,12 +0,0 @@
// PA1 parse refs pass
class Test {
void p() {
a = true;
a [b] = c;
p ();
a.b[3] = d;
c.p(e);
}
}

View File

@ -1,11 +0,0 @@
// PA1 parse decl pass
class Test {
int [] a;
Test [] t;
void p() {
void x = this.t[3].a[4].p();
}
}

View File

@ -1,9 +0,0 @@
// PA1 parse refs pass
class Test {
void p() {
A a = 23;
boolean b = c;
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse assign pass
class Test {
void p() {
a = b;
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse call pass
class Test {
void p(int a, boolean b) {
p(a,b);
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse decl pass
class Test {
void p(int a) {
Test [ ] v = a;
}
}

View File

@ -1,8 +0,0 @@
// PA1 parse assign pass
class Test {
void p(int a) {
Test [ a + 1] = a * 3;
}
}

Some files were not shown because too many files have changed in this diff Show More