diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2014-12-12 11:30:04 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2014-12-12 11:30:04 +0200 |
commit | 257ad3c2c5e633d2fd3f2228021ac3ae8d6d07cb (patch) | |
tree | ecfa5df6e8abca5bd483d5498bf84412ae58930e /build/bd.cxx | |
parent | 0dcf07989b4b942f6ff872023b2886b7f698d711 (diff) |
Initial buildfile parser implementation
g++-4.9 -std=c++14 -g -I../../.. -o driver driver.cxx ../../../build/lexer.cxx ../../../build/parser.cxx && ./driver
Diffstat (limited to 'build/bd.cxx')
-rw-r--r-- | build/bd.cxx | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/build/bd.cxx b/build/bd.cxx index 33ee02f..82d283c 100644 --- a/build/bd.cxx +++ b/build/bd.cxx @@ -16,8 +16,8 @@ #include <build/process> #include <build/diagnostics> -#include <build/token> #include <build/lexer> +#include <build/parser> using namespace std; @@ -148,41 +148,20 @@ main (int argc, char* argv[]) } ifs.exceptions (ifstream::failbit | ifstream::badbit); - lexer l (ifs, bf.string ()); + parser p; try { - for (token t (l.next ());; t = l.next ()) - { - cout << t.line () << ':' << t.column () << ": "; - - switch (t.type ()) - { - case token_type::eos: cout << "<eos>"; break; - case token_type::punctuation: - { - switch (t.punctuation ()) - { - case token_punctuation::newline: cout << "\\n"; break; - case token_punctuation::colon: cout << ':'; break; - case token_punctuation::lcbrace: cout << '{'; break; - case token_punctuation::rcbrace: cout << '}'; break; - } - break; - } - case token_type::name: cout << '\'' << t.name () << '\''; break; - } - - cout << endl; - - if (t.type () == token_type::eos) - break; - } + p.parse (ifs, bf); } catch (const lexer_error&) { return 1; // Diagnostics has already been issued. } + catch (const parser_error&) + { + return 1; // Diagnostics has already been issued. + } catch (const std::ios_base::failure&) { cerr << "error: failed to read from " << bf << endl; |