From d4be6965ed8d5cacb79776fa892b763548e3d070 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 4 Nov 2016 08:17:40 +0200 Subject: Handle printing of extended tokens (testscript) --- build2/test/script/token.cxx | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 build2/test/script/token.cxx (limited to 'build2/test/script/token.cxx') diff --git a/build2/test/script/token.cxx b/build2/test/script/token.cxx new file mode 100644 index 0000000..bfff25a --- /dev/null +++ b/build2/test/script/token.cxx @@ -0,0 +1,42 @@ +// file : build2/test/script/token.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include + +using namespace std; + +namespace build2 +{ + namespace test + { + namespace script + { + void + token_printer (ostream& os, const token& t, bool d) + { + // Only quote non-name tokens for diagnostics. + // + const char* q (d ? "'" : ""); + + switch (t.type) + { + case token_type::pipe: os << q << '|' << q; break; + case token_type::clean: os << q << '&' << q; break; + case token_type::log_and: os << q << "&&" << q; break; + case token_type::log_or: os << q << "||" << q; break; + + case token_type::in_null: os << q << "