1 | /* |
---|
2 | Copyright (C) 2009 Modelon AB |
---|
3 | |
---|
4 | This program is free software: you can redistribute it and/or modify |
---|
5 | it under the terms of the GNU General Public License as published by |
---|
6 | the Free Software Foundation, version 3 of the License. |
---|
7 | |
---|
8 | This program is distributed in the hope that it will be useful, |
---|
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | GNU General Public License for more details. |
---|
12 | |
---|
13 | You should have received a copy of the GNU General Public License |
---|
14 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
15 | */ |
---|
16 | |
---|
17 | |
---|
18 | /** |
---|
19 | * \mainpage API documentation of the JModelica.org Modelica Front-end |
---|
20 | * |
---|
21 | * The API documentation of the Modelica %compiler front-end is yet rudimentary. |
---|
22 | * Also, the APIs for the Java classes contains several methods that are |
---|
23 | * part of the internal JastAdd run-time system - these methods are not intended |
---|
24 | * to be used by the user. |
---|
25 | * |
---|
26 | * We are currently working together with the JastAdd team to develop a |
---|
27 | * documentation system where internal methods are hidden and where the user |
---|
28 | * API is exposed. |
---|
29 | * |
---|
30 | * The Modelica %compiler is organized into a number of different packages: |
---|
31 | * <ul> |
---|
32 | * <li> org.jmodelica.modelica.parser containing parsers for Modelica |
---|
33 | * and Flat Modelica code.</li> |
---|
34 | * <li> org.jmodelica.modelica.compiler contains the actual %compiler, including |
---|
35 | * the classes used to construct the Abstract Syntax Trees (ASTs) and the |
---|
36 | * %compiler driver class ModelicaCompiler.</li> |
---|
37 | * <li> org.jmodelica.util contains some helper classes which are independent |
---|
38 | * of the AST classes.</li> |
---|
39 | * </ul> |
---|
40 | * |
---|
41 | * Notice that the Java classes are not intended to be edited manually (with |
---|
42 | * the exception of the classes in org.jmodelica.util), but are rather |
---|
43 | * automatically generated by the JastAdd tool. In order to extend or |
---|
44 | * modify the functionality of the %compiler, edit the .%ast, .jrag and .jadd |
---|
45 | * files. |
---|
46 | * |
---|
47 | */ |
---|
48 | |
---|
49 | |
---|
50 | // Modelica abstract grammar |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | |
---|
55 | /** |
---|
56 | * \package org.jmodelica.ast Package containing all AST classes. |
---|
57 | */ |
---|
58 | |
---|
59 | abstract SrcBaseNode : BaseNode; |
---|
60 | |
---|
61 | /** |
---|
62 | * A class representing the root node of a source AST. |
---|
63 | */ |
---|
64 | SourceRoot : Root ::= Program; |
---|
65 | |
---|
66 | |
---|
67 | Program : SrcBaseNode ::= |
---|
68 | UnstructuredEntity:SrcStoredDefinition* |
---|
69 | /SrcUnknownClassDecl/ |
---|
70 | /UnknownComponent:SrcComponentClause/ |
---|
71 | /EnumBaseDecl:SrcEnumClassDecl/ |
---|
72 | /PredefinedType:SrcBaseClassDecl*/ |
---|
73 | /BuiltInType:SrcClassDecl*/ |
---|
74 | /BuiltInFunction:SrcBaseClassDecl*/ |
---|
75 | /SrcLibNode*/ |
---|
76 | /AnonymousClass:SrcBaseClassDecl*/ |
---|
77 | /InstProgramRoot/; |
---|
78 | |
---|
79 | SrcStoredDefinition : SrcBaseNode ::= |
---|
80 | [SrcWithin] |
---|
81 | SrcClassDecl* |
---|
82 | <LoadInfo:LoadInfo>; |
---|
83 | |
---|
84 | SrcWithin : SrcBaseNode ::= [PackageName:SrcAccess]; |
---|
85 | |
---|
86 | abstract SrcClassDecl : SrcElement ::= Name:SrcIdDecl; |
---|
87 | abstract SrcBaseClassDecl : SrcClassDecl ::= <Encapsulated:boolean> |
---|
88 | <Partial:boolean> |
---|
89 | SrcRestriction |
---|
90 | <Redeclare:boolean> |
---|
91 | <Final:boolean> |
---|
92 | <Inner:boolean> |
---|
93 | <Outer:boolean> |
---|
94 | <Replaceable:boolean> |
---|
95 | [SrcConstrainingClause] |
---|
96 | [ConstrainingClauseComment:SrcComment]; |
---|
97 | |
---|
98 | SrcUnknownClassDecl : SrcFullClassDecl; |
---|
99 | |
---|
100 | SrcFullClassDecl : SrcBaseClassDecl ::= [SrcStringComment] |
---|
101 | SrcClause* |
---|
102 | [SrcExternalClause] |
---|
103 | [SrcAnnotation] |
---|
104 | SrcEndDecl; |
---|
105 | |
---|
106 | SrcLibClassDecl : SrcFullClassDecl ::= SrcLibNode*; |
---|
107 | SrcLibNode : SrcClassDecl ::= |
---|
108 | <Structured:boolean> |
---|
109 | <Version:String> |
---|
110 | <Reason:SrcLibNode.LoadReason> |
---|
111 | <LoadInfo:LoadInfo> |
---|
112 | /SrcStoredDefinition/; |
---|
113 | |
---|
114 | SrcShortClassDecl : SrcBaseClassDecl ::= SrcExtendsClauseShortClass; |
---|
115 | |
---|
116 | SrcExtendsClauseShortClass : SrcExtendsClause ::= [SrcTypePrefixFlow] |
---|
117 | [SrcTypePrefixVariability] |
---|
118 | [SrcTypePrefixInputOutput] |
---|
119 | [SrcArraySubscripts] |
---|
120 | SrcComment; |
---|
121 | |
---|
122 | SrcExtendClassDecl : SrcFullClassDecl ::= SrcInlineExtendsClause; |
---|
123 | |
---|
124 | SrcPrimitiveClassDecl : SrcFullClassDecl; |
---|
125 | SrcRealClassDecl : SrcPrimitiveClassDecl; |
---|
126 | SrcIntegerClassDecl : SrcPrimitiveClassDecl; |
---|
127 | SrcBooleanClassDecl : SrcPrimitiveClassDecl; |
---|
128 | SrcStringClassDecl : SrcPrimitiveClassDecl; |
---|
129 | SrcEnumClassDecl : SrcPrimitiveClassDecl; |
---|
130 | |
---|
131 | SrcEnumLiteralDecl : SrcComponentDecl; |
---|
132 | |
---|
133 | SrcBuiltInClassDecl : SrcClassDecl; |
---|
134 | |
---|
135 | SrcConstrainingClause : SrcBaseNode ::= SrcAccess [SrcClassModification]; |
---|
136 | |
---|
137 | abstract SrcRestriction : SrcBaseNode; |
---|
138 | SrcModel : SrcRestriction; |
---|
139 | SrcBlock : SrcRestriction; |
---|
140 | SrcClass : SrcRestriction; |
---|
141 | SrcConnector : SrcRestriction; |
---|
142 | SrcExpandableConnector : SrcConnector; |
---|
143 | SrcType : SrcRestriction; |
---|
144 | SrcPackage : SrcRestriction; |
---|
145 | SrcFunction : SrcRestriction; |
---|
146 | SrcRecord : SrcRestriction; |
---|
147 | SrcOperatorRecord : SrcRecord; |
---|
148 | SrcOperator : SrcRestriction; |
---|
149 | SrcOperatorFunction : SrcFunction; |
---|
150 | |
---|
151 | SrcExternalClause : SrcBaseNode ::= [SrcExternalLanguage] |
---|
152 | [SrcExternalFunctionCall] |
---|
153 | [SrcAnnotation]; |
---|
154 | |
---|
155 | SrcExternalFunctionCall : SrcBaseNode ::= [ReturnVar:SrcAccess] FunctionName:SrcIdDecl Arg:SrcExp*; |
---|
156 | |
---|
157 | SrcExternalLanguage : SrcBaseNode ::= <Language>; |
---|
158 | |
---|
159 | abstract SrcClause : SrcBaseNode; |
---|
160 | |
---|
161 | abstract SrcElementList : SrcClause ::= SrcElement*; |
---|
162 | SrcPublicElementList : SrcElementList; |
---|
163 | SrcDefaultElementList : SrcPublicElementList; |
---|
164 | SrcProtectedElementList : SrcElementList; |
---|
165 | SrcEquationClause : SrcClause ::= SrcAbstractEquation*; |
---|
166 | SrcInitialEquationClause : SrcEquationClause; |
---|
167 | SrcAlgorithm : SrcClause ::= SrcStatement*; |
---|
168 | SrcInitialAlgorithm : SrcAlgorithm; |
---|
169 | |
---|
170 | abstract SrcElement : SrcBaseNode; |
---|
171 | SrcExtendsClause : SrcElement ::= Super:SrcAccess [SrcClassModification] [SrcAnnotation]; |
---|
172 | SrcInlineExtendsClause : SrcExtendsClause; |
---|
173 | abstract SrcImportClause : SrcElement ::= PackageName:SrcAccess SrcComment; |
---|
174 | SrcImportClauseQualified : SrcImportClause; |
---|
175 | SrcImportClauseUnqualified : SrcImportClause; |
---|
176 | SrcImportClauseRename : SrcImportClause ::= SrcIdDecl; |
---|
177 | |
---|
178 | SrcComponentClause : SrcElement ::= <Redeclare:boolean> |
---|
179 | <Final:boolean> |
---|
180 | <Inner:boolean> |
---|
181 | <Outer:boolean> |
---|
182 | <Replaceable:boolean> |
---|
183 | [SrcTypePrefixFlow] |
---|
184 | [SrcTypePrefixVariability] |
---|
185 | [SrcTypePrefixInputOutput] |
---|
186 | ClassName:SrcAccess |
---|
187 | [TypeArraySubscripts:SrcArraySubscripts] |
---|
188 | SrcComponentDecl* |
---|
189 | [SrcConstrainingClause] |
---|
190 | SrcComment; |
---|
191 | SrcEnumComponentClause : SrcComponentClause; |
---|
192 | |
---|
193 | SrcComponentDecl : SrcBaseNode ::= Name:SrcIdDecl |
---|
194 | [VarArraySubscripts:SrcArraySubscripts] |
---|
195 | [SrcModification] |
---|
196 | [SrcConditionalAttribute] |
---|
197 | SrcComment; |
---|
198 | |
---|
199 | SrcUnknownComponentDecl : SrcComponentDecl; |
---|
200 | |
---|
201 | abstract SrcTypePrefix : SrcBaseNode; |
---|
202 | abstract SrcTypePrefixFlow : SrcTypePrefix; |
---|
203 | SrcFlow : SrcTypePrefixFlow; |
---|
204 | SrcStream : SrcTypePrefixFlow; |
---|
205 | abstract SrcTypePrefixVariability : SrcTypePrefix; |
---|
206 | SrcContinuous : SrcTypePrefixVariability; |
---|
207 | SrcDiscrete : SrcTypePrefixVariability; |
---|
208 | SrcParameter : SrcTypePrefixVariability; |
---|
209 | SrcIndexParameter : SrcParameter; |
---|
210 | SrcConstant : SrcTypePrefixVariability; |
---|
211 | abstract SrcTypePrefixInputOutput : SrcTypePrefix; |
---|
212 | SrcInput : SrcTypePrefixInputOutput; |
---|
213 | SrcOutput : SrcTypePrefixInputOutput; |
---|
214 | |
---|
215 | SrcComment : SrcBaseNode ::= [SrcStringComment] [SrcAnnotation]; |
---|
216 | SrcStringComment : SrcBaseNode ::= SrcExp; |
---|
217 | |
---|
218 | // Annotations and modifications |
---|
219 | SrcConditionalAttribute : SrcBaseNode ::= SrcExp; |
---|
220 | |
---|
221 | abstract SrcModification : SrcBaseNode; |
---|
222 | SrcCompleteModification : SrcModification ::= SrcClassModification [SrcValueModification]; |
---|
223 | SrcValueModification : SrcModification ::= SrcExp; |
---|
224 | SrcDummyModification : SrcValueModification; |
---|
225 | |
---|
226 | SrcClassModification : SrcModification ::= SrcArgument*; |
---|
227 | abstract SrcArgument : SrcModification ::= <Each:boolean> <Final:boolean>; |
---|
228 | |
---|
229 | abstract SrcNamedModification : SrcArgument ::= Name:SrcAccess; |
---|
230 | abstract SrcElementModification : SrcNamedModification ::= [SrcModification] SrcComment; |
---|
231 | SrcComponentModification : SrcElementModification; |
---|
232 | abstract SrcElementRedeclare : SrcNamedModification; |
---|
233 | SrcClassRedeclare : SrcElementRedeclare ::= SrcBaseClassDecl; |
---|
234 | SrcComponentRedeclare : SrcElementRedeclare ::= SrcComponentClause; |
---|
235 | |
---|
236 | abstract SrcAnnotation : SrcBaseNode; |
---|
237 | |
---|
238 | SrcParseAnnotation : SrcAnnotation ::= SrcClassModification; |
---|
239 | |
---|
240 | abstract SrcAbstractExp : SrcBaseNode; |
---|
241 | abstract SrcExp : SrcAbstractExp; |
---|
242 | |
---|
243 | abstract SrcAbstractEquation : SrcBaseNode ::= SrcComment; |
---|
244 | SrcEquation : SrcAbstractEquation ::= Left:SrcExp Right:SrcExp; |
---|
245 | SrcConnectClause : SrcAbstractEquation ::= Connector1:SrcAccess Connector2:SrcAccess; |
---|
246 | abstract SrcIfWhenElseEquation : SrcAbstractEquation ::= SrcAbstractEquation*; |
---|
247 | abstract SrcIfWhenEquation : SrcIfWhenElseEquation ::= Test:SrcExp [Else:SrcIfWhenElseEquation]; |
---|
248 | SrcIfEquation : SrcIfWhenEquation; |
---|
249 | SrcWhenEquation : SrcIfWhenEquation; |
---|
250 | SrcElseEquation : SrcIfWhenElseEquation; |
---|
251 | SrcForClauseE : SrcAbstractEquation ::= SrcForIndex* SrcAbstractEquation*; |
---|
252 | SrcFunctionCallEquation : SrcAbstractEquation ::= Left:SrcFunctionCallLeft* Call:SrcFunctionCall; |
---|
253 | |
---|
254 | SrcFunctionCallLeft : SrcBaseNode ::= [SrcAccess]; |
---|
255 | SrcForIndex : SrcComponentClause ::= [SrcExp]; |
---|
256 | SrcForIndexDecl : SrcComponentDecl; |
---|
257 | |
---|
258 | abstract SrcStatement : SrcBaseNode ::= SrcComment; |
---|
259 | SrcAssignStmt : SrcStatement ::= Left:SrcAccess Right:SrcExp; |
---|
260 | SrcFunctionCallStmt : SrcStatement ::= Left:SrcFunctionCallLeft* SrcFunctionCall; |
---|
261 | SrcBreakStmt : SrcStatement; |
---|
262 | SrcReturnStmt : SrcStatement; |
---|
263 | abstract SrcIfWhenStmt : SrcStatement ::= SrcIfWhenClause*; |
---|
264 | SrcIfStmt : SrcIfWhenStmt ::= [SrcElseClause]; |
---|
265 | SrcWhenStmt : SrcIfWhenStmt; |
---|
266 | SrcElseClause : SrcBaseNode ::= Stmt:SrcStatement*; |
---|
267 | abstract SrcIfWhenClause : SrcBaseNode ::= Test:SrcExp SrcStatement*; |
---|
268 | SrcIfClause : SrcIfWhenClause; |
---|
269 | SrcWhenClause : SrcIfWhenClause; |
---|
270 | SrcForStmt : SrcStatement ::= SrcForIndex* SrcStatement*; |
---|
271 | SrcWhileStmt : SrcStatement ::= Test:SrcExp SrcWhileStmt:SrcStatement*; |
---|
272 | |
---|
273 | SrcParExp : SrcExp ::= SrcExp; |
---|
274 | SrcIfExp : SrcExp ::= SrcIfExp:SrcExp ThenExp:SrcExp ElseExp:SrcExp; |
---|
275 | |
---|
276 | abstract SrcBinExp : SrcExp ::= Left:SrcExp Right:SrcExp; |
---|
277 | |
---|
278 | abstract SrcArtmBinExp : SrcBinExp; |
---|
279 | SrcDotAddExp : SrcArtmBinExp; |
---|
280 | SrcDotSubExp : SrcArtmBinExp; |
---|
281 | SrcDotMulExp : SrcArtmBinExp; |
---|
282 | SrcDotDivExp : SrcArtmBinExp; |
---|
283 | SrcDotPowExp : SrcArtmBinExp; // Easy to make parser take care of this: should be a Primary |
---|
284 | SrcAddExp : SrcDotAddExp; |
---|
285 | SrcSubExp : SrcDotSubExp; |
---|
286 | SrcMulExp : SrcDotMulExp; |
---|
287 | SrcDivExp : SrcDotDivExp; |
---|
288 | SrcPowExp : SrcDotPowExp; // Easy to make parser take care of this: should be a Primary |
---|
289 | SrcNegExp : SrcExp ::= SrcExp; |
---|
290 | |
---|
291 | SrcRealLitExp : SrcExp ::= <UNSIGNED_NUMBER>; |
---|
292 | SrcIntegerLitExp : SrcExp ::= <UNSIGNED_INTEGER>; |
---|
293 | SrcStringLitExp : SrcExp ::= <STRING>; |
---|
294 | abstract SrcBooleanLitExp : SrcExp; |
---|
295 | SrcBooleanLitExpTrue : SrcBooleanLitExp; |
---|
296 | SrcBooleanLitExpFalse : SrcBooleanLitExp; |
---|
297 | |
---|
298 | SrcFunctionCall : SrcExp ::= Name:SrcAccess [SrcFunctionArguments]; |
---|
299 | SrcPartialFunctionCall : SrcFunctionCall; |
---|
300 | |
---|
301 | SrcFunctionArguments : SrcBaseNode::= SrcExp* SrcNamedArgument*; |
---|
302 | SrcNamedArgument : SrcBaseNode::= Name:SrcAccess SrcExp; |
---|
303 | |
---|
304 | SrcIterExp : SrcExp ::= SrcExp SrcForIndex*; |
---|
305 | SrcRangeExp : SrcExp ::= SrcExp*; |
---|
306 | |
---|
307 | abstract SrcLogBinExp : SrcBinExp; |
---|
308 | SrcLtExp : SrcLogBinExp; |
---|
309 | SrcLeqExp : SrcLogBinExp; |
---|
310 | SrcGtExp : SrcLogBinExp; |
---|
311 | SrcGeqExp : SrcLogBinExp; |
---|
312 | SrcEqExp : SrcLogBinExp; |
---|
313 | SrcNeqExp : SrcLogBinExp; |
---|
314 | SrcNotExp : SrcExp ::= SrcExp; |
---|
315 | SrcOrExp : SrcLogBinExp; |
---|
316 | SrcAndExp : SrcLogBinExp; |
---|
317 | |
---|
318 | SrcIdDecl : SrcBaseNode ::= <ID>; |
---|
319 | |
---|
320 | SrcDerExp : SrcExp ::= SrcExp; |
---|
321 | |
---|
322 | SrcAccessExp : SrcExp ::= SrcAccess; |
---|
323 | |
---|
324 | abstract SrcAccess : SrcBaseNode; |
---|
325 | SrcDot : SrcAccess ::= SrcAccess*; |
---|
326 | SrcGlobalAccess : SrcAccess ::= SrcAccess; |
---|
327 | SrcNamedAccess : SrcAccess ::= <ID>; |
---|
328 | SrcArrayAccess : SrcNamedAccess ::= SrcArraySubscripts; |
---|
329 | |
---|
330 | SrcArrayConstructor : SrcExp ::= SrcFunctionArguments; |
---|
331 | SrcMatrix : SrcExp ::= Row:SrcMatrixRow*; |
---|
332 | SrcMatrixRow : SrcExp ::= SrcExp*; |
---|
333 | |
---|
334 | SrcArraySubscripts : SrcBaseNode ::= SrcSubscript*; |
---|
335 | abstract SrcSubscript : SrcBaseNode; |
---|
336 | SrcColonSubscript : SrcSubscript; |
---|
337 | SrcExpSubscript : SrcSubscript ::= SrcExp; |
---|
338 | |
---|
339 | SrcTimeExp : SrcExp; |
---|
340 | SrcEndExp : SrcExp; |
---|
341 | |
---|
342 | SrcEndDecl : SrcBaseNode ::= <EndID:String>; |
---|