CBMC
xml_parser.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 
10 #ifndef CPROVER_XMLLANG_XML_PARSER_H
11 #define CPROVER_XMLLANG_XML_PARSER_H
12 
13 #include <util/parser.h>
14 
15 #include "xml_parse_tree.h"
16 
17 class xml_parsert:public parsert
18 {
19 public:
20  explicit xml_parsert(message_handlert &message_handler)
21  : parsert(message_handler)
22  {
23  // Simplistic check that we don't attempt to do reentrant parsing as the
24  // Bison-generated parser has global state.
26  stack.push_back(&parse_tree.element);
27  }
28 
29  xml_parsert(const xml_parsert &) = delete;
30 
31  ~xml_parsert() override
32  {
34  }
35 
37 
38  std::list<xmlt *> stack;
39 
41  {
42  return *stack.back();
43  }
44 
45  bool parse() override;
46 
47  void new_level()
48  {
49  current().elements.push_back(xmlt());
50  stack.push_back(&current().elements.back());
51  }
52 
53 protected:
54  static int instance_count;
55 };
56 
57 int yyxmlerror(xml_parsert &, void *, const std::string &);
58 
59 // 'do it all' functions
60 bool parse_xml(
61  std::istream &in,
62  const std::string &filename,
63  message_handlert &message_handler,
64  xmlt &dest);
65 
66 bool parse_xml(
67  const std::string &filename,
68  message_handlert &message_handler,
69  xmlt &dest);
70 
71 #endif // CPROVER_XMLLANG_XML_PARSER_H
Definition: parser.h:25
xml_parsert(const xml_parsert &)=delete
static int instance_count
Definition: xml_parser.h:54
std::list< xmlt * > stack
Definition: xml_parser.h:38
xmlt & current()
Definition: xml_parser.h:40
bool parse() override
Definition: xml_parser.cpp:19
void new_level()
Definition: xml_parser.h:47
xml_parsert(message_handlert &message_handler)
Definition: xml_parser.h:20
xml_parse_treet parse_tree
Definition: xml_parser.h:36
~xml_parsert() override
Definition: xml_parser.h:31
Definition: xml.h:21
elementst elements
Definition: xml.h:42
Parser utilities.
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
bool parse_xml(std::istream &in, const std::string &filename, message_handlert &message_handler, xmlt &dest)
Definition: xml_parser.cpp:29
int yyxmlerror(xml_parsert &, void *, const std::string &)