Skip to content

Commit

Permalink
Make mathescape=true by default
Browse files Browse the repository at this point in the history
This significantly reduces the clutter around all the \lstinline where math is used.
  • Loading branch information
henrikt-ma committed Jun 18, 2020
1 parent 59d768b commit 300ad90
Show file tree
Hide file tree
Showing 17 changed files with 226 additions and 225 deletions.
4 changes: 2 additions & 2 deletions chapters/annotations.tex
Expand Up @@ -1796,7 +1796,7 @@ \subsection{Version Date and Build Information}\doublelabel{version-date-and-bui
\end{lstlisting}

\begin{example}
\begin{lstlisting}[language=modelica]
\begin{lstlisting}[language=modelica,mathescape=false]
package Modelica
...
annotation(version = "3.0.1",
Expand Down Expand Up @@ -1912,7 +1912,7 @@ \section{Annotations for Access Control to Protect Intellectual Property}\double

In this section annotations are defined for protection and licensing. Obfuscation and encryption are not standardized.
Protection and licensing are both defined inside the \lstinline!Protection! annotation:
\begin{lstlisting}[language=modelica,mathescape=true]
\begin{lstlisting}[language=modelica]
annotation(Protection($\ldots$));
\end{lstlisting}

Expand Down
200 changes: 100 additions & 100 deletions chapters/arrays.tex

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions chapters/classes.tex
Expand Up @@ -864,11 +864,11 @@ \section{Specialized Classes}\doublelabel{specialized-classes}
record.
\begin{nonnormative}
A function declaration
\begin{lstlisting}[language=modelica,mathescape=true]
\begin{lstlisting}[language=modelica]
operator function foo $\ldots$ end foo;
\end{lstlisting}
is conceptually treated as
\begin{lstlisting}[language=modelica,mathescape=true]
\begin{lstlisting}[language=modelica]
operator foo function foo1
$\ldots$
end foo1; end foo;
Expand All @@ -885,7 +885,7 @@ \section{Specialized Classes}\doublelabel{specialized-classes}

\begin{example}
Use of \lstinline!operator!:
\begin{lstlisting}[language=modelica,mathescape=true]
\begin{lstlisting}[language=modelica]
operator record Complex
Real re;
Real im;
Expand Down
2 changes: 1 addition & 1 deletion chapters/connectors.tex
Expand Up @@ -9,7 +9,7 @@ \section{Connect-Equations and Connectors}\doublelabel{connect-equations-and-con

Connections between objects are introduced by connect-equations in the
equation part of a class. A connect-equation has the following syntax:
\begin{lstlisting}[language=modelica,mathescape=true]
\begin{lstlisting}[language=modelica]
connect(component-reference, component-reference);
\end{lstlisting}

Expand Down
4 changes: 2 additions & 2 deletions chapters/equations.tex
Expand Up @@ -754,7 +754,7 @@ \section{Initialization, initial equation, and initial algorithm}\doublelabel{in
(such as simulation or linearization). The equations of a
when-clause are active during initialization, if and only if they are
explicitly enabled with \lstinline!initial()!; and only in one of the
two forms \lstinline!when initial() then! or \lstinline[mathescape=true]!when {$\ldots$, initial(), $\ldots$} then!
two forms \lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then!
(and similarly for algorithms see below). In this case, the when-clause equations remain active during the
whole initialization phase. In case of a
\lstinline!reinit(x, expr)! being active during initialization (due to being inside
Expand All @@ -769,7 +769,7 @@ \section{Initialization, initial equation, and initial algorithm}\doublelabel{in

The algorithmic statements within a when-statement are active during initialization, if and only they are
explicitly enabled with \lstinline!initial()!; and only in one of the
two forms \lstinline!when initial() then! or \lstinline[mathescape=true]!when {$\ldots$, initial(), $\ldots$} then!.
two forms \lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then!.
In this case, the algorithmic statements within the when-statement remain active during the whole initialization phase.

\begin{nonnormative}
Expand Down
40 changes: 20 additions & 20 deletions chapters/functions.tex
Expand Up @@ -16,7 +16,7 @@ \section{Function Declaration}\doublelabel{function-declaration}
\begin{nonnormative}
The structure of a typical function declaration is sketched by
the following schematic function example:
\begin{lstlisting}[language=modelica,mathescape=true,escapechar=!]
\begin{lstlisting}[language=modelica,escapechar=!]
function !\emph{functionname}!
input TypeI1 in1;
input TypeI2 in2;
Expand Down Expand Up @@ -318,7 +318,7 @@ \section{Pure Modelica Functions}\doublelabel{pure-modelica-functions}
\item
a when-statement,
\item
\lstinline[mathescape=true]!pure(impureFunctionCall($\ldots$))! --- which allows calling impure
\lstinline!pure(impureFunctionCall($\ldots$))! --- which allows calling impure
functions in any pure context,
\item
in initial equations and initial algorithms,
Expand Down Expand Up @@ -684,7 +684,7 @@ \subsection{Output Formal Parameters of Functions}\doublelabel{output-formal-par
the equation or assignment shall contain a list of component references
within parentheses:

\lstinline[mathescape=true]!(out1, out2, out3) = f($\ldots$);!
\lstinline!(out1, out2, out3) = f($\ldots$);!

The component references are associated with the output components
according to their position in the list. Thus output component i is set
Expand Down Expand Up @@ -889,7 +889,7 @@ \subsection{Scalar Functions Applied to Array Arguments}\doublelabel{scalar-func
If the argument is not a foreach argument, it is used as-is.
\item
If the argument is a foreach argument, the element at index
\lstinline[mathescape=true]![i, $\ldots$, j]! is used.
\lstinline![i, $\ldots$, j]! is used.
\end{itemize}
\end{enumerate}

Expand Down Expand Up @@ -1596,7 +1596,7 @@ \section{Declaring Inverses of Functions}\doublelabel{declaring-inverses-of-func

Every function with one output formal parameter may have one or more
\lstinline!inverse! annotations to define inverses of this function:
\begin{lstlisting}[language=modelica,mathescape=true]
\begin{lstlisting}[language=modelica]
function $f_1$
input $A_1$ $u_1$;
...
Expand All @@ -1619,8 +1619,8 @@ \section{Declaring Inverses of Functions}\doublelabel{declaring-inverses-of-func
Several inverses are separated by commas.

\begin{nonnormative}
The inverse requires that for all valid values of the input arguments of \lstinline[mathescape=true]!$f_2$(..., y, ...)! and $u_k$ being calculated as \lstinline[mathescape=true]!$u_k$ := $f_2$(..., y, ...)! implies
the equality \lstinline[mathescape=true]!y = $f_1$(..., $u_k$, ...,)! up to a certain precision.
The inverse requires that for all valid values of the input arguments of \lstinline!$f_2$(..., y, ...)! and $u_k$ being calculated as \lstinline!$u_k$ := $f_2$(..., y, ...)! implies
the equality \lstinline!y = $f_1$(..., $u_k$, ...,)! up to a certain precision.
\end{nonnormative}

Function $f_1$ can have any number and types of formal
Expand Down Expand Up @@ -1884,14 +1884,14 @@ \subsubsection{Arrays}\doublelabel{arrays-1}
\tablehead{Modelica} & \tablehead{C}\\ \hline
& \tablehead{Input and Output}\\ \hline
\endhead
\lstinline[mathescape=true]!T[$\textit{dim}_{1}$]! &
\lstinline[mathescape=true,language=C]!T' *, size_t $\textit{dim}_{1}$!
\lstinline!T[$\textit{dim}_{1}$]! &
\lstinline[language=C]!T' *, size_t $\textit{dim}_{1}$!
\\ \hline
\lstinline[mathescape=true]!T[$\textit{dim}_{1}$, $\textit{dim}_{2}$]! &
\lstinline[mathescape=true,language=C]!T' *, size_t $\textit{dim}_{1}$, size_t$\textit{dim}_{2}$!
\lstinline!T[$\textit{dim}_{1}$, $\textit{dim}_{2}$]! &
\lstinline[language=C]!T' *, size_t $\textit{dim}_{1}$, size_t$\textit{dim}_{2}$!
\\ \hline
\lstinline[mathescape=true]!T[$\textit{dim}_{1}$, $\ldots$, $\textit{dim}_{n}$]! &
\lstinline[mathescape=true,language=C]!T' *, size_t $\textit{dim}_{1}$, $\ldots$, size_t $\textit{dim}_{n}$!
\lstinline!T[$\textit{dim}_{1}$, $\ldots$, $\textit{dim}_{n}$]! &
\lstinline[language=C]!T' *, size_t $\textit{dim}_{1}$, $\ldots$, size_t $\textit{dim}_{n}$!
\\ \hline
\end{longtable}

Expand All @@ -1908,14 +1908,14 @@ \subsubsection{Arrays}\doublelabel{arrays-1}
\tablehead{Modelica} & \tablehead{FORTRAN~77}\\ \hline
& \tablehead{Input and Output}\\ \hline
\endhead
\lstinline[mathescape=true]!T[$\textit{dim}_{1}$]! &
\lstinline[mathescape=true,language=FORTRAN77]!T', INTEGER $\textit{dim}_{1}$!
\lstinline!T[$\textit{dim}_{1}$]! &
\lstinline[language=FORTRAN77]!T', INTEGER $\textit{dim}_{1}$!
\\ \hline
\lstinline[mathescape=true]!T[$\textit{dim}_{1}$, $\textit{dim}_{2}$]! &
\lstinline[mathescape=true,language=FORTRAN77]!T', INTEGER $\textit{dim}_{1}$, INTEGER $\textit{dim}_{2}$!
\lstinline!T[$\textit{dim}_{1}$, $\textit{dim}_{2}$]! &
\lstinline[language=FORTRAN77]!T', INTEGER $\textit{dim}_{1}$, INTEGER $\textit{dim}_{2}$!
\\ \hline
\lstinline[mathescape=true]!T[$\textit{dim}_{1}$, $\ldots$, $\textit{dim}_{n}$]! &
\lstinline[mathescape=true,language=FORTRAN77]!T', INTEGER $\textit{dim}_{1}$, $\ldots$, INTEGER $\textit{dim}_{n}$!
\lstinline!T[$\textit{dim}_{1}$, $\ldots$, $\textit{dim}_{n}$]! &
\lstinline[language=FORTRAN77]!T', INTEGER $\textit{dim}_{1}$, $\ldots$, INTEGER $\textit{dim}_{n}$!
\\ \hline
\end{longtable}

Expand Down Expand Up @@ -2068,7 +2068,7 @@ \subsection{Return Type Mapping}\doublelabel{return-type-mapping}
\lstinline!Integer! & \lstinline!int! & \lstinline!INTEGER!\\ \hline
\lstinline!Boolean! & \lstinline!int! & \lstinline!LOGICAL!\\ \hline
\lstinline!String! & \lstinline!const char*! & Not allowed.\\ \hline
\lstinline[mathescape=true]!T[$\mathit{dim}_{1}$, $\ldots$, $\mathit{dim}_{n}$]! & Not allowed. & Not allowed.\\ \hline
\lstinline!T[$\mathit{dim}_{1}$, $\ldots$, $\mathit{dim}_{n}$]! & Not allowed. & Not allowed.\\ \hline
Enumeration type & \lstinline!int! & \lstinline!INTEGER!\\ \hline
Record & See \autoref{records}. & Not allowed.\\ \hline
\end{longtable}
Expand Down
6 changes: 3 additions & 3 deletions chapters/inheritance.tex
Expand Up @@ -685,12 +685,12 @@ \section{Redeclaration}\doublelabel{redeclaration}

\subsection{The class extends Redeclaration Mechanism}\doublelabel{the-class-extends-redeclaration-mechanism}

A class declaration of the type \lstinline[mathescape=true]!redeclare class extends B($\ldots$)! ,
A class declaration of the type \lstinline!redeclare class extends B($\ldots$)! ,
where \lstinline!class! as usual can be replaced by any other specialized class,
replaces the inherited class \lstinline!B! with another declaration that extends the
inherited class where the optional class-modification is applied to the
inherited class. Inherited \lstinline!B! here means that the class
containing \lstinline[mathescape=true]!redeclare class extends B($\ldots$)! should also inherit
containing \lstinline!redeclare class extends B($\ldots$)! should also inherit
another declaration of \lstinline!B! from one of its extends-clauses. The new
declaration should explicitly include redeclare.

Expand All @@ -699,7 +699,7 @@ \subsection{The class extends Redeclaration Mechanism}\doublelabel{the-class-ext
to apply modifiers to the new declaration.
\end{nonnormative}

For \lstinline[mathescape=true]!redeclare class extends B($\ldots$)! the inherited class is subject
For \lstinline!redeclare class extends B($\ldots$)! the inherited class is subject
to the same restrictions as a redeclare of the inherited element, and
the original class \lstinline!B! should be replaceable, and the new element is only
replaceable if the new definition is replaceable. In contrast to normal
Expand Down
2 changes: 1 addition & 1 deletion chapters/lexicalstructure.tex
Expand Up @@ -87,7 +87,7 @@ \subsection{Identifiers}\doublelabel{identifiers}
A full BNF definition of the Modelica syntax and
lexical units is available in \autoref{modelica-concrete-syntax}.

\begin{lstlisting}[language=grammar]
\begin{lstlisting}[language=grammar,mathescape=false]
IDENT = NONDIGIT { DIGIT | NONDIGIT } | Q-IDENT
Q-IDENT = "'" { Q-CHAR | S-ESCAPE | """ } "'"
NONDIGIT = "_" | letters "a" ... "z" | letters "A" ... "Z"
Expand Down
28 changes: 14 additions & 14 deletions chapters/operatorsandexpressions.tex
Expand Up @@ -55,11 +55,11 @@ \section{Operator Precedence and Associativity}\doublelabel{operator-precedence-
\tablehead{Operator Group} & \tablehead{Operator Syntax} & \tablehead{Examples}\\ \hline
postfix array index operator & \lstinline![]! & \lstinline!arr[index]! \\ \hline
postfix access operator & \lstinline!.! & \lstinline!a.b! \\ \hline
postfix function call & \lstinline[mathescape=true]!$\mathit{funcName}$($\mathit{functionArguments}$)! & \lstinline!sin(4.36)! \\ \hline
postfix function call & \lstinline!$\mathit{funcName}$($\mathit{functionArguments}$)! & \lstinline!sin(4.36)! \\ \hline
array construct/concat & \begin{tabular}{@{}p{5cm}@{}}
\lstinline[mathescape=true]!{$\mathit{expressions}$}!\\
\lstinline[mathescape=true]![$\mathit{expressions}$]!\\
\lstinline[mathescape=true]![$\mathit{expressions}$; $\mathit{expressions}\ldots$]!
\lstinline!{$\mathit{expressions}$}!\\
\lstinline![$\mathit{expressions}$]!\\
\lstinline![$\mathit{expressions}$; $\mathit{expressions}\ldots$]!
\end{tabular} & \begin{tabular}{@{}p{5cm}@{}}
\lstinline!{2,3}! \\
\lstinline![5,6]! \\
Expand All @@ -70,21 +70,21 @@ \section{Operator Precedence and Associativity}\doublelabel{operator-precedence-
\lstinline!2*3!, \lstinline!2/3! \\
\lstinline![1,2;3,4].*[2,3;5,6]!
\end{tabular} \\ \hline
additive and array elementwise additive & \lstinline[mathescape=true]!+ - +$\mathit{expr}$ -$\mathit{expr}$ .+ .-! & \lstinline![1,2;3,4].+[2,3;5,6]!\\ \hline
additive and array elementwise additive & \lstinline!+ - +$\mathit{expr}$ -$\mathit{expr}$ .+ .-! & \lstinline![1,2;3,4].+[2,3;5,6]!\\ \hline
relational & \lstinline!< <= > >= == <>! &
\lstinline!a<b!, \lstinline!a<=b!, \lstinline!a>b!, \ldots\\ \hline
unary negation & \lstinline[mathescape=true]!not $\mathit{expr}$! & \lstinline!not b1! \\ \hline
unary negation & \lstinline!not $\mathit{expr}$! & \lstinline!not b1! \\ \hline
logical and & \lstinline!and! & \lstinline!b1 and b2! \\ \hline
logical or & \lstinline!or! & \lstinline!b1 or b2!\\ \hline
array range & \begin{tabular}{@{}p{5cm}@{}}
\lstinline[mathescape=true]!$\mathit{expr}$ : $\mathit{expr}$! \\
\lstinline[mathescape=true]!$\mathit{expr}$ : $\mathit{expr}$ : $\mathit{expr}$!
\lstinline!$\mathit{expr}$ : $\mathit{expr}$! \\
\lstinline!$\mathit{expr}$ : $\mathit{expr}$ : $\mathit{expr}$!
\end{tabular} & \begin{tabular}{@{}p{5cm}@{}}
\lstinline!1:5! \\
\lstinline!start:step:stop!
\end{tabular} \\ \hline
conditional & \lstinline[mathescape=true]!if $\mathit{expr}$ then $\mathit{expr}$ else $\mathit{expr}$! & \lstinline!if b then 3 else x!\\ \hline
named argument & \lstinline[mathescape=true]!$\mathit{ident}$ = $\mathit{expr}$! & \lstinline!x = 2.26!\\ \hline
conditional & \lstinline!if $\mathit{expr}$ then $\mathit{expr}$ else $\mathit{expr}$! & \lstinline!if b then 3 else x!\\ \hline
named argument & \lstinline!$\mathit{ident}$ = $\mathit{expr}$! & \lstinline!x = 2.26!\\ \hline
\end{tabular}
\end{table}

Expand Down Expand Up @@ -270,11 +270,11 @@ \subsection{String Concatenation}\doublelabel{string-concatenation}

\subsection{Array Constructor Operator}\doublelabel{array-constructor-operator}

The array constructor operator \lstinline[mathescape=true]!{ $\ldots$ }! is described in \autoref{vector-matrix-and-array-constructors}.
The array constructor operator \lstinline!{ $\ldots$ }! is described in \autoref{vector-matrix-and-array-constructors}.

\subsection{Array Concatenation Operator}\doublelabel{array-concatenation-operator}

The array concatenation operator \lstinline[mathescape=true]![ $\ldots$ ]! is described in \autoref{array-concatenation}.
The array concatenation operator \lstinline![ $\ldots$ ]! is described in \autoref{array-concatenation}.

\subsection{Array Range Operator}\doublelabel{array-range-operator}

Expand Down Expand Up @@ -891,7 +891,7 @@ \subsubsection{homotopy}\doublelabel{homotopy}
over the whole model, and not several homotopy iterations over the
respective non-linear algebraic equation systems. The reason is that the
following structure can be present:
\begin{lstlisting}[language=modelica, mathescape=true]
\begin{lstlisting}[language=modelica]
w = $f_1$(x) // has homotopy
0 = $f_2$(der(x), x, z, w)
\end{lstlisting}
Expand Down Expand Up @@ -1024,7 +1024,7 @@ \subsubsection{semiLinear}\doublelabel{semilinear}
...
\end{lstlisting}
may be replaced by
\begin{lstlisting}[language=modelica, mathescape=true]
\begin{lstlisting}[language=modelica]
s1 = if x >= 0 then sa else sb
s2 = s1;
s3 = s2;
Expand Down

0 comments on commit 300ad90

Please sign in to comment.