Mid-semester Project - BNF for SLAT and Java


SLAT Concrete and Abstract Syntax

SLAT Concrete Syntax (terminals are red) SLAT Abstract Syntax
<declaration>      ::= <name> ::= <production-list> slat-decl( name slat-prod-lst )
<production-list>  ::= <production> { | <production> }*  
<production>       ::= <name> ( <fieldlist> ) slat-prod( name fields )
<fieldlist>        ::= { <name> }*  

Java Concrete and Abstract Syntax

Since you will be writing a program that generates abstract syntax for Java, you need to have a good understanding of the abstract syntax and how it relates to the structure of a Java program.  As you know, the abstract syntax for a language follows the BNF, but leaves out concrete features such as order, terminals, etc.  The following will present the BNF for a subset of Java (sufficient to do both parts of the project) along with the abstract syntax.

Java Concrete Syntax (terminals are red) Java Abstract Syntax
<modifier>           ::= public | abstract
 
<declaration-list>   ::= { <declaration> }*
 
<declaration>        ::= <modifier-list> <declaration-type>
java-decl( modifiers decl-type )
<modifier-list>      ::= { <modifier> }*
 
<declaration-type>   ::= <var-declaration> ;
                       | <method-declaration>
                       | <class-declaration>
 
<var-declaration>    ::= <type> <identifier>
java-var( type name )
<method-declaration> ::= <method-heading> {
                             <statement-list>
                         }
java-method( head body )
<method-heading>     ::= [<type>] <identifier> ( [<parameter-list>] )
java-m-head( type name params )
<parameter-list>     ::= <var-declaration> { , <var-declaration> }*
 
<statement-list>     ::= { <statement> }*
 
<statement>          ::= <declaration>
                       | <assignment>
 
<class-declaration>  ::= <class-heading> {
                             <declaration-list>
                         }
java-class( head body )
<class-heading>      ::= class <identifier> [extends <identifier>]
java-c-head( name base )
<assignment>         ::= <l-value> = <r-value> ;
java-assign( l-val r-val )
<l-value>            ::= <identifier>
                       | <compound-variable>
 
<r-value>            ::= <identifier>
                       | <compound-variable>
 
<compund-variable>   ::= <identifier>.<identifier>
java-compound( name field )