22 #define NO_VALUE "(none)"
35 real.from_expr(constant);
36 os << real.to_float();
49 os << assignment.
lhs().
get(ID_identifier) <<
" := ";
51 expr_try_dynamic_cast<constant_exprt>(assignment.
rhs());
55 os << assignment.
rhs().
get(ID_identifier);
64 out <<
"============== Function Block ==============\n";
69 for(
const auto &
function : parse_tree.
functions)
71 out <<
"================= Function =================\n";
76 if(!parse_tree.
tags.empty())
78 out <<
"================= Tag List =================\n";
79 for(
const auto &tag : parse_tree.
tags)
111 os <<
"Name: " << module.
name <<
'\n';
112 os <<
"Version: " << module.
version <<
"\n\n";
119 os <<
"Return type: ";
120 if(
function.return_type.is_nil())
123 os <<
function.return_type.id();
133 os <<
"--------- Input Variables ----------\n\n";
139 os <<
"--------- In/Out Variables ---------\n\n";
145 os <<
"--------- Output Variables ---------\n\n";
151 os <<
"-------- Constant Variables --------\n\n";
157 os <<
"---------- Temp Variables ----------\n\n";
168 os <<
"--------- Static Variables ---------\n\n";
177 for(
const auto &declaration : declarations)
189 os <<
" * default_value: ";
204 os <<
"-------------- Networks --------------\n\n";
205 for(
const auto &network : networks)
217 os <<
"Instructions: ";
235 for(
const auto &expr : token.
operands())
238 expr_try_dynamic_cast<symbol_exprt>(expr);
245 expr_try_dynamic_cast<constant_exprt>(expr);
252 if(
const auto assign = expr_try_dynamic_cast<code_frontend_assignt>(expr))
258 os <<
'\t' << expr.id();
Pre-defined bitvector types.
bool can_cast_type< floatbv_typet >(const typet &type)
Check whether a reference to a typet is a floatbv_typet.
A codet representing an assignment in the program.
Data structure for representing an arbitrary statement in a program.
const irep_idt & get_statement() const
A constant literal expression.
const irep_idt & get_value() const
typet & type()
Return the type of the expression.
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
const irep_idt & get(const irep_idt &name) const
Intermediate representation of a parsed Statement List file before converting it into a goto program.
std::list< var_declarationt > var_declarationst
functionst functions
List of functions this parse tree includes.
function_blockst function_blocks
List of function blocks this parse tree includes.
std::vector< symbol_exprt > tags
List of tags that were included in the source.
std::list< networkt > networkst
Expression to hold a symbol (variable)
const irep_idt & get_identifier() const
#define NO_VALUE
String to indicate that there is no value.
void output_var_declaration(std::ostream &os, const statement_list_parse_treet::var_declarationt &declaration)
Prints the given Statement List variable declaration in a human-readable form to the given output str...
void output_return_value(const statement_list_parse_treet::functiont &function, std::ostream &os)
Prints the return value of a function to the given output stream.
static void output_parameter_assignment(std::ostream &os, const code_frontend_assignt &assignment)
Prints the assignment of a module parameter to the given output stream.
void output_instruction(std::ostream &os, const statement_list_parse_treet::instructiont &instruction)
Prints the given Statement List instruction in a human-readable form to the given output stream.
void output_var_declaration_list(std::ostream &os, const statement_list_parse_treet::var_declarationst &declarations)
Prints all variable declarations of the given list to the given output stream.
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.
static void output_constant(std::ostream &os, const constant_exprt &constant)
Prints a constant to the given output stream.
void output_tia_module_properties(const statement_list_parse_treet::tia_modulet &module, std::ostream &os)
Prints the basic information about a TIA module to the given output stream.
void output_function(std::ostream &os, const statement_list_parse_treet::functiont &function)
Prints the given Statement List function in a human-readable form to the given output stream.
void output_common_var_declarations(std::ostream &os, const statement_list_parse_treet::tia_modulet &module)
Prints all variable declarations functions and function blocks have in common to the given output str...
void output_network_list(std::ostream &os, const statement_list_parse_treet::networkst &networks)
Prints the given network list in a human-readable form to the given output stream.
void output_network(std::ostream &os, const statement_list_parse_treet::networkt &network)
Prints the given Statement List network in a human-readable form to the given output stream.
void output_function_block(std::ostream &os, const statement_list_parse_treet::function_blockt &function_block)
Prints the given Statement List function block in a human-readable form to the given output stream.
void output_static_var_declarations(std::ostream &os, const statement_list_parse_treet::function_blockt &block)
Prints the static variable declarations of a function block to the given output stream.
Statement List Language Parse Tree Output.
floatbv_typet get_real_type()
Creates a new type that resembles the 'Real' type of the Siemens PLC languages.
Statement List Type Helper.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
Structure for a simple function block in Statement List.
var_declarationst var_static
FB-exclusive static variable declarations.
Structure for a simple function in Statement List.
Represents a regular Statement List instruction which consists out of one or more codet tokens.
std::vector< codet > tokens
Data structure for all tokens of the instruction.
Representation of a network in Siemens TIA.
instructionst instructions
std::optional< std::string > title
Base element of all modules in the Totally Integrated Automation (TIA) portal by Siemens.
var_declarationst var_constant
Constant variable declarations.
var_declarationst var_input
Input variable declarations.
const std::string version
Version of the module.
const irep_idt name
Name of the module.
var_declarationst var_inout
Inout variable declarations.
networkst networks
List of all networks of this module.
var_declarationst var_temp
Temp variable declarations.
var_declarationst var_output
Output variable declarations.
Struct for a single variable declaration in Statement List.
std::optional< exprt > default_value
Optional default value of the variable.
symbol_exprt variable
Representation of the variable, including identifier and type.