BNF grammar definition
of the Programming CD




For the benefit of the people accustomed to BNF grammars, we give here a BNF definition of the objects defined by the Programming CD. The tokens not defined here are taken from the Basic CD. (The * and + postfix unary operators are understood to have their usual meanings)

TopLevel :: Declaration( DeclSequence ) |
            TypeDeclaration( DeclSequence ) |
            Function( symbol, Parameters, TypeDeclaration,
                Statement ) |
            Procedure( symbol, Parameters, Statement ) |
            Program( symbol, Statement );

DeclSequence :: NameSequence = TypeDeclaration |
                DeclSequence, NameSequence = TypeDeclaration;

NameSequence :: symbol | [symbol*];

Parameters :: Params( DeclSequence );

TypeDeclaration :: TypeToken | [TypeToken*];

Statement :: Assign( Name, BasicOMobject ) |
             Block( Statement* ) |
             Comment( string ) |
             Declaration( DeclSequence ) |
             Error( BasicOMobject* ) |
             ForLoop( Name, BasicOMobject, BasicOMobject,
                BasicOMobject, Statement ) |
             ForWhile( Statement, BasicOMobject, Statement,
                Statement ) |
             If( BasicOMobject, Statement ) |
             If( BasicOMobject, Statement, Statement ) |
             Return |
             Return( BasicOMobject ) |
             BasicOMobject ;

TypeToken :: Local | Global |
             Integer | Float | Char | Type( BasicOMobject ) |
             Long | Short |
             Constant( BasicOMobject ) |
             Array( BasicOMobject+, TypeToken ) |
             Record( DeclSequence ) ;

Name :: symbol | symbol[ BasicOMobject* ] ;