forked from modelica/ModelicaSpecification
/
syntax.tex
84 lines (69 loc) · 3.5 KB
/
syntax.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
\chapter{Modelica Concrete Syntax}\doublelabel{modelica-concrete-syntax}
\section{Lexical conventions}\doublelabel{lexical-conventions}
The following syntactic meta symbols are used (extended BNF):
\begin{lstlisting}[language=grammar]
[ ] optional
{ } repeat zero or more times
| or
"text" The text is treated as a single token (no whitespace between any characters)
\end{lstlisting}
The following lexical units are defined (the ones in boldface are the
ones used in the grammar, the rest are just internal to the definition
of other lexical units):
\input{grammar/B1_lexical_conventions.g.tex}
\textrm{S-CHAR} is any member of the Unicode character set
(\url{http://www.unicode.org}; see \autoref{mapping-package-class-structures-to-a-hierarchical-file-system} for storing as UTF-8 on files) except double-quote """, and backslash "\textbackslash{}"
For identifiers the redundant escapes (\lstinline!'\?' and '\"'!) are the same as the corresponding non-escaped
variants (\lstinline!'?' and '"'!). {[}\emph{The single quotes are part of an
identifier. E.g. 'x' and x are different IDENTs}{]}.
Note:
\begin{itemize}
\item
Whitespace and comments can be used between separate lexical units
and/or symbols, and also separates them. Whitespace and comments
cannot be used inside other lexical units, except for STRING and
Q-IDENT where they are treated as part of the STRING or Q-IDENT
lexical unit.
\item
String constant concatenation \lstinline!"a" "b"! becoming \lstinline!"ab"! (as in C) is
replaced by the \lstinline!"+"! operator in Modelica.
\item
Modelica uses the same comment syntax as C++ and Java (i.e., \lstinline!//!
signals the start of a line comment and \lstinline!/*! .... \lstinline!*/! is a multi-line
comment); comments may contain any Unicode character. Modelica also
has structured comments in the form of annotations and string
comments.
\item
Description strings (= production ``string-comment'' in the grammar)
and strings in annotations (= STRING with production annotation-comment in the
grammar) may contain any member of the Unicode character set. All
other strings have to contain only the sub-set of Unicode characters
identical with the 7-bit US-ASCII character set. {[}\emph{As a
consequence, operators like ``\textgreater{}'' or ``\textless{}'', and
external functions only operate on ASCII strings and not on
Unicode-strings.} \emph{Within a description string the tags
\lstinline!<HTML>! and \lstinline!</HTML>! or
\lstinline!<html>! and \lstinline!</html>!
define optionally begin and end of content that is HTML encoded.}{]}
\item
Boldface denotes keywords of the Modelica language. Keywords are
reserved words and may not be used as identifiers.
\item
Productions use hyphen as separator both in the grammar and in the
text. Previously the grammar used underscore.
\end{itemize}
\section{Grammar}\doublelabel{grammar}
\subsection{Stored Definition -- Within}\doublelabel{stored-definition-within}
\input{grammar/B21_stored_definition.g.tex}
\subsection{Class Definition}\doublelabel{class-definition}
\input{grammar/B22_class_definition.g.tex}
\subsection{Extends}\doublelabel{extends}
\input{grammar/B23_extends.g.tex}
\subsection{Component Clause}\doublelabel{component-clause}
\input{grammar/B24_component_clause.g.tex}
\subsection{Modification}\doublelabel{modification}
\input{grammar/B25_modification.g.tex}
\subsection{Equations}\doublelabel{equations1}
\input{grammar/B26_equations.g}
\subsection{Expressions}\doublelabel{expressions1}
\input{grammar/B27_expressions.g}