cprover
statement_list_parse_tree.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Statement List Language Parse Tree
4 
5 Author: Matthias Weiss, matthias.weiss@diffblue.com
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_STATEMENT_LIST_STATEMENT_LIST_PARSE_TREE_H
13 #define CPROVER_STATEMENT_LIST_STATEMENT_LIST_PARSE_TREE_H
14 
15 #include <util/std_code.h>
16 #include <util/std_expr.h>
17 
22 {
23 public:
25  void clear();
26 
30  {
35 
38  explicit var_declarationt(const symbol_exprt &symbol);
39  };
40  using var_declarationst = std::list<var_declarationt>;
41 
44  struct instructiont
45  {
47  std::vector<codet> tokens;
48 
51  void add_token(const codet &token);
52  };
53  using instructionst = std::list<instructiont>;
54 
59  struct networkt
60  {
63 
67  void set_title(const std::string &value);
69  void add_instruction(const instructiont &inst);
70 
72  explicit networkt(const std::string &title);
73 
74  networkt() = default;
75  };
76  using networkst = std::list<networkt>;
77 
80  struct tia_modulet
81  {
83  const irep_idt name;
85  const std::string version;
86 
97 
100 
103  void add_var_input_entry(const var_declarationt &declaration);
106  void add_var_inout_entry(const var_declarationt &declaration);
109  void add_var_output_entry(const var_declarationt &declaration);
112  void add_var_temp_entry(const var_declarationt &declaration);
115  void add_var_constant_entry(const var_declarationt &declaration);
118  void add_network(networkt &network);
119 
123  tia_modulet(const irep_idt &name, const std::string &version);
124  };
125 
129  {
132 
138  functiont(
139  const irep_idt &name,
140  const std::string &version,
141  const typet &return_type);
142  };
143  using functionst = std::list<functiont>;
144 
148  {
151 
155  function_blockt(const irep_idt &name, const std::string &version);
156 
159  void add_var_static_entry(const var_declarationt &declaration);
160  };
161  using function_blockst = std::list<function_blockt>;
162 
165  void add_function_block(function_blockt &block);
168  void add_function(functiont &function);
171  void swap(statement_list_parse_treet &other);
172 
178  std::vector<symbol_exprt> tags;
179 };
180 
181 #endif // CPROVER_STATEMENT_LIST_STATEMENT_LIST_PARSE_TREE_H
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:37
statement_list_parse_treet::var_declarationt::default_value
optionalt< exprt > default_value
Optional default value of the variable.
Definition: statement_list_parse_tree.h:34
statement_list_parse_treet::tia_modulet::networks
networkst networks
List of all networks of this module.
Definition: statement_list_parse_tree.h:99
statement_list_parse_treet::networkst
std::list< networkt > networkst
Definition: statement_list_parse_tree.h:76
statement_list_parse_treet::var_declarationst
std::list< var_declarationt > var_declarationst
Definition: statement_list_parse_tree.h:40
typet
The type of an expression, extends irept.
Definition: type.h:29
statement_list_parse_treet::tia_modulet::version
const std::string version
Version of the module.
Definition: statement_list_parse_tree.h:85
statement_list_parse_treet::tia_modulet::var_temp
var_declarationst var_temp
Temp variable declarations.
Definition: statement_list_parse_tree.h:94
statement_list_parse_treet::tia_modulet::add_var_temp_entry
void add_var_temp_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of temp variables.
Definition: statement_list_parse_tree.cpp:38
statement_list_parse_treet::networkt::set_title
void set_title(const std::string &value)
Sets the title of the network to a specific value.
Definition: statement_list_parse_tree.cpp:55
statement_list_parse_treet::functiont::return_type
const typet return_type
FC-exclusive return type.
Definition: statement_list_parse_tree.h:131
statement_list_parse_treet::var_declarationt
Struct for a single variable declaration in Statement List.
Definition: statement_list_parse_tree.h:30
statement_list_parse_treet::tia_modulet::var_input
var_declarationst var_input
Input variable declarations.
Definition: statement_list_parse_tree.h:88
statement_list_parse_treet::tia_modulet::add_var_constant_entry
void add_var_constant_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of constant variables.
Definition: statement_list_parse_tree.cpp:32
statement_list_parse_treet::instructiont
Represents a regular Statement List instruction which consists out of one or more codet tokens.
Definition: statement_list_parse_tree.h:45
statement_list_parse_treet::tia_modulet
Base element of all modules in the Totally Integrated Automation (TIA) portal by Siemens.
Definition: statement_list_parse_tree.h:81
statement_list_parse_treet::var_declarationt::variable
symbol_exprt variable
Representation of the variable, including identifier and type.
Definition: statement_list_parse_tree.h:32
statement_list_parse_treet::instructionst
std::list< instructiont > instructionst
Definition: statement_list_parse_tree.h:53
statement_list_parse_treet::function_blockt::add_var_static_entry
void add_var_static_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of static variables.
Definition: statement_list_parse_tree.cpp:44
symbol_exprt
Expression to hold a symbol (variable)
Definition: std_expr.h:82
statement_list_parse_treet::tia_modulet::add_var_output_entry
void add_var_output_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of output variables.
Definition: statement_list_parse_tree.cpp:26
statement_list_parse_treet::function_blockt
Structure for a simple function block in Statement List.
Definition: statement_list_parse_tree.h:148
statement_list_parse_treet::tia_modulet::add_network
void add_network(networkt &network)
Adds a network to the function.
Definition: statement_list_parse_tree.cpp:50
statement_list_parse_treet::tia_modulet::var_constant
var_declarationst var_constant
Constant variable declarations.
Definition: statement_list_parse_tree.h:96
statement_list_parse_treet::networkt::networkt
networkt()=default
statement_list_parse_treet::add_function
void add_function(functiont &function)
Adds a function to the parse tree.
Definition: statement_list_parse_tree.cpp:93
statement_list_parse_treet::swap
void swap(statement_list_parse_treet &other)
Swaps the contents of the parse tree with the parameter.
Definition: statement_list_parse_tree.cpp:105
statement_list_parse_treet::tia_modulet::add_var_inout_entry
void add_var_inout_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of inout variables.
Definition: statement_list_parse_tree.cpp:20
statement_list_parse_treet::function_blockt::function_blockt
function_blockt(const irep_idt &name, const std::string &version)
Create the function block name with a specific version.
Definition: statement_list_parse_tree.cpp:81
statement_list_parse_treet::function_blocks
function_blockst function_blocks
List of function blocks this parse tree includes.
Definition: statement_list_parse_tree.h:174
statement_list_parse_treet::tia_modulet::name
const irep_idt name
Name of the module.
Definition: statement_list_parse_tree.h:83
statement_list_parse_treet::tia_modulet::add_var_input_entry
void add_var_input_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of input variables.
Definition: statement_list_parse_tree.cpp:14
statement_list_parse_treet::instructiont::tokens
std::vector< codet > tokens
Data structure for all tokens of the instruction.
Definition: statement_list_parse_tree.h:47
statement_list_parse_treet::functiont::functiont
functiont(const irep_idt &name, const std::string &version, const typet &return_type)
Create the function name with a specific version and a return_value.
Definition: statement_list_parse_tree.cpp:112
statement_list_parse_treet::function_blockst
std::list< function_blockt > function_blockst
Definition: statement_list_parse_tree.h:161
statement_list_parse_treet::networkt::instructions
instructionst instructions
Definition: statement_list_parse_tree.h:62
std_code.h
optionalt
nonstd::optional< T > optionalt
Definition: optional.h:35
statement_list_parse_treet::networkt::title
optionalt< std::string > title
Definition: statement_list_parse_tree.h:61
statement_list_parse_treet::function_blockt::var_static
var_declarationst var_static
FB-exclusive static variable declarations.
Definition: statement_list_parse_tree.h:150
statement_list_parse_treet
Intermediate representation of a parsed Statement List file before converting it into a goto program.
Definition: statement_list_parse_tree.h:22
statement_list_parse_treet::var_declarationt::var_declarationt
var_declarationt(const symbol_exprt &symbol)
Creates a new.
Definition: statement_list_parse_tree.cpp:125
statement_list_parse_treet::clear
void clear()
Removes all functions and function blocks from the parse tree.
Definition: statement_list_parse_tree.cpp:98
statement_list_parse_treet::instructiont::add_token
void add_token(const codet &token)
Adds a codet element to the list of all tokens.
Definition: statement_list_parse_tree.cpp:120
statement_list_parse_treet::tags
std::vector< symbol_exprt > tags
List of tags that were included in the source.
Definition: statement_list_parse_tree.h:178
statement_list_parse_treet::networkt::add_instruction
void add_instruction(const instructiont &inst)
Adds an instruction to the network.
Definition: statement_list_parse_tree.cpp:68
statement_list_parse_treet::tia_modulet::var_inout
var_declarationst var_inout
Inout variable declarations.
Definition: statement_list_parse_tree.h:90
statement_list_parse_treet::functiont
Structure for a simple function in Statement List.
Definition: statement_list_parse_tree.h:129
statement_list_parse_treet::tia_modulet::var_output
var_declarationst var_output
Output variable declarations.
Definition: statement_list_parse_tree.h:92
statement_list_parse_treet::functionst
std::list< functiont > functionst
Definition: statement_list_parse_tree.h:143
std_expr.h
API to expression classes.
statement_list_parse_treet::tia_modulet::tia_modulet
tia_modulet(const irep_idt &name, const std::string &version)
Create the module name with a specific version.
Definition: statement_list_parse_tree.cpp:74
statement_list_parse_treet::functions
functionst functions
List of functions this parse tree includes.
Definition: statement_list_parse_tree.h:176
statement_list_parse_treet::networkt
Representation of a network in Siemens TIA.
Definition: statement_list_parse_tree.h:60
statement_list_parse_treet::add_function_block
void add_function_block(function_blockt &block)
Adds a function block to the parse tree.
Definition: statement_list_parse_tree.cpp:88
codet
Data structure for representing an arbitrary statement in a program.
Definition: std_code.h:35