<refentry id="productionset.element" revision='EBNF'>
<?dbhtml filename="productionset.html"?>
<refentryinfo>
<pubdate>$Date$</pubdate>
<releaseinfo>$Revision$</releaseinfo>
</refentryinfo>

<refmeta>
<indexterm><primary>elements</primary>
<secondary>productionset</secondary></indexterm>
<refentrytitle>productionset</refentrytitle>
<refmiscinfo>Element</refmiscinfo>
</refmeta>
<refnamediv>
<refname>productionset</refname>
<refpurpose>&productionset.purpose;</refpurpose>
</refnamediv>

&productionset.synopsis.gen;
<refsect1 condition='ref.description'><title>Description</title>

<para>This element is only available if you are using the
<link linkend="ebnf.module">EBNF Module</link>.</para>

<para>A <sgmltag>ProductionSet</sgmltag> is a collection of
<glossterm>Extended Backus-Naur Form</glossterm> (EBNF)
<sgmltag>Production</sgmltag>s.</para>

<para>EBNF is a notation for describing the grammar of context-free
languages. Even if you aren't conversant in the programming language
concepts of context-free languages and grammars, it's not really
as hard to understand as it sounds.</para>

<para>A set of EBNF productions describes the legal arrangements of
tokens in a language. Consider arithmetic expressions as a simple
example.</para>

<para>The expression
<quote><literal>3 + 4</literal></quote>
is valid and so is
<quote><literal>3 + 4 - 5</literal></quote>, but
<quote><literal>3 - + - 4</literal></quote> is not, nor is
<quote><literal>3 + 4 6</literal></quote>. We can use EBNF to
describe all the possible legal arrangements:</para>

<productionset><title>Arithemetic Expressions</title>
<production id="ebnf.expression">
  <lhs>Expression</lhs>
  <rhs><nonterminal def="ebnf.arith">ArithExpression</nonterminal> |
       <nonterminal def="ebnf.mult">MultExpression</nonterminal>
  <lineannotation>Does this grammar actually get precedence right?
  </lineannotation>
  </rhs>
</production>
<production id="ebnf.arith">
  <lhs>ArithExpression</lhs>
  <rhs><nonterminal def="ebnf.expression">Expression</nonterminal>
       '+'
       <nonterminal def="ebnf.mult">MultExpression</nonterminal> |
       <nonterminal def="ebnf.expression">Expression</nonterminal>
       '-'
       <nonterminal def="ebnf.mult">MultExpression</nonterminal>
  </rhs>
</production>
<production id="ebnf.mult">
  <lhs>MultExpression</lhs>
  <rhs><nonterminal def="ebnf.mult">MultExpression</nonterminal>
       '*'
       <nonterminal def="ebnf.mult">MultExpression</nonterminal> |
       <nonterminal def="ebnf.mult">MultExpression</nonterminal>
       '/'
       <nonterminal def="ebnf.mult">MultExpression</nonterminal> |
       <nonterminal def="ebnf.number">Number</nonterminal>
  </rhs>
  <constraint linkend="div0"/>
</production>
<production id="ebnf.number">
  <lhs>Number</lhs>
  <rhs>[0-9]+</rhs>
</production>
</productionset>

<constraintdef id="div0" role="Err">
<title>Division by Zero</title>
<para>Division by zero is an error. Constraints, such as this one,
are used to express conditions that cannot be expressed in the grammar.</para>
</constraintdef>

<refsect2><title>Processing expectations</title>
<para>
&format.block; The detailed processing expecations with respect to
individual productions, left-hand sides, and right-hand sides are quite
complex.
</para>
<para><sgmltag>Production</sgmltag>s should be numbered.</para>
</refsect2>


&productionset.parents.gen;
&productionset.children.gen;
</refsect1>
<refsect1><title>Examples</title>

<informalexample role="example-source">
<programlisting>&productionset.example.1.txt;</programlisting>
</informalexample>

&productionset.example.seealso.gen;
</refsect1>
</refentry>

