Pipe-calculus: Difference between revisions

Line 105: Line 105:
\def\rule{ ::= ~}
\def\rule{ ::= ~}


\begin{alignat}{2}
\begin{alignat}{3}
& \mbox{Atoms}~        & a, b \rule & \mathsf{A} \mid \mathsf{B} \mid \mathsf{'foo} \mid \mathsf{'bar} \mid ... \\
& \mbox{Atoms}~        & a, b \rule & \mathsf{A} \mid \mathsf{B} \mid \mathsf{'foo} \mid \mathsf{'bar} \mid \mathsf{'+} \mid \mathsf{'*} \mid ... \\


& \mbox{Variables}~    & x, y \rule & \mathsf{a} \mid \mathsf{b} \mid ... \\
& \mbox{Variables}~    & x, y \rule & \mathsf{a} \mid \mathsf{b} \mid ... \\


& \mbox{Prefixes}~    & p, q \rule & a^+ \mid a^- \mid ~?x \mid ~!s \\
& \mbox{Prefixes}~    & p, q \rule  
        & ~ a^+             & & \text{Positive literal (signal)} \\
& & \mid & ~ a^-             & & \text{Negative literal (match)} \\
& & \mid & ~ ?x             & & \text{Abstraction (input)} \\
& & \mid & ~ !s             & & \text{Argument (output)} \\


& \mbox{Terms}~        & s, t \rule & ~
& \mbox{Terms}~        & s, t \rule
p . s
        & ~ p . s           & & \text{Prefix operator} \\
\mid s \seq t \mid \succeed
& & \mid & ~ s \seq t         & & \text{Sequential composition} \\
\mid s \mathsf{|} t \mid \fail
& & \mid & ~ s \mathsf{|} t   & & \text{Alternative composition} \\
\mid s \pipe t \mid \pass
& & \mid & ~ s \pipe t       & & \text{Pipe (interpretation)} \\
\mid x
& & \mid & ~ \succeed        & & \text{Successful termination} \\
\mid (s)
& & \mid & ~ \fail            & & \text{Failure} \\
& & \mid & ~ \pass           & & \text{Passive process} \\
& & \mid & ~ x               & & \text{Variable} \\
& & \mid & ~ (s)             & & \text{Grouping} \\
\end{alignat}
\end{alignat}
</math>
</math>
'''Atoms''' are unscoped symbols. We assume a countably infinite set of atoms that is disjunct from the set of constants (operators, keywords and punctuation).
There are two kinds of '''prefixes''', positive and negative literals. They can only occur on the left hand side of a prefix operator.
'''Sequential composition''' <math>\seq</math> constructs ordered pairs. The symbol <math>\succeed</math> denotes an empty sequence which can be interpreted as successful termination.
'''Alternative composition''' <math>\alt</math> connects a pair of alternatives. <math>\fail</math> denotes an empty set of alternatives, or intuitively failure to find any viable alternative.
The <math>\pipe</math> '''pipe''' operator constructs '''pipelines'''. Intuitively a pipeline is a transformer with unidirectional data flow.
<math>\pass</math> denotes a passive pipeline that transfers its input unchanged to the output.
For better readability, let's define some syntax sugar that will be used throughout this article. Extend the syntax of terms as follows.
<math>\mbox{Terms}~ s, t ::= ... \mid a \pto s \mid a \nto s \mbox{, where}</math>
<math>
\begin{alignat}{1}
~~~~ & a \pto s & = & ~\pos a \seq s \\
~~~~ & a \nto s & = & ~\neg a \seq s \\
\end{alignat}
</math>
We name the new operators '''positive arrow''' and '''negative arrow''' respectively.
When it is clear from context, we can call a negative arrow simply an arrow.
The precedence and associativity of operators is summarized in the following table.


{| class="wikitable"
{| class="wikitable"
|+ Summary of operators
|+ Operator summary
|-
|-
! style="text-align:left;"| Symbol
! style="text-align:left;"| Symbol
Line 156: Line 141:
! style="text-align:left;"| Precedence
! style="text-align:left;"| Precedence
|-
|-
| <math>\seq~\pto~\nto</math> || right || highest
| <math>\seq</math> || right || highest
|-
|-
| <math>\mid</math>           || right ||  
| <math>\mid</math> || right ||  
|-
|-
| <math>\rhd</math>           || right || lowest
| <math>\rhd</math> || right || lowest
|}
|}


283

edits