summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-10-04 11:38:44 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-10-04 11:38:44 +0200
commit6caffa6a23befba0d7a7e4f39e08928ba317866a (patch)
treef9cbcd6c9226dee050e67e7dbd23ae4f830725aa
parentcfb91e263c22f6f81ae05a2027a2befac6d41e06 (diff)
Add support for option name aliases and string literals
-rw-r--r--cli/lexer.cxx2
-rw-r--r--cli/options.cli2
-rw-r--r--cli/options.cxx2
-rw-r--r--cli/parser.cxx15
-rw-r--r--cli/source.cxx15
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<options, bool, &options::suppress_inline_>;
_cli_options_map_["--output-dir"] =
&::cli::thunk<options, std::string, &options::output_dir_>;
+ _cli_options_map_["-o"] =
+ &::cli::thunk<options, std::string, &options::output_dir_>;
_cli_options_map_["--hxx-suffix"] =
&::cli::thunk<options, std::string, &options::hxx_suffix_>;
_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 << ">;";
+ }
}
};