From 64e3e8703376c58ccefd1084f00a800bfb38272f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 3 Apr 2010 07:57:20 +0200 Subject: Split parser into interface and implementation --- odb/parser.hxx | 124 ++++----------------------------------------------------- 1 file changed, 7 insertions(+), 117 deletions(-) (limited to 'odb/parser.hxx') diff --git a/odb/parser.hxx b/odb/parser.hxx index 128abb5..e1689f8 100644 --- a/odb/parser.hxx +++ b/odb/parser.hxx @@ -8,141 +8,31 @@ #include -#include -#include #include // std::auto_ptr -#include #include #include -#include +#include class parser { public: class failed {}; - parser (options const& ops, loc_pragmas const&, decl_pragmas const&); + parser (options const&, loc_pragmas const&, decl_pragmas const&); std::auto_ptr parse (tree global_scope, semantics::path const& main_file); private: - typedef semantics::path path; - typedef semantics::access access; + parser (parser const&); - // Extended GGC tree declaration that is either a tree node or a - // pragma. If this declaration is a pragma, then the assoc flag - // indicated whether this pragma has been associated with a - // declaration. - // - struct tree_decl - { - tree decl; - pragma const* prag; - mutable bool assoc; // Allow modification via std::set iterator. - - tree_decl (tree d): decl (d), prag (0) {} - tree_decl (pragma const& p): decl (0), prag (&p), assoc (false) {} - - bool - operator< (tree_decl const& y) const; - }; - - typedef std::multiset decl_set; + parser& + operator= (parser const&); private: - void - collect (tree ns); - - void - emit (); - - // Emit a type declaration. This is either a named class-type definition/ - // declaration or a typedef. In the former case the function returns the - // newly created type node. In the latter case it returns 0. - // - semantics::type* - emit_type_decl (tree); - - // Emit a template declaration. - // - void - emit_template_decl (tree); - - semantics::class_template& - emit_class_template (tree, bool stub = false); - - semantics::union_template& - emit_union_template (tree, bool stub = false); - - template - T& - emit_class (tree, path const& f, size_t l, size_t c, bool stub = false); - - template - T& - emit_union (tree, path const& f, size_t l, size_t c, bool stub = false); - - semantics::enum_& - emit_enum (tree, path const& f, size_t l, size_t c, bool stub = false); - - // Create new or find existing semantic graph type. - // - semantics::type& - emit_type (tree, path const& f, size_t l, size_t c); - - semantics::type& - create_type (tree, path const& f, size_t l, size_t c); - - std::string - emit_type_name (tree, bool direct = true); - - - // Pragma handling. - // - void - process_pragmas (tree, - semantics::node&, - std::string const& name, - decl_set::const_iterator begin, - decl_set::const_iterator cur, - decl_set::const_iterator end); - - void - diagnose_unassoc_pragmas (decl_set const&); - - // Return declaration's fully-qualified scope name (e.g., ::foo::bar). - // - std::string - fq_scope (tree); - - // Return declaration's access. - // - access - decl_access (tree); - - // - // - template - void - define_fund (tree); - -private: - options const& ops_; - loc_pragmas const& loc_pragmas_; - decl_pragmas const& decl_pragmas_; - - bool trace; - std::ostream& ts; - - semantics::unit* unit_; - semantics::scope* scope_; - - std::size_t error_; - - decl_set decls_; + class impl; + std::auto_ptr impl_; }; - #endif // ODB_PARSER_HXX -- cgit v1.1