From c0c85b67516653c181fbce7c61c2df3e31e4edd8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 18 Dec 2014 07:14:53 +0200 Subject: Initial support for loading dependency info from buildfiles Also a new iteration on the overall architecture. Now, for the first time, build can read the buildfile and build itself. g++-4.9 -std=c++14 -g -I.. -o bd bd.cxx algorithm.cxx scope.cxx parser.cxx lexer.cxx target.cxx prerequisite.cxx rule.cxx native.cxx cxx/target.cxx cxx/rule.cxx process.cxx timestamp.cxx path.cxx g++-4.9 -std=c++14 -g -I../../.. -o driver driver.cxx ../../../build/lexer.cxx g++-4.9 -std=c++14 -g -I../../.. -o driver driver.cxx ../../../build/lexer.cxx ../../../build/parser.cxx ../../../build/scope.cxx ../../../build/target.cxx ../../../build/native.cxx ../../../build/prerequisite.cxx ../../../build/path.cxx ../../../build/timestamp.cxx --- build/parser | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'build/parser') diff --git a/build/parser b/build/parser index c487015..e8e7314 100644 --- a/build/parser +++ b/build/parser @@ -8,12 +8,16 @@ #include #include #include +#include // std::move #include + #include namespace build { + class scope; + class token; enum class token_type; class lexer; @@ -28,12 +32,21 @@ namespace build parser (std::ostream& diag): diag_ (diag) {} void - parse (std::istream&, const path&); + parse (std::istream&, const path&, scope&); // Recursive descent parser. // private: - typedef std::vector names; + struct name_type + { + name_type (std::string t, std::string n) + : type (std::move (t)), name (std::move (n)) {} + + std::string type; // Empty if untyped. + std::string name; + }; + + typedef std::vector names; void parse_clause (token&, token_type&); @@ -42,12 +55,12 @@ namespace build parse_names (token& t, token_type& tt) { names ns; - parse_names (t, tt, ns); + parse_names (t, tt, ns, nullptr); return ns; } void - parse_names (token&, token_type&, names&); + parse_names (token&, token_type&, names&, const std::string* type); // Utilities. // @@ -63,6 +76,7 @@ namespace build lexer* lexer_; const path* path_; + scope* scope_; }; } -- cgit v1.1