EBNF of Java

In this section I want to present an EBNF for the Java language to better understand it and to get an overview. See how far we will get with this.

Extended Backus Naur Formalism

   Letter	= ('a' .. 'z') | ('A' .. 'Z') .
   Digit	= '0' .. '9' .
   HexDigit	= Digit | ( 'A' .. 'F' ) | ( 'a' .. 'f' ) .
   Identifier	= Letter { Letter | Digit | '$' } .
   ConstIdent	= Letter { Letter | Digit | '_' | '$' } .
   
   boolean	= true | false .
   byte		= 0 .. 255 .
   short	= -32768 .. 32767 .
   int		= -2,147,483,648 .. 2,147,483,647 .
   long		= -9,223,372,036,854,775,808 .. 9,223,372,036,854,775,807 .
   char		= 0000 .. 65535 .
   
   DataType	= byte | short | int | long | float | double | boolean | char .
   

After reading a few chapters in tutorials and learningbooks, I come to the conculusion that an EBNF notation of Java is very difficult. The language is 'visual'. You need to scan each line of text as a human programmer with your eye going left, right, left, right, etcetera, over the line of code, thereby extracting the meaning of the written code.

I see many overlaps and parallels between Java and Modula-2 when I look at the programming concepts but not when it comes down to the structure of the language. It must be a nightmare to make a Java compiler. No wonder it is such a huge project.

Still, when you skip the bloating of the OO guys, Java isn't that bad. It 'borrows' a lot of functionality from Wirthian languages but it uses completely different names for them. Below is a short list of how things are called in Java and Modula-2:


	Java		Modula-2
	--------	--------
	Class		{Qualified Import}-ed MODULE
	Object		{Qualified Import}-ed VARiable
	Method		{Qualified Import}-ed PROCEDURE
	Fields		Local variables

   
At least, that was what I learned from the Head First book. Which I quit reading. I dont like it. So at amazon I bought a few leftover books for a few bucks each. I have good hopes that these books will get me going again for and with Java.

Page created on 23 September 2009 and

Page equipped with FroogleBuster technology