This is your first assignment for this course that accounts for 20% of your total marks for the course.

others

Description

This is your first assignment for this course that accounts for 20% of your total marks for the course. 


You should extend MiniJava's syntax to allow the following (all of which are legal in full Java too):


 double is a legal (base) type. 

 A floating-point literal constant is a legal expression. 

 An array of a base type, e.g., int[], boolean[][][], and in general type[] where type is an arbitrary base type. (Base types are ints, booleans, doubles, and arrays of base types. Only class types are not base types; this restriction is included only because otherwise the language becomes too hard to parse! The AST and the rest of the compiler should not depend on this restriction against arrays of class types, however.) 


 A one-level array allocation expression, e.g., new int[10], new boolean[20][][], and in general new type[expr]dims where type is an arbitrary non-array base type, expr is an arbitrary expression, and dims is a possibly-empty sequence of []'s, is a legal expression. 


 An array dereference, e.g., a[i], b[i][j][k], and in general expr1[expr2] where expr1 is an arbitrary atomic expression and expr2 is an arbitrary expression, is a legal expression. An array dereference is also legal on the left-hand side of an assignment statement. (Atomic expressions exclude unary and binary operator expressions and array allocation expressions.) 


 An array length expression, e.g., a.length and in general expr.length where expr is an arbitrary atomic expression, is a legal expression. length is a reserved word in MiniJava (unlike Java). 


 An or expression (using the || infix operator) is a legal expression. 


 if statements do not require else clauses. 


 For loops of the restricted form for (i = expr1; expr2; i = expr3) stmt are allowed, where expr1, expr2, and expr3 are arbitrary expressions, i is an arbitrary variable, and stmt is an arbitrary statement. 


 break statements are allowed. (You do not need to check in the syntax that break statements only appear inside of loops; semantic checking will enforce this.) 


 A class variable declaration may be preceded by the static reserved word to declare a static class variable.


Related Questions in others category