diff options
Diffstat (limited to 'libbuild2/build/script')
-rw-r--r-- | libbuild2/build/script/lexer.test.cxx | 2 | ||||
-rw-r--r-- | libbuild2/build/script/parser+line.test.testscript | 39 | ||||
-rw-r--r-- | libbuild2/build/script/parser.test.cxx | 21 | ||||
-rw-r--r-- | libbuild2/build/script/token.cxx | 4 | ||||
-rw-r--r-- | libbuild2/build/script/token.hxx | 2 |
5 files changed, 60 insertions, 8 deletions
diff --git a/libbuild2/build/script/lexer.test.cxx b/libbuild2/build/script/lexer.test.cxx index 15c0954..1c47442 100644 --- a/libbuild2/build/script/lexer.test.cxx +++ b/libbuild2/build/script/lexer.test.cxx @@ -55,7 +55,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); cout << endl; } } diff --git a/libbuild2/build/script/parser+line.test.testscript b/libbuild2/build/script/parser+line.test.testscript new file mode 100644 index 0000000..df4e77b --- /dev/null +++ b/libbuild2/build/script/parser+line.test.testscript @@ -0,0 +1,39 @@ +# file : libbuild2/build/script/parser+line.test.testscript +# license : MIT; see accompanying LICENSE file + +test.options += -d + +#\ +: if-else +: +$* <<EOI >| + if foo + bar + elif fox + baz + end + if! foo + bar + elif! fox + baz + end + EOI + +: command +: +$* <<EOI >| + foo >| 2>- &a &?b + foo >=c 2>~/error:.*/ &!c + foo >>:/~%EOF% + %.* + abc + %xyz.*% + EOF + EOI + +: quoting +: +$* <<EOI >| + foo 'bar' "baz" '' "" + EOI +#\ diff --git a/libbuild2/build/script/parser.test.cxx b/libbuild2/build/script/parser.test.cxx index 2763464..77f6596 100644 --- a/libbuild2/build/script/parser.test.cxx +++ b/libbuild2/build/script/parser.test.cxx @@ -67,7 +67,10 @@ namespace build2 bool line_; }; - // Usage: argv[0] [-l] + // Usages: + // + // argv[0] [-l] + // argv[0] -d // int main (int argc, char* argv[]) @@ -86,6 +89,7 @@ namespace build2 context ctx (sched, mutexes); bool line (false); + bool dump (false); for (int i (1); i != argc; ++i) { @@ -93,10 +97,14 @@ namespace build2 if (a == "-l") line = true; + else if (a == "-d") + dump = true; else assert (false); } + assert (!dump || !line); + try { cin.exceptions (istream::failbit | istream::badbit); @@ -123,9 +131,14 @@ namespace build2 parser p (ctx); p.pre_parse (cin, nm, 11 /* line */, s); - environment e (s, tt); - print_runner r (line); - p.execute (e, r); + if (!dump) + { + environment e (s, tt); + print_runner r (line); + p.execute (e, r); + } + else + build2::script::dump (cout, "", s.lines); } catch (const failed&) { diff --git a/libbuild2/build/script/token.cxx b/libbuild2/build/script/token.cxx index 289dfd2..7c15dff 100644 --- a/libbuild2/build/script/token.cxx +++ b/libbuild2/build/script/token.cxx @@ -12,11 +12,11 @@ namespace build2 namespace script { void - token_printer (ostream& os, const token& t, bool d) + token_printer (ostream& os, const token& t, print_mode m) { // No build script-specific tokens so far. // - build2::script::token_printer (os, t, d); + build2::script::token_printer (os, t, m); } } } diff --git a/libbuild2/build/script/token.hxx b/libbuild2/build/script/token.hxx index 4cd90d7..90c1379 100644 --- a/libbuild2/build/script/token.hxx +++ b/libbuild2/build/script/token.hxx @@ -28,7 +28,7 @@ namespace build2 }; void - token_printer (ostream&, const token&, bool); + token_printer (ostream&, const token&, print_mode); } } } |