diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2020-04-28 08:48:53 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-05-27 15:47:28 +0200 |
commit | b808c255b6a9ddba085bf5646e7d20ec344f2e2d (patch) | |
tree | 32730291f7e6de8ef0a227905520dd66fb4ec0f3 /libbuild2/lexer.test.cxx | |
parent | 3552356a87402727e663131994fa87f48b3cd4fb (diff) |
Initial support for ad hoc recipes (still work in progress)
Diffstat (limited to 'libbuild2/lexer.test.cxx')
-rw-r--r-- | libbuild2/lexer.test.cxx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libbuild2/lexer.test.cxx b/libbuild2/lexer.test.cxx index 5e39e43..24f0528 100644 --- a/libbuild2/lexer.test.cxx +++ b/libbuild2/lexer.test.cxx @@ -1,6 +1,7 @@ // file : libbuild2/lexer.test.cxx -*- C++ -*- // license : MIT; see accompanying LICENSE file +#include <cstdlib> // strtoul() #include <cassert> #include <iostream> @@ -14,13 +15,15 @@ using namespace std; namespace build2 { - // Usage: argv[0] [-q] [<lexer-mode>] + // Usage: argv[0] [-q] [<lexer-mode>[=<data>]] // int main (int argc, char* argv[]) { bool quote (false); + lexer_mode m (lexer_mode::normal); + uintptr_t d (0); for (int i (1); i != argc; ++i) { @@ -36,7 +39,12 @@ namespace build2 else if (a == "attributes") m = lexer_mode::attributes; else if (a == "eval") m = lexer_mode::eval; else if (a == "buildspec") m = lexer_mode::buildspec; - else assert (false); + else if (a.compare (0, 8, "foreign=") == 0) + { + m = lexer_mode::foreign; + d = strtoul (a.c_str () + 8, nullptr, 10); + } + else assert (false); break; } } @@ -51,7 +59,7 @@ namespace build2 lexer l (cin, in); if (m != lexer_mode::normal) - l.mode (m); + l.mode (m, '\0', nullopt, d); // No use printing eos since we will either get it or loop forever. // @@ -62,7 +70,7 @@ namespace build2 // Print each token on a separate line without quoting operators. // - t.printer (cout, t, false); + t.printer (cout, t, print_mode::normal); if (quote) { |