CBMC
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_base.h>
16 #include <util/std_expr.h>
17 
18 #include <list>
19 
24 {
25 public:
27  void clear();
28 
32  {
36  std::optional<exprt> default_value;
37 
40  explicit var_declarationt(const symbol_exprt &symbol);
41  };
42  using var_declarationst = std::list<var_declarationt>;
43 
46  struct instructiont
47  {
49  std::vector<codet> tokens;
50 
53  void add_token(const codet &token);
54  };
55  using instructionst = std::list<instructiont>;
56 
61  struct networkt
62  {
63  std::optional<std::string> title;
65 
69  void set_title(const std::string &value);
71  void add_instruction(const instructiont &inst);
72 
74  explicit networkt(const std::string &title);
75 
76  networkt() = default;
77  };
78  using networkst = std::list<networkt>;
79 
82  struct tia_modulet
83  {
85  const irep_idt name;
87  const std::string version;
88 
99 
102 
105  void add_var_input_entry(const var_declarationt &declaration);
108  void add_var_inout_entry(const var_declarationt &declaration);
111  void add_var_output_entry(const var_declarationt &declaration);
114  void add_var_temp_entry(const var_declarationt &declaration);
117  void add_var_constant_entry(const var_declarationt &declaration);
120  void add_network(networkt &network);
121 
125  tia_modulet(const irep_idt &name, const std::string &version);
126  };
127 
131  {
134 
140  functiont(
141  const irep_idt &name,
142  const std::string &version,
143  const typet &return_type);
144  };
145  using functionst = std::list<functiont>;
146 
150  {
153 
157  function_blockt(const irep_idt &name, const std::string &version);
158 
161  void add_var_static_entry(const var_declarationt &declaration);
162  };
163  using function_blockst = std::list<function_blockt>;
164 
167  void add_function_block(function_blockt &block);
170  void add_function(functiont &function);
173  void swap(statement_list_parse_treet &other);
174 
180  std::vector<symbol_exprt> tags;
181 };
182 
183 #endif // CPROVER_STATEMENT_LIST_STATEMENT_LIST_PARSE_TREE_H
Data structure for representing an arbitrary statement in a program.
Definition: std_code_base.h:29
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
Intermediate representation of a parsed Statement List file before converting it into a goto program.
std::list< function_blockt > function_blockst
std::list< var_declarationt > var_declarationst
void clear()
Removes all functions and function blocks from the parse tree.
void add_function_block(function_blockt &block)
Adds a function block to the parse tree.
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.
void add_function(functiont &function)
Adds a function to the parse tree.
std::list< instructiont > instructionst
void swap(statement_list_parse_treet &other)
Swaps the contents of the parse tree with the parameter.
Expression to hold a symbol (variable)
Definition: std_expr.h:131
The type of an expression, extends irept.
Definition: type.h:29
API to expression classes.
Structure for a simple function block in Statement List.
function_blockt(const irep_idt &name, const std::string &version)
Create the function block name with a specific version.
void add_var_static_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of static variables.
var_declarationst var_static
FB-exclusive static variable declarations.
Structure for a simple function in Statement List.
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.
const typet return_type
FC-exclusive return type.
Represents a regular Statement List instruction which consists out of one or more codet tokens.
void add_token(const codet &token)
Adds a codet element to the list of all tokens.
std::vector< codet > tokens
Data structure for all tokens of the instruction.
Representation of a network in Siemens TIA.
void set_title(const std::string &value)
Sets the title of the network to a specific value.
void add_instruction(const instructiont &inst)
Adds an instruction to the network.
Base element of all modules in the Totally Integrated Automation (TIA) portal by Siemens.
void add_var_inout_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of inout variables.
var_declarationst var_constant
Constant variable declarations.
void add_var_constant_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of constant variables.
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.
void add_var_input_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of input variables.
tia_modulet(const irep_idt &name, const std::string &version)
Create the module name with a specific version.
void add_network(networkt &network)
Adds a network to the function.
networkst networks
List of all networks of this module.
var_declarationst var_temp
Temp variable declarations.
var_declarationst var_output
Output variable declarations.
void add_var_output_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of output variables.
void add_var_temp_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of temp variables.
Struct for a single variable declaration in Statement List.
var_declarationt(const symbol_exprt &symbol)
Creates a new.
std::optional< exprt > default_value
Optional default value of the variable.
symbol_exprt variable
Representation of the variable, including identifier and type.