libutap  0.93
Uppaal Timed Automata Parser
UTAP::StatementBuilder Class Referenceabstract

Partial implementation of the builder interface, useful for building something with statements that is not a UTAP system. More...

#include <statementbuilder.h>

Inheritance diagram for UTAP::StatementBuilder:
Collaboration diagram for UTAP::StatementBuilder:

Public Member Functions

 StatementBuilder (TimedAutomataSystem *)
 
 ~StatementBuilder ()
 
void typeArrayOfSize (size_t) override
 Called to create an array type. More...
 
void typeArrayOfType (size_t) override
 Called to create an array type. More...
 
void typeStruct (PREFIX, uint32_t fields) override
 Used to construct a new struct type, which is then pushed onto the type stack. More...
 
void structField (const char *name) override
 Used to declare the fields of a structure. More...
 
void declTypeDef (const char *name) override
 A type definition. More...
 
void declVar (const char *name, bool init) override
 Declare a new variable of the given name. More...
 
void declInitialiserList (uint32_t num) override
 
void declFieldInit (const char *name) override
 
void declParameter (const char *name, bool) override
 
void declFuncBegin (const char *name) override
 
void declFuncEnd () override
 
void blockBegin () override
 
void blockEnd () override
 
void emptyStatement () override
 
void forBegin () override
 
void forEnd () override
 
void iterationBegin (const char *name) override
 
void iterationEnd (const char *name) override
 
void whileBegin () override
 
void whileEnd () override
 
void doWhileBegin () override
 
void doWhileEnd () override
 
void ifBegin () override
 
void ifCondition () override
 
void ifThen () override
 
void ifEnd (bool) override
 
void exprStatement () override
 
void returnStatement (bool) override
 
void assertStatement () override
 
void exprCallBegin () override
 
- Public Member Functions inherited from UTAP::ExpressionBuilder
 ExpressionBuilder (TimedAutomataSystem *)
 
ExpressionFragmentsgetExpressions ()
 
void addPosition (uint32_t position, uint32_t offset, uint32_t line, const std::string &path) override
 Add mapping from an absolute position to a relative XML element. More...
 
void handleError (const std::string &) override
 
void handleWarning (const std::string &) override
 
void typeDuplicate () override
 Duplicate type at the top of the type stack. More...
 
void typePop () override
 Pop type at the topof the type stack. More...
 
void typeBool (PREFIX) override
 Called whenever a boolean type is parsed. More...
 
void typeInt (PREFIX) override
 Called whenever an integer type is parsed. More...
 
void typeDouble (PREFIX) override
 Called whenever a double type is parsed. More...
 
void typeBoundedInt (PREFIX) override
 Called whenever an integer type with a range is parsed. More...
 
void typeChannel (PREFIX) override
 Called whenever a channel type is parsed. More...
 
void typeClock (PREFIX) override
 Called whenever a clock type is parsed. More...
 
void typeVoid () override
 Called whenever a void type is parsed. More...
 
void typeScalar (PREFIX) override
 Called whenever a scalar type is parsed. More...
 
void typeName (PREFIX, const char *name) override
 Called when a type name has been parsed. More...
 
bool isType (const char *) override
 Must return true if and only if name is registered in the symbol table as a named type, for instance, "int" or "bool" or a user defined type. More...
 
void exprTrue () override
 
void exprFalse () override
 
void exprDouble (double) override
 
void exprId (const char *varName) override
 
void exprNat (int32_t) override
 
void exprCallEnd (uint32_t n) override
 
void exprArray () override
 
void exprPostIncrement () override
 
void exprPreIncrement () override
 
void exprPostDecrement () override
 
void exprPreDecrement () override
 
void exprAssignment (Constants::kind_t op) override
 
void exprUnary (Constants::kind_t unaryop) override
 
void exprBinary (Constants::kind_t binaryop) override
 
void exprNary (Constants::kind_t op, uint32_t num) override
 
void exprScenario (const char *name) override
 
