Skip to content

Commit

Permalink
Better definition of comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
HansOlsson committed Dec 8, 2021
1 parent 23646e1 commit 6eadb38
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions chapters/lexicalstructure.tex
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,31 @@ \section{Comments}\label{comments}
The following comment variants are available:
%TODO-FORMAT should be a table instead of lstlisting?
\begin{lstlisting}[language=modelica]
// comment & Characters from // to the end of the line are ignored.
/* comment */ & Characters between /* and */ are ignored, including line terminators.
// Rest-of-line comment: Everything from // to the end of the line are ignored.
"Not part of comment"
/* Delimited comment: Characters after /* are ignored,
including line termination. The comment ends with */
\end{lstlisting}

\begin{nonnormative}
The comment syntax is identical to that of C++.
\end{nonnormative}

Modelica comments do not nest, i.e., /* */ cannot be embedded within /*
Delimited Modelica comments do not nest, i.e., /* */ cannot be embedded within /*
*/. The following is \emph{invalid}:
\begin{lstlisting}[language=modelica]
/* Commented out - erroneous comment, invalid nesting of comments!
/* This is an interesting model */
model interesting
$\ldots$
end interesting;
/* Invalid nesting of comments, the comment ends just before 'end'
model Interesting
/* To be done */
end Interesting;
*/
\end{lstlisting}
Rest-of-line comments can safely be used to comment out blocks of code without risk of conflict with comments inside.
\begin{lstlisting}[language=modelica]
//model Valid // Some other comment
// /* To be done */
//end Valid;
\end{lstlisting}

There is also a description-string, that is part of the Modelica language and
therefore not ignored by the Modelica translator. Such a description-string may
Expand Down

0 comments on commit 6eadb38

Please sign in to comment.