MicroModelicaCCompiler  4.5.3
ast_builder.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  This file is part of QSS Solver.
4 
5  QSS Solver is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  QSS Solver is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QSS Solver. If not, see <http://www.gnu.org/licenses/>.
17 
18  ******************************************************************************/
19 
20 #include <algorithm>
21 #include <cassert>
22 #include <cstdlib>
23 #include <iostream>
24 #include <list>
25 #include <string>
26 
27 #include "ast_builder.hpp"
28 #include <ast/parser/mocc_parser.h>
29 #include "ast_types.hpp"
30 #include "../util/ast_util.hpp"
31 #include "class.hpp"
32 #include "composition.hpp"
33 #include "element.hpp"
34 #include "equation.hpp"
35 #include "expression.hpp"
36 #include "modification.hpp"
37 #include "statement.hpp"
38 #include "stored_definition.hpp"
39 
40 class MCC_Parser;
41 class MCC_Lexer;
42 int block;
43 
44 MCC_Lexer *MCC_Parser::lexer = nullptr;
45 
46 AST_StoredDefinition newAST_StoredDefinition(AST_ClassList cl, AST_String within) { return new AST_StoredDefinition_(cl, within); }
47 
48 AST_String AST_SanitizeString(std::string new_string)
49 {
50  if (new_string.find("'") != std::string::npos) {
51  new_string.erase(std::remove(new_string.begin(), new_string.end(), '\''), new_string.end());
52  std::replace(new_string.begin(), new_string.end(), '.', '_');
53  }
54  return new string(new_string);
55 }
56 
57 AST_String newAST_String(string s) { return AST_SanitizeString(string(s)); }
58 
59 AST_String newAST_String(char *s) { return AST_SanitizeString(string(s)); }
60 
61 AST_String newAST_String(const char *s) { return AST_SanitizeString(string(s)); }
62 
64 {
65  AST_String ret = AST_SanitizeString(string(*s));
66  delete s;
67  return ret;
68 }
69 
71 {
72  AST_String ret = AST_SanitizeString(string(*s));
73  return ret;
74 }
75 
77 {
78  AST_String ret = AST_SanitizeString(string(*s));
79  ret->insert(0, ".");
80  delete s;
81  return ret;
82 }
83 
85 {
86  if (ret == nullptr) {
87  ret = new string();
88  }
89  if (a != nullptr) {
90  ret->append(".");
91  ret->append(*AST_SanitizeString(string(*a)));
92  delete a;
93  }
94  return ret;
95 }
96 
97 AST_String newAST_StringNull() { return nullptr; }
98 
99 AST_ClassList newAST_ClassList() { return new list<AST_Class>(); }
100 
102 
103 AST_Composition newAST_Composition(AST_ElementList el) { return new AST_Composition_(el, newAST_CompositionElementList()); }
104 
105 AST_Composition newAST_Composition(AST_ElementList el, AST_CompositionElementList cl) { return new AST_Composition_(el, cl); }
106 
107 AST_Composition newAST_Composition(AST_CompositionElementList cl) { return new AST_Composition_(newAST_ElementList(), cl); }
108 
109 AST_ElementList newAST_ElementList() { return new list<AST_Element>(); }
110 
111 AST_Element AST_ImportToElement(AST_Element_ImportClause i) { return i; }
112 
113 AST_Element AST_ExtendsToElement(AST_Element_ExtendsClause e) { return e; }
114 
115 AST_Element_ExtendsClause newAST_Element_ExtendsClause(AST_String name)
116 {
117  AST_Element_ExtendsClause ret = new AST_Element_ExtendsClause_(*name);
118  delete name;
119  return ret;
120 }
121 
122 AST_Element newAST_Element_ClassWrapper(AST_Class c) { return new AST_Element_ClassWrapper_(c); }
123 
124 AST_Element AST_Element_ComponentToElement(AST_Element_Component c) { return c; }
125 
126 AST_CompositionElementList newAST_CompositionElementList() { return new list<AST_CompositionElement>(); }
127 
128 AST_Element_ImportClause newAST_ImportClause(AST_String name) { return new AST_Element_ImportClause_(*name); }
129 
130 AST_Expression newAST_Expression_Integer(int i) { return new AST_Expression_Integer_(i); }
131 
132 AST_ExpressionList newAST_ExpressionList(AST_Expression e) { return newAST_SimpleList(e); }
133 
134 AST_ExpressionList newAST_ExpressionList()
135 {
136  AST_ExpressionList l = new list<AST_Expression>();
137  return l;
138 }
139 
140 AST_Argument AST_ArgumentSet(bool each, bool final, AST_Argument arg)
141 {
142  if (each) {
143  arg->setEach();
144  }
145  if (final) {
146  arg->setFinal();
147  }
148  return arg;
149 }
150 
151 AST_EquationList newAST_EquationList() { return new list<AST_Equation>(); }
152 
153 AST_Equation newAST_Equation_Equality(AST_Expression left, AST_Expression right, AST_Comment comment)
154 {
155  return new AST_Equation_Equality_(left, right, comment);
156 }
157 
158 AST_Equation newAST_Equation_Connect(AST_Expression_ComponentReference cr1, AST_Expression_ComponentReference cr2)
159 {
160  return new AST_Equation_Connect_(cr1, cr2);
161 }
162 
163 AST_Expression newAST_Expression_Real(AST_Real r) { return new AST_Expression_Real_(r); }
164 
166 {
167  AST_Expression_String ret = new AST_Expression_String_(*AST_SanitizeString(*s));
168  delete s;
169  return ret;
170 }
171 
173 
174 AST_Expression newAST_Expression_Derivative(AST_ExpressionList el) { return new AST_Expression_Derivative_(el); }
175 
177 
178 AST_Class newAST_Class(AST_String s, AST_Composition comp) { return new AST_Class_(s, comp); }
179 
180 AST_Element_Component newAST_Element_Component(AST_DeclarationList cl, AST_String type, AST_TypePrefix tp, AST_ExpressionList ind)
181 {
182  AST_Element_Component c = new AST_Element_Component_(cl, *type, tp, ind);
183  delete type;
184  return c;
185 }
186 
187 AST_Declaration newAST_Declaration(AST_String s, AST_ExpressionList indexes, AST_Modification m)
188 {
189  AST_Declaration ret = new AST_Declaration_(*AST_SanitizeString(*s), indexes, m);
190  delete s;
191  return ret;
192 }
193 
194 AST_DeclarationList newAST_DeclarationList(AST_Declaration d) { return newAST_SimpleList(d); }
195 
196 AST_CompositionElement newAST_CompositionElement(AST_ElementList el) { return new AST_CompositionElement_(el); }
197 
199 {
200  AST_Expression_ComponentReference e = newAST_Expression_ComponentReference();
201  e->append(AST_SanitizeString(*s), newAST_ExpressionList());
202  return e;
203 }
204 
206 {
207  if (s2 != nullptr) {
208  s->append(*s2);
209  delete s2;
210  }
212 }
213 
215 {
216  s->insert(0, ".");
217  s->append(rest->c_str());
218  delete rest;
220 }
221 
222 AST_Expression_ComponentReference newAST_Expression_ComponentReference()
223 {
224  // Empty cref
226 }
227 
228 AST_Expression_ComponentReference AST_Expression_ComponentReference_AddDot(AST_Expression_ComponentReference cr, AST_String s,
229  AST_ExpressionList subs)
230 {
231  s->insert(0, ".");
232  cr->prepend(s, subs);
233  return cr;
234 }
235 
236 AST_Expression_ComponentReference AST_Expression_ComponentReference_Add(AST_Expression_ComponentReference cr, AST_String s,
237  AST_ExpressionList subs)
238 {
239  cr->append(AST_SanitizeString(*s), subs);
240  return cr;
241 }
242 
243 ostream &operator<<(ostream &os, const AST_CompositionElement &ce)
244 {
245  assert(ce != nullptr);
246  os << *ce;
247  return os;
248 }
249 
250 ostream &operator<<(ostream &os, const AST_String &s)
251 {
252  assert(s != nullptr);
253  os << *s;
254  return os;
255 }
256 
257 AST_Element_ComponentList newAST_Element_ComponentList() { return new list<AST_Element_Component>(); }
258 
260 
262 
264 
265 AST_Expression newAST_Expression_BinOp(AST_Expression left, AST_Expression right, BinOpType type)
266 {
267  if ((type == BINOPADD || type == BINOPSUB) && right->expressionType() == EXPINTEGER && right->getAsInteger()->val() == 0) {
268  return left;
269  }
270  if ((type == BINOPADD || type == BINOPSUB) && left->expressionType() == EXPINTEGER && left->getAsInteger()->val() == 0) {
271  return right;
272  }
273  if (type == BINOPMULT && right->expressionType() == EXPINTEGER && right->getAsInteger()->val() == 1) {
274  return left;
275  }
276  if (type == BINOPMULT && left->expressionType() == EXPINTEGER && left->getAsInteger()->val() == 1) {
277  return right;
278  }
279  if (type == BINOPMULT && right->expressionType() == EXPREAL && right->getAsReal()->val() == 0.0) {
280  return right;
281  }
282  if (type == BINOPMULT && right->expressionType() == EXPINTEGER && right->getAsInteger()->val() == 0) {
283  return right;
284  }
285  if (type == BINOPMULT && left->expressionType() == EXPREAL && left->getAsReal()->val() == 0.0) {
286  return left;
287  }
288  if (type == BINOPMULT && left->expressionType() == EXPINTEGER && left->getAsInteger()->val() == 0) {
289  return left;
290  }
291  return new AST_Expression_BinOp_(left, right, type);
292 }
293 
294 AST_Expression newAST_Expression_UnaryMinus(AST_Expression e)
295 {
296  // Remove doble negation
297  if (e->expressionType() == EXPUMINUS) {
298  AST_Expression e2 = e->getAsUMinus()->exp();
299  delete e;
300  return e2;
301  }
302  return new AST_Expression_UMinus_(e);
303 }
304 
305 AST_Expression newAST_Expression_If(AST_Expression cond, AST_Expression then, AST_ExpressionList else_list, AST_Expression else_exp)
306 {
307  return new AST_Expression_If_(cond, then, else_exp, else_list);
308 }
309 
310 AST_Equation newAST_Equation_If(AST_Expression e, AST_EquationList eql, AST_Equation_ElseList elseif, AST_EquationList elseeqs)
311 {
312  return new AST_Equation_If_(e, eql, elseif, elseeqs);
313 }
314 
315 AST_StringList newAST_StringList() { return new list<AST_String>(); }
316 
317 AST_Expression newAST_Expression_End() { return new AST_Expression_End_(); }
318 
319 AST_Expression newAST_Expression_Null() { return new AST_Expression_Null_(); }
320 
321 AST_Expression newAST_Expression_DotCall(AST_String name, AST_String rest, AST_ExpressionList args)
322 {
323  name->insert(0, ".");
324  if (rest != nullptr) {
325  name->append(rest->c_str());
326  delete rest;
327  }
328  return new AST_Expression_Call_(name, args);
329 }
330 
331 AST_Expression newAST_Expression_Call(AST_String name, AST_String rest, AST_ExpressionList args)
332 {
333  if (rest != nullptr) {
334  name->append(rest->c_str());
335  delete rest;
336  }
337  return new AST_Expression_Call_(name, args);
338 }
339 
340 AST_Expression newAST_Expression_Call(AST_String name, AST_String rest, AST_ExpressionList args, AST_ExpressionList output_args)
341 {
342  return new AST_Expression_Call_(name, args, output_args);
343 }
344 
345 AST_Expression newAST_Expression_Colon() { return new AST_Expression_Colon_(); }
346 
347 AST_Expression newAST_Expression_BooleanNot(AST_Expression e) { return new AST_Expression_BooleanNot_(e); }
348 
349 AST_Equation newAST_Equation_Call(AST_Expression e)
350 {
351  if (e->expressionType() != EXPCALL) {
352  cerr << "Not valid equation" << endl;
353  exit(-1);
354  }
355  return new AST_Equation_Call_(e);
356 }
357 
359 
361 
363 {
364  if (oper) {
365  return CP_RECORD | CP_OPERATOR;
366  }
367  return CP_RECORD;
368 }
369 
371 
373 {
374  if (expandable) {
375  return CP_CONNECTOR | CP_EXPANDABLE;
376  }
377  return CP_CONNECTOR;
378 }
379 
381 
383 
385 
387 
389 {
390  if (oper) {
391  return CP_IMPURE | CP_OPERATOR;
392  }
393  return CP_IMPURE;
394 }
395 
397 {
398  if (oper) {
399  return CP_PURE | CP_OPERATOR;
400  }
401  return CP_PURE;
402 }
403 
405 
407 {
408  if (partial) {
409  return p | CP_PARTIAL;
410  }
411  return p;
412 }
413 
414 AST_Equation newAST_EquationFor(AST_ForIndexList ind, AST_EquationList eql) { return new AST_Equation_For_(ind, eql); }
415 
416 AST_ForIndex newAST_ForIndex(AST_String ident, AST_Expression exp) { return new AST_ForIndex_(ident, exp); }
417 
418 AST_ForIndexList newAST_ForIndexList() { return new list<AST_ForIndex>(); }
419 
420 AST_Equation newAST_Equation_For(AST_ForIndexList ind, AST_EquationList eql) { return new AST_Equation_For_(ind, eql); }
421 
422 AST_Class AST_Class_SetFinal(AST_Class c, AST_Boolean final)
423 {
424  if (final) {
425  c->setFinal();
426  }
427  return c;
428 }
429 
431 {
432  if (enc) {
433  c->setEncapsulated();
434  }
435  c->setPrefixes(prefix);
436  return c;
437 }
438 
439 AST_Expression AST_Expression_ComponentReferenceExpAddDot(AST_Expression_ComponentReference cr, AST_String id, AST_String rest,
440  AST_ExpressionList subs)
441 {
442  if (rest != nullptr) {
443  id->append(rest->c_str());
444  delete rest;
445  }
446  return AST_Expression_ComponentReference_AddDot(cr, id, subs);
447 }
448 
449 AST_Expression AST_Expression_ComponentReferenceExpAdd(AST_Expression_ComponentReference cr, AST_String id, AST_String rest,
450  AST_ExpressionList subs)
451 {
452  if (rest != nullptr) {
453  id->append(rest->c_str());
454  delete rest;
455  }
456  return AST_Expression_ComponentReference_Add(cr, id, subs);
457 }
458 
459 AST_Expression newAST_Expression_NamedArgument(AST_String s, AST_Expression e)
460 {
461  AST_Expression_NamedArgument na = new AST_Expression_NamedArgument_(s, e);
462  return na;
463 }
464 
465 AST_Expression newAST_Expression_FunctionCallArgs(AST_ExpressionList el)
466 {
467  AST_Expression e = new AST_Expression_CallArgs_(el);
468  return e;
469 }
470 
471 AST_Expression newAST_Expression_Function(AST_String, AST_ExpressionList)
472 {
473  /* TODO */
474  return nullptr;
475 }
476 
477 AST_Equation_ElseList newAST_Equation_ElseIfList() { return new list<AST_Equation_Else>(); }
478 
479 AST_Equation_Else newAST_Equation_Else(AST_Expression cond, AST_EquationList eqs) { return new AST_Equation_Else_(cond, eqs); }
480 
481 AST_StatementList newAST_StatementList() { return new list<AST_Statement>(); }
482 
483 AST_Statement newAST_Statement_Break() { return new AST_Statement_Break_(); }
484 
485 AST_Statement newAST_Statement_Return() { return new AST_Statement_Return_(); }
486 
487 AST_Modification newAST_ModificationNull() { return nullptr; }
488 
489 AST_Statement_ElseList newAST_Statement_ElseList() { return new list<AST_Statement_Else>(); }
490 
491 AST_Equation_ElseList newAST_Equation_ElseList() { return new list<AST_Equation_Else>(); }
492 
493 AST_ArgumentList newAST_ArgumentList() { return new list<AST_Argument>(); }
494 
495 AST_Argument newAST_Argument_Modification(AST_String s, AST_Modification m) { return new AST_Argument_Modification_(s, m); }
496 
497 AST_ExpressionListList newAST_ExpressionListList() { return new list<AST_ExpressionList>(); }
498 
499 AST_Argument AST_ArgumentSetReplaceable(AST_Argument arg) { return arg; }
500 
501 AST_Modification newAST_Modification_Equal(AST_Expression e) { return new AST_Modification_Equal_(e); }
502 
503 AST_Modification newAST_Modification_Assign(AST_Expression e) { return new AST_Modification_Assign_(e); }
504 
505 AST_Expression newAST_Expression_Range(AST_Expression e1, AST_Expression e2)
506 {
507  AST_ExpressionList l;
508  if (e1->expressionType() == EXPRANGE) {
509  l = e1->getAsRange()->expressionList();
510  if (l->size() > 2) {
511  cerr << "Not valid range expression: line " << e1->lineNum() << endl;
512  exit(-1);
513  }
514  l = AST_ListAppend(l, e2);
515  } else {
516  l = newAST_ExpressionList(e1);
517  l = AST_ListAppend(l, e2);
518  }
519  return new AST_Expression_Range_(l);
520 }
521 
522 AST_Expression newAST_Expression_OutputExpressions(AST_ExpressionList exp_list) { return new AST_Expression_Output_(exp_list); }
523 
524 AST_Expression newAST_Expression_Brace(AST_ExpressionList el) { return new AST_Expression_Brace_(el); }
525 
526 AST_Expression newAST_BracketExpList(AST_ExpressionListList expss)
527 {
528  AST_ExpressionListListIterator exps_it = expss->begin();
529  AST_ExpressionListIterator exps_range_it;
530  AST_ExpressionList l = newAST_ExpressionList();
531  foreach (exps_it, expss) {
532  if (current_element(exps_it)->size()) {
533  foreach (exps_range_it, current_element(exps_it)) {
534  if (current_element(exps_range_it)->expressionType() == EXPRANGE) {
535  l = AST_ListAppend(l, current_element(exps_range_it));
536  }
537  }
538  }
539  }
540  return new AST_Expression_Bracket_(l);
541 }
542 
543 AST_Expression newAST_Expression_ElseIf(AST_Expression c, AST_Expression t) { return new AST_Expression_If_ElseIf_(c, t); }
544 
545 AST_Statement_Else newAST_Statement_Else(AST_Expression cond, AST_StatementList st) { return new AST_Statement_Else_(cond, st); }
546 
547 AST_Statement newAST_Statement_If(AST_Expression cond, AST_StatementList true_st, AST_Statement_ElseList else_st,
548  AST_StatementList false_st)
549 {
550  return new AST_Statement_If_(cond, true_st, else_st, false_st);
551 }
552 
553 AST_Statement newAST_Statement_For(AST_ForIndexList index, AST_StatementList st) { return new AST_Statement_For_(index, st); }
554 
555 AST_Statement newAST_Statement_While(AST_Expression cond, AST_StatementList st) { return new AST_Statement_While_(cond, st); }
556 
557 AST_Statement newAST_Statement_When(AST_Expression cond, AST_StatementList sts, AST_Statement_ElseList else_st, AST_Comment c)
558 {
559  return new AST_Statement_When_(cond, sts, else_st, c);
560 }
561 
562 AST_Statement newAST_Statement_OutputAssign(AST_ExpressionList out_vars, AST_Expression_ComponentReference funname, AST_ExpressionList args)
563 {
564  return new AST_Statement_OutputAssigment_(out_vars, funname, args);
565 }
566 
567 AST_Statement newAST_Statement_Assign(AST_Expression_ComponentReference cr, AST_Expression exp)
568 {
569  return new AST_Statement_Assign_(cr, exp);
570 }
571 
572 AST_Equation newAST_Equation_When(AST_Expression cond, AST_EquationList eqs, AST_Equation_ElseList else_list, AST_Comment comment)
573 {
574  return new AST_Equation_When_(cond, eqs, else_list, comment);
575 }
576 
577 AST_CompositionEqsAlgs newAST_CompositionInitialEquations(AST_EquationList eqlist) { return new AST_CompositionEqsAlgs_(eqlist, true); }
578 
579 AST_CompositionEqsAlgs newAST_CompositionEquations(AST_EquationList eqlist) { return new AST_CompositionEqsAlgs_(eqlist); }
580 
581 AST_CompositionEqsAlgs newAST_CompositionInitialAlgorithms(AST_StatementList stlist) { return new AST_CompositionEqsAlgs_(stlist, true); }
582 
583 AST_CompositionEqsAlgs newAST_CompositionAlgorithms(AST_StatementList stlist) { return new AST_CompositionEqsAlgs_(stlist); }
584 
585 AST_ShortClassExp newAST_ShortClassExp(AST_TypePrefix, AST_String, AST_ExpressionList, AST_ArgumentList)
586 {
587  /* TODO */
588  return nullptr;
589 }
590 AST_ShortClassExp newAST_ShortClassExp_Enum(AST_StringList)
591 {
592  /* TODO */
593  return nullptr;
594 }
595 
596 AST_Argument newAST_Redeclaration(AST_Boolean, AST_Boolean, AST_Argument)
597 {
598  /* TODO */
599  return nullptr;
600 }
601 
602 AST_Argument newAST_ShortClass(AST_ClassPrefix, AST_String, AST_ShortClassExp)
603 {
604  /* TODO */
605  return nullptr;
606 }
607 
608 AST_Argument newAST_ElementModification(AST_String n, AST_Modification m) { return new AST_Argument_Modification_(n, m); }
609 
610 AST_Modification newAST_Modification_Class(AST_ArgumentList al, AST_Expression e) { return new AST_Modification_Class_(al, e); }
611 
612 AST_CompositionElement newAST_CompositionElement(AST_CompositionEqsAlgs comp_eq_algs) { return new AST_CompositionElement_(comp_eq_algs); }
613 
614 AST_Class newAST_ClassExtends(AST_String, AST_Composition)
615 {
616  /* TODO */
617  return nullptr;
618 }
619 
620 AST_Class newAST_ClassEnumeration(AST_String, AST_StringList)
621 {
622  /* TODO */
623  return nullptr;
624 }
625 
626 AST_Class newAST_ClassDerivation(AST_String, AST_String, AST_StringList)
627 {
628  /* TODO */
629  return nullptr;
630 }
631 
632 AST_Class newAST_ClassModification(AST_String, AST_TypePrefix, AST_String, AST_ExpressionList, AST_ArgumentList)
633 {
634  /* TODO */
635  return nullptr;
636 }
637 
638 AST_CompositionEqsAlgs newAST_NullCompositionEquations() { return nullptr; }
639 
640 AST_Declaration AST_Declaration_AddCondComment(AST_Declaration decl, AST_Expression exp, AST_Comment comment)
641 {
642  decl->setComment(comment);
643  return decl;
644 }
645 
646 AST_Comment newAST_Comment(AST_String st, AST_ArgumentList al)
647 {
648  if (al->size() || st != nullptr) {
649  return new AST_Comment_(st, al);
650  }
651  return nullptr;
652 }
653 
654 AST_External_Function_Call newAST_ExternalCall() { return nullptr; }
655 
656 AST_External_Function_Call newAST_ExternalCall(AST_String lang, AST_Expression_ComponentReference cr, AST_Expression args,
657  AST_ArgumentList annot)
658 {
659  return new AST_External_Function_Call_(lang, cr, args, annot);
660 }
661 
662 AST_Composition AST_Composition_SetExternalAnnotation(AST_Composition c, AST_External_Function_Call ext, AST_ArgumentList annot)
663 {
664  c->setExternalFunctionCall(ext);
665  c->setAnnotation(annot);
666  return c;
667 }
newAST_Statement_Assign
AST_Statement newAST_Statement_Assign(AST_Expression_ComponentReference cr, AST_Expression exp)
Definition: ast_builder.cpp:567
equation.hpp
EXPINTEGER
@ EXPINTEGER
Definition: ast_types.hpp:180
newAST_Equation_For
AST_Equation newAST_Equation_For(AST_ForIndexList ind, AST_EquationList eql)
Definition: ast_builder.cpp:420
AST_Element_ExtendsClause_
Definition: element.hpp:42
newAST_Statement_While
AST_Statement newAST_Statement_While(AST_Expression cond, AST_StatementList st)
Definition: ast_builder.cpp:555
AST_StoredDefinition_
Definition: stored_definition.hpp:29
AST_Expression_Call_
Definition: expression.hpp:135
AST_ClassPrefix_Record
AST_ClassPrefix AST_ClassPrefix_Record(AST_Boolean oper)
Definition: ast_builder.cpp:362
newAST_DeclarationList
AST_DeclarationList newAST_DeclarationList(AST_Declaration d)
Definition: ast_builder.cpp:194
ast_builder.hpp
newAST_ShortClass
AST_Argument newAST_ShortClass(AST_ClassPrefix, AST_String, AST_ShortClassExp)
Definition: ast_builder.cpp:602
AST_Statement_For_
Definition: statement.hpp:120
newAST_NullCompositionEquations
AST_CompositionEqsAlgs newAST_NullCompositionEquations()
Definition: ast_builder.cpp:638
AST_ForIndex_
Definition: equation.hpp:114
newAST_Statement_ElseList
AST_Statement_ElseList newAST_Statement_ElseList()
Definition: ast_builder.cpp:489
CP_BLOCK
@ CP_BLOCK
Definition: ast_types.hpp:216
newAST_ElementList
AST_ElementList newAST_ElementList()
Definition: ast_builder.cpp:109
newAST_StringNull
AST_String newAST_StringNull()
Definition: ast_builder.cpp:97
newAST_ClassEnumeration
AST_Class newAST_ClassEnumeration(AST_String, AST_StringList)
Definition: ast_builder.cpp:620
AST_Expression_UMinus_
Definition: expression.hpp:113
newAST_ForIndexList
AST_ForIndexList newAST_ForIndexList()
Definition: ast_builder.cpp:418
newAST_Expression_Real
AST_Expression newAST_Expression_Real(AST_Real r)
Definition: ast_builder.cpp:163
newAST_Expression_String
AST_Expression newAST_Expression_String(AST_String s)
Definition: ast_builder.cpp:165
AST_Equation_Call_
Definition: equation.hpp:72
EXPUMINUS
@ EXPUMINUS
Definition: ast_types.hpp:176
AST_ExtendsToElement
AST_Element AST_ExtendsToElement(AST_Element_ExtendsClause e)
Definition: ast_builder.cpp:113
copyAST_String
AST_String copyAST_String(AST_String s)
Definition: ast_builder.cpp:70
newAST_EquationFor
AST_Equation newAST_EquationFor(AST_ForIndexList ind, AST_EquationList eql)
Definition: ast_builder.cpp:414
AST_Expression_Colon_
Definition: expression.hpp:248
newAST_Statement_If
AST_Statement newAST_Statement_If(AST_Expression cond, AST_StatementList true_st, AST_Statement_ElseList else_st, AST_StatementList false_st)
Definition: ast_builder.cpp:547
newAST_Statement_Break
AST_Statement newAST_Statement_Break()
Definition: ast_builder.cpp:483
newAST_Expression_End
AST_Expression newAST_Expression_End()
Definition: ast_builder.cpp:317
AST_Expression_Derivative_
Definition: expression.hpp:102
AST_ClassPrefix_Impure
AST_ClassPrefix AST_ClassPrefix_Impure(AST_Boolean oper)
Definition: ast_builder.cpp:388
AST_Expression_End_
Definition: expression.hpp:223
AST_Expression_If_ElseIf_
Definition: expression.hpp:235
AST_Modification_Class_
Definition: modification.hpp:249
AST_Expression_ComponentReference_
Definition: expression.hpp:174
AST_Equation_For_
Definition: equation.hpp:101
newAST_Expression_BooleanNot
AST_Expression newAST_Expression_BooleanNot(AST_Expression e)
Definition: ast_builder.cpp:347
AST_Expression_ComponentReference_AddDot
AST_Expression_ComponentReference AST_Expression_ComponentReference_AddDot(AST_Expression_ComponentReference cr, AST_String s, AST_ExpressionList subs)
Definition: ast_builder.cpp:228
newAST_Statement_Return
AST_Statement newAST_Statement_Return()
Definition: ast_builder.cpp:485
AST_Real
double AST_Real
Definition: ast_types.hpp:48
AST_Element_ImportClause_
Definition: element.hpp:53
AST_ClassPrefix_Package
AST_ClassPrefix AST_ClassPrefix_Package()
Definition: ast_builder.cpp:382
newAST_Statement_Else
AST_Statement_Else newAST_Statement_Else(AST_Expression cond, AST_StatementList st)
Definition: ast_builder.cpp:545
element.hpp
newAST_TypePrefix
AST_TypePrefix newAST_TypePrefix()
Definition: ast_builder.cpp:259
composition.hpp
AST_External_Function_Call_
Definition: composition.hpp:92
CP_IMPURE
@ CP_IMPURE
Definition: ast_types.hpp:223
newAST_ExternalCall
AST_External_Function_Call newAST_ExternalCall()
Definition: ast_builder.cpp:654
EXPRANGE
@ EXPRANGE
Definition: ast_types.hpp:183
AST_Expression_BooleanNot_
Definition: expression.hpp:124
AST_Composition_SetExternalAnnotation
AST_Composition AST_Composition_SetExternalAnnotation(AST_Composition c, AST_External_Function_Call ext, AST_ArgumentList annot)
Definition: ast_builder.cpp:662
AST_String
string * AST_String
Definition: ast_types.hpp:46
newAST_Modification_Equal
AST_Modification newAST_Modification_Equal(AST_Expression e)
Definition: ast_builder.cpp:501
newAST_Expression_Range
AST_Expression newAST_Expression_Range(AST_Expression e1, AST_Expression e2)
Definition: ast_builder.cpp:505
AST_ArgumentSetReplaceable
AST_Argument AST_ArgumentSetReplaceable(AST_Argument arg)
Definition: ast_builder.cpp:499
newAST_Expression_NamedArgument
AST_Expression newAST_Expression_NamedArgument(AST_String s, AST_Expression e)
Definition: ast_builder.cpp:459
newAST_Element_Component
AST_Element_Component newAST_Element_Component(AST_DeclarationList cl, AST_String type, AST_TypePrefix tp, AST_ExpressionList ind)
Definition: ast_builder.cpp:180
newAST_Equation_Equality
AST_Equation newAST_Equation_Equality(AST_Expression left, AST_Expression right, AST_Comment comment)
Definition: ast_builder.cpp:153
newAST_StringList
AST_StringList newAST_StringList()
Definition: ast_builder.cpp:315
BINOPMULT
@ BINOPMULT
Definition: ast_types.hpp:152
AST_Expression_ComponentReference_Add
AST_Expression_ComponentReference AST_Expression_ComponentReference_Add(AST_Expression_ComponentReference cr, AST_String s, AST_ExpressionList subs)
Definition: ast_builder.cpp:236
AST_ClassPrefix_Class
AST_ClassPrefix AST_ClassPrefix_Class()
Definition: ast_builder.cpp:358
newAST_ElementModification
AST_Argument newAST_ElementModification(AST_String n, AST_Modification m)
Definition: ast_builder.cpp:608
newAST_Expression_ComponentReferenceExp
AST_Expression newAST_Expression_ComponentReferenceExp(AST_String s)
Definition: ast_builder.cpp:198
AST_Class_
Definition: class.hpp:28
AST_Expression_If_
Definition: expression.hpp:208
AST_Equation_Else_
Definition: equation.hpp:128
newAST_EquationList
AST_EquationList newAST_EquationList()
Definition: ast_builder.cpp:151
AST_ClassPrefix
int AST_ClassPrefix
Definition: ast_types.hpp:51
AST_Argument_Modification_
Definition: modification.hpp:93
newAST_Expression_UnaryMinus
AST_Expression newAST_Expression_UnaryMinus(AST_Expression e)
Definition: ast_builder.cpp:294
AST_Declaration_AddCondComment
AST_Declaration AST_Declaration_AddCondComment(AST_Declaration decl, AST_Expression exp, AST_Comment comment)
Definition: ast_builder.cpp:640
newAST_ClassModification
AST_Class newAST_ClassModification(AST_String, AST_TypePrefix, AST_String, AST_ExpressionList, AST_ArgumentList)
Definition: ast_builder.cpp:632
AST_Statement_Break_
Definition: statement.hpp:51
newAST_ShortClassExp
AST_ShortClassExp newAST_ShortClassExp(AST_TypePrefix, AST_String, AST_ExpressionList, AST_ArgumentList)
Definition: ast_builder.cpp:585
newAST_CompositionInitialAlgorithms
AST_CompositionEqsAlgs newAST_CompositionInitialAlgorithms(AST_StatementList stlist)
Definition: ast_builder.cpp:581
AST_Expression_Range_
Definition: expression.hpp:265
newAST_Modification_Assign
AST_Modification newAST_Modification_Assign(AST_Expression e)
Definition: ast_builder.cpp:503
newAST_Expression_ElseIf
AST_Expression newAST_Expression_ElseIf(AST_Expression c, AST_Expression t)
Definition: ast_builder.cpp:543
newAST_Statement_OutputAssign
AST_Statement newAST_Statement_OutputAssign(AST_ExpressionList out_vars, AST_Expression_ComponentReference funname, AST_ExpressionList args)
Definition: ast_builder.cpp:562
BINOPSUB
@ BINOPSUB
Definition: ast_types.hpp:148
newAST_Redeclaration
AST_Argument newAST_Redeclaration(AST_Boolean, AST_Boolean, AST_Argument)
Definition: ast_builder.cpp:596
AST_CompositionElement_
Definition: composition.hpp:56
AST_Modification_Assign_
Definition: modification.hpp:219
AST_ImportToElement
AST_Element AST_ImportToElement(AST_Element_ImportClause i)
Definition: ast_builder.cpp:111
newAST_BracketExpList
AST_Expression newAST_BracketExpList(AST_ExpressionListList expss)
Definition: ast_builder.cpp:526
AST_Boolean
bool AST_Boolean
Definition: ast_types.hpp:45
AST_Statement_While_
Definition: statement.hpp:107
AST_Element_ComponentToElement
AST_Element AST_Element_ComponentToElement(AST_Element_Component c)
Definition: ast_builder.cpp:124
AST_Expression_BinOp_
Definition: expression.hpp:194
newAST_Modification_Class
AST_Modification newAST_Modification_Class(AST_ArgumentList al, AST_Expression e)
Definition: ast_builder.cpp:610
AST_TypePrefix
int AST_TypePrefix
Definition: ast_types.hpp:50
newAST_Equation_Else
AST_Equation_Else newAST_Equation_Else(AST_Expression cond, AST_EquationList eqs)
Definition: ast_builder.cpp:479
newAST_Expression_Null
AST_Expression newAST_Expression_Null()
Definition: ast_builder.cpp:319
AST_Expression_NamedArgument_
Definition: expression.hpp:276
newAST_ExpressionListList
AST_ExpressionListList newAST_ExpressionListList()
Definition: ast_builder.cpp:497
stored_definition.hpp
AST_ListAppend
list< T1 > * AST_ListAppend(list< T1 > *l, T1 e)
Definition: ast_types.hpp:240
newAST_Element_ExtendsClause
AST_Element_ExtendsClause newAST_Element_ExtendsClause(AST_String name)
Definition: ast_builder.cpp:115
newAST_ModificationNull
AST_Modification newAST_ModificationNull()
Definition: ast_builder.cpp:487
newAST_Element_ClassWrapper
AST_Element newAST_Element_ClassWrapper(AST_Class c)
Definition: ast_builder.cpp:122
AST_Comment_
Definition: element.hpp:126
newAST_Class
AST_Class newAST_Class(AST_String s)
Definition: ast_builder.cpp:176
AST_Expression_ComponentReferenceExpAddDot
AST_Expression AST_Expression_ComponentReferenceExpAddDot(AST_Expression_ComponentReference cr, AST_String id, AST_String rest, AST_ExpressionList subs)
Definition: ast_builder.cpp:439
newAST_StatementList
AST_StatementList newAST_StatementList()
Definition: ast_builder.cpp:481
AST_ClassPrefix_Block
AST_ClassPrefix AST_ClassPrefix_Block()
Definition: ast_builder.cpp:370
AST_Statement_Assign_
Definition: statement.hpp:76
AST_Expression_Real_
Definition: expression.hpp:69
newAST_Expression_Function
AST_Expression newAST_Expression_Function(AST_String, AST_ExpressionList)
Definition: ast_builder.cpp:471
EXPCALL
@ EXPCALL
Definition: ast_types.hpp:173
newAST_Equation_ElseList
AST_Equation_ElseList newAST_Equation_ElseList()
Definition: ast_builder.cpp:491
newAST_Expression_BinOp
AST_Expression newAST_Expression_BinOp(AST_Expression left, AST_Expression right, BinOpType type)
Definition: ast_builder.cpp:265
newAST_Equation_ElseIfList
AST_Equation_ElseList newAST_Equation_ElseIfList()
Definition: ast_builder.cpp:477
newAST_Equation_If
AST_Equation newAST_Equation_If(AST_Expression e, AST_EquationList eql, AST_Equation_ElseList elseif, AST_EquationList elseeqs)
Definition: ast_builder.cpp:310
AST_ClassPrefix_Model
AST_ClassPrefix AST_ClassPrefix_Model()
Definition: ast_builder.cpp:360
newAST_CompositionInitialEquations
AST_CompositionEqsAlgs newAST_CompositionInitialEquations(AST_EquationList eqlist)
Definition: ast_builder.cpp:577
AST_SanitizeString
AST_String AST_SanitizeString(std::string new_string)
Definition: ast_builder.cpp:48
AST_ClassPrefix_None
AST_ClassPrefix AST_ClassPrefix_None()
Definition: ast_builder.cpp:404
newAST_Expression_Derivative
AST_Expression newAST_Expression_Derivative(AST_ExpressionList el)
Definition: ast_builder.cpp:174
AST_Class_SetFinal
AST_Class AST_Class_SetFinal(AST_Class c, AST_Boolean final)
Definition: ast_builder.cpp:422
AST_Equation_Equality_
Definition: equation.hpp:44
CP_TYPE
@ CP_TYPE
Definition: ast_types.hpp:219
AST_Equation_If_
Definition: equation.hpp:83
newAST_Comment
AST_Comment newAST_Comment(AST_String st, AST_ArgumentList al)
Definition: ast_builder.cpp:646
newAST_CompositionElement
AST_CompositionElement newAST_CompositionElement(AST_ElementList el)
Definition: ast_builder.cpp:196
newAST_DotString
AST_String newAST_DotString(AST_String s)
Definition: ast_builder.cpp:76
AST_ClassPrefix_AddPartial
AST_ClassPrefix AST_ClassPrefix_AddPartial(AST_Boolean partial, AST_ClassPrefix p)
Definition: ast_builder.cpp:406
newAST_Expression_Colon
AST_Expression newAST_Expression_Colon()
Definition: ast_builder.cpp:345
newAST_ClassList
AST_ClassList newAST_ClassList()
Definition: ast_builder.cpp:99
AST_ClassPrefix_Pure
AST_ClassPrefix AST_ClassPrefix_Pure(AST_Boolean oper)
Definition: ast_builder.cpp:396
newAST_Statement_When
AST_Statement newAST_Statement_When(AST_Expression cond, AST_StatementList sts, AST_Statement_ElseList else_st, AST_Comment c)
Definition: ast_builder.cpp:557
newAST_Expression_ComponentReference
AST_Expression_ComponentReference newAST_Expression_ComponentReference()
Definition: ast_builder.cpp:222
newAST_CompositionAlgorithms
AST_CompositionEqsAlgs newAST_CompositionAlgorithms(AST_StatementList stlist)
Definition: ast_builder.cpp:583
AST_Expression_ComponentReferenceExpAdd
AST_Expression AST_Expression_ComponentReferenceExpAdd(AST_Expression_ComponentReference cr, AST_String id, AST_String rest, AST_ExpressionList subs)
Definition: ast_builder.cpp:449
class.hpp
CP_PURE
@ CP_PURE
Definition: ast_types.hpp:222
newAST_Composition
AST_Composition newAST_Composition()
Definition: ast_builder.cpp:101
newAST_SimpleList
list< T1 > * newAST_SimpleList(T1 t)
Definition: ast_types.hpp:311
newAST_ClassExtends
AST_Class newAST_ClassExtends(AST_String, AST_Composition)
Definition: ast_builder.cpp:614
newAST_Expression_FunctionCallArgs
AST_Expression newAST_Expression_FunctionCallArgs(AST_ExpressionList el)
Definition: ast_builder.cpp:465
AST_CompositionEqsAlgs_
Definition: composition.hpp:73
AST_TypePrefixAdd
AST_TypePrefix AST_TypePrefixAdd(AST_TypePrefix tp, AST_TypePrefix tpadd)
Definition: ast_builder.cpp:263
block
int block
Definition: ast_builder.cpp:41
newAST_Statement_For
AST_Statement newAST_Statement_For(AST_ForIndexList index, AST_StatementList st)
Definition: ast_builder.cpp:553
AST_Expression_String_
Definition: expression.hpp:80
modification.hpp
newAST_CompositionElementList
AST_CompositionElementList newAST_CompositionElementList()
Definition: ast_builder.cpp:126
operator<<
ostream & operator<<(ostream &os, const AST_CompositionElement &ce)
Definition: ast_builder.cpp:243
newAST_ForIndex
AST_ForIndex newAST_ForIndex(AST_String ident, AST_Expression exp)
Definition: ast_builder.cpp:416
AST_Expression_Output_
Definition: expression.hpp:254
newAST_Expression_Boolean
AST_Expression newAST_Expression_Boolean(AST_Boolean b)
Definition: ast_builder.cpp:172
newAST_Expression_If
AST_Expression newAST_Expression_If(AST_Expression cond, AST_Expression then, AST_ExpressionList else_list, AST_Expression else_exp)
Definition: ast_builder.cpp:305
CP_OPERATOR
@ CP_OPERATOR
Definition: ast_types.hpp:220
newAST_Expression_OutputExpressions
AST_Expression newAST_Expression_OutputExpressions(AST_ExpressionList exp_list)
Definition: ast_builder.cpp:522
AST_Statement_When_
Definition: statement.hpp:57
newAST_ArgumentList
AST_ArgumentList newAST_ArgumentList()
Definition: ast_builder.cpp:493
CP_CONNECTOR
@ CP_CONNECTOR
Definition: ast_types.hpp:218
AST_ClassPrefix_Connector
AST_ClassPrefix AST_ClassPrefix_Connector(AST_Boolean expandable)
Definition: ast_builder.cpp:372
AST_ClassPrefix_Function
AST_ClassPrefix AST_ClassPrefix_Function(AST_ClassPrefix p)
Definition: ast_builder.cpp:384
CP_RECORD
@ CP_RECORD
Definition: ast_types.hpp:217
ast_types.hpp
CP_PACKAGE
@ CP_PACKAGE
Definition: ast_types.hpp:224
AST_Equation_Connect_
Definition: equation.hpp:60
CP_EXPANDABLE
@ CP_EXPANDABLE
Definition: ast_types.hpp:221
AST_Element_Component_
Definition: element.hpp:83
newAST_Element_ComponentList
AST_Element_ComponentList newAST_Element_ComponentList()
Definition: ast_builder.cpp:257
BINOPADD
@ BINOPADD
Definition: ast_types.hpp:146
newAST_Expression_Call
AST_Expression newAST_Expression_Call(AST_String name, AST_String rest, AST_ExpressionList args)
Definition: ast_builder.cpp:331
CP_PARTIAL
@ CP_PARTIAL
Definition: ast_types.hpp:213
CP_FUNCTION
@ CP_FUNCTION
Definition: ast_types.hpp:225
AST_Expression_Brace_
Definition: expression.hpp:163
BinOpType
BinOpType
Definition: ast_types.hpp:137
newAST_Expression_Brace
AST_Expression newAST_Expression_Brace(AST_ExpressionList el)
Definition: ast_builder.cpp:524
newAST_Argument_Modification
AST_Argument newAST_Argument_Modification(AST_String s, AST_Modification m)
Definition: ast_builder.cpp:495
AST_Expression_Boolean_
Definition: expression.hpp:91
newAST_Expression_DotCall
AST_Expression newAST_Expression_DotCall(AST_String name, AST_String rest, AST_ExpressionList args)
Definition: ast_builder.cpp:321
newAST_Expression_ComponentReferenceExpDot
AST_Expression newAST_Expression_ComponentReferenceExpDot(AST_String s, AST_String rest)
Definition: ast_builder.cpp:214
AST_Statement_If_
Definition: statement.hpp:91
EXPREAL
@ EXPREAL
Definition: ast_types.hpp:179
newAST_ExpressionList
AST_ExpressionList newAST_ExpressionList(AST_Expression e)
Definition: ast_builder.cpp:132
AST_ArgumentSet
AST_Argument AST_ArgumentSet(bool each, bool final, AST_Argument arg)
Definition: ast_builder.cpp:140
AST_Class_SetPrefixEncapsulated
AST_Class AST_Class_SetPrefixEncapsulated(AST_Class c, AST_ClassPrefix prefix, AST_Boolean enc)
Definition: ast_builder.cpp:430
newAST_ClassDerivation
AST_Class newAST_ClassDerivation(AST_String, AST_String, AST_StringList)
Definition: ast_builder.cpp:626
AST_Expression_Integer_
Definition: expression.hpp:58
AST_Expression_Bracket_
Definition: expression.hpp:302
CP_CLASS
@ CP_CLASS
Definition: ast_types.hpp:214
AST_StringDotAppend
AST_String AST_StringDotAppend(AST_String ret, AST_String a)
Definition: ast_builder.cpp:84
AST_Element_ClassWrapper_
Definition: element.hpp:115
CP_MODEL
@ CP_MODEL
Definition: ast_types.hpp:215
newAST_Declaration
AST_Declaration newAST_Declaration(AST_String s, AST_ExpressionList indexes, AST_Modification m)
Definition: ast_builder.cpp:187
AST_Equation_When_
Definition: equation.hpp:141
AST_ClassPrefix_Operator
AST_ClassPrefix AST_ClassPrefix_Operator()
Definition: ast_builder.cpp:386
newAST_Equation_When
AST_Equation newAST_Equation_When(AST_Expression cond, AST_EquationList eqs, AST_Equation_ElseList else_list, AST_Comment comment)
Definition: ast_builder.cpp:572
newAST_ImportClause
AST_Element_ImportClause newAST_ImportClause(AST_String name)
Definition: ast_builder.cpp:128
AST_Expression_CallArgs_
Definition: expression.hpp:152
newAST_Equation_Call
AST_Equation newAST_Equation_Call(AST_Expression e)
Definition: ast_builder.cpp:349
AST_ClassPrefix_Type
AST_ClassPrefix AST_ClassPrefix_Type()
Definition: ast_builder.cpp:380
AST_Modification_Equal_
Definition: modification.hpp:189
AST_Statement_OutputAssigment_
Definition: statement.hpp:133
newAST_Expression_Integer
AST_Expression newAST_Expression_Integer(int i)
Definition: ast_builder.cpp:130
newAST_ShortClassExp_Enum
AST_ShortClassExp newAST_ShortClassExp_Enum(AST_StringList)
Definition: ast_builder.cpp:590
current_element
#define current_element(it)
Definition: ast_types.hpp:34
AST_Statement_Else_
Definition: statement.hpp:150
AST_Composition_
Definition: composition.hpp:34
AST_Statement_Return_
Definition: statement.hpp:45
expression.hpp
AST_Expression_Null_
Definition: expression.hpp:229
newAST_CompositionEquations
AST_CompositionEqsAlgs newAST_CompositionEquations(AST_EquationList eqlist)
Definition: ast_builder.cpp:579
newAST_String
AST_String newAST_String(string s)
Definition: ast_builder.cpp:57
AST_Declaration_
Definition: element.hpp:64
newAST_Equation_Connect
AST_Equation newAST_Equation_Connect(AST_Expression_ComponentReference cr1, AST_Expression_ComponentReference cr2)
Definition: ast_builder.cpp:158
newAST_StoredDefinition
AST_StoredDefinition newAST_StoredDefinition(AST_ClassList cl, AST_String within)
Definition: ast_builder.cpp:46
statement.hpp