forked from modelica/ModelicaSpecification
/
B27_expressions.tex
105 lines (74 loc) · 2.27 KB
/
B27_expressions.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
\begin{lstlisting}[language=grammar]
expression :
simple-expression
| if expression then expression { elseif expression then expression }
else expression
simple-expression :
logical-expression [ ":" logical-expression [ ":" logical-expression ] ]
logical-expression :
logical-term { or logical-term }
logical-term :
logical-factor { and logical-factor }
logical-factor :
[ not ] relation
relation :
arithmetic-expression [ relational-operator arithmetic-expression ]
relational-operator :
"<" | "<=" | ">" | ">=" | "==" | "<>"
arithmetic-expression :
[ add-operator ] term { add-operator term }
add-operator :
"+" | "-" | ".+" | ".-"
term :
factor { mul-operator factor }
mul-operator :
"*" | "/" | ".*" | "./"
factor :
primary [ ("^" | ".^") primary ]
primary :
UNSIGNED-NUMBER
| STRING
| false
| true
| ( component-reference | der | initial | pure ) function-call-args
| component-reference
| "(" output-expression-list ")"
| "[" expression-list { ";" expression-list } "]"
| "{" array-arguments "}"
| end
type-specifier : ["."] name
name : IDENT { "." IDENT }
component-reference :
[ "." ] IDENT [ array-subscripts ] { "." IDENT [ array-subscripts ] }
function-call-args :
"(" [ function-arguments ] ")"
function-arguments :
expression [ "," function-arguments-non-first | for for-indices ]
| function name "(" [ named-arguments ] ")" [ "," function-arguments-non-first ]
| named-arguments
function-arguments-non-first :
function-argument [ "," function-arguments-non-first ]
| named-arguments
array-arguments :
expression [ "," array-arguments-non-first | for for-indices ]
array-arguments-non-first :
expression [ "," array-arguments-non-first ]
named-arguments: named-argument [ "," named-arguments ]
named-argument: IDENT "=" function-argument
function-argument :
function name "(" [ named-arguments ] ")" | expression
output-expression-list:
[ expression ] { "," [ expression ] }
expression-list :
expression { "," expression }
array-subscripts :
"[" subscript { "," subscript } "]"
subscript :
":" | expression
comment :
string-comment [ annotation-comment ]
string-comment :
[ STRING { "+" STRING } ]
annotation-comment :
annotation class-modification
\end{lstlisting}