expression_t exprScenario ()
 
void exprTernary (Constants::kind_t ternaryop, bool firstMissing) override
 
void exprInlineIf () override
 
void exprComma () override
 
void exprDot (const char *) override
 
void exprDeadlock () override
 
void exprForAllBegin (const char *name) override
 
void exprForAllEnd (const char *name) override
 
void exprExistsBegin (const char *name) override
 
void exprExistsEnd (const char *name) override
 
void exprSumBegin (const char *name) override
 
void exprSumEnd (const char *name) override
 
void exprBuiltinFunction1 (Constants::kind_t) override
 
void exprBuiltinFunction2 (Constants::kind_t) override
 
void exprBuiltinFunction3 (Constants::kind_t) override
 
void exprSMCControl () override
 
void exprProbaQualitative (Constants::kind_t, Constants::kind_t, double) override
 
void exprProbaQuantitative (Constants::kind_t) override
 
void exprProbaCompare (Constants::kind_t, Constants::kind_t) override
 
void exprProbaExpected (const char *aggregatingOp) override
 
void exprSimulate (int, bool=false, int=0) override
 
void exprMitlFormula () override
 
void exprMitlUntil (int, int) override
 
void exprMitlRelease (int, int) override
 
void exprMitlDisj () override
 
void exprMitlConj () override
 
void exprMitlNext () override
 
void exprMitlAtom () override
 
void exprMitlDiamond (int, int) override
 
void exprMitlBox (int, int) override
 
void exprSpawn (int params) override
 
void exprExit () override
 
void exprNumOf () override
 
void exprForAllDynamicBegin (const char *, const char *) override
 
void exprForAllDynamicEnd (const char *name) override
 
void exprExistsDynamicBegin (const char *, const char *) override
 
void exprExistsDynamicEnd (const char *) override
 
void exprSumDynamicBegin (const char *, const char *) override
 
void exprSumDynamicEnd (const char *name) override
 
void exprForeachDynamicBegin (const char *, const char *) override
 
void exprForeachDynamicEnd (const char *name) override
 
void pushDynamicFrameOf (template_t *t, const std::string &name)
 
void popDynamicFrameOf (const std::string &name)
 
- Public Member Functions inherited from UTAP::AbstractBuilder
 AbstractBuilder ()
 
void setPosition (uint32_t, uint32_t) override
 Sets the current position. More...
 
void ganttDeclStart (const char *name) override
 
void ganttDeclSelect (const char *id) override
 
void ganttDeclEnd () override
 
void ganttEntryStart () override
 
void ganttEntrySelect (const char *id) override
 
void ganttEntryEnd () override
 
void declProgress (bool) override
 Guard progress measure declaration. More...
 
void procBegin (const char *name, const bool isTA=true, const std::string type="", const std::string mode="") override
 
void procEnd () override
 
void procState (const char *name, bool hasInvariant, bool hasER) override
 
void procStateCommit (const char *name) override
 
void procStateUrgent (const char *name) override
 
void procStateInit (const char *name) override
 
void procBranchpoint (const char *name) override
 
void procEdgeBegin (const char *from, const char *to, const bool control, const char *actname) override
 
void procEdgeEnd (const char *from, const char *to) override
 
void procSelect (const char *id) override
 
void procGuard () override
 
void procSync (Constants::synchronisation_t type) override
 
void procUpdate () override
 
void procProb () override
 
void procInstanceLine () override
 
void instanceName (const char *name, bool templ=true) override
 
void instanceNameBegin (const char *name) override
 
void instanceNameEnd (const char *name, size_t arguments) override
 
void procMessage (const char *from, const char *to, const int loc, const bool pch) override
 
void procMessage (Constants::synchronisation_t type) override
 
void procCondition (const std::vector< char *> anchors, const int loc, const bool pch, const bool hot) override
 
void procCondition () override
 
void procLscUpdate (const char *anchor, const int loc, const bool pch) override
 
void procLscUpdate () override
 
void hasPrechart (const bool pch) override
 
