File: bison_to_ast_visitor.hpp

package info (click to toggle)
foundry 0.0.20130809-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 632 kB
  • ctags: 2,340
  • sloc: cpp: 6,376; yacc: 366; makefile: 192; lex: 184
file content (58 lines) | stat: -rw-r--r-- 1,769 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* Copyright 2009 Simon Richter <Simon.Richter@hogyros.de>
 *
 * Released under the GNU General Public Licence version 3.
 */

#ifndef foundry_tree_bison_to_ast_visitor_hpp_
#define foundry_tree_bison_to_ast_visitor_hpp_ 1

#include <tree_bison_cst.hpp>
#include <tree_tree.hpp>

#include <set>
#include <list>
#include <string>

namespace foundry {
namespace tree {

class bison_to_ast_visitor :
        public bison::node_const_visitor
{
public:
        bison_to_ast_visitor(void);
        virtual ~bison_to_ast_visitor(void) throw() { }

        root_ptr get_ast(void) { return ast; }

        virtual void visit(bison::start const &);
        virtual void visit(bison::empty_rules const &);
        virtual void visit(bison::chained_rules const &);
        virtual void visit(bison::rule const &);
        virtual void visit(bison::unnamed_alternative const &);
        virtual void visit(bison::named_alternative const &);
        virtual void visit(bison::single_alternative const &);
        virtual void visit(bison::chained_alternatives const &);
        virtual void visit(bison::terminated_alternatives const &);
        virtual void visit(bison::empty_components const &);
        virtual void visit(bison::chained_components const &);
        virtual void visit(bison::symbol const &);
        virtual void visit(bison::literal const &);

        void push_initial_namespace(std::string const &);

private:
        root_ptr ast;
        namespace_node_weak_ptr current_namespace;
        group_node_weak_ptr current_group;
        node_node_weak_ptr current_node;
        std::string current_identifier;
        unsigned int current_count;
        std::set<std::string> nonterminals;
        std::list<basic_type_node_weak_ptr> unresolved;
};

}
}

#endif