Go to the documentation of this file.
36 if(op.get(ID_statement_list_type) == ID_statement_list_identifier)
37 return op.get(ID_value);
61 if(op.get(ID_statement_list_type) == ID_statement_list_version)
78 root.
id() == ID_statement_list_function,
79 "Expression ID should be statement_list_function");
83 if(op.get(ID_statement_list_type) == ID_statement_list_return)
99 if(op.id() == ID_statement_list_var_decls)
112 const exprt &var_list)
116 std::vector<symbol_exprt> symbols;
121 expr_try_dynamic_cast<symbol_exprt>(part);
123 symbols.push_back(*symbol);
125 default_value = part;
133 parse_tree_list.push_back(declaration);
144 const exprt &temp_vars)
151 expr_try_dynamic_cast<symbol_exprt>(part);
155 parse_tree_list.push_back(declaration);
168 const exprt &var_decls)
172 if(decls.id() == ID_statement_list_var_input)
174 else if(decls.id() == ID_statement_list_var_inout)
176 else if(decls.id() == ID_statement_list_var_output)
178 else if(decls.id() == ID_statement_list_var_constant)
180 else if(decls.id() == ID_statement_list_var_temp)
190 const exprt &var_decls)
194 if(ID_statement_list_var_input == decls.id())
196 else if(ID_statement_list_var_inout == decls.id())
198 else if(ID_statement_list_var_output == decls.id())
200 else if(ID_statement_list_var_static == decls.id())
202 else if(ID_statement_list_var_constant == decls.id())
204 else if(ID_statement_list_var_temp == decls.id())
218 if(op.id() == ID_statement_list_networks)
232 if(network_element.get(ID_statement_list_type) == ID_statement_list_title)
233 return network_element.get(ID_value).c_str();
247 if(network_element.id() == ID_statement_list_instructions)
248 return network_element;
258 const exprt &instructions)
266 if(operand.is_not_nil() && operand.id() != code_token.
get_statement())
280 const exprt &network_list)
295 block.
id() == ID_statement_list_function_block,
296 "Root expression ID should be ID_statement_list_function_block");
312 function.
id() == ID_statement_list_function,
313 "Expression ID should be statement_list_function");
#define UNREACHABLE
This should be used to mark dead code.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
optionalt< exprt > default_value
Optional default value of the variable.
Statement List Language Parser.
void add_function_block(const exprt &block)
Adds a function block to the parse tree by converting the block expression tree.
void print_tree(std::ostream &out) const
Prints the parse tree of this instance to the given output stream.
std::list< var_declarationt > var_declarationst
statement_list_parsert statement_list_parser
Instance of the parser, used by other modules.
The type of an expression, extends irept.
var_declarationst var_temp
Temp variable declarations.
bool parse() override
Starts the parsing process and saves the result inside of this instance's parse tree.
static std::string find_version(const exprt &root)
Searches for the version of the TIA module inside of its root expression.
static std::string find_network_title(const exprt &network)
Searches for the title of a network inside of its root expression.
const string_constantt & to_string_constant(const exprt &expr)
Struct for a single variable declaration in Statement List.
var_declarationst var_input
Input variable declarations.
char * yystatement_listtext
Base class for all expressions.
Represents a regular Statement List instruction which consists out of one or more codet tokens.
Base element of all modules in the Totally Integrated Automation (TIA) portal by Siemens.
static void fill_vars_with_default_values(statement_list_parse_treet::var_declarationst &parse_tree_list, const exprt &var_list)
Adds all variable declarations (which can have a default value) to the given list.
static void find_instructions(statement_list_parse_treet::networkt &network, const exprt &instructions)
Adds all valid instructions to the given network.
Expression to hold a symbol (variable)
Structure for a simple function block in Statement List.
void output_parse_tree(std::ostream &out, const statement_list_parse_treet &parse_tree)
Prints the given Statement List parse tree in a human-readable form to the given output stream.
void add_network(networkt &network)
Adds a network to the function.
void add_tag_list(const exprt &tag_list)
Adds a tag list to the parse tree by converting the tag_list expression tree.
void swap_tree(statement_list_parse_treet &other)
Swaps the contents of the parse tree of this instance with other.
Statement List Language Parse Tree Output.
var_declarationst var_constant
Constant variable declarations.
static exprt find_network_instructions(const exprt &network)
Searches for the instruction list of a network inside of its root expression.
statement_list_parse_treet parse_tree
Tree that is being filled by the parsing process.
void add_function(functiont &function)
Adds a function to the parse tree.
void swap(statement_list_parse_treet &other)
Swaps the contents of the parse tree with the parameter.
const std::string & id2string(const irep_idt &d)
Statement List Language Parse Tree.
static exprt find_network_list(const exprt &root)
Searches for the network list of the TIA element inside of its root expression.
static void fill_temp_vars(statement_list_parse_treet::var_declarationst &parse_tree_list, const exprt &temp_vars)
Adds all temp variable declarations (variable declarations which can't have a default value) to the g...
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const irep_idt & id() const
std::vector< exprt > operandst
int yystatement_listparse()
Defined in statement_list_y.tab.cpp.
void parse_error(const std::string &message, const std::string &before)
var_declarationst var_static
FB-exclusive static variable declarations.
void clear() override
Removes all functions and function blocks from the parse tree and clears the internal state of the pa...
Intermediate representation of a parsed Statement List file before converting it into a goto program.
void clear()
Removes all functions and function blocks from the parse tree.
static irep_idt find_name(const exprt &root)
Searches for the name of the TIA module inside of its root expression.
void add_token(const codet &token)
Adds a codet element to the list of all tokens.
std::vector< symbol_exprt > tags
List of tags that were included in the source.
void add_function(const exprt &function)
Adds a function to the parse tree by converting the function expression tree.
static void find_networks(statement_list_parse_treet::tia_modulet &module, const exprt &network_list)
Adds all valid networks and their instructions to the given function element.
void add_instruction(const instructiont &inst)
Adds an instruction to the network.
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
static typet find_return_value(const exprt &root)
Searches for the return type of a function inside of its root expression.
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
var_declarationst var_inout
Inout variable declarations.
int yystatement_listerror(const std::string &error)
Forwards any errors that are encountered during the parse process.
Structure for a simple function in Statement List.
var_declarationst var_output
Output variable declarations.
const irep_idt & get_statement() const
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
static exprt find_variable_list(const exprt &root)
Searches for the variable list of the TIA module inside of its root expression.
Responsible for starting the parse process and to translate the result into a statement_list_parse_tr...
Representation of a network in Siemens TIA.
void add_function_block(function_blockt &block)
Adds a function block to the parse tree.
static void find_variables(statement_list_parse_treet::functiont &function, const exprt &var_decls)
Adds all valid variable declarations to the given function.
Statement List Type Helper.
Data structure for representing an arbitrary statement in a program.