Skip to content

Commit

Permalink
First attempt at environments for operator/function definitions, with…
Browse files Browse the repository at this point in the history
… application to 'previous'
  • Loading branch information
henrikt-ma committed Sep 10, 2020
1 parent afd8783 commit 53b3ebe
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
12 changes: 7 additions & 5 deletions chapters/synchronous.tex
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,16 @@ \section{Clocked State Variables}\label{clocked-state-variables}

The previous value of a clocked variable can be accessed with the \lstinline!previous! operator. A variable to which \lstinline!previous! has been applied is called a \firstuse{clocked state variable}.

\begin{longtable}[]{|l|p{12cm}|}
\hline \endhead
\lstinline!previous(u)! &
\begin{operatordefinition}[previous]
\begin{synopsis}\begin{lstlisting}[language=synopsis]
previous(u)
\end{lstlisting}\end{synopsis}
\begin{semantics}
The input argument is a \emph{component expression} (see \cref{argument-restrictions-component-expression}) or a parameter expression. The return argument has the same type as the input argument.
Input and return arguments are on the same clock. At the first tick of the clock of \lstinline!u! or after a reset transition (see \cref{reset-handling}), the start value of \lstinline!u! is
returned, see \cref{initialization-of-clocked-partitions}. At subsequent activations of the clock of \lstinline!u!, the value of \lstinline!u! from the previous clock activation is returned.\\
\hline
\end{longtable}
\end{semantics}
\end{operatordefinition}

\section{Partitioning Operators}\label{partitioning-operators}

Expand Down
34 changes: 34 additions & 0 deletions preamble.tex
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,33 @@
\newenvironment{definition}{\begin{definition@inner}}{\qed\end{definition@inner}}
\makeatother

\newtheoremstyle{modelicadefinition}
{\topsep} % ABOVESPACE
{\topsep} % BELOWSPACE
{} % BODYFONT
{} % INDENT (empty value is the same as 0pt)
{\bfseries} % HEADFONT
{\\} % HEADPUNCT
{.75em} % HEADSPACE
{#1~#2. \texttt{#3}} % CUSTOM-HEAD-SPEC
\theoremstyle{modelicadefinition}
\newtheorem{operatordefinition}{Operator}[chapter]
\crefname{operatordefinition}{operator}{operators}
\Crefname{operatordefinition}{Operator}{Operators}
\newtheorem{functiondefinition}{Function}[chapter]
\crefname{functiondefinition}{function}{functions}
\Crefname{functiondefinition}{Function}{Functions}

\newenvironment{synopsis}{%
~\vspace*{-\parskip}\par
}{%
}
\newenvironment{semantics}{%
\list{}{\setlength{\leftmargin}{1em}}\item[]%
}{%
\endlist
}

\setcounter{secnumdepth}{5}
% Note: Toc changed for appendex
\setcounter{tocdepth}{1}
Expand Down Expand Up @@ -217,6 +244,13 @@
basicstyle=\upshape\ttfamily, % Font size for inline code snippets.
}

\lstdefinelanguage{synopsis}[]{modelica}{% Language for use with the \lstinline command.
basicstyle=\upshape\ttfamily, % Same size as \lstinline
frame=none,
aboveskip=0pt,
xleftmargin=1em
}

% Note: within only a keyword in grammar
\lstdefinelanguage{grammar}{%
basicstyle=\upshape\small\ttfamily, % size of fonts used for the code
Expand Down

0 comments on commit 53b3ebe

Please sign in to comment.