Links und Funktionen
Sprachumschaltung

Navigationspfad
Sie sind hier: Startseite / Lehre / WS 2014/15 / Compilerbau / Material / MiniJava-Grammatik


Inhaltsbereich

MiniJava-Grammatik

Goal ::= 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" "[" "]"

| "boolean"

| "int"

| Identifier
Statement ::= "{" ( Statement )* "}"

| "if" "(" Expression ")" Statement "else" Statement

| "while" "(" Expression ")" Statement

| "System.out.println" "(" Expression ")" ";"

| "System.out.print" "(" "(" "char" ")" Expression ")" ";"

| Identifier "=" Expression ";"

| Identifier "[" Expression "]" "=" Expression ";"
Expression ::= Expression ( "&&" | "<" | "+" | "-" | "*" | "/" ) Expression

| Expression "[" Expression "]"

| Expression "." "length"

| Expression "." Identifier "(" ( Expression ( "," Expression )* )? ")"

| <INTEGER_LITERAL>

| "true"

| "false"

| Identifier

| "this"

| "new" "int" "[" Expression "]"

| "new" Identifier "(" ")"

| "!" Expression

| "(" Expression ")"
Identifier ::= <IDENTIFIER>

Artikelaktionen


Funktionsleiste