diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-07-19 19:33:22 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-07-19 19:33:22 +0200 |
commit | 183a0f3d21dce7e50ac001f626c6492c0d36e7a3 (patch) | |
tree | 30578be48463b93f848f08b658be0777850b9abd | |
parent | 78d150347d345edd264b13911b680ea9b848116a (diff) |
Add support for fail, warn, info, text directives
-rw-r--r-- | build2/parser.cxx | 41 | ||||
-rw-r--r-- | build2/parser.hxx | 3 |
2 files changed, 43 insertions, 1 deletions
diff --git a/build2/parser.cxx b/build2/parser.cxx index 96694c5..0c45e17 100644 --- a/build2/parser.cxx +++ b/build2/parser.cxx @@ -295,10 +295,17 @@ namespace build2 { f = &parser::parse_assert; } - else if (n == "print") + else if (n == "print") // Unlike text goes to stdout. { f = &parser::parse_print; } + else if (n == "fail" || + n == "warn" || + n == "info" || + n == "text") + { + f = &parser::parse_diag; + } else if (n == "source") { f = &parser::parse_source; @@ -1529,6 +1536,38 @@ namespace build2 next (t, tt); // Swallow newline. } + void parser:: + parse_diag (token& t, type& tt) + { + diag_record dr; + const location l (get_location (t)); + + switch (t.value[0]) + { + case 'f': dr << fail (l); break; + case 'w': dr << warn (l); break; + case 'i': dr << info (l); break; + case 't': dr << text (l); break; + default: assert (false); + } + + // Parse the rest as a variable value to get expansion, attributes, etc. + // + value rhs (parse_variable_value (t, tt)); + + value lhs; + apply_value_attributes (nullptr, lhs, move (rhs), type::assign); + + if (lhs) + { + names storage; + dr << reverse (lhs, storage); + } + + if (tt != type::eos) + next (t, tt); // Swallow newline. + } + string parser:: parse_variable_name (names&& ns, const location& l) { diff --git a/build2/parser.hxx b/build2/parser.hxx index e7afe3a..2ee0a64 100644 --- a/build2/parser.hxx +++ b/build2/parser.hxx @@ -81,6 +81,9 @@ namespace build2 parse_print (token&, token_type&); void + parse_diag (token&, token_type&); + + void parse_source (token&, token_type&); void |