Skip to content

Commit

Permalink
Define lexical unit PACKAGE-VERSION for contents of package version s…
Browse files Browse the repository at this point in the history
…tring

Addressing review comment by Elena.
  • Loading branch information
henrikt-ma committed Apr 14, 2022
1 parent a0b1ca0 commit 87b8f4a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
27 changes: 15 additions & 12 deletions chapters/annotations.tex
Expand Up @@ -1536,15 +1536,18 @@ \section{Versions}\label{annotations-for-version-handling}\label{versions}
\subsection{Version Numbering}\label{version-numbering}

Version numbers can be in one of several forms:
% The syntax highlighting gets confused by the quoted double quote below, making " PACKAGE-VERSION " be styled as a string literal.
% We should figure out a better way to do this, or tweak the syntax highlighting to give special treatment to """.
\begin{lstlisting}[language=grammar]
package-version :
""" ( main-version | pre-release-version | unordered-version ) """
PACKAGE-VERSION-STRING = """ PACKAGE-VERSION """

main-version : UNSIGNED-INTEGER { "." UNSIGNED-INTEGER }
PACKAGE-VERSION = MAIN-VERSION | PRE-RELEASE-VERSION | UNORDERED-VERSION

pre-release-version : UNSIGNED-INTEGER { "." UNSIGNED-INTEGER } " " { S-CHAR }
MAIN-VERSION = UNSIGNED-INTEGER { "." UNSIGNED-INTEGER }

unordered-version : NON-DIGIT { S-CHAR }
PRE-RELEASE-VERSION = UNSIGNED-INTEGER { "." UNSIGNED-INTEGER } " " { S-CHAR }

UNORDERED-VERSION = NON-DIGIT { S-CHAR }
\end{lstlisting}

Examples:
Expand All @@ -1567,7 +1570,7 @@ \subsection{Version Handling}\label{version-handling}

\begin{annotationdefinition}[version]
\begin{synopsis}[grammar]\begin{lstlisting}
"version" "=" package-version
"version" "=" PACKAGE-VERSION-STRING
\end{lstlisting}\end{synopsis}
\begin{semantics}
\lstinline!version = $\mathit{currentVersion}$! defines the version number of the model or package.
Expand All @@ -1581,12 +1584,12 @@ \subsection{Version Handling}\label{version-handling}

conversion : conversion-none | conversion-with-rules

conversion-none : "noneFromVersion" "=" package-version
conversion-none : "noneFromVersion" "=" PACKAGE-VERSION-STRING

conversion-with-rules :
"from" "("
"version" = package-versions
[ "," "to" "=" package-version ]
[ "," "to" "=" PACKAGE-VERSION-STRING ]
"," conversion-rules
")"

Expand All @@ -1597,8 +1600,8 @@ \subsection{Version Handling}\label{version-handling}
conversion-rule : STRING

package-versions :
package-version
| "{" package-version { "," package-version } "}"
PACKAGE-VERSION-STRING
| "{" PACKAGE-VERSION-STRING { "," PACKAGE-VERSION-STRING } "}"
\end{lstlisting}\end{synopsis}
\begin{semantics}
\lstinline!conversion(noneFromVersion = $\mathit{fromVersion}$)! defines that models and packages using the $\mathit{fromVersion}$ can be upgraded to the $\mathit{currentVersion}$ of the current class without any changes.
Expand All @@ -1619,7 +1622,7 @@ \subsection{Version Handling}\label{version-handling}

used-package :
IDENT "("
"version" "=" package-version
"version" "=" PACKAGE-VERSION-STRING
[ "," "versionBuild" "=" UNSIGNED-INTEGER ]
[ "," "dateModified" "=" STRING ]
")"
Expand Down Expand Up @@ -1899,7 +1902,7 @@ \subsubsection{Conversion Rules}\label{conversion-rules}

\subsection{Versions in the File System}\label{mapping-of-versions-to-file-system}\label{versions-in-the-File-System}

The top-level class $\mathit{packageName}$ with version $\mathit{packageVersion}$ can be stored in one of the following ways in a directory given in the \lstinline!MODELICAPATH! (\cref{the-modelica-library-path-modelicapath}):
The top-level class $\mathit{packageName}$ with version $\mathit{packageVersion}$ (matching \lstinline[language=grammar]!PACKAGE-VERSION! defined in \cref{version-numbering}) can be stored in one of the following ways in a directory given in the \lstinline!MODELICAPATH! (\cref{the-modelica-library-path-modelicapath}):
\begin{itemize}
\item
The file $\mathit{packageName}$\filename{.mo}\\
Expand Down
3 changes: 3 additions & 0 deletions chapters/syntax.tex
Expand Up @@ -19,6 +19,9 @@ \section{Lexical conventions}\label{lexical-conventions}

The following lexical units are defined:
% Beware that the first lines of the lexing rules below are duplicated in \cref{identifiers}, and must be kept in sync.
%
% The syntax highlighting gets confused by the quoted double quote below, making " PACKAGE-VERSION " be styled as a string literal.
% We should figure out a better way to do this, or tweak the syntax highlighting to give special treatment to """.
\begin{lstlisting}[language=grammar]
IDENT = NON-DIGIT { DIGIT | NON-DIGIT } | Q-IDENT
Q-IDENT = "'" { Q-CHAR | S-ESCAPE } "'"
Expand Down

0 comments on commit 87b8f4a

Please sign in to comment.