diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2014-12-12 08:02:14 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2014-12-12 08:02:14 +0200 |
commit | 0dcf07989b4b942f6ff872023b2886b7f698d711 (patch) | |
tree | b169cd924cadf6767adbd2feae912acc4b80e797 /build | |
parent | e6d92a1fb21232ab09886431d39ccb8a95c7c68d (diff) |
Add test for lexer
g++-4.9 -std=c++14 -g -I../../.. -o driver driver.cxx ../../../build/lexer.cxx && ./driver
Diffstat (limited to 'build')
-rw-r--r-- | build/lexer | 3 | ||||
-rw-r--r-- | build/lexer.cxx | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/build/lexer b/build/lexer index 987efab..34b6fcc 100644 --- a/build/lexer +++ b/build/lexer @@ -21,6 +21,9 @@ namespace build class lexer { public: + // If name is empty, then no diagnostics is issued, just lexer_error + // is thrown (use for testing). + // lexer (std::istream& is, const std::string& name) : is_ (is), name_ (name) {} diff --git a/build/lexer.cxx b/build/lexer.cxx index 101227e..8566788 100644 --- a/build/lexer.cxx +++ b/build/lexer.cxx @@ -56,8 +56,10 @@ namespace build if (!is_eos (c)) return c; - cerr << name_ << ':' << c.line () << ':' << c.column () << ": error: " << - "unterminated escape sequence" << endl; + if (!name_.empty ()) + cerr << name_ << ':' << c.line () << ':' << c.column () << ": error: " << + "unterminated escape sequence" << endl; + throw lexer_error (); } |