Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Class

...

, Interface

Code Block
titleGrammar
Class                  ::= "class" ID ("extends" QName)? ("implements" QName ("," QName)*)? "{" (Attribute | Method)* "}". 
Interface              ::= "interface" ID ("extends" QName ("," QName)*)? "{" (MethodDeclaration)* "}".
Attribute              ::= VariableDeclaration (VariableInit)? ";".
VariableDeclaration    ::= Type ID.
Type                   ::= (PrimitiveType | QName) ("[" "]")*.
PrimitiveType          ::= "boolean" | "byte" | "char" | "short" | "int" | "float" | "long" | "double".
Method                 ::= ("override")? MethodDeclaration StatementBlock.  
MethodDeclaration      ::= ID (MethodParameters)? (":" Type)?.
MethodParameters       ::= "(" (VariableDeclaration ("," VariableDeclaration)*)? ")".

 

...

 

Statements

Code Block
titleGrammar
Statement              ::= ( StatementBlock | IfStatement | SwitchStatement | WhileStatement | DoWhileStatement | ForStatement | ForEachStatement
                           | VariableStatement | ConstructorStatement | ExpressionStatement | BreakStatement | ContinueStatement | ReturnStatement ).
StatementBlock         ::= "{" (Statement)* "}".
IfStatement            ::= "if" "(" Expression ")" Statement ("else" Statement)?.
SwitchStatement        ::= "switch" "(" Expression ")" "{" ("case" Expression ":" (Statement)*)* ("default" ":" (Statement)*)? "}"
WhileStatement         ::= "while" "(" Expression ")" Statement.
DoWhileStatement       ::= "do" Statement "while" "(" Expression ")" ";".
ForStatement           ::= "for" "(" VariableDeclaration ";" Expression ";" Expression ")" Statement.
ForEachStatement       ::= "for" "(" VariableDeclaration ":" Expression ")" Statement.
VariableStatement      ::= VariableDeclaration VariableInit ";".
ConstructorStatement   ::= ("super" | "this") "(" (ArgsList)? ")" ";".
ExpressionStatement    ::= Expression ";".
BreakStatement         ::= "break" ";".
ContinueStatement      ::= "continue" ";".
ReturnStatement        ::= "return" (Expression)? ";".

...