33 #include <boost/tuple/tuple.hpp> 36 using namespace Constants;
108 boost::format w = boost::format(
"%1% $shadows_a_variable") % id;
180 const string type,
const string mode)
199 if (
frames.top().getIndexOf(name) != -1)
201 boost::format err = boost::format(
"$Duplicate_definition_of %1%") % name;
205 vector<string>::iterator result;
261 handleError(
"$States_cannot_be_committed_and_urgent_at_the_same_time");
279 handleError(
"$States_cannot_be_committed_and_urgent_at_the_same_time");
311 handleError(
"$No_such_location_or_branchpoint_(source)");
316 handleError(
"$No_such_location_or_branchpoint_(destination)");
375 const char* name,
size_t parameters,
const char* templ_name)
379 if (
frames.top().getIndexOf(name) != -1)
381 boost::format err = boost::format(
"$Duplicate_definition_of %1%") % name;
403 const char *name,
size_t parameters,
const char *templ_name,
size_t arguments)
409 assert(parameters == pars.
getSize());
423 size_t expected =
id.getType().size();
424 if (arguments < expected)
428 else if (arguments > expected)
436 vector<expression_t> exprs(arguments);
456 std::set<symbol_t> &restricted = old_instance->
restricted;
457 for (
size_t i = 0; i < expected; i++)
459 if (restricted.find(old_instance->
parameters[i]) != restricted.end())
476 throw TypeException(boost::format(
"$No_such_process: %1%") % name);
542 boost::format err = boost::format(
"$No_such_process: %1%") % name;
572 string instName = string(name);
573 string templName = instName.substr(0, instName.find(
'('));
586 handleError(
"$Wrong_number_of_arguments_in_instance_line_name");
606 std::string i_name = std::string(name);
607 vector<expression_t>::const_iterator itr;
625 size_t expected =
id.getType().size();
626 if (arguments < expected)
630 else if (arguments > expected)
638 vector<expression_t> exprs(arguments);
646 for (itr = exprs.begin(); itr != exprs.end(); ++itr)
648 if (itr != exprs.begin() && exprs.size() > 1)
652 i_name += itr->toString();
666 std::set<symbol_t> &restricted = old_instance->
restricted;
667 for (
size_t i = 0; i < expected; i++)
669 if (restricted.find(old_instance->
parameters[i]) != restricted.end())
691 handleError(
"$No_such_instance_line_(destination)");
710 const bool pch,
const bool hot){
713 vector<symbol_t> v_anchorid;
717 for (
unsigned int i(0);i<anchors.size();++i){
725 v_anchorid.push_back(anchorid);
806 for(
int i = 0; i < nbParam; ++i)
819 if (
frames.top().getIndexOf(name) != -1)
821 boost::format err = boost::format(
"$Duplicate_definition_of %1%") % name;
826 if (!
params[i].getType().isInteger() &&
827 !
params[i].getType().isBoolean() &&
830 handleError(
"Parameters to a dynamic template must be either booleans or integers and cannot be references");
void procLscUpdate() override
Partial instance of a template.
void procPriority(const char *) override
void addProgressMeasure(declarations_t *, expression_t guard, expression_t measure)
void exprSync(Constants::synchronisation_t type) override
edge_t & addEdge(symbol_t src, symbol_t dst, bool type, const std::string &actname)
Add edge to template.
void ganttEntrySelect(const char *id) override
std::list< ganttmap_t > mapping
expression_t label
The label.
instance_t & addInstance(const std::string &name, instance_t &instance, frame_t params, const std::vector< expression_t > &arguments)
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.
void addQuery(const query_t &query)
uint32_t getSize() const
Returns the number of symbols in this frame.
instance_t & addLscInstance(const std::string &name, instance_t &instance, frame_t params, const std::vector< expression_t > &arguments)
void ganttEntryEnd() override
void popFrame()
Pop the topmost frame.
void addGantt(declarations_t *, gantt_t &)
void incProcPriority() override
condition_t & addCondition(std::vector< symbol_t > anchors, int loc, bool pch, bool isHot)
Add condition to template.
bool isInteger() const
Shortcut for is(INT).
expression_t label
The label.
expression_t guard
The guard.
void setBeforeUpdate(expression_t)
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
void processListEnd() override
void procUpdate() override
std::string getName() const
Returns the name (identifier) of this symbol.
expression_t sync
The synchronisation.
type_t createPrefix(Constants::kind_t kind, position_t=position_t()) const
Creates a new type by adding a prefix to it.
std::list< expression_t > outputs
void addSelectSymbolToFrame(const char *name, frame_t &)
edge_t * currentEdge
The edge under construction.
frame_t parameters
The parameters.
static type_t createPrimitive(Constants::kind_t, position_t=position_t())
Create a primitive type.
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
update_t & addUpdate(symbol_t anchor, int loc, bool pch)
Add update to template.
void addChanPriority(char separator) override
void ganttDeclStart(const char *name) override
void pushFrame(frame_t)
Push a new frame.
void afterUpdate() override
expression_t assign
The assignment.
variable_t * addVariable(type_t type, const char *name, expression_t init) override
void instanceNameBegin(const char *name) override
instanceLine_t & addInstanceLine()
Add another instance line to template.
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.
void push(expression_t e)
condition_t * currentCondition
The condition under construction.
std::list< expression_t > inputs
void instantiationEnd(const char *, size_t, const char *, size_t) override
void beginChanPriority(expression_t chan)
void procCondition() override
expression_t label
The label.
void procSelect(const char *id) override
void addChanPriority(char separator, expression_t chan)
static frame_t createFrame()
Creates and returns a new root-frame.
void setProcPriority(const char *name, int priority)
Sets process priority for process name.
template_t * getDynamicTemplate(const std::string &name)
template_t * currentTemplate
The template currently being parsed.
Base type for variables, clocks, etc.
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.
bool isBranchpoint() const
Shortcut for is(BRANCHPOINT).
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.
void beginChanPriority() override
void handleError(const std::string &) override
void ganttEntryStart() override
void setAfterUpdate(expression_t)
Exception indicating a type error.
static void collectDependencies(std::set< symbol_t > &, expression_t)
void instantiationBegin(const char *, size_t, const char *) override
type_t getType() const
Returns the type of this symbol.
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.
std::list< expression_t > csp
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.
void setType(type_t)
Alters the type of this symbol.
void procGuard() override
frame_t select
Frame for non-deterministic select.
void procBranchpoint(const char *name) override
void addProcess(instance_t &instance)
Gantt map bool expr -> int expr that can be expanded.
A reference to an expression.
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)
void addParameters(instance_t &inst, frame_t params, const std::vector< expression_t > &arguments)
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.
void * getData()
Returns the user data of this symbol.
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.
std::vector< std::string > lscTemplateNames
symbol_t init
The initial location.
void declProgress(bool) override
Guard progress measure declaration.
branchpoint_t & addBranchpoint(const std::string &)
Add another branchpoint to template.
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()...
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.
update_t * currentUpdate
The update under construction.
bool isLocation() const
Shortcut for is(LOCATION).
void declIO(const char *, int, int) override
instanceLine_t * currentInstanceLine
The instance line under construction.
static expression_t createSync(expression_t, Constants::synchronisation_t, position_t=position_t())
Create a SYNC expression.
message_t * currentMessage
The message under construction.
void ganttDeclSelect(const char *id) override
bool isScalar() const
Shortcut for is(SCALAR).
void instanceNameEnd(const char *name, size_t arguments) override
void procStateUrgent(const char *name) override
template_t & addDynamicTemplate(const std::string &, frame_t params)
void hasPrechart(const bool pch) override
declarations_t & getGlobals()
Returns the global declarations of the system.
TypeFragments typeFragments
Type stack.
int32_t currentProcPriority
The current process priority level.
bool isInstanceLine() const
Shortcut for is(INSTANCELINE).
Constants::kind_t getKind() const
Returns the kind of type object.
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.
expression_t makeConstant(int value)
void queryComment(const char *comment) override
void add(symbol_t)
Add all symbols from the given frame.
void queryFormula(const char *formula, const char *location) override