libutap  0.93
Uppaal Timed Automata Parser
systembuilder.cpp
Go to the documentation of this file.
1 // -*- mode: C++; c-file-style: "stroustrup"; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 
3 /* libutap - Uppaal Timed Automata Parser.
4  Copyright (C) 2002-2006 Uppsala University and Aalborg University.
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public License
8  as published by the Free Software Foundation; either version 2.1 of
9  the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  USA
20 */
21 
22 #include "utap/systembuilder.h"
23 
24 #include <vector>
25 #include <climits>
26 #include <cmath>
27 #include <cstring>
28 #include <cstdio>
29 #include <cassert>
30 #include <cinttypes>
31 #include <stdexcept>
32 #include <sstream>
33 #include <boost/tuple/tuple.hpp>
34 
35 using namespace UTAP;
36 using namespace Constants;
37 
38 using std::vector;
39 using std::pair;
40 using std::make_pair;
41 using std::min;
42 using std::max;
43 using std::string;
44 
46  : StatementBuilder(_system)
47 {
48  currentEdge = NULL;
49  currentGantt = NULL;
50  currentMessage = NULL;
51  currentCondition = NULL;
52  currentUpdate = NULL;
53  currentInstanceLine = NULL;
54  currentIODecl = NULL;
56  currentQuery = NULL;
57 };
58 
59 /************************************************************
60  * Variable and function declarations
61  */
63  expression_t init)
64 {
65  if (currentFun)
66  {
67  return system->addVariableToFunction(currentFun, frames.top(), type, name, init);
68  }
69  else
70  {
71  return system->addVariable(getCurrentDeclarationBlock(), type, name, init);
72  }
73 }
74 
75 bool SystemBuilder::addFunction(type_t type, const char* name)
76 {
77  return getCurrentDeclarationBlock()->addFunction(type, name, currentFun);
78 }
79 
81 {
83 }
84 
85 void SystemBuilder::addSelectSymbolToFrame(const char *id, frame_t& frame)
86 {
87  type_t type = typeFragments[0];
89 
90  if (!type.is(CONSTANT))
91  {
92  type = type.createPrefix(CONSTANT);
93  }
94 
95  if (!type.isScalar() && !type.isInteger())
96  {
97  handleError("$Scalar_set_or_integer_expected");
98  }
99  else if (!type.is(RANGE))
100  {
101  handleError("$Range_expected");
102  }
103  else
104  {
105  symbol_t uid;
106  if (resolve(id, uid))
107  {
108  boost::format w = boost::format("%1% $shadows_a_variable") % id;
109  handleWarning(w.str());
110  }
111  frame.addSymbol(id, type);
112  }
113 }
114 
115 /************************************************************
116  * Gantt chart
117  */
118 
119 void SystemBuilder::ganttDeclStart(const char* name)
120 {
121  currentGantt = new gantt_t(name);
123 }
124 
125 void SystemBuilder::ganttDeclSelect(const char *id)
126 {
127  addSelectSymbolToFrame(id, frames.top());
128 }
129 
131 {
132  currentGantt->parameters = frames.top();
133  popFrame();
135  delete currentGantt;
136  currentGantt = NULL;
137 }
138 
140 {
142 }
143 
145 {
146  addSelectSymbolToFrame(id, frames.top());
147 }
148 
150 {
151  ganttmap_t gm;
152  gm.parameters = frames.top();
153  gm.predicate = fragments[1];
154  gm.mapping = fragments[0];
155  fragments.pop(2);
156  popFrame();
157  currentGantt->mapping.push_back(gm);
158 }
159 
160 /************************************************************
161  * Guarded progress measure
162  */
163 void SystemBuilder::declProgress(bool hasGuard)
164 {
165  expression_t guard, measure;
166  measure = fragments[0];
167  fragments.pop();
168  if (hasGuard)
169  {
170  guard = fragments[0];
171  fragments.pop();
172  }
174 }
175 
176 /********************************************************************
177  * Process declarations
178  */
179 void SystemBuilder::procBegin(const char* name, const bool isTA,
180  const string type, const string mode)
181 {
182  currentTemplate = system->getDynamicTemplate (std::string(name));
183  if (currentTemplate) {
184 /* check if parameters match */
186  handleError("Inconsistent parameters");
187  }
188  else {
189  for(size_t i=0;i<params.getSize ();i++) {
190  if (params[i].getName () != currentTemplate->parameters[i].getName () || params[i].getType ().getKind() != currentTemplate->parameters[i].getType ().getKind ())
191  handleError("Inconsistent parameters");
192  }
193 
194  }
195  currentTemplate->isDefined = true;
196  }
197  else {
198 
199  if (frames.top().getIndexOf(name) != -1)
200  {
201  boost::format err = boost::format("$Duplicate_definition_of %1%") % name;
202  handleError(err.str());
203  }
204 
205  vector<string>::iterator result;
206 
207  //we search if the given name is a name of LSC
208  result = find( lscTemplateNames.begin(), lscTemplateNames.end(), string(name));
209 
210  bool b = (!isTA)? false : (result == lscTemplateNames.end());
211  if (b) //TA
212  {
214  }
215  else //LSC
216  {
217  currentTemplate = &system->addTemplate(name, params, b, type, mode);
218  }
219  }
220 
223 }
224 
225 void SystemBuilder::procEnd() // 1 ProcBody
226 {
227  currentTemplate = NULL;
228  popFrame();
229 }
230 
236 void SystemBuilder::procState(const char* name, bool hasInvariant, bool hasER) // 1 expr
237 {
238  expression_t e,f;
239  if (hasER)
240  {
241  f = fragments[0];
242  fragments.pop();
243  }
244  if (hasInvariant)
245  {
246  e = fragments[0];
247  fragments.pop();
248  }
249  currentTemplate->addLocation(name, e, f);
250 }
251 
252 void SystemBuilder::procStateCommit(const char* name)
253 {
254  symbol_t uid;
255  if (!resolve(name, uid) || !uid.getType().isLocation())
256  {
257  handleError("$Location_expected");
258  }
259  else if (uid.getType().is(URGENT))
260  {
261  handleError("$States_cannot_be_committed_and_urgent_at_the_same_time");
262  }
263  else
264  {
266  }
267 }
268 
269 void SystemBuilder::procStateUrgent(const char* name)
270 {
271  symbol_t uid;
272 
273  if (!resolve(name, uid) || !uid.getType().isLocation())
274  {
275  handleError("$Location_expected");
276  }
277  else if (uid.getType().is(COMMITTED))
278  {
279  handleError("$States_cannot_be_committed_and_urgent_at_the_same_time");
280  }
281  else
282  {
284  }
285 }
286 
287 void SystemBuilder::procBranchpoint(const char* name)
288 {
290 }
291 
292 void SystemBuilder::procStateInit(const char* name)
293 {
294  symbol_t uid;
295  if (!resolve(name, uid) || !uid.getType().isLocation())
296  {
297  handleError("$Location_expected");
298  }
299  else
300  {
301  currentTemplate->init = uid;
302  }
303 }
304 
305 void SystemBuilder::procEdgeBegin(const char* from, const char* to, const bool control, const char* actname)
306 {
307  symbol_t fid, tid;
308 
309  if (!resolve(from, fid) || (!fid.getType().isLocation() && !fid.getType().isBranchpoint()))
310  {
311  handleError("$No_such_location_or_branchpoint_(source)");
312  pushFrame(frame_t::createFrame(frames.top())); // dummy frame for upcoming popFrame
313  }
314  else if (!resolve(to, tid) || (!tid.getType().isLocation() && !tid.getType().isBranchpoint()))
315  {
316  handleError("$No_such_location_or_branchpoint_(destination)");
317  pushFrame(frame_t::createFrame(frames.top())); // dummy frame for upcoming popFrame
318  }
319  else
320  {
321  currentEdge = &currentTemplate->addEdge(fid, tid, control, actname);
324 #ifdef ENABLE_PROB
325  // default "probability" weight is 1.
326  currentEdge->prob = makeConstant(1);
327 #endif
329  }
330 }
331 
332 void SystemBuilder::procEdgeEnd(const char* from, const char* to)
333 {
334  popFrame();
335 }
336 
337 void SystemBuilder::procSelect(const char *id)
338 {
340 }
341 
343 {
345  fragments.pop();
346 }
347 
349 {
351  fragments.pop();
352 }
353 
355 {
357  fragments.pop();
358 }
359 
360 
362 {
363 #ifdef ENABLE_PROB
364  currentEdge->prob = fragments[0];
365 #endif
366  fragments.pop();
367 }
368 
369 
370 /********************************************************************
371  * System declaration
372  */
373 
375  const char* name, size_t parameters, const char* templ_name)
376 {
377  /* Make sure this identifier is new.
378  */
379  if (frames.top().getIndexOf(name) != -1)
380  {
381  boost::format err = boost::format("$Duplicate_definition_of %1%") % name;
382  handleError(err.str());
383  }
384 
385  /* Lookup symbol.
386  */
387  symbol_t id;
388  if (!resolve(templ_name, id) || (id.getType().getKind() != INSTANCE
389  && id.getType().getKind() != LSCINSTANCE))
390  {
391  handleError("$Not_a_template");
392  }
393 
394  /* Push parameters to frame stack.
395  */
396  frame_t frame = frame_t::createFrame(frames.top());
397  frame.add(params);
398  pushFrame(frame);
400 }
401 
403  const char *name, size_t parameters, const char *templ_name, size_t arguments)
404 {
405  /* Parameters are at the top of the frame stack.
406  */
407  frame_t pars = frames.top();
408  popFrame();
409  assert(parameters == pars.getSize());
410 
411  /* Lookup symbol. In case of failure, instantiationBegin already
412  * reported the problem.
413  */
414  symbol_t id;
415  if (resolve(templ_name, id) &&
416  (id.getType().getKind() == INSTANCE||id.getType().getKind() == LSCINSTANCE))
417  {
418  instance_t *old_instance = static_cast<instance_t*>(id.getData());
419 
420  /* Check number of arguments. If too many arguments, pop the
421  * rest.
422  */
423  size_t expected = id.getType().size();
424  if (arguments < expected)
425  {
426  handleError("$Too_few_arguments");
427  }
428  else if (arguments > expected)
429  {
430  handleError("$Too_many_arguments");
431  }
432  else
433  {
434  /* Collect arguments from expression stack.
435  */
436  vector<expression_t> exprs(arguments);
437  while (arguments)
438  {
439  arguments--;
440  exprs[arguments] = fragments[0];
441  fragments.pop();
442  }
443 
444  /* Create template composition.
445  */
446  instance_t &new_instance = (id.getType().getKind() == INSTANCE) ?
447  system->addInstance(name, *old_instance, pars, exprs) :
448  system->addLscInstance(name, *old_instance, pars, exprs);
449 
450  /* Propagate information about restricted variables. The
451  * variables used in arguments to restricted parameters of
452  * old_instance are restricted in new_instance.
453  *
454  * REVISIT: Move to system.cpp?
455  */
456  std::set<symbol_t> &restricted = old_instance->restricted;
457  for (size_t i = 0; i < expected; i++)
458  {
459  if (restricted.find(old_instance->parameters[i]) != restricted.end())
460  {
461  collectDependencies(new_instance.restricted, exprs[i]);
462  }
463  }
464  }
465  }
466  fragments.pop(arguments);
467 }
468 
469 // Adds process_t* pointer to system_line
470 // Checks for duplicate entries
471 void SystemBuilder::process(const char* name)
472 {
474  if (!resolve(name, symbol))
475  {
476  throw TypeException(boost::format("$No_such_process: %1%") % name);
477  }
478  type_t type = symbol.getType();
479  if (type.getKind() != INSTANCE)
480  {
481  throw TypeException(boost::format("$Not_a_template: %1%") % symbol.getName());
482  }
483  if (type.size() > 0)
484  {
485  // FIXME: Check type of unbound parameters
486  }
487  system->addProcess(*static_cast<instance_t*>(symbol.getData()));
488  procPriority(name);
489 }
490 
492 {
493 }
494 
496 {
497 }
498 
500 {
502  fragments.pop();
503 }
504 
506 {
508  fragments.pop();
509 }
510 
511 /********************************************************************
512  * Priority
513  */
514 
516 {
518  fragments.pop();
519 }
520 
521 void SystemBuilder::addChanPriority(char separator)
522 {
523  system->addChanPriority(separator, fragments[0]);
524  fragments.pop();
525 }
526 
528 {
530 }
531 
533 {
535 }
536 
537 void SystemBuilder::procPriority(const char* name)
538 {
540  if (!resolve(name, symbol))
541  {
542  boost::format err = boost::format("$No_such_process: %1%") % name;
543  handleError(err.str());
544  }
545  else
546  {
548  }
549 }
550 
555 {
557 }
567 void SystemBuilder::instanceName(const char* name, bool templ)
568 {
569  symbol_t uid;
570  if (templ)
571  {
572  string instName = string(name);
573  string templName = instName.substr(0, instName.find('(')); // std::cout << templName << std::endl;
574  if (!resolve(templName, uid) || (uid.getType().getKind() != INSTANCE))
575  {
576  handleError("$Not_a_template");
577  }
578  }
579  else
580  {
581  if (resolve(string(name), uid) && (uid.getType().getKind() == INSTANCE))
582  {
583  template_t* t = static_cast<template_t*>(uid.getData());
584  if (t->parameters.getSize() > 0)
585  {
586  handleError("$Wrong_number_of_arguments_in_instance_line_name");
587  }
588  }
589  }
592 }
593 
594 void SystemBuilder::instanceNameBegin(const char* name)
595 {
596  /* Push parameters to frame stack.
597  */
598  frame_t frame = frame_t::createFrame(frames.top());
599  frame.add(params);
600  pushFrame(frame);
602 }
603 
604 void SystemBuilder::instanceNameEnd(const char *name, size_t arguments)
605 {
606  std::string i_name = std::string(name);
607  vector<expression_t>::const_iterator itr;
608  /* Parameters are at the top of the frame stack.
609  */
610  frame_t pars = frames.top();
611  popFrame();
612  //assert(parameters == pars.getSize());
613 
614  /* Lookup symbol. In case of failure, instanceNameBegin already
615  * reported the problem.
616  */
617  symbol_t id;
618  if (resolve(name, id) && id.getType().getKind() == INSTANCE)
619  {
620  instance_t *old_instance = static_cast<instance_t*>(id.getData());
621 
622  /* Check number of arguments. If too many arguments, pop the
623  * rest.
624  */
625  size_t expected = id.getType().size();
626  if (arguments < expected)
627  {
628  handleError("$Too_few_arguments");
629  }
630  else if (arguments > expected)
631  {
632  handleError("$Too_many_arguments");
633  }
634  else
635  {
636  /* Collect arguments from expression stack.
637  */
638  vector<expression_t> exprs(arguments);
639  while (arguments)
640  {
641  arguments--;
642  exprs[arguments] = fragments[0];
643  fragments.pop();
644  }
645  i_name += '(';
646  for (itr = exprs.begin(); itr != exprs.end(); ++itr)
647  {
648  if (itr != exprs.begin() && exprs.size() > 1)
649  {
650  i_name += ',';
651  }
652  i_name += itr->toString();
653  }
654  i_name += ')';
655  instanceName(i_name.c_str()); //std::cout << "instance line name: " << i_name << std::endl;
656  /* Create template composition.
657  */
658  currentInstanceLine->addParameters(*old_instance, pars, exprs);
659 
660  /* Propagate information about restricted variables. The
661  * variables used in arguments to restricted parameters of
662  * old_instance are restricted in new_instance.
663  *
664  * REVISIT: Move to system.cpp?
665  */
666  std::set<symbol_t> &restricted = old_instance->restricted;
667  for (size_t i = 0; i < expected; i++)
668  {
669  if (restricted.find(old_instance->parameters[i]) != restricted.end())
670  {
672  }
673  }
674  }
675  }
676  fragments.pop(arguments);
677 }
678 
679 
683 void SystemBuilder::procMessage(const char* from, const char* to, const int loc, const bool pch){
684  symbol_t fid, tid;
685  if (!resolve(from, fid) || !fid.getType().isInstanceLine())
686  {
687  handleError("$No_such_instance_line_(source)");
688  }
689  else if (!resolve(to, tid) || !tid.getType().isInstanceLine())
690  {
691  handleError("$No_such_instance_line_(destination)");
692  }
693  else
694  {
695  currentMessage = &currentTemplate->addMessage(fid, tid, loc, pch);
696  }
697 }
698 
700 {
701  if (currentMessage)
703  fragments.pop();
704 }
705 
709 void SystemBuilder::procCondition(const vector<char*> anchors, const int loc,
710  const bool pch, const bool hot){
711  symbol_t anchorid;
712  char* anchor;
713  vector<symbol_t> v_anchorid;
714  bool error=false;
715  bool isHot = hot;
716 
717  for (unsigned int i(0);i<anchors.size();++i){
718  anchor = anchors[i];
719  if (!resolve(anchor, anchorid) || !anchorid.getType().isInstanceLine())
720  {
721  handleError("$No_such_instance_line_(anchor)");
722  error = true;
723  }
724  else if (!error){
725  v_anchorid.push_back(anchorid);
726  }
727  }
728  if (pch && hot)
729  {
730  handleWarning("$In_the_prechart_all_conditions_are_cold");
731  isHot = false;
732  }
733  if (!error)
734  {
735  currentCondition = &currentTemplate->addCondition(v_anchorid, loc, pch, isHot);
737  }
738 }
739 
741 {
742  if (currentCondition)
744  fragments.pop();
745 }
746 
750 void SystemBuilder::procLscUpdate(const char* anchor, const int loc, const bool pch)
751 {
752  symbol_t anchorid;
753 
754  if (!resolve(anchor, anchorid) || !anchorid.getType().isInstanceLine())
755  {
756  handleError("$No_such_instance_line_(anchor)");
757  }
758  else
759  {
760  currentUpdate = &currentTemplate->addUpdate(anchorid, loc, pch);
762  }
763 }
764 
766 {
767  if (currentUpdate)
769  fragments.pop();
770 }
771 
772 void SystemBuilder::hasPrechart(const bool pch){
774 }
775 
776 
778 {
779  if (!currentIODecl)
780  {
782  }
783 
784  switch(type)
785  {
786  case SYNC_BANG:
787  currentIODecl->outputs.push_back(fragments[0]);
788  break;
789  case SYNC_QUE:
790  currentIODecl->inputs.push_back(fragments[0]);
791  break;
792  case SYNC_CSP:
793  currentIODecl->csp.push_back(fragments[0]);
794  break;
795  }
796 
797  fragments.pop();
798 }
799 
800 void SystemBuilder::declIO(const char* name, int nbParam, int nbSync)
801 {
802  assert(currentIODecl);
803 
804  currentIODecl->instanceName = name;
805  currentIODecl->param.resize(nbParam);
806  for(int i = 0; i < nbParam; ++i)
807  {
808  currentIODecl->param[i] = fragments[nbParam-i-1];
809  }
810  fragments.pop(nbParam);
811  assert(currentIODecl->inputs.size() + currentIODecl->outputs.size() + currentIODecl->csp.size() == size_t(nbSync));
812  currentIODecl = NULL;
813 }
814 
815 void SystemBuilder::declDynamicTemplate(const std::string& name)
816 {
817  assert(!currentTemplate);
818  /* check if name already exists */
819  if (frames.top().getIndexOf(name) != -1)
820  {
821  boost::format err = boost::format("$Duplicate_definition_of %1%") % name;
822  handleError(err.str());
823  }
824 
825  for (size_t i = 0; i<params.getSize(); ++i)
826  if (!params[i].getType().isInteger() &&
827  !params[i].getType().isBoolean() &&
828  !(params[i].getType().is(REF) &&
829  params[i].getType()[0].is(BROADCAST)))
830  handleError("Parameters to a dynamic template must be either booleans or integers and cannot be references");
831 
833 
834  params = frame_t::createFrame(); //reset params
835 }
836 
838  currentQuery = new query_t;
839 }
840 
841 void SystemBuilder::queryFormula(const char* formula, const char* location)
842 {
843  if (formula) {
844  currentQuery->formula = formula;
845  }
846  if (location) {
847  currentQuery->location = location;
848  }
849 }
850 
852 {
853  if (comment) {
855  }
856 }
858 {
860  delete currentQuery;
861  currentQuery = NULL;
862 }
expression_t mapping
Definition: system.h:142
void procLscUpdate() override
Partial instance of a template.
Definition: system.h:329
std::string formula
Definition: system.h:438
void procPriority(const char *) override
void addProgressMeasure(declarations_t *, expression_t guard, expression_t measure)
Definition: system.cpp:1189
void exprSync(Constants::synchronisation_t type) override
bool isDefined
Definition: system.h:390
edge_t & addEdge(symbol_t src, symbol_t dst, bool type, const std::string &actname)
Add edge to template.
Definition: system.cpp:325
void ganttEntrySelect(const char *id) override
std::list< ganttmap_t > mapping
Definition: system.h:155
expression_t label
The label.
Definition: system.h:205
instance_t & addInstance(const std::string &name, instance_t &instance, frame_t params, const std::vector< expression_t > &arguments)
Definition: system.cpp:1037
void procProb() override
TimedAutomataSystem * system
Pointer to the system under construction.
void procBegin(const char *name, const bool isTA=true, const std::string type="", const std::string mode="") override
std::set< symbol_t > restricted
Restricted variables.
Definition: system.h:337
void addQuery(const query_t &query)
Definition: system.cpp:1120
std::string comment
Definition: system.h:439
bool hasPrechart
Definition: system.h:387
uint32_t getSize() const
Returns the number of symbols in this frame.
Definition: symbols.cpp:328
instance_t & addLscInstance(const std::string &name, instance_t &instance, frame_t params, const std::vector< expression_t > &arguments)
Definition: system.cpp:1061
void ganttEntryEnd() override
void popFrame()
Pop the topmost frame.
void addGantt(declarations_t *, gantt_t &)
Definition: system.cpp:1115
void incProcPriority() override
condition_t & addCondition(std::vector< symbol_t > anchors, int loc, bool pch, bool isHot)
Add condition to template.
Definition: system.cpp:398
bool isInteger() const
Shortcut for is(INT).
Definition: type.h:202
expression_t label
The label.
Definition: system.h:194
expression_t guard
The guard.
Definition: system.h:95
void setBeforeUpdate(expression_t)
Definition: system.cpp:1300
void procMessage(const char *from, const char *to, const int loc, const bool pch) override
Add a message to the current template.
void ganttDeclEnd() override
void beforeUpdate() override
A reference to a symbol.
Definition: symbols.h:107
void processListEnd() override
void procUpdate() override
std::string getName() const
Returns the name (identifier) of this symbol.
Definition: symbols.cpp:228
expression_t sync
The synchronisation.
Definition: system.h:97
type_t createPrefix(Constants::kind_t kind, position_t=position_t()) const
Creates a new type by adding a prefix to it.
Definition: type.cpp:532
std::list< expression_t > outputs
Definition: system.h:132
void addSelectSymbolToFrame(const char *name, frame_t &)
edge_t * currentEdge
The edge under construction.
Definition: systembuilder.h:76
void queryEnd() override
frame_t parameters
The parameters.
Definition: system.h:332
static type_t createPrimitive(Constants::kind_t, position_t=position_t())
Create a primitive type.
Definition: type.cpp:527
void handleWarning(const std::string &) override
bool resolve(const std::string &, symbol_t &)
void declDynamicTemplate(const std::string &) override
Dynamic.
void process(const char *) override
std::vector< expression_t > param
Definition: system.h:131
update_t & addUpdate(symbol_t anchor, int loc, bool pch)
Add update to template.
Definition: system.cpp:387
void addChanPriority(char separator) override
void ganttDeclStart(const char *name) override
std::string location
Definition: system.h:440
void pushFrame(frame_t)
Push a new frame.
void afterUpdate() override
expression_t assign
The assignment.
Definition: system.h:96
variable_t * addVariable(type_t type, const char *name, expression_t init) override
frame_t parameters
Definition: system.h:141
void instanceNameBegin(const char *name) override
instanceLine_t & addInstanceLine()
Add another instance line to template.
Definition: system.cpp:357
bool addFunction(type_t type, const char *name) override
Partial implementation of the builder interface, useful for building something with statements that i...
message_t & addMessage(symbol_t src, symbol_t dst, int loc, bool pch)
Add message to template.
Definition: system.cpp:374
Gantt chart entry.
Definition: system.h:148
condition_t * currentCondition
The condition under construction.
Definition: systembuilder.h:82
std::list< expression_t > inputs
Definition: system.h:132
void instantiationEnd(const char *, size_t, const char *, size_t) override
void beginChanPriority(expression_t chan)
Definition: system.cpp:1320
void procCondition() override
#define comment
Definition: lexer.cc:856
expression_t label
The label.
Definition: system.h:218
void procSelect(const char *id) override
void addChanPriority(char separator, expression_t chan)
Definition: system.cpp:1328
static frame_t createFrame()
Creates and returns a new root-frame.
Definition: symbols.cpp:474
void setProcPriority(const char *name, int priority)
Sets process priority for process name.
Definition: system.cpp:1345
template_t * getDynamicTemplate(const std::string &name)
Definition: system.cpp:1026
template_t * currentTemplate
The template currently being parsed.
Base type for variables, clocks, etc.
Definition: system.h:43
void done() override
function_t * currentFun
The function currently being parsed.
SystemBuilder(TimedAutomataSystem *)
ExpressionFragments fragments
Expression stack.
static string symbol(const char *str)
Extracts the alpha-numerical symbol used for variable/type identifiers.
Definition: xmlreader.cpp:107
bool isBranchpoint() const
Shortcut for is(BRANCHPOINT).
Definition: type.h:223
std::stack< frame_t > frames
Frame stack.
void procInstanceLine() override
Adds an instance line to the current template.
bool addFunction(type_t type, const std::string &, function_t *&)
Add function declaration.
Definition: system.cpp:130
void procEnd() override
void beginChanPriority() override
void handleError(const std::string &) override
void ganttEntryStart() override
std::string instanceName
Definition: system.h:130
void setAfterUpdate(expression_t)
Definition: system.cpp:1310
Exception indicating a type error.
Definition: builder.h:39
static void collectDependencies(std::set< symbol_t > &, expression_t)
A reference to a frame.
Definition: symbols.h:183
iodecl_t * addIODecl()
Definition: system.cpp:1461
void instantiationBegin(const char *, size_t, const char *) override
A reference to a type.
Definition: type.h:93
type_t getType() const
Returns the type of this symbol.
Definition: symbols.cpp:205
void procStateInit(const char *name) override
frame_t params
The params frame is used temporarily during parameter parsing.
state_t & addLocation(const std::string &, expression_t inv, expression_t er)
Add another location to template.
Definition: system.cpp:287
std::list< expression_t > csp
Definition: system.h:132
void defaultChanPriority() override
void procEdgeBegin(const char *from, const char *to, const bool control, const char *actname) override
size_t size() const
Returns the number of children.
Definition: type.cpp:81
void setType(type_t)
Alters the type of this symbol.
Definition: symbols.cpp:210
void procGuard() override
frame_t select
Frame for non-deterministic select.
Definition: system.h:94
void procBranchpoint(const char *name) override
void addProcess(instance_t &instance)
Definition: system.cpp:1098
Gantt map bool expr -> int expr that can be expanded.
Definition: system.h:139
A reference to an expression.
Definition: expression.h:70
variable_t * addVariable(declarations_t *, type_t type, const std::string &, expression_t initial)
void queryBegin() override
Verification queries.
variable_t * addVariableToFunction(function_t *, frame_t, type_t, const std::string &, expression_t initital)
Definition: system.cpp:1142
void addParameters(instance_t &inst, frame_t params, const std::vector< expression_t > &arguments)
Definition: system.cpp:658
expression_t predicate
Definition: system.h:142
template_t & addTemplate(const std::string &, frame_t params, const bool isTA=true, const std::string &type="", const std::string &mode="")
Creates and returns a new template.
Definition: system.cpp:971
void * getData()
Returns the user data of this symbol.
Definition: symbols.cpp:216
void procSync(Constants::synchronisation_t type) override
void instanceName(const char *name, bool templ=true) override
templ is true if the name of the instance contains parameters like "Train(1)".
declarations_t * getCurrentDeclarationBlock()
frame_t parameters
The select parameters.
Definition: system.h:154
std::vector< std::string > lscTemplateNames
Definition: builder.h:94
symbol_t init
The initial location.
Definition: system.h:356
query_t * currentQuery
Definition: systembuilder.h:95
void declProgress(bool) override
Guard progress measure declaration.
branchpoint_t & addBranchpoint(const std::string &)
Add another branchpoint to template.
Definition: system.cpp:308
void procStateCommit(const char *name) override
bool is(Constants::kind_t kind) const
Returns true if the type has kind kind or if type is a prefix, RANGE or REF type and the getChild()...
Definition: type.cpp:176
void procEdgeEnd(const char *from=0, const char *to=0) override
symbol_t addSymbol(const std::string &name, type_t, void *user=NULL)
Adds a symbol of the given name and type to the frame.
Definition: symbols.cpp:352
update_t * currentUpdate
The update under construction.
Definition: systembuilder.h:85
bool isLocation() const
Shortcut for is(LOCATION).
Definition: type.h:217
iodecl_t * currentIODecl
Definition: systembuilder.h:93
Definition: lexer.cc:817
void declIO(const char *, int, int) override
instanceLine_t * currentInstanceLine
The instance line under construction.
Definition: systembuilder.h:91
static expression_t createSync(expression_t, Constants::synchronisation_t, position_t=position_t())
Create a SYNC expression.
message_t * currentMessage
The message under construction.
Definition: systembuilder.h:88
void ganttDeclSelect(const char *id) override
bool isScalar() const
Shortcut for is(SCALAR).
Definition: type.h:232
void instanceNameEnd(const char *name, size_t arguments) override
void procStateUrgent(const char *name) override
template_t & addDynamicTemplate(const std::string &, frame_t params)
Definition: system.cpp:994
void hasPrechart(const bool pch) override
declarations_t & getGlobals()
Returns the global declarations of the system.
Definition: system.cpp:961
TypeFragments typeFragments
Type stack.
int32_t currentProcPriority
The current process priority level.
Definition: systembuilder.h:73
bool isInstanceLine() const
Shortcut for is(INSTANCELINE).
Definition: type.h:220
Constants::kind_t getKind() const
Returns the kind of type object.
Definition: type.cpp:120
void procState(const char *name, bool hasInvariant, bool hasER) override
Add a state to the current template.
gantt_t * currentGantt
The gantt map under construction.
Definition: systembuilder.h:79
expression_t makeConstant(int value)
void queryComment(const char *comment) override
void add(symbol_t)
Add all symbols from the given frame.
Definition: symbols.cpp:367
void queryFormula(const char *formula, const char *location) override
symbol_t uid
The name.
Definition: system.h:331