diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2017-05-01 16:08:43 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2017-05-01 16:59:24 +0300 |
commit | 61377c582e0f2675baa5f5e6e30a35d1a4164b33 (patch) | |
tree | 11cdca992834d7f7f197f72856712fbcb3020e3d /butl/tab-parser.cxx | |
parent | 442c1a6790e52baa0c081f310d4d9e9b6f1ff638 (diff) |
Add hxx extension for headers and lib prefix for library dir
Diffstat (limited to 'butl/tab-parser.cxx')
-rw-r--r-- | butl/tab-parser.cxx | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/butl/tab-parser.cxx b/butl/tab-parser.cxx deleted file mode 100644 index 4743e69..0000000 --- a/butl/tab-parser.cxx +++ /dev/null @@ -1,88 +0,0 @@ -// file : butl/tab-parser.cxx -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#include <butl/tab-parser> - -#include <cassert> -#include <sstream> - -#include <butl/string-parser> - -using namespace std; - -namespace butl -{ - using parsing = tab_parsing; - - // tab_parser - // - tab_fields tab_parser:: - next () - { - tab_fields r; - - // Read lines until a non-empty one or EOF is encountered. In the first - // case parse the line and bail out. - // - // Note that we check for character presence in the stream prior to the - // getline() call, to prevent it from setting the failbit. - // - while (!is_.eof () && is_.peek () != istream::traits_type::eof ()) - { - string s; - getline (is_, s); - - ++line_; - - // Skip empty line. - // - auto i (s.begin ()); - auto e (s.end ()); - for (; i != e && (*i == ' ' || *i == '\t'); ++i) ; // Skip spaces. - - if (i == e || *i == '#') - continue; - - r.line = line_; - r.end_column = s.size () + 1; // Newline position. - - vector<std::pair<string, size_t>> sp; - - try - { - sp = string_parser::parse_quoted_position (s, false); - } - catch (const invalid_string& e) - { - throw parsing (name_, line_, e.position + 1, e.what ()); - } - - for (auto& s: sp) - r.emplace_back (tab_field ({move (s.first), s.second + 1})); - - break; - } - - return r; - } - - // tab_parsing - // - static string - format (const string& n, uint64_t l, uint64_t c, const string& d) - { - ostringstream os; - if (!n.empty ()) - os << n << ':'; - os << l << ':' << c << ": error: " << d; - return os.str (); - } - - tab_parsing:: - tab_parsing (const string& n, uint64_t l, uint64_t c, const string& d) - : runtime_error (format (n, l, c, d)), - name (n), line (l), column (c), description (d) - { - } -} |