doc-src/IsarAdvanced/Codegen/Thy/document/Adaption.tex
changeset 28635 cc53d2ab0170
parent 28609 d8fdecb1ea00
child 28679 d7384e8e99b3
equal deleted inserted replaced
28634:764ef122a164 28635:cc53d2ab0170
   144   keywords which have to be avoided for generated code.
   144   keywords which have to be avoided for generated code.
   145   However, if you consider \isa{adaption} mechanisms, the code generated
   145   However, if you consider \isa{adaption} mechanisms, the code generated
   146   by the serializer is just the tip of the iceberg:
   146   by the serializer is just the tip of the iceberg:
   147 
   147 
   148   \begin{itemize}
   148   \begin{itemize}
   149     \item parametrise \isa{serialisation}
   149     \item \isa{serialisation} can be \emph{parametrised} such that
   150     \item \isa{library} \isa{reserved}
   150       logical entities are mapped to target-specific ones
   151     \item \isa{includes} \isa{reserved}
   151       (e.g. target-specific list syntax,
   152   \end{itemize}%
   152         see also \secref{sec:adaption_mechanisms})
   153 \end{isamarkuptext}%
   153     \item Such parametrisations can involve references to a
   154 \isamarkuptrue%
   154       target-specific standard \isa{library} (e.g. using
   155 %
   155       the \isa{Haskell} \verb|Maybe| type instead
   156 \isamarkupsubsection{Common adaption cases%
   156       of the \isa{HOL} \isa{option} type);
       
   157       if such are used, the corresponding identifiers
       
   158       (in our example, \verb|Maybe|, \verb|Nothing|
       
   159       and \verb|Just|) also have to be considered \isa{reserved}.
       
   160     \item Even more, the user can enrich the library of the
       
   161       target-language by providing code snippets
       
   162       (\qt{\isa{includes}}) which are prepended to
       
   163       any generated code (see \secref{sec:include});  this typically
       
   164       also involves further \isa{reserved} identifiers.
       
   165   \end{itemize}
       
   166 
       
   167   \noindent As figure \ref{fig:adaption} illustrates, all these adaption mechanisms
       
   168   have to act consistently;  it is at the discretion of the user
       
   169   to take care for this.%
       
   170 \end{isamarkuptext}%
       
   171 \isamarkuptrue%
       
   172 %
       
   173 \isamarkupsubsection{Common adaption patterns%
   157 }
   174 }
   158 \isamarkuptrue%
   175 \isamarkuptrue%
   159 %
   176 %
   160 \begin{isamarkuptext}%
   177 \begin{isamarkuptext}%
   161 The \hyperlink{theory.HOL}{\mbox{\isa{HOL}}} \hyperlink{theory.Main}{\mbox{\isa{Main}}} theory already provides a code
   178 The \hyperlink{theory.HOL}{\mbox{\isa{HOL}}} \hyperlink{theory.Main}{\mbox{\isa{Main}}} theory already provides a code
   198     strange effects may occur otherwise.
   215     strange effects may occur otherwise.
   199   \end{warn}%
   216   \end{warn}%
   200 \end{isamarkuptext}%
   217 \end{isamarkuptext}%
   201 \isamarkuptrue%
   218 \isamarkuptrue%
   202 %
   219 %
   203 \isamarkupsubsection{Adaption mechanisms \label{sec:adaption_mechanisms}%
   220 \isamarkupsubsection{Parametrising serialisation \label{sec:adaption_mechanisms}%
   204 }
   221 }
   205 \isamarkuptrue%
   222 \isamarkuptrue%
   206 %
   223 %
   207 \begin{isamarkuptext}%
   224 \begin{isamarkuptext}%
   208 Consider the following function and its corresponding
   225 Consider the following function and its corresponding
   603 %
   620 %
   604 \isadelimquotett
   621 \isadelimquotett
   605 %
   622 %
   606 \endisadelimquotett
   623 \endisadelimquotett
   607 %
   624 %
   608 \isamarkupsubsection{Enhancing the target language context%
   625 \isamarkupsubsection{Enhancing the target language context \label{sec:include}%
   609 }
   626 }
   610 \isamarkuptrue%
   627 \isamarkuptrue%
   611 %
   628 %
   612 \begin{isamarkuptext}%
   629 \begin{isamarkuptext}%
   613 In rare cases it is necessary to \emph{enrich} the context of a
   630 In rare cases it is necessary to \emph{enrich} the context of a