Module pylilac.Symbol
An interface to build expressions in the Backus-Naur form (BNF), used
as right hand symbols in the rules of a Grammar
.
Hierarchy
The classes in this module follow this hierarchy:
<pre class="base-tree">
<a href="../private/pylilac.Symbol._Symbol-class.html"><code>_Symbol</code></a> --+
|
<a href="../private/pylilac.Symbol._Aggregation-class.html"><code>_Aggregation</code></a> --+
|
<b>Alternation</b>
</pre><br />
_Symbol --+
|
+------Terminal-----+
| |
| +--_Epsilon
|
+---NonTerminal
|
+--_Aggregation-----+
|
+--Concatenation
|
+----Alternation
Supported operations
Over the set Σ of possible BNF
expressions, two operations are defined:
-
concatenation (+), for example: A + B ≡ AB
-
alternation (|) o choice, for example: A | B
Σ has the following properties:
-
Closure of Σ under | and +
-
For all a, b belonging to Σ,
both a | b and a + b belong to Σ
(or more formally, | and + are binary operations on Σ).
-
Both | and + are
associative
-
For all a, b, c in Σ, a | (b |
c) = (a | b) | c and a + (b + c) = (a + b) + c.
-
Both | is commutative
-
For all a, b belonging to Σ a |
b = b | a.
-
The operation + is distributive over the
operation |
-
For all a, b, c, belonging to Σ,
a + (b | c) = (a + b) | (a + c).
-
Idempotence respect to |
-
For all a belonging to Σ, a | a
= a.
-
Existence of a multiplicative or juxtapositive (i.e. for +) identity
-
There exists an element ε in
Σ, such that for all a belonging to
Σ, a + ε = a.
To Do: _kleene() function and * operator (rank 3)