Syntactic Specification - Backus-Naur Form (BNF) **
Free Practice Version
This is an "beta" version of a class activity in the course "Introduction to Computer Science" that includes a brief introduction to compilers, syntax and syntactic specification using BNF. The rules are as follows:
- Productions have the general form LHS ::= RHS
- Where the LHS can only be a single non-terminal
- Where the RHS is a set of alternatives (separated by the symbol | )
- Where each RHS element can be any string of no more than five terminals and non-terminals
- Where non-terminal names are always surrounded by < and >
- Where non-terminal names may be upper or lower case, but which are case sensitive
- Where terminals may be upper or lower case, but which are case sensitive
- Where concatenated terminal strings are treated as a single element
- Where spaces are treated as separators or punctation (space is not recognizable in this version)
- Where left recursion is not permitted
- Where alternatives in the same RHS commence with the same sub-string of terminals or non-terminals, the longer alternative must come first
- Where the first production is assumed to include the root symbol on the LHS
- Where ALL the definitions of a non-terminal must be included in a single production (i.e. no two productions can have the same LHS)
Procedure:
- Enter the syntax into the table below.
- Check the syntax for "syntactic" correctness by clicking on the CHECK SYNTAX button.
- Certain preferences for the format of the input strings are available - click SET PREFERENCES to set
- Thereafter you may test strings against this syntax by clicking the SUBMIT STRING button without having to check the syntax again. Where possible reasons for invalid strings will be given.
- The syntax may be modified at any time though it will be necessary to check the syntax again before a string is submitted.
** There was a discussion on the proper title for this methodology of specification at the 1978 History of Programming Languages Conference, it originally having been given the title Backus Normal Form, after John Backus the developer of FORTRAN and then the developer of this system for the language ALGOL. The first major use of the specification language was by Peter Naur, the secretary of the ALGOL committee and the author of the first ALGOL Report. Naur slightly extended the notation and thereafter it got the name Backus-Naur Form. Naur denies the attribution!
Last updated 2000/12/31
© J.A.N. Lee, 2000.