Links und Funktionen
Sprachumschaltung

Navigationspfad
Sie sind hier: Startseite / Lehre / WS 2011/12 / Compilerbau / minijava-grammar.html


Inhaltsbereich

minijava-grammar.html

HTML icon minijava-grammar.html — HTML, 6 KB (6984 bytes)

Dateiinhalt

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!-- saved from url=(0065)http://www.cambridge.org/resources/052182060X/MCIIJ2e/grammar.htm -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>BNF for MiniJava</title>

</head>
<body bgcolor="#FFFFFF" link="#0000EE" vlink="#0000EE">
<h1 align="CENTER">BNF for MiniJava</h1>
<h2 align="CENTER">NON-TERMINALS</h2>
<table>
<tbody><tr>
<td align="RIGHT" valign="BASELINE"><a name="prod1">Goal</a></td>
<td align="CENTER" valign="BASELINE">::=</td>
<td align="LEFT" valign="BASELINE"><a href="#prod2">MainClass</a> ( <a href="#prod3">ClassDeclaration</a> )* &lt;EOF&gt;</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"><a name="prod2">MainClass</a></td>
<td align="CENTER" valign="BASELINE">::=</td>
<td align="LEFT" valign="BASELINE">"class" <a href="#prod4">Identifier</a> "{" "public" "static" "void" "main" "(" "String" "[" "]" <a href="#prod4">Identifier</a> ")" "{" <a href="#prod5">Statement</a> "}" "}"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"><a name="prod3">ClassDeclaration</a></td>
<td align="CENTER" valign="BASELINE">::=</td>
<td align="LEFT" valign="BASELINE">"class" <a href="#prod4">Identifier</a> ( "extends" <a href="#prod4">Identifier</a> )? "{" ( <a href="#prod6">VarDeclaration</a> )* ( <a href="#prod7">MethodDeclaration</a> )* "}"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"><a name="prod6">VarDeclaration</a></td>
<td align="CENTER" valign="BASELINE">::=</td>
<td align="LEFT" valign="BASELINE"><a href="#prod8">Type</a> <a href="#prod4">Identifier</a> ";"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"><a name="prod7">MethodDeclaration</a></td>
<td align="CENTER" valign="BASELINE">::=</td>
<td align="LEFT" valign="BASELINE">"public" <a href="#prod8">Type</a> <a href="#prod4">Identifier</a> "(" ( <a href="#prod8">Type</a> <a href="#prod4">Identifier</a> ( "," <a href="#prod8">Type</a> <a href="#prod4">Identifier</a> )* )? ")" "{" ( <a href="#prod6">VarDeclaration</a> )* ( <a href="#prod5">Statement</a> )* "return" <a href="#prod9">Expression</a> ";" "}"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"><a name="prod8">Type</a></td>
<td align="CENTER" valign="BASELINE">::=</td>
<td align="LEFT" valign="BASELINE">"int" "[" "]"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE">"boolean"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE">"int"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE"><a href="#prod4">Identifier</a></td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"><a name="prod5">Statement</a></td>
<td align="CENTER" valign="BASELINE">::=</td>
<td align="LEFT" valign="BASELINE">"{" ( <a href="#prod5">Statement</a> )* "}"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE">"if" "(" <a href="#prod9">Expression</a> ")" <a href="#prod5">Statement</a> "else" <a href="#prod5">Statement</a></td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE">"while" "(" <a href="#prod9">Expression</a> ")" <a href="#prod5">Statement</a></td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE">"System.out.println" "(" <a href="#prod9">Expression</a> ")" ";"</td>
</tr>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE">"System.out.print" "(" "(" "char" ")" <a href="#prod9">Expression</a> ")" ";"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE"><a href="#prod4">Identifier</a> "=" <a href="#prod9">Expression</a> ";"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE"><a href="#prod4">Identifier</a> "[" <a href="#prod9">Expression</a> "]" "=" <a href="#prod9">Expression</a> ";"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"><a name="prod9">Expression</a></td>
<td align="CENTER" valign="BASELINE">::=</td>
<td align="LEFT" valign="BASELINE"><a href="#prod9">Expression</a> ( "&amp;&amp;" | "&lt;" | "+" | "-" | "*" | "/" ) <a href="#prod9">Expression</a></td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE"><a href="#prod9">Expression</a> "[" <a href="#prod9">Expression</a> "]"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE"><a href="#prod9">Expression</a> "." "length"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE"><a href="#prod9">Expression</a> "." <a href="#prod4">Identifier</a> "(" ( <a href="#prod9">Expression</a> ( "," <a href="#prod9">Expression</a> )* )? ")"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE">&lt;INTEGER_LITERAL&gt;</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE">"true"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE">"false"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE"><a href="#prod4">Identifier</a></td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE">"this"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE">"new" "int" "[" <a href="#prod9">Expression</a> "]"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE">"new" <a href="#prod4">Identifier</a> "(" ")"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE">"!" <a href="#prod9">Expression</a></td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"></td>
<td align="CENTER" valign="BASELINE">|</td>
<td align="LEFT" valign="BASELINE">"(" <a href="#prod9">Expression</a> ")"</td>
</tr>
<tr>
<td align="RIGHT" valign="BASELINE"><a name="prod4">Identifier</a></td>
<td align="CENTER" valign="BASELINE">::=</td>
<td align="LEFT" valign="BASELINE">&lt;IDENTIFIER&gt;</td>
</tr>
</tbody></table>


</body></html>

Artikelaktionen


Funktionsleiste