Syntax definition
. Context free grammars
- a set of tokens (terminal symbols)
- a set of non terminal symbols
- a set of productions of the form
nonterminal String of terminals & non terminals
- a start symbol
<T, N, P, S>
. A grammar derives strings by beginning with a start symbol and repeatedly replacing a non terminal by the right hand side of a production for that non terminal.
. The strings that can be derived from the start symbol of a grammar G form the language L(G) defined by the grammar.
In this section, we review the definition of a context free grammar and introduce terminology for talking about parsing. A context free grammar has four components:
-
A set of tokens , known as terminal symbols. Terminals are the basic symbols from which strings are formed.
- A set of non-terminals . Non-terminals are syntactic variables that denote sets of strings. The non-terminals define sets of strings that help define the language generated by the grammar.
-
A set of productions . The productions of a grammar specify the manner in which the terminals and non-terminals can be combined to form strings. Each production consists of a non-terminal called the left side of the production, an arrow, and a sequence of tokens and/or on- terminals, called the right side of the production.
-
A designation of one of the non-terminals as the start symbol , and the set of strings it denotes is the language defined by the grammar.
The strings are derived from the start symbol by repeatedly replacing a non-terminal (initially the start symbol) by the right hand side of a production for that non-terminal.
|