Commit 22687bec authored by erwan's avatar erwan

Doc: add a section describing quickly the use of 'nor', '#', and n-ary xor

parent ec5a638d
...@@ -631,6 +631,30 @@ declare in the combinator profile that it is a reference using the ...@@ -631,6 +631,30 @@ declare in the combinator profile that it is a reference using the
Another example of the use of reference variables is given in Another example of the use of reference variables is given in
Section~\ref{up-and-down}. Section~\ref{up-and-down}.
\subsubsection{Pre-defined combinators: nor, xor, and \#}
\label{Pre-defined-combinators}
Some useful combinators are predefined to state that, among a list of
Boolean expressions:
\begin{itemize}
\item none is true (\key{not})
\item exactly one is true (\key{xor})
\item exactly zero or one is true (\key{\#})
\end{itemize}
\begin{example}
\begin{program}
\key{node} N() \key{returns} (\key{x,y,t}:bool) = \\
\{ \\
| \key{nor}(x,y,z) or \key{xor}(x,y,z) \\
| \#(x,y,t) -- actually equivalent to the previous line\\
\}
\end{program}
\end{example}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Calling external code} \subsection{Calling external code}
......
...@@ -57,7 +57,10 @@ TK_OPEN_PAR ( ...@@ -57,7 +57,10 @@ TK_OPEN_PAR (
TK_CLOSE_PAR ) TK_CLOSE_PAR )
TK_NOT not TK_NOT not
TK_OR or TK_OR or
TK_NOR nor
TK_XOR xor TK_XOR xor
TK_NXOR xor
TK_DIESE #
TK_AND and TK_AND and
TK_IMPL => TK_IMPL =>
TK_ARROW -> TK_ARROW ->
......
...@@ -875,7 +875,7 @@ lutBinExp: ...@@ -875,7 +875,7 @@ lutBinExp:
| lutExp TK_LTE lutExp { make_val_exp (CALL_n (flagit "lte" $2, [$1;$3])) $2 } | lutExp TK_LTE lutExp { make_val_exp (CALL_n (flagit "lte" $2, [$1;$3])) $2 }
| lutExp TK_GT lutExp { make_val_exp (CALL_n (flagit "gt" $2, [$1;$3])) $2 } | lutExp TK_GT lutExp { make_val_exp (CALL_n (flagit "gt" $2, [$1;$3])) $2 }
| lutExp TK_GTE lutExp { make_val_exp (CALL_n (flagit "gte" $2, [$1;$3])) $2 } | lutExp TK_GTE lutExp { make_val_exp (CALL_n (flagit "gte" $2, [$1;$3])) $2 }
;
lutNaryExp: lutNaryExp:
/* n-ary */ /* n-ary */
| TK_DIESE TK_OPEN_PAR lutExpList TK_CLOSE_PAR | TK_DIESE TK_OPEN_PAR lutExpList TK_CLOSE_PAR
...@@ -884,7 +884,7 @@ lutNaryExp: ...@@ -884,7 +884,7 @@ lutNaryExp:
{ make_val_exp (CALL_n (flagit "nor" $1, (List.rev $3))) $1 } { make_val_exp (CALL_n (flagit "nor" $1, (List.rev $3))) $1 }
| TK_XOR TK_OPEN_PAR lutExpList TK_CLOSE_PAR | TK_XOR TK_OPEN_PAR lutExpList TK_CLOSE_PAR
{ make_val_exp (CALL_n (flagit "nxor" $1, (List.rev $3))) $1 } { make_val_exp (CALL_n (flagit "nxor" $1, (List.rev $3))) $1 }
;
lutExpList: lutExpList:
/* empty */ /* empty */
{ [] } { [] }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment