Program:
MainClass
ClassDeclaration
eof
Program
::=
MainClass
ClassDeclaration
* 'eof'
no references
MainClass:
class
Identifier
{
public
static
void
main
(
String
[
]
Identifier
)
{
Statement
}
}
MainClass
::= 'class'
Identifier
'{' 'public' 'static' 'void' 'main' '(' 'String' '[' ']'
Identifier
')' '{'
Statement
'}' '}'
referenced by:
Program
ClassDeclaration:
class
Identifier
extends
Identifier
{
VarDeclaration
ConstructorDeclaration
MethodDeclaration
}
ClassDeclaration
::= 'class'
Identifier
( 'extends'
Identifier
)? '{'
VarDeclaration
* (
ConstructorDeclaration
|
MethodDeclaration
)* '}'
referenced by:
Program
VarDeclaration:
Type
Identifier
;
VarDeclaration
::=
Type
Identifier
';'
referenced by:
ClassDeclaration
ConstructorDeclaration
MethodDeclaration
ConstructorDeclaration:
public
private
Identifier
(
Type
Identifier
,
)
{
VarDeclaration
Statement
}
ConstructorDeclaration
::= ( 'public' | 'private' )
Identifier
'(' (
Type
Identifier
( ','
Type
Identifier
)* )? ')' '{'
VarDeclaration
*
Statement
* '}'
referenced by:
ClassDeclaration
MethodDeclaration:
public
private
Type
Identifier
(
Type
Identifier
,
)
{
VarDeclaration
Statement
return
Expression
;
}
MethodDeclaration
::= ( 'public' | 'private' )
Type
Identifier
'(' (
Type
Identifier
( ','
Type
Identifier
)* )? ')' '{'
VarDeclaration
*
Statement
* 'return'
Expression
';' '}'
referenced by:
ClassDeclaration
Type:
int
[
]
boolean
Identifier
Type
::= 'int' ( '[' ']' )?
| 'boolean'
|
Identifier
referenced by:
ConstructorDeclaration
MethodDeclaration
VarDeclaration
Statement:
{
Statement
}
if
(
Expression
)
Statement
else
while
(
Expression
)
Statement
System.out.println
(
Expression
)
Identifier
[
Expression
]
=
Expression
;
Statement
::= '{'
Statement
* '}'
| ( 'if' '('
Expression
')'
Statement
'else' | 'while' '('
Expression
')' )
Statement
| ( 'System.out.println' '('
Expression
')' |
Identifier
( '['
Expression
']' )? '='
Expression
) ';'
referenced by:
ConstructorDeclaration
MainClass
MethodDeclaration
Statement
Expression:
Expression
&&
<
==
+
-
*
Expression
[
Expression
]
.
length
Identifier
(
Expression
,
)
Integer
true
false
Identifier
this
new
int
[
Expression
]
Identifier
(
)
!
Expression
(
Expression
)
Expression
::=
Expression
( ( '&&' | '<' | '==' | '+' | '-' | '*' )
Expression
| '['
Expression
']' | '.' ( 'length' |
Identifier
'(' (
Expression
( ','
Expression
)* )? ')' ) )
|
Integer
| 'true'
| 'false'
|
Identifier
| 'this'
| 'new' ( 'int' '['
Expression
']' |
Identifier
'(' ')' )
| '!'
Expression
| '('
Expression
')'
referenced by:
Expression
MethodDeclaration
Statement
Integer:
[0-9]
Integer
::= [0-9]+
referenced by:
Expression
Identifier:
[a-z]
[A-Z]
_
[a-z]
[A-Z]
[0-9]
_
Identifier
::= [a-zA-Z_] [a-zA-Z0-9_]*
referenced by:
ClassDeclaration
ConstructorDeclaration
Expression
MainClass
MethodDeclaration
Statement
Type
VarDeclaration
... generated by
Railroad Diagram Generator
R
R