CBMC
statement_list_parsert Class Reference

Responsible for starting the parse process and to translate the result into a statement_list_parse_treet. More...

#include <statement_list_parser.h>

+ Inheritance diagram for statement_list_parsert:
+ Collaboration diagram for statement_list_parsert:

Public Member Functions

 statement_list_parsert (message_handlert &message_handler)
 Constructor. More...
 
 statement_list_parsert (const statement_list_parsert &)=delete
 
 ~statement_list_parsert () override
 
bool parse () override
 Starts the parsing process and saves the result inside of this instance's parse tree. More...
 
void add_function_block (const exprt &block)
 Adds a function block to the parse tree by converting the block expression tree. More...
 
void add_function (const exprt &function)
 Adds a function to the parse tree by converting the function expression tree. More...
 
void add_tag_list (const exprt &tag_list)
 Adds a tag list to the parse tree by converting the tag_list expression tree. More...
 
void print_tree (std::ostream &out) const
 Prints the parse tree of this instance to the given output stream. More...
 
void swap_tree (statement_list_parse_treet &other)
 Swaps the contents of the parse tree of this instance with other. More...
 
- Public Member Functions inherited from parsert
 parsert ()
 
 parsert (message_handlert &message_handler)
 
virtual ~parsert ()
 
bool read (char &ch)
 
bool eof ()
 
void parse_error (const std::string &message, const std::string &before)
 
void inc_line_no ()
 
void set_line_no (unsigned _line_no)
 
void set_file (const irep_idt &file)
 
irep_idt get_file () const
 
unsigned get_line_no () const
 
unsigned get_column () const
 
void set_column (unsigned _column)
 
void set_source_location (exprt &e)
 
void set_function (const irep_idt &function)
 
void advance_column (unsigned token_width)
 

Private Attributes

statement_list_parse_treet parse_tree
 Tree that is being filled by the parsing process. More...
 

Static Private Attributes

static int instance_count = 0
 

Additional Inherited Members

- Public Attributes inherited from parsert
std::istream * in
 
std::string this_line
 
std::string last_line
 
std::vector< exprtstack
 
messaget log
 
- Protected Attributes inherited from parsert
source_locationt source_location
 
unsigned line_no
 
unsigned previous_line_no
 
unsigned column
 

Detailed Description

Responsible for starting the parse process and to translate the result into a statement_list_parse_treet.

This parser works by using the expression stack of its base class. During the parse process, expressions with different IDs and types are put on this stack and may get associated with each other. This way a tree structure with expressions as nodes is created. If the parser encounters a function or function block, it invokes add_function() or add_function_block(). These functions then convert the expression tree structure into a statement_list_parse_treet::functiont or statement_list_parse_treet::function_blockt and add it to the statement_list_parse_treet. See the implementation of scanner.l and parser.y for details about how and when the stack operations are performed.

Definition at line 30 of file statement_list_parser.h.

Constructor & Destructor Documentation

◆ statement_list_parsert() [1/2]

statement_list_parsert::statement_list_parsert ( message_handlert message_handler)
inlineexplicit

Constructor.

Definition at line 34 of file statement_list_parser.h.

◆ statement_list_parsert() [2/2]

statement_list_parsert::statement_list_parsert ( const statement_list_parsert )
delete

◆ ~statement_list_parsert()

statement_list_parsert::~statement_list_parsert ( )
inlineoverride

Definition at line 44 of file statement_list_parser.h.

Member Function Documentation

◆ add_function()

void statement_list_parsert::add_function ( const exprt function)

Adds a function to the parse tree by converting the function expression tree.

Parameters
functionRoot of a function expression tree.

Definition at line 319 of file statement_list_parser.cpp.

◆ add_function_block()

void statement_list_parsert::add_function_block ( const exprt block)

Adds a function block to the parse tree by converting the block expression tree.

Parameters
blockRoot of a function block expression tree.

Definition at line 302 of file statement_list_parser.cpp.

◆ add_tag_list()

void statement_list_parsert::add_tag_list ( const exprt tag_list)

Adds a tag list to the parse tree by converting the tag_list expression tree.

Parameters
tag_listRoot of a tag list expression tree.

Definition at line 41 of file statement_list_parser.cpp.

◆ parse()

bool statement_list_parsert::parse ( )
overridevirtual

Starts the parsing process and saves the result inside of this instance's parse tree.

Returns
False if successful.

Implements parsert.

Definition at line 343 of file statement_list_parser.cpp.

◆ print_tree()

void statement_list_parsert::print_tree ( std::ostream &  out) const

Prints the parse tree of this instance to the given output stream.

Parameters
outStream that should receive the result.

Definition at line 355 of file statement_list_parser.cpp.

◆ swap_tree()

void statement_list_parsert::swap_tree ( statement_list_parse_treet other)

Swaps the contents of the parse tree of this instance with other.

Parameters
otherParse tree which should be used in the swap operation.

Definition at line 360 of file statement_list_parser.cpp.

Member Data Documentation

◆ instance_count

int statement_list_parsert::instance_count = 0
staticprivate

Definition at line 81 of file statement_list_parser.h.

◆ parse_tree

statement_list_parse_treet statement_list_parsert::parse_tree
private

Tree that is being filled by the parsing process.

Definition at line 79 of file statement_list_parser.h.


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