From 6caffa6a23befba0d7a7e4f39e08928ba317866a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 4 Oct 2009 11:38:44 +0200 Subject: Add support for option name aliases and string literals --- cli/lexer.cxx | 2 +- cli/options.cli | 2 +- cli/options.cxx | 2 ++ cli/parser.cxx | 15 ++++++++++++++- cli/source.cxx | 15 +++++++++++---- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/cli/lexer.cxx b/cli/lexer.cxx index 8b17d8f..12e182c 100644 --- a/cli/lexer.cxx +++ b/cli/lexer.cxx @@ -429,7 +429,7 @@ string_literal (xchar c) break; get (); - lexeme += " \""; + lexeme += "\""; } return token (token::t_string_lit, lexeme, ln, cl); diff --git a/cli/options.cli b/cli/options.cli index 8c7bdda..3fe6fa8 100644 --- a/cli/options.cli +++ b/cli/options.cli @@ -18,7 +18,7 @@ class options bool --suppress-inline; - std::string --output-dir; + std::string --output-dir | -o; std::string --hxx-suffix = ".hxx"; std::string --ixx-suffix = ".ixx"; std::string --cxx-suffix = ".cxx"; diff --git a/cli/options.cxx b/cli/options.cxx index b47a5c8..1cbbfb4 100644 --- a/cli/options.cxx +++ b/cli/options.cxx @@ -321,6 +321,8 @@ struct _cli_options_map_init &::cli::thunk; _cli_options_map_["--output-dir"] = &::cli::thunk; + _cli_options_map_["-o"] = + &::cli::thunk; _cli_options_map_["--hxx-suffix"] = &::cli::thunk; _cli_options_map_["--ixx-suffix"] = diff --git a/cli/parser.cxx b/cli/parser.cxx index 54ab78a..55c609a 100644 --- a/cli/parser.cxx +++ b/cli/parser.cxx @@ -405,7 +405,20 @@ option_def (token& t) case token::t_string_lit: { if (valid_) - nl.push_back (t.literal ()); + { + // Get rid of '"'. + // + string r; + string const& l (t.literal ()); + + for (size_t i (0), n (l.size ()); i < n; ++i) + { + if (l[i] != '"' || (i != 0 && l[i - 1] == '\\')) + r += l[i]; + } + + nl.push_back (r); + } break; } diff --git a/cli/source.cxx b/cli/source.cxx index e9e4365..afac17e 100644 --- a/cli/source.cxx +++ b/cli/source.cxx @@ -65,14 +65,21 @@ namespace virtual void traverse (type& o) { - string name (ename (o)); + using semantics::names; + + string member (emember (o)); string type (o.type ().name ()); string scope (escape (o.scope ().name ())); string map ("_cli_" + scope + "_map_"); - os << "_cli_" << scope << "_map_[\"" << o.name () << "\"] = " << endl - << "&::cli::thunk<" << scope << ", " << type << ", " << - "&" << scope << "::" << emember (o) << ">;"; + names& n (o.named ()); + + for (names::name_iterator i (n.name_begin ()); i != n.name_end (); ++i) + { + os << "_cli_" << scope << "_map_[\"" << *i << "\"] = " << endl + << "&::cli::thunk<" << scope << ", " << type << ", " << + "&" << scope << "::" << member << ">;"; + } } }; -- cgit v1.1