From 257ad3c2c5e633d2fd3f2228021ac3ae8d6d07cb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 12 Dec 2014 11:30:04 +0200 Subject: Initial buildfile parser implementation g++-4.9 -std=c++14 -g -I../../.. -o driver driver.cxx ../../../build/lexer.cxx ../../../build/parser.cxx && ./driver --- build/parser | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 build/parser (limited to 'build/parser') diff --git a/build/parser b/build/parser new file mode 100644 index 0000000..04ef00d --- /dev/null +++ b/build/parser @@ -0,0 +1,55 @@ +// file : build/parser -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD_PARSER +#define BUILD_PARSER + +#include +#include +#include + +#include + +namespace build +{ + class token; + enum class token_type; + class lexer; + + // The handler must assume the diagnostics has already been issued. + // + struct parser_error: std::exception {}; + + class parser + { + public: + parser (std::ostream& diag): diag_ (diag) {} + + void + parse (std::istream&, const path&); + + // Recursive descent parser. + // + private: + void + names (token&, token_type&); + + // Utilities. + // + private: + void + next (token&, token_type&); + + std::ostream& + error (const token&); + + private: + std::ostream& diag_; + + lexer* lexer_; + const path* path_; + }; +} + +#endif // BUILD_PARSER -- cgit v1.1