User Tools

Site Tools


cc17:eminijava

This is an old revision of the document!


Extended MiniJava (E-MiniJava)

MiniJava is a subset of the programming language Java as described in the Appendix of the Tiger book. Extended MiniJava (E-MiniJava) is an extension to MiniJava that we use in this course. Each group will gradually develop a compiler through implementing different phases of the compiler step by step.

General Overview

  • Object oriented. It supports classes with inheritance and method overriding (but not overloading).
  • Imperative. All class fields and local variables are mutable. While-loop and conditional statement are the main control structure.
  • It supports the following types: Ints, Booleans, Strings, Int arrays and reference types (classes).
  • All classes in a E-MiniJava program are included in a single source file.

BNF

The syntax of Tool is given by the following BNF grammar:

Program::=MainClass ( ClassDeclaration )* <EOF>
MainClass::=class Identifier { public static void main ( String [ ] Identifier ) { Statement } }
ClassDeclaration::=class Identifier ( extends Identifier )? { ( VarDeclaration )* ( MethodDeclaration )* }
VarDeclaration::=Type Identifier ;
MethodDeclaration::=public Type Identifier ( ( Type Identifier ( , Type Identifier )* )? ) { ( VarDeclaration )* ( Statement )* return Expression ; }
Type::=Int
Bool
String
Int [ ]
Identifier
Statement::={ ( Statement )* }
if ( Expression ) Statement ( else Statement )?
while ( Expression ) Statement
System.out.println ( Expression ) ;
Identifier = Expression ;
Identifier [ Expression ] = Expression ;
sidef ( Expression ) ;
Expression::=Expression ( && | || | == | < | + | - | * | / ) Expression
Expression [ Expression ]
Expression . length
Expression . Identifier ( ( Expression ( , Expression )* )? )
<INTEGER_LITERAL>
" <STRING_LITERAL> "
true
false
Identifier
this
new Int [ Expression ]
new Identifier ( )
! Expression
( Expression )
Identifier::=<IDENTIFIER>
  • <IDENTIFIER> represents a sequence of letters, digits and underscores, starting with a letter and which is not a keyword. Identifiers are case-sensitive.
  • <INTEGER_LITERAL> represents a sequence of digits
  • <STRING_LITERAL> represents a sequence of arbitrary characters, except new lines and ". We don't ask you to support escape characters such as \n.
  • <EOF> represents the special end-of-file character
cc17/eminijava.1486061426.txt.gz · Last modified: 2017/02/02 13:50 by hossein