Note:

1.  '{ 'and '}' are metasymbols and not part of the language. { grammar_symbol} indicates zero
     or more occurrences of grammar_symbol.

2.  Comments are sequence of characters enclosed between /* and */, as in C.  Comments should
     be identified during lexical analysis and discarded.

3. Here are some of the predefined features that the implementation should support

        a. The types integer, real  and boolean.
        b. The functions
                     i. writeln and readln.
                    ii. succ and pred on enumerated types.
4.  If there are obvious bugs in the grammar, please let me know.


The grammar:
 

      <program>  ::= <block> .

      <block>  ::= <type definition part >
                            <variable declaration part>
                            <function declaration part>
                            <statement part>

      <type definition part>  ::= empty  |   type <type definition>  { <type definition> } ;

      <type definition>  ::= <identifier> = <type>

      <type> ::=  <simple type>  |  <structured type>

      <simple type> ::= <type identifier>

     <type identifier>  ::=  <identifier>

      <structured type>  ::=  <array type>

      <array type>  ::= array [<index type>  { <index type>}]  of <component type>

      <index type>  ::=  <integer constant> . . <integer constant>

      <component type>  ::=  <type>

      <variable declaration part>   ::=  empty  |  var <variable declaration>  { , <variable declaration> }  ;

      <variable declaration>  ::=  <identifier>  { ,  <identifier>} : <type>

      <function declaration part>  ::=   { <function declaration> ; }

      <formal parameter section>  ::=  <parameter group>  |  var <parameter group>

      <parameter group> ::=  <identifier>  { <identifier>}  : <type identifier>

      <function declaration>  ::=  <function heading>    <block>

      <function  heading>  ::= function   <identifier> : <result type> ;   |
                                                   function  <identifier> (< formal parameter section>  { ; <formal parameter section>}) : <result type>;

      <result type>  ::=  <type identifier>

      <statement part>  ::=    <compound statement>

      <compound statement>  ::=  begin  <statement>   { ; <statement> }   end

      <statement>   ::=  <compound statement>  |  <conditional statement>  |  <while statement>   |  <simple statement>

      <conditional statement>  ::=   if <expression> then <statement>  else  <statement>

      <while statement>   ::= while <expression> do<statement>

       <simple statement>  ::=  <assignment statement>  |  <return statement>

       <actual parameter>  ::=  <expression>

       <assignment statement>  ::=  <variable>  :=  <expression>  |

       < return statement> ::= return expression

       <variable>  ::=  <entire variable>  |  <component variable>

       <entire variable>  ::=  <identifier>

       <component variable>  ::= <indexed variable>

       <indexed variable>  ::=  <array variable>   <expression>  { , <expression> } ]

       <array variable>  ::= <identifier>

       <expression>  ::=  <simple expression> | <simple expression> <relational operator> <simple expression>

       <relational operator> := = | <> | | >  | <=  | >=

       <simple expression> ::=  <simple expression> <addition operator>  <term> |  <term>

       <addition operator> ::= +  |  -  |  or

       <term>  ::=  <term>   <multiplying  operator>  <factor>   |   <factor>

       <mutiplying operator>  ::=  *  |  /  |  and

       <factor>  ::=  -  <factor>    |   <variable>  |  <constant>   |  ( <expression> |  <function call>

       <function call>  ::=  <function identifier>  |  <function identifier> ( <actual parameter> { <actual parameter>})

       <constant> ::=  <integer constant>  |   <real constant>

       <integer constant>  ::=   define it yourself

       <string constant>  ::=   define it yourself

       <boolean constant>  ::=  true   |    false

       <real constant>  ::=   define it yourself

       <identifier>  ::=   define it yourself