User Tools

Site Tools


cc17:eminijava

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cc17:eminijava [2017/02/02 21:02]
hossein [+]
cc17:eminijava [2017/02/20 17:17] (current)
hossein [BNF]
Line 9: Line 9:
   * Object oriented. It supports classes with inheritance and method overriding (but not overloading).   * 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.   * Imperative. All class fields and local variables are mutable. While-loop and conditional statement are the main control structure.
-  * It supports the following types: ''​int'',​ ''​boolean'',​ ''​String'',​ ''​int'' ​array and reference types (classes).+  * It supports the following types: ''​int'',​ ''​boolean'',​ ''​String'',​ ''​int ​array''​ and reference types (classes).
   * All classes in a eMiniJava program are included in a single source file.   * All classes in a eMiniJava program are included in a single source file.
  
  
 ===== BNF ===== ===== BNF =====
-The syntax of Tool is given by the following BNF grammar:+The syntax of eMiniJava ​is given by the following BNF grammar:
  
 |  //​Program//​|::​=|//​MainClass//​ ( //​ClassDeclaration//​ )* <​EOF> ​ | |  //​Program//​|::​=|//​MainClass//​ ( //​ClassDeclaration//​ )* <​EOF> ​ |
Line 38: Line 38:
 |      |   ​|//​Expression//​ **.** //​Identifier//​ **(** ( //​Expression//​ ( **,** //​Expression//​ )* )? **)**  | |      |   ​|//​Expression//​ **.** //​Identifier//​ **(** ( //​Expression//​ ( **,** //​Expression//​ )* )? **)**  |
 |      |   ​|<​INTEGER_LITERAL> ​ | |      |   ​|<​INTEGER_LITERAL> ​ |
-|      |   ​|**%%"​%%** <​STRING_LITERAL>​ **%%"​%%** ​ |+|      |   ​|**%%"​%%**<​STRING_LITERAL>​**%%"​%%** ​ |
 |      |   ​|**true** ​ | |      |   ​|**true** ​ |
 |      |   ​|**false** ​ | |      |   ​|**false** ​ |
 |      |   ​|//​Identifier// ​ | |      |   ​|//​Identifier// ​ |
 |      |   ​|**this** ​ | |      |   ​|**this** ​ |
-|      |   ​|**new ​Int [** //​Expression//​ **]**  |+|      |   ​|**new ​int [** //​Expression//​ **]**  |
 |      |   ​|**new** //​Identifier//​ **( )**  | |      |   ​|**new** //​Identifier//​ **( )**  |
 |      |   ​|**!** //​Expression// ​ | |      |   ​|**!** //​Expression// ​ |
Line 156: Line 156:
   * The operator precedence is the same as in Java. From highest priority to lowest: **!**, then **%%*%%** and **/**, then **+** and **-**, then **<** and **==**, then **&&​**,​ then **||**. Also, ''​new''​ binds tighter than ''​.''​ (method call or ''​.length''​),​ which binds tighter than ''​[]''​ (array read), which binds tighter than any operator. So ''​ 1 + new Foo().bar().baz()[42]''​ means ''​1 + ( ( ( (new Foo()).bar()).baz())[42])''​.   * The operator precedence is the same as in Java. From highest priority to lowest: **!**, then **%%*%%** and **/**, then **+** and **-**, then **<** and **==**, then **&&​**,​ then **||**. Also, ''​new''​ binds tighter than ''​.''​ (method call or ''​.length''​),​ which binds tighter than ''​[]''​ (array read), which binds tighter than any operator. So ''​ 1 + new Foo().bar().baz()[42]''​ means ''​1 + ( ( ( (new Foo()).bar()).baz())[42])''​.
   * All binary operators are left-associative. E.g. ''​1-2+3''​ means ''​(1-2)+3''​ and **not** ''​1-(2+3)''​. (Of course this does not matter for operators of different precedence).   * All binary operators are left-associative. E.g. ''​1-2+3''​ means ''​(1-2)+3''​ and **not** ''​1-(2+3)''​. (Of course this does not matter for operators of different precedence).
 +
 +===== Examples =====
 +
 +There are a set of MiniJava programs on the [[http://​www.cambridge.org/​resources/​052182060X/​|MiniJava webpage]]. Since eMiniJava is a superset of MiniJava, they are eMiniJava programs as well.
 +
cc17/eminijava.1486087328.txt.gz ยท Last modified: 2017/02/02 21:02 by hossein