void breakStatement () override
 
void continueStatement () override
 
void switchBegin () override
 
void switchEnd () override
 
void caseBegin () override
 
void caseEnd () override
 
void defaultBegin () override
 
void defaultEnd () override
 
void exprSync (Constants::synchronisation_t type) override
 
void declIO (const char *, int, int) override
 
void instantiationBegin (const char *, size_t, const char *) override
 
void instantiationEnd (const char *, size_t, const char *, size_t) override
 
void process (const char *) override
 
void processListEnd () override
 
void done () override
 
void handleExpect (const char *text) override
 
void property () override
 
void scenario (const char *) override
 
void parse (const char *) override
 
void beforeUpdate () override
 
void afterUpdate () override
 
void beginChanPriority () override
 
void addChanPriority (char separator) override
 
void defaultChanPriority () override
 
void incProcPriority () override
 
void procPriority (const char *) override
 
void declDynamicTemplate (const std::string &) override
 Dynamic. More...
 
void exprDynamicProcessExpr (const char *) override
 
void exprMITLForAllDynamicBegin (const char *, const char *) override
 
void exprMITLForAllDynamicEnd (const char *name) override
 
void exprMITLExistsDynamicBegin (const char *, const char *) override
 
void exprMITLExistsDynamicEnd (const char *name) override
 
void queryBegin () override
 Verification queries. More...
 
void queryFormula (const char *formula, const char *location) override
 
void queryComment (const char *comment) override
 
void queryEnd () override
 
- Public Member Functions inherited from UTAP::ParserBuilder
virtual ~ParserBuilder ()
 
void handleWarning (const char *msg,...)
 
void handleError (const char *msg,...)
 

Protected Member Functions

virtual variable_taddVariable (type_t type, const char *name, expression_t init)=0
 
virtual bool addFunction (type_t type, const char *name)=0
 
- Protected Member Functions inherited from UTAP::ExpressionBuilder
void pushFrame (frame_t)
 Push a new frame. More...
 
void popFrame ()
 Pop the topmost frame. More...
 
bool resolve (const std::string &, symbol_t &)
 
expression_t makeConstant (int value)
 
expression_t makeConstant (double value)
 
type_t applyPrefix (PREFIX, type_t type)
 Given a prefix and a type, this method creates a new type by applying the prefix. More...
 
virtual bool allowProcessReferences ()
 If this method returns true, it is allowed to access the private identifiers of a process by prefixing the identifier with the process name. More...
 

Static Protected Member Functions

static void collectDependencies (std::set< symbol_t > &, expression_t)
 
static void collectDependencies (std::set< symbol_t > &, type_t)
 

Protected Attributes

frame_t params
 The params frame is used temporarily during parameter parsing. More...
 
function_tcurrentFun
 The function currently being parsed. More...
 
std::vector< BlockStatement * > blocks
 Stack of nested statement blocks. More...
 
std::vector< type_tfields
 The types of a struct. More...
 
std::vector< std::string > labels
 The labels of a struct. More...
 
- Protected Attributes inherited from UTAP::ExpressionBuilder
ExpressionFragments fragments
 Expression stack. More...
 
TypeFragments typeFragments
 Type stack. More...
 
std::stack< frame_tframes
 Frame stack. More...
 
TimedAutomataSystemsystem
 Pointer to the system under construction. More...
 
template_tcurrentTemplate
 The template currently being parsed. More...
 
int32_t scalar_count
 Counter for creating unique scalarset names. More...
 
std::map< std::string, frame_tdynamicFrames
 
- Protected Attributes inherited from UTAP::AbstractBuilder
position_t position
 

Additional Inherited Members

- Public Types inherited from UTAP::ParserBuilder
enum  PREFIX {
  PREFIX_NONE = 0, PREFIX_CONST = 1, PREFIX_URGENT = 2, PREFIX_BROADCAST = 4,
  PREFIX_URGENT_BROADCAST = 6, PREFIX_SYSTEM_META = 8, PREFIX_HYBRID = 16
}
 
