Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chapters/lexicalstructure.tex
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ \subsection{Modelica Keywords}\label{modelica-keywords}
\end{center}

In particular, it is not allowed to declare an element or enumeration literal with these names.
This also applies to the identifiers that name the predefined types \lstinline!Real!, \lstinline!Integer!, \lstinline!Boolean!, and \lstinline!String!, see \cref{predefined-types-and-classes}.
This also applies to the identifiers that name the predefined types \lstinline!Real!, \lstinline!Integer!, \lstinline!Boolean!, and \lstinline!String!, see \cref{predefined-types-and-classes}, and the variable \lstinline!time!, see \cref{built-in-variable-time}.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is not the same "need" to treat time similar to Real, as there is only one trivial change needed in the grammar for time, whereas the builtin types would require a bit more. Hence, I think we should do time properly instead of expanding the non-keyword mess.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, as far as I can see it was not entirely trivial - and since tool grammars are unlikely to exactly match the grammar in the specification there's a risk that something was missed.


\begin{example}
Not all predefined types have names with restrictions:
Expand Down
1 change: 1 addition & 0 deletions chapters/operatorsandexpressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ \subsection{Built-in Variable time}\label{built-in-variable-time}\indexinline{ti

All declared variables are functions of the independent variable \lstinline!time!.
The variable \lstinline!time! is a built-in variable available in all models and blocks, which is treated as an input variable.
The name \lstinline!time! is reserved and may not declared in any class.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the plan in #1243 (comment) was to make it a keyword? That still sounds like the clean way to do it; just add it to primary in the grammar.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would be the alternative.

I see two minor issues:

  • I'm not sure we want it syntax highlighted as a keyword in the specification.
  • Describing its attributes (in particular its start-attribute - which may be useful for clocked semantics) becomes a bit messy, but by just stating that it corresponds to a variable defined as:... would likely work.

Copy link
Collaborator

@henrikt-ma henrikt-ma Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally prefer that time does not look like any other identifier.

This is what we have today:
time-current

This is with time as a morekeywords=[1] (next to true and false):
time-keyword

Stating that time references a built-in variable defined as… sounds like a good approach to me.

It is implicitly defined as:
\begin{lstlisting}[language=modelica]
input Real time (final quantity = "Time",
Expand Down