Contents | Prev | Next

20.1 Grammar notation

In this manual the syntax of the Irie Pascal language is described using a context-free grammar. Context-free grammars are often used to describe the syntax of programming languages because they produce short and precise definitions. A context-free grammar breaks the syntax of a complex language into a number of simpler elements called non-terminal symbols. The syntax of each non-terminal symbol is defined by a production. Each production consists of a non-terminal symbol followed by some sort of assignment operator, and then followed by a sequence of special symbols, terminal symbols and non-terminal symbols. The special symbols are used to describe how the other symbols can be combined. The terminals symbols are literal text that can occur in the language being defined. The full context-free grammar takes the form of a sequence of productions for all the non-terminal symbols in the language.

The context-free grammar used in this manual has the following notation. The equal sign (i.e. =) is used as the assignment operator in productions to separate the non-terminal symbol being defined from its definition. The special symbols are |, {}, [], and (). The | symbol is used to separate alternatives (i.e. the grammar allows either the symbols on its left-hand side or the symbols on its right-hand side). The {} symbols are used to enclose symbols that can appear zero, one, or more times. The [] symbols are used to enclose optional symbols (i.e. symbols that can appear zero or one time). The () symbols are used to group symbols that are evaluated together. The 'terminal symbols' appear in boldface and are enclosed in single quotation marks to distinguish them from non-terminal symbols. For example here are the productions that define the syntax for identifiers.

   identifier = letter { letter | digit }

   letter = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' |
               'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' |
               'u' | 'v' | 'w' | 'x' | 'y' | 'z' |
               '_'

   digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'

These productions mean: An identifier is a letter followed by zero or more letters or digits. A letter is one of the listed characters (i.e. a-z) or an underscore. A digit is one of the decimal numerals.

The complete grammar for Irie Pascal is given in here.

Contents | Prev | Next