- Public Attributes inherited from UTAP::ParserBuilder
std::vector< std::string > lscTemplateNames
 

Detailed Description

Partial implementation of the builder interface, useful for building something with statements that is not a UTAP system.

Definition at line 39 of file statementbuilder.h.

Constructor & Destructor Documentation

◆ StatementBuilder()

StatementBuilder::StatementBuilder ( TimedAutomataSystem system)

Definition at line 44 of file statementbuilder.cpp.

References UTAP::frame_t::createFrame(), currentFun, UTAP::ExpressionBuilder::currentTemplate, and params.

Here is the call graph for this function:

◆ ~StatementBuilder()

StatementBuilder::~StatementBuilder ( )

Definition at line 52 of file statementbuilder.cpp.

References blocks.

Member Function Documentation

◆ addFunction()

virtual bool UTAP::StatementBuilder::addFunction ( type_t  type,
const char *  name 
)
protectedpure virtual

Implemented in UTAP::SystemBuilder.

Referenced by declFuncBegin().

Here is the caller graph for this function:

◆ addVariable()

virtual variable_t* UTAP::StatementBuilder::addVariable ( type_t  type,
const char *  name,
expression_t  init 
)
protectedpure virtual

Implemented in UTAP::SystemBuilder.

Referenced by declVar(), and iterationBegin().

Here is the caller graph for this function:

◆ assertStatement()

void StatementBuilder::assertStatement ( )
overridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 611 of file statementbuilder.cpp.

References blocks, UTAP::ExpressionBuilder::fragments, and UTAP::ExpressionBuilder::ExpressionFragments::pop().

Referenced by ifThen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blockBegin()

void StatementBuilder::blockBegin ( )
overridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 455 of file statementbuilder.cpp.

References blocks, UTAP::frame_t::createFrame(), UTAP::ExpressionBuilder::frames, and UTAP::ExpressionBuilder::pushFrame().

Here is the call graph for this function:

◆ blockEnd()

void StatementBuilder::blockEnd ( )
overridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 461 of file statementbuilder.cpp.

References blocks, and UTAP::ExpressionBuilder::popFrame().

Here is the call graph for this function:

◆ collectDependencies() [1/2]

void StatementBuilder::collectDependencies ( std::set< symbol_t > &  dependencies,
expression_t  expr 
)
staticprotected

Definition at line 57 of file statementbuilder.cpp.

References UTAP::expression_t::collectPossibleReads(), UTAP::variable_t::expr, and UTAP::symbol_t::getData().

Referenced by collectDependencies(), UTAP::SystemBuilder::instanceNameEnd(), UTAP::SystemBuilder::instantiationEnd(), and typeArrayOfType().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ collectDependencies() [2/2]

void StatementBuilder::collectDependencies ( std::set< symbol_t > &  dependencies,
type_t  type 
)
staticprotected

Definition at line 78 of file statementbuilder.cpp.

References collectDependencies(), UTAP::type_t::getKind(), UTAP::type_t::getRange(), UTAP::Constants::RANGE, and UTAP::type_t::size().

Here is the call graph for this function:

◆ declFieldInit()

void StatementBuilder::declFieldInit ( const char *  name)
overridevirtual

◆ declFuncBegin()

◆ declFuncEnd()

void StatementBuilder::declFuncEnd ( )
overridevirtual

◆ declInitialiserList()

◆ declParameter()

void StatementBuilder::declParameter ( const char *  name,
bool  ref 
)
overridevirtual

◆ declTypeDef()

void StatementBuilder::declTypeDef ( const char *  name)
overridevirtual

A type definition.

Assign the name to the given type on the type fragment stack. In case of array types, dim constant expressions are expected on and popped from the expression stack.

Reimplemented from UTAP::AbstractBuilder.

Definition at line 190 of file statementbuilder.cpp.

References UTAP::type_t::createTypeDef(), UTAP::ExpressionBuilder::frames, UTAP::ExpressionBuilder::TypeFragments::pop(), UTAP::AbstractBuilder::position, and UTAP::ExpressionBuilder::typeFragments.

Here is the call graph for this function:

◆ declVar()

void StatementBuilder::declVar ( const char *  name,
bool  hasInit 
)
overridevirtual

Declare a new variable of the given name.

The type is expected to be on the type stack. If the variable has an initialiser (the init parameter is true), then a constant expression is expected at the top of the expression stack. The expressions will be popped of the stack (the type is left untouched).

Reimplemented from UTAP::AbstractBuilder.

Definition at line 271 of file statementbuilder.cpp.

References addVariable(), currentFun, UTAP::ExpressionBuilder::fragments, UTAP::ExpressionBuilder::handleError(), initialisable(), mustInitialise(), UTAP::ExpressionBuilder::ExpressionFragments::pop(), UTAP::ExpressionBuilder::TypeFragments::pop(), and UTAP::ExpressionBuilder::typeFragments.

Here is the call graph for this function:

◆ doWhileBegin()

void StatementBuilder::doWhileBegin ( )
overridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 548 of file statementbuilder.cpp.

◆ doWhileEnd()

void StatementBuilder::doWhileEnd ( )
overridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 552 of file statementbuilder.cpp.

References blocks, UTAP::ExpressionBuilder::fragments, and UTAP::ExpressionBuilder::ExpressionFragments::pop().

Here is the call graph for this function:

◆ emptyStatement()

void StatementBuilder::emptyStatement ( )
overridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 473 of file statementbuilder.cpp.

References blocks.

◆ exprCallBegin()

void StatementBuilder::exprCallBegin ( )
overridevirtual

Reimplemented from UTAP::ExpressionBuilder.

Definition at line 621 of file statementbuilder.cpp.

References currentFun, UTAP::ExpressionBuilder::exprCallBegin(), UTAP::ExpressionBuilder::fragments, UTAP::ExpressionBuilder::handleError(), and UTAP::function_t::uid.

Referenced by ifThen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exprStatement()

void StatementBuilder::exprStatement ( )
overridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 570 of file statementbuilder.cpp.

References blocks, UTAP::ExpressionBuilder::fragments, and UTAP::ExpressionBuilder::ExpressionFragments::pop().

Referenced by ifThen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ forBegin()

void StatementBuilder::forBegin ( )
overridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 478 of file statementbuilder.cpp.

◆ forEnd()

void StatementBuilder::forEnd ( )
overridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 482 of file statementbuilder.cpp.

References blocks, UTAP::ExpressionBuilder::fragments, and UTAP::ExpressionBuilder::ExpressionFragments::pop().

Here is the call graph for this function:

◆ ifBegin()

void UTAP::StatementBuilder::ifBegin ( )
inlineoverridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 93 of file statementbuilder.h.

◆ ifCondition()

void UTAP::StatementBuilder::ifCondition ( )
inlineoverridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 94 of file statementbuilder.h.

◆ ifEnd()

void StatementBuilder::ifEnd ( bool  elsePart)
overridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 559 of file statementbuilder.cpp.

References blocks, UTAP::ExpressionBuilder::fragments, and UTAP::ExpressionBuilder::ExpressionFragments::pop().

Referenced by ifThen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ifThen()

void UTAP::StatementBuilder::ifThen ( )
inlineoverridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 95 of file statementbuilder.h.

References assertStatement(), exprCallBegin(), exprStatement(), ifEnd(), and returnStatement().

Here is the call graph for this function:

◆ iterationBegin()

◆ iterationEnd()

void StatementBuilder::iterationEnd ( const char *  name)
overridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 520 of file statementbuilder.cpp.

References blocks, and UTAP::ExpressionBuilder::popFrame().

Here is the call graph for this function:

◆ returnStatement()

void StatementBuilder::returnStatement ( bool  args)
overridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 576 of file statementbuilder.cpp.

References blocks, currentFun, UTAP::ExpressionBuilder::fragments, UTAP::symbol_t::getType(), UTAP::ExpressionBuilder::handleError(), UTAP::type_t::isVoid(), UTAP::ExpressionBuilder::ExpressionFragments::pop(), and UTAP::function_t::uid.

Referenced by ifThen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ structField()

void StatementBuilder::structField ( const char *  name)
overridevirtual

Used to declare the fields of a structure.

The type of the field is expected to be on the type fragment stack.

Reimplemented from UTAP::AbstractBuilder.

Definition at line 159 of file statementbuilder.cpp.

References UTAP::Constants::CONSTANT, fields, UTAP::ExpressionBuilder::handleError(), UTAP::type_t::is(), UTAP::type_t::isIntegral(), UTAP::type_t::isRecord(), UTAP::type_t::isScalar(), labels, UTAP::ExpressionBuilder::TypeFragments::pop(), UTAP::type_t::stripArray(), and UTAP::ExpressionBuilder::typeFragments.

Here is the call graph for this function:

◆ typeArrayOfSize()

void StatementBuilder::typeArrayOfSize ( size_t  )
overridevirtual

◆ typeArrayOfType()

void StatementBuilder::typeArrayOfType ( size_t  )
overridevirtual

Called to create an array type.

The size of the array was previously pushed as a type.

Reimplemented from UTAP::AbstractBuilder.

Definition at line 115 of file statementbuilder.cpp.

References collectDependencies(), UTAP::type_t::createArray(), UTAP::ExpressionBuilder::currentTemplate, UTAP::ExpressionBuilder::handleError(), UTAP::type_t::is(), UTAP::type_t::isInteger(), UTAP::type_t::isScalar(), UTAP::ExpressionBuilder::TypeFragments::pop(), UTAP::AbstractBuilder::position, UTAP::Constants::RANGE, UTAP::instance_t::restricted, and UTAP::ExpressionBuilder::typeFragments.

Referenced by typeArrayOfSize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ typeStruct()

void StatementBuilder::typeStruct ( PREFIX  prefix,
uint32_t  n 
)
overridevirtual

Used to construct a new struct type, which is then pushed onto the type stack.

The type is based on n fields, which are expected to be on and will be popped off the type stack.

Reimplemented from UTAP::AbstractBuilder.

Definition at line 143 of file statementbuilder.cpp.

References UTAP::ExpressionBuilder::applyPrefix(), UTAP::type_t::createRecord(), fields, labels, UTAP::AbstractBuilder::position, UTAP::ExpressionBuilder::TypeFragments::push(), and UTAP::ExpressionBuilder::typeFragments.

Here is the call graph for this function:

◆ whileBegin()

void StatementBuilder::whileBegin ( )
overridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 535 of file statementbuilder.cpp.

◆ whileEnd()

void StatementBuilder::whileEnd ( )
overridevirtual

Reimplemented from UTAP::AbstractBuilder.

Definition at line 539 of file statementbuilder.cpp.

References blocks, UTAP::ExpressionBuilder::fragments, and UTAP::ExpressionBuilder::ExpressionFragments::pop().

Here is the call graph for this function:

Member Data Documentation

◆ blocks

std::vector<BlockStatement*> UTAP::StatementBuilder::blocks
protected

◆ currentFun

function_t* UTAP::StatementBuilder::currentFun
protected

◆ fields

std::vector<type_t> UTAP::StatementBuilder::fields
protected

The types of a struct.

Definition at line 55 of file statementbuilder.h.

Referenced by declInitialiserList(), structField(), and typeStruct().

◆ labels

std::vector<std::string> UTAP::StatementBuilder::labels
protected

The labels of a struct.

Definition at line 58 of file statementbuilder.h.

Referenced by declFuncBegin(), declInitialiserList(), structField(), and typeStruct().

◆ params

frame_t UTAP::StatementBuilder::params
protected

The documentation for this class was generated from the following files: