summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceGrid/Grammar.y423
-rw-r--r--cpp/src/IceGrid/Parser.cpp99
-rw-r--r--cpp/src/IceGrid/Parser.h13
-rw-r--r--cpp/src/IceGrid/Scanner.l212
4 files changed, 355 insertions, 392 deletions
diff --git a/cpp/src/IceGrid/Grammar.y b/cpp/src/IceGrid/Grammar.y
index 0d7c2fc33bd..d66bb46f66e 100644
--- a/cpp/src/IceGrid/Grammar.y
+++ b/cpp/src/IceGrid/Grammar.y
@@ -110,75 +110,11 @@ command
{
parser->usage();
}
-| ICE_GRID_HELP ICE_GRID_APPLICATION ';'
-{
- parser->usage("application");
-}
-| ICE_GRID_HELP ICE_GRID_NODE ';'
-{
- parser->usage("node");
-}
-| ICE_GRID_HELP ICE_GRID_REGISTRY ';'
-{
- parser->usage("registry");
-}
-| ICE_GRID_HELP ICE_GRID_SERVER ';'
-{
- parser->usage("server");
-}
-| ICE_GRID_HELP ICE_GRID_ADAPTER ';'
-{
- parser->usage("adapter");
-}
-| ICE_GRID_HELP ICE_GRID_OBJECT ';'
-{
- parser->usage("object");
-}
-| ICE_GRID_HELP ICE_GRID_SERVER ICE_GRID_TEMPLATE ';'
-{
- parser->usage("server template");
-}
-| ICE_GRID_HELP ICE_GRID_SERVICE ICE_GRID_TEMPLATE ';'
-{
- parser->usage("servcice template");
-}
-| ICE_GRID_APPLICATION ICE_GRID_HELP ';'
-{
- parser->usage("application");
-}
-| ICE_GRID_NODE ICE_GRID_HELP ';'
-{
- parser->usage("node");
-}
-| ICE_GRID_REGISTRY ICE_GRID_HELP ';'
-{
- parser->usage("registry");
-}
-| ICE_GRID_SERVER ICE_GRID_HELP ';'
-{
- parser->usage("server");
-}
-| ICE_GRID_ADAPTER ICE_GRID_HELP ';'
-{
- parser->usage("adapter");
-}
-| ICE_GRID_OBJECT ICE_GRID_HELP ';'
-{
- parser->usage("object");
-}
-| ICE_GRID_SERVER ICE_GRID_TEMPLATE ICE_GRID_HELP ';'
-{
- parser->usage("server template");
-}
-| ICE_GRID_SERVICE ICE_GRID_TEMPLATE ICE_GRID_HELP ';'
-{
- parser->usage("service template");
-}
| ICE_GRID_EXIT ';'
{
return 0;
}
-| ICE_GRID_APPLICATION ICE_GRID_ADD optional_strings ';'
+| ICE_GRID_APPLICATION ICE_GRID_ADD strings ';'
{
parser->addApplication($3);
}
@@ -186,7 +122,7 @@ command
{
parser->usage("application", "add");
}
-| ICE_GRID_APPLICATION ICE_GRID_REMOVE optional_strings ';'
+| ICE_GRID_APPLICATION ICE_GRID_REMOVE strings ';'
{
parser->removeApplication($3);
}
@@ -194,7 +130,7 @@ command
{
parser->usage("application", "remove");
}
-| ICE_GRID_APPLICATION ICE_GRID_DIFF optional_strings ';'
+| ICE_GRID_APPLICATION ICE_GRID_DIFF strings ';'
{
parser->diffApplication($3);
}
@@ -202,7 +138,7 @@ command
{
parser->usage("application", "diff");
}
-| ICE_GRID_APPLICATION ICE_GRID_UPDATE optional_strings ';'
+| ICE_GRID_APPLICATION ICE_GRID_UPDATE strings ';'
{
parser->updateApplication($3);
}
@@ -210,7 +146,7 @@ command
{
parser->usage("application", "update");
}
-| ICE_GRID_APPLICATION ICE_GRID_DESCRIBE optional_strings ';'
+| ICE_GRID_APPLICATION ICE_GRID_DESCRIBE strings ';'
{
parser->describeApplication($3);
}
@@ -218,7 +154,7 @@ command
{
parser->usage("application", "describe");
}
-| ICE_GRID_APPLICATION ICE_GRID_PATCH optional_strings ';'
+| ICE_GRID_APPLICATION ICE_GRID_PATCH strings ';'
{
parser->patchApplication($3);
}
@@ -226,7 +162,7 @@ command
{
parser->usage("application", "patch");
}
-| ICE_GRID_SERVER ICE_GRID_TEMPLATE ICE_GRID_DESCRIBE optional_strings ';'
+| ICE_GRID_SERVER ICE_GRID_TEMPLATE ICE_GRID_DESCRIBE strings ';'
{
parser->describeServerTemplate($4);
}
@@ -234,7 +170,7 @@ command
{
parser->usage("server template", "describe");
}
-| ICE_GRID_SERVER ICE_GRID_TEMPLATE ICE_GRID_INSTANTIATE optional_strings ';'
+| ICE_GRID_SERVER ICE_GRID_TEMPLATE ICE_GRID_INSTANTIATE strings ';'
{
parser->instantiateServerTemplate($4);
}
@@ -242,7 +178,7 @@ command
{
parser->usage("server template", "instantiate");
}
-| ICE_GRID_SERVICE ICE_GRID_TEMPLATE ICE_GRID_DESCRIBE optional_strings ';'
+| ICE_GRID_SERVICE ICE_GRID_TEMPLATE ICE_GRID_DESCRIBE strings ';'
{
parser->describeServiceTemplate($4);
}
@@ -250,11 +186,11 @@ command
{
parser->usage("service template", "describe");
}
-| ICE_GRID_APPLICATION ICE_GRID_LIST ';'
+| ICE_GRID_APPLICATION ICE_GRID_LIST strings ';'
{
- parser->listAllApplications();
+ parser->listAllApplications($3);
}
-| ICE_GRID_NODE ICE_GRID_DESCRIBE optional_strings ';'
+| ICE_GRID_NODE ICE_GRID_DESCRIBE strings ';'
{
parser->describeNode($3);
}
@@ -262,7 +198,7 @@ command
{
parser->usage("node", "describe");
}
-| ICE_GRID_NODE ICE_GRID_PING optional_strings ';'
+| ICE_GRID_NODE ICE_GRID_PING strings ';'
{
parser->pingNode($3);
}
@@ -270,7 +206,7 @@ command
{
parser->usage("node", "ping");
}
-| ICE_GRID_NODE ICE_GRID_LOAD optional_strings ';'
+| ICE_GRID_NODE ICE_GRID_LOAD strings ';'
{
parser->printLoadNode($3);
}
@@ -278,7 +214,7 @@ command
{
parser->usage("node", "lost");
}
-| ICE_GRID_NODE ICE_GRID_SHUTDOWN optional_strings ';'
+| ICE_GRID_NODE ICE_GRID_SHUTDOWN strings ';'
{
parser->shutdownNode($3);
}
@@ -286,11 +222,11 @@ command
{
parser->usage("node", "shutdown");
}
-| ICE_GRID_NODE ICE_GRID_LIST ';'
+| ICE_GRID_NODE ICE_GRID_LIST strings ';'
{
- parser->listAllNodes();
+ parser->listAllNodes($3);
}
-| ICE_GRID_NODE ICE_GRID_SHOW strings_and_log_filename ';'
+| ICE_GRID_NODE ICE_GRID_SHOW strings ';'
{
parser->showFile("node", $3);
}
@@ -298,7 +234,7 @@ command
{
parser->usage("node", "show");
}
-| ICE_GRID_REGISTRY ICE_GRID_DESCRIBE optional_strings ';'
+| ICE_GRID_REGISTRY ICE_GRID_DESCRIBE strings ';'
{
parser->describeRegistry($3);
}
@@ -306,7 +242,7 @@ command
{
parser->usage("registry", "describe");
}
-| ICE_GRID_REGISTRY ICE_GRID_PING optional_strings ';'
+| ICE_GRID_REGISTRY ICE_GRID_PING strings ';'
{
parser->pingRegistry($3);
}
@@ -314,7 +250,7 @@ command
{
parser->usage("registry", "ping");
}
-| ICE_GRID_REGISTRY ICE_GRID_SHUTDOWN optional_strings ';'
+| ICE_GRID_REGISTRY ICE_GRID_SHUTDOWN strings ';'
{
parser->shutdownRegistry($3);
}
@@ -322,11 +258,11 @@ command
{
parser->usage("registry", "shutdown");
}
-| ICE_GRID_REGISTRY ICE_GRID_LIST ';'
+| ICE_GRID_REGISTRY ICE_GRID_LIST strings ';'
{
- parser->listAllRegistries();
+ parser->listAllRegistries($3);
}
-| ICE_GRID_REGISTRY ICE_GRID_SHOW strings_and_log_filename ';'
+| ICE_GRID_REGISTRY ICE_GRID_SHOW strings ';'
{
parser->showFile("registry", $3);
}
@@ -334,7 +270,7 @@ command
{
parser->usage("registry", "show");
}
-| ICE_GRID_SERVER ICE_GRID_REMOVE optional_strings ';'
+| ICE_GRID_SERVER ICE_GRID_REMOVE strings ';'
{
parser->removeServer($3);
}
@@ -342,7 +278,7 @@ command
{
parser->usage("server", "remove");
}
-| ICE_GRID_SERVER ICE_GRID_DESCRIBE optional_strings ';'
+| ICE_GRID_SERVER ICE_GRID_DESCRIBE strings ';'
{
parser->describeServer($3);
}
@@ -350,7 +286,7 @@ command
{
parser->usage("server", "describe");
}
-| ICE_GRID_SERVER ICE_GRID_START optional_strings ';'
+| ICE_GRID_SERVER ICE_GRID_START strings ';'
{
parser->startServer($3);
}
@@ -358,7 +294,7 @@ command
{
parser->usage("server", "start");
}
-| ICE_GRID_SERVER ICE_GRID_STOP optional_strings ';'
+| ICE_GRID_SERVER ICE_GRID_STOP strings ';'
{
parser->stopServer($3);
}
@@ -366,7 +302,7 @@ command
{
parser->usage("server", "stop");
}
-| ICE_GRID_SERVER ICE_GRID_PATCH optional_strings ';'
+| ICE_GRID_SERVER ICE_GRID_PATCH strings ';'
{
parser->patchServer($3);
}
@@ -374,7 +310,7 @@ command
{
parser->usage("server", "patch");
}
-| ICE_GRID_SERVER ICE_GRID_SIGNAL optional_strings ';'
+| ICE_GRID_SERVER ICE_GRID_SIGNAL strings ';'
{
parser->signalServer($3);
}
@@ -382,7 +318,7 @@ command
{
parser->usage("server", "signal");
}
-| ICE_GRID_SERVER ICE_GRID_STDOUT optional_strings ';'
+| ICE_GRID_SERVER ICE_GRID_STDOUT strings ';'
{
parser->writeMessage($3, 1);
}
@@ -390,7 +326,7 @@ command
{
parser->usage("server", "stdout");
}
-| ICE_GRID_SERVER ICE_GRID_STDERR optional_strings ';'
+| ICE_GRID_SERVER ICE_GRID_STDERR strings ';'
{
parser->writeMessage($3, 2);
}
@@ -398,7 +334,7 @@ command
{
parser->usage("server", "stderr");
}
-| ICE_GRID_SERVER ICE_GRID_STATE optional_strings ';'
+| ICE_GRID_SERVER ICE_GRID_STATE strings ';'
{
parser->stateServer($3);
}
@@ -406,7 +342,7 @@ command
{
parser->usage("server", "start");
}
-| ICE_GRID_SERVER ICE_GRID_PID optional_strings ';'
+| ICE_GRID_SERVER ICE_GRID_PID strings ';'
{
parser->pidServer($3);
}
@@ -414,7 +350,7 @@ command
{
parser->usage("server", "pid");
}
-| ICE_GRID_SERVER ICE_GRID_ENABLE optional_strings ';'
+| ICE_GRID_SERVER ICE_GRID_ENABLE strings ';'
{
parser->enableServer($3, true);
}
@@ -422,7 +358,7 @@ command
{
parser->usage("server", "enable");
}
-| ICE_GRID_SERVER ICE_GRID_DISABLE optional_strings ';'
+| ICE_GRID_SERVER ICE_GRID_DISABLE strings ';'
{
parser->enableServer($3, false);
}
@@ -430,11 +366,11 @@ command
{
parser->usage("server", "disable");
}
-| ICE_GRID_SERVER ICE_GRID_LIST ';'
+| ICE_GRID_SERVER ICE_GRID_LIST strings ';'
{
- parser->listAllServers();
+ parser->listAllServers($3);
}
-| ICE_GRID_SERVER ICE_GRID_SHOW strings_and_log_filename ';'
+| ICE_GRID_SERVER ICE_GRID_SHOW strings ';'
{
parser->showFile("server", $3);
}
@@ -442,7 +378,7 @@ command
{
parser->usage("server", "show");
}
-| ICE_GRID_ADAPTER ICE_GRID_ENDPOINTS optional_strings ';'
+| ICE_GRID_ADAPTER ICE_GRID_ENDPOINTS strings ';'
{
parser->endpointsAdapter($3);
}
@@ -450,7 +386,7 @@ command
{
parser->usage("adapter", "endpoints");
}
-| ICE_GRID_ADAPTER ICE_GRID_REMOVE optional_strings ';'
+| ICE_GRID_ADAPTER ICE_GRID_REMOVE strings ';'
{
parser->removeAdapter($3);
}
@@ -458,11 +394,11 @@ command
{
parser->usage("adapter", "remove");
}
-| ICE_GRID_ADAPTER ICE_GRID_LIST ';'
+| ICE_GRID_ADAPTER ICE_GRID_LIST strings ';'
{
- parser->listAllAdapters();
+ parser->listAllAdapters($3);
}
-| ICE_GRID_OBJECT ICE_GRID_ADD optional_strings ';'
+| ICE_GRID_OBJECT ICE_GRID_ADD strings ';'
{
parser->addObject($3);
}
@@ -470,7 +406,7 @@ command
{
parser->usage("object", "add");
}
-| ICE_GRID_OBJECT ICE_GRID_REMOVE optional_strings ';'
+| ICE_GRID_OBJECT ICE_GRID_REMOVE strings ';'
{
parser->removeObject($3);
}
@@ -478,7 +414,7 @@ command
{
parser->usage("object", "remove");
}
-| ICE_GRID_OBJECT ICE_GRID_FIND optional_strings ';'
+| ICE_GRID_OBJECT ICE_GRID_FIND strings ';'
{
parser->findObject($3);
}
@@ -486,11 +422,11 @@ command
{
parser->usage("object", "find");
}
-| ICE_GRID_OBJECT ICE_GRID_LIST optional_strings ';'
+| ICE_GRID_OBJECT ICE_GRID_LIST strings ';'
{
parser->listObject($3);
}
-| ICE_GRID_OBJECT ICE_GRID_DESCRIBE optional_strings ';'
+| ICE_GRID_OBJECT ICE_GRID_DESCRIBE strings ';'
{
parser->describeObject($3);
}
@@ -506,99 +442,37 @@ command
{
parser->showWarranty();
}
-| ICE_GRID_APPLICATION optional_strings ';'
-{
- if($2.empty())
- {
- parser->error("invalid command `application' (use `help application'\n"
- "to get the list of available commands)");
- }
- else
- {
- parser->error("invalid command: `application " + $2.front() + "' (use `help application'\n"
- "to get the list of available commands)");
- }
-}
-| ICE_GRID_SERVER optional_strings ';'
-{
- if($2.empty())
- {
- parser->error("invalid command `server' (use `help server'\n"
- "to get the list of available commands)");
- }
- else
- {
- parser->error("invalid command: `server " + $2.front() + "' (use `help server'\n"
- "to get the list of available commands)");
- }
-}
-| ICE_GRID_NODE optional_strings ';'
-{
- if($2.empty())
- {
- parser->error("invalid command `node' (use `help node'\n"
- "to get the list of available commands)");
- }
- else
- {
- parser->error("invalid command: `node " + $2.front() + "' (use `help node'\n"
- "to get the list of available commands)");
- }
-}
-| ICE_GRID_REGISTRY optional_strings ';'
-{
- if($2.empty())
- {
- parser->error("invalid command `registry' (use `help registry'\n"
- "to get the list of available commands)");
- }
- else
- {
- parser->error("invalid command: `registry " + $2.front() + "' (use `help registry'\n"
- "to get the list of available commands)");
- }
-}
-| ICE_GRID_SERVICE optional_strings ';'
-{
- if($2.empty())
- {
- parser->invalidCommand("invalid command `service' ");
- }
- else
- {
- parser->invalidCommand("invalid command: `service " + $2.front() + "'");
- }
-}
-| ICE_GRID_OBJECT optional_strings ';'
-{
- if($2.empty())
- {
- parser->error("invalid command `object' (use `help object'\n"
- "to get the list of available commands)");
- }
- else
- {
- parser->error("invalid command: `object " + $2.front() + "' (use `help object'\n"
- "to get the list of available commands)");
- }
-}
-| ICE_GRID_ADAPTER optional_strings ';'
-{
- if($2.empty())
- {
- parser->error("invalid command `adapter' (use `help adapter'\n"
- "to get the list of available commands)");
- }
- else
- {
- parser->error("invalid command: `adapter " + $2.front() + "' (use `help adapter'\n"
- "to get the list of available commands)");
- }
-}
-| strings ';'
-{
- parser->error("invalid command `" + $1.front() + "' (use `help'\n"
- "to get the list of available commands)");
+| ICE_GRID_HELP keyword ';'
+{
+ parser->usage($2.front());
+}
+| ICE_GRID_HELP ICE_GRID_STRING ';'
+{
+ parser->usage($2.front());
+}
+| ICE_GRID_HELP error ';'
+{
+ parser->usage();
+}
+| keyword ICE_GRID_HELP ';'
+{
+ parser->usage($1.front());
+}
+| keyword ICE_GRID_STRING error ';'
+{
+ $1.push_back($2.front());
+ parser->invalidCommand($1);
+ yyerrok;
+}
+| keyword error ';'
+{
+ parser->invalidCommand($1);
+ yyerrok;
+}
+| ICE_GRID_STRING error ';'
+{
+ parser->invalidCommand($1);
+ yyerrok;
}
| error ';'
{
@@ -611,51 +485,140 @@ command
// ----------------------------------------------------------------------
-strings_and_log_filename
+strings
// ----------------------------------------------------------------------
: ICE_GRID_STRING strings
{
$$ = $2;
$$.push_front($1.front());
}
-| strings ICE_GRID_STDERR
+| keyword strings
{
- $$ = $1;
- $$.push_back("stderr");
+ $$ = $2;
+ $$.push_front($1.front());
}
-| strings ICE_GRID_STDOUT
+| ICE_GRID_STRING ICE_GRID_HELP strings
{
- $$ = $1;
- $$.push_back("stdout");
+ $$ = $2;
+ $$.push_front("help");
+ $$.push_front($1.front());
}
-;
-
-// ----------------------------------------------------------------------
-strings
-// ----------------------------------------------------------------------
-: ICE_GRID_STRING strings
+| keyword ICE_GRID_HELP strings
{
$$ = $2;
+ $$.push_front("help");
$$.push_front($1.front());
}
-| ICE_GRID_STRING
+|
{
- $$ = $1;
+ $$ = YYSTYPE();
}
;
-// ----------------------------------------------------------------------
-optional_strings
-// ----------------------------------------------------------------------
-: ICE_GRID_STRING optional_strings
+keyword
+: ICE_GRID_EXIT
{
- $$ = $2;
- $$.push_front($1.front());
}
-|
+| ICE_GRID_APPLICATION
+{
+}
+| ICE_GRID_NODE
+{
+}
+| ICE_GRID_REGISTRY
+{
+}
+| ICE_GRID_SERVER
+{
+}
+| ICE_GRID_ADAPTER
+{
+}
+| ICE_GRID_PING
+{
+}
+| ICE_GRID_LOAD
+{
+}
+| ICE_GRID_ADD
+{
+}
+| ICE_GRID_REMOVE
+{
+}
+| ICE_GRID_LIST
+{
+}
+| ICE_GRID_SHUTDOWN
+{
+}
+| ICE_GRID_START
+{
+}
+| ICE_GRID_STOP
+{
+}
+| ICE_GRID_PATCH
+{
+}
+| ICE_GRID_SIGNAL
+{
+}
+| ICE_GRID_DESCRIBE
+{
+}
+| ICE_GRID_STATE
+{
+}
+| ICE_GRID_PID
+{
+}
+| ICE_GRID_ENDPOINTS
+{
+}
+| ICE_GRID_ACTIVATION
+{
+}
+| ICE_GRID_OBJECT
+{
+}
+| ICE_GRID_FIND
+{
+}
+| ICE_GRID_SHOW
+{
+}
+| ICE_GRID_COPYING
+{
+}
+| ICE_GRID_WARRANTY
+{
+}
+| ICE_GRID_DIFF
+{
+}
+| ICE_GRID_UPDATE
+{
+}
+| ICE_GRID_INSTANTIATE
+{
+}
+| ICE_GRID_TEMPLATE
+{
+}
+| ICE_GRID_SERVICE
+{
+}
+| ICE_GRID_ENABLE
+{
+}
+| ICE_GRID_DISABLE
+{
+}
+| ICE_GRID_STDERR
+{
+}
+| ICE_GRID_STDOUT
{
- $$ = YYSTYPE()
}
;
-
-%%
diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp
index 98a27828054..44c6a92b47b 100644
--- a/cpp/src/IceGrid/Parser.cpp
+++ b/cpp/src/IceGrid/Parser.cpp
@@ -220,7 +220,7 @@ Parser::usage(const string& category, const string& command)
{
if(_helpCommands.find(category) == _helpCommands.end())
{
- invalidCommand("unknown category `" + category + "'");
+ invalidCommand("unknown command `" + category + "'");
}
else if(_helpCommands[category].find(command) == _helpCommands[category].end())
{
@@ -559,8 +559,14 @@ Parser::patchApplication(const list<string>& origArgs)
}
void
-Parser::listAllApplications()
+Parser::listAllApplications(const list<string>& args)
{
+ if(!args.empty())
+ {
+ invalidCommand("application list", "doesn't require any argument");
+ return;
+ }
+
try
{
Ice::StringSeq names = _admin->getAllApplicationNames();
@@ -801,8 +807,14 @@ Parser::shutdownNode(const list<string>& args)
}
void
-Parser::listAllNodes()
+Parser::listAllNodes(const list<string>& args)
{
+ if(!args.empty())
+ {
+ invalidCommand("node list", "doesn't require any argument");
+ return;
+ }
+
try
{
Ice::StringSeq names = _admin->getAllNodeNames();
@@ -892,8 +904,14 @@ Parser::shutdownRegistry(const list<string>& args)
}
void
-Parser::listAllRegistries()
+Parser::listAllRegistries(const list<string>& args)
{
+ if(!args.empty())
+ {
+ invalidCommand("registry list", "doesn't require any argument");
+ return;
+ }
+
try
{
Ice::StringSeq names = _admin->getAllRegistryNames();
@@ -1205,8 +1223,14 @@ Parser::enableServer(const list<string>& args, bool enable)
}
void
-Parser::listAllServers()
+Parser::listAllServers(const list<string>& args)
{
+ if(!args.empty())
+ {
+ invalidCommand("server list", "doesn't require any argument");
+ return;
+ }
+
try
{
Ice::StringSeq ids = _admin->getAllServerIds();
@@ -1272,8 +1296,14 @@ Parser::removeAdapter(const list<string>& args)
}
void
-Parser::listAllAdapters()
+Parser::listAllAdapters(const list<string>& args)
{
+ if(!args.empty())
+ {
+ invalidCommand("adapter list", "doesn't require any argument");
+ return;
+ }
+
try
{
Ice::StringSeq ids = _admin->getAllAdapterIds();
@@ -1288,9 +1318,9 @@ Parser::listAllAdapters()
void
Parser::addObject(const list<string>& args)
{
- if(args.size() < 1)
+ if(args.size() != 1 && args.size() != 2)
{
- invalidCommand("object add", "requires at least one argument");
+ invalidCommand("object add", "requires one or two arguments");
return;
}
@@ -1361,6 +1391,12 @@ Parser::findObject(const list<string>& args)
void
Parser::describeObject(const list<string>& args)
{
+ if(args.size() > 1)
+ {
+ invalidCommand("object find", "requires at most one argument");
+ return;
+ }
+
try
{
ObjectInfoSeq objects;
@@ -1399,6 +1435,12 @@ Parser::describeObject(const list<string>& args)
void
Parser::listObject(const list<string>& args)
{
+ if(args.size() > 1)
+ {
+ invalidCommand("object find", "requires at most one argument");
+ return;
+ }
+
try
{
ObjectInfoSeq objects;
@@ -1816,19 +1858,52 @@ Parser::scanPosition(const char* s)
void
Parser::invalidCommand(const char* s)
{
- error(string(s) + "\n(`help' for more info)");
+ error(s);
}
void
Parser::invalidCommand(const string& s)
{
- invalidCommand(s.c_str());
+ error(s.c_str());
}
void
-Parser::invalidCommand(const string& command, const string& s)
+Parser::invalidCommand(const string& command, const string& msg)
{
- error("`" + command + "'\n(`" + command + " help' for more info)");
+ error("`" + command + "' " + msg + "\n(`" + command + " help' for more info)");
+}
+
+void
+Parser::invalidCommand(const list<string>& s)
+{
+ if(s.empty())
+ {
+ return;
+ }
+
+ string cat = *s.begin();
+ if(_helpCommands.find(cat) == _helpCommands.end())
+ {
+ cerr << "unknown `" << cat << "' command (see `help' for more info)" << endl;
+ }
+ else if(s.size() == 1)
+ {
+ cerr << "invalid `" << cat << "' command (see `" << cat << " help' for more info)" << endl;
+ }
+ else
+ {
+ string cmd = *(++s.begin());
+ if(_helpCommands[cat].find(cmd) == _helpCommands[cat].end())
+ {
+ cmd = cat + " " + cmd;
+ cerr << "unknown `" << cmd << "' command (see `" << cat << " help' for more info)" << endl;
+ }
+ else
+ {
+ cmd = cat + " " + cmd;
+ cerr << "invalid `" << cmd << "' command (see `" << cmd << " help' for more info)" << endl;
+ }
+ }
}
void
diff --git a/cpp/src/IceGrid/Parser.h b/cpp/src/IceGrid/Parser.h
index acd6b3267e6..0ec89f6900a 100644
--- a/cpp/src/IceGrid/Parser.h
+++ b/cpp/src/IceGrid/Parser.h
@@ -83,7 +83,7 @@ public:
void diffApplication(const std::list<std::string>&);
void updateApplication(const std::list<std::string>&);
void patchApplication(const std::list<std::string>&);
- void listAllApplications();
+ void listAllApplications(const std::list<std::string>&);
void describeServerTemplate(const std::list<std::string>&);
void describeServiceTemplate(const std::list<std::string>&);
@@ -93,12 +93,12 @@ public:
void pingNode(const std::list<std::string>&);
void printLoadNode(const std::list<std::string>&);
void shutdownNode(const std::list<std::string>&);
- void listAllNodes();
+ void listAllNodes(const std::list<std::string>&);
void describeRegistry(const std::list<std::string>&);
void pingRegistry(const std::list<std::string>&);
void shutdownRegistry(const std::list<std::string>&);
- void listAllRegistries();
+ void listAllRegistries(const std::list<std::string>&);
void removeServer(const std::list<std::string>&);
void startServer(const std::list<std::string>&);
@@ -110,11 +110,11 @@ public:
void stateServer(const std::list<std::string>&);
void enableServer(const std::list<std::string>&, bool);
void pidServer(const std::list<std::string>&);
- void listAllServers();
+ void listAllServers(const std::list<std::string>&);
void endpointsAdapter(const std::list<std::string>&);
void removeAdapter(const std::list<std::string>&);
- void listAllAdapters();
+ void listAllAdapters(const std::list<std::string>&);
void addObject(const std::list<std::string>&);
void removeObject(const std::list<std::string>&);
@@ -137,6 +137,9 @@ public:
void invalidCommand(const char*);
void invalidCommand(const std::string&);
void invalidCommand(const std::string&, const std::string&);
+
+ void invalidCommand(const std::list<std::string>&);
+
void patchFailed(const Ice::StringSeq&);
void error(const char*);
void error(const std::string&);
diff --git a/cpp/src/IceGrid/Scanner.l b/cpp/src/IceGrid/Scanner.l
index b75b7e2def1..e21f5541275 100644
--- a/cpp/src/IceGrid/Scanner.l
+++ b/cpp/src/IceGrid/Scanner.l
@@ -27,14 +27,27 @@ using namespace IceGrid;
#define YY_INPUT(buf, result, maxSize) parser->getInput(buf, result, maxSize)
+namespace IceGrid
+{
+
+typedef std::map<std::string, int> StringTokenMap;
+static StringTokenMap keywordMap;
+
+void initScanner();
+
+}
+#define YY_USER_INIT initScanner();
+
%}
WS [ \t\v\f\r]
NL [\n]
+keyword [[:alpha:]]*
%option noyywrap
%option never-interactive
+
%%
^"#"[[:blank:]]*[[:digit:]]+[[:blank:]]*$ {
@@ -96,150 +109,6 @@ NL [\n]
}
}
-"help" {
- return ICE_GRID_HELP;
-}
-
-"quit"|"exit" {
- return ICE_GRID_EXIT;
-}
-
-"application" {
- return ICE_GRID_APPLICATION;
-}
-
-"server" {
- return ICE_GRID_SERVER;
-}
-
-"adapter" {
- return ICE_GRID_ADAPTER;
-}
-
-"add" {
- return ICE_GRID_ADD;
-}
-
-"remove" {
- return ICE_GRID_REMOVE;
-}
-
-"list" {
- return ICE_GRID_LIST;
-}
-
-"shutdown" {
- return ICE_GRID_SHUTDOWN;
-}
-
-"describe" {
- return ICE_GRID_DESCRIBE;
-}
-
-"state" {
- return ICE_GRID_STATE;
-}
-
-"pid" {
- return ICE_GRID_PID;
-}
-
-"endpoints" {
- return ICE_GRID_ENDPOINTS;
-}
-
-"start" {
- return ICE_GRID_START;
-}
-
-"patch" {
- return ICE_GRID_PATCH;
-}
-
-"stop" {
- return ICE_GRID_STOP;
-}
-
-"signal" {
- return ICE_GRID_SIGNAL;
-}
-
-"stdout" {
- return ICE_GRID_STDOUT;
-}
-
-"stderr" {
- return ICE_GRID_STDERR;
-}
-
-"node" {
- return ICE_GRID_NODE;
-}
-
-"registry" {
- return ICE_GRID_REGISTRY;
-}
-
-"ping" {
- return ICE_GRID_PING;
-}
-
-"load" {
- return ICE_GRID_LOAD;
-}
-
-"activation" {
- return ICE_GRID_ACTIVATION;
-}
-
-"object" {
- return ICE_GRID_OBJECT;
-}
-
-"find" {
- return ICE_GRID_FIND;
-}
-
-"show" {
- return ICE_GRID_SHOW;
-}
-
-"copying" {
- return ICE_GRID_COPYING;
-}
-
-"warranty" {
- return ICE_GRID_WARRANTY;
-}
-
-"diff" {
- return ICE_GRID_DIFF;
-}
-
-"update" {
- return ICE_GRID_UPDATE;
-}
-
-"instantiate" {
- return ICE_GRID_INSTANTIATE;
-}
-
-"template" {
- return ICE_GRID_TEMPLATE;
-}
-
-"service" {
- return ICE_GRID_SERVICE;
-}
-
-"enable" {
- return ICE_GRID_ENABLE;
-}
-
-"disable" {
- return ICE_GRID_DISABLE;
-}
-
{WS}*(\\{WS}*{NL})? {
size_t len = strlen(yytext);
for(size_t i = 0; i < len; ++i)
@@ -395,9 +264,62 @@ NL [\n]
s += c;
}
+
yylvalp->clear();
yylvalp->push_back(s);
- return ICE_GRID_STRING;
+
+ StringTokenMap::const_iterator pos = keywordMap.find(s);
+ return pos != keywordMap.end() ? pos->second : ICE_GRID_STRING;
}
%%
+
+namespace IceGrid {
+
+//
+// initScanner() fills the keyword map with all keyword-token pairs.
+//
+
+void
+initScanner()
+{
+ keywordMap["help"] = ICE_GRID_HELP;
+ keywordMap["quit"] = ICE_GRID_EXIT;
+ keywordMap["exit"] = ICE_GRID_EXIT;
+ keywordMap["application"] = ICE_GRID_APPLICATION;
+ keywordMap["server"] = ICE_GRID_SERVER;
+ keywordMap["adapter"] = ICE_GRID_ADAPTER;
+ keywordMap["add"] = ICE_GRID_ADD;
+ keywordMap["remove"] = ICE_GRID_REMOVE;
+ keywordMap["list"] = ICE_GRID_LIST;
+ keywordMap["shutdown"] = ICE_GRID_SHUTDOWN;
+ keywordMap["describe"] = ICE_GRID_DESCRIBE;
+ keywordMap["state"] = ICE_GRID_STATE;
+ keywordMap["pid"] = ICE_GRID_PID;
+ keywordMap["endpoints"] = ICE_GRID_ENDPOINTS;
+ keywordMap["start"] = ICE_GRID_START;
+ keywordMap["patch"] = ICE_GRID_PATCH;
+ keywordMap["stop"] = ICE_GRID_STOP;
+ keywordMap["signal"] = ICE_GRID_SIGNAL;
+ keywordMap["stdout"] = ICE_GRID_STDOUT;
+ keywordMap["stderr"] = ICE_GRID_STDERR;
+ keywordMap["node"] = ICE_GRID_NODE;
+ keywordMap["registry"] = ICE_GRID_REGISTRY;
+ keywordMap["ping"] = ICE_GRID_PING;
+ keywordMap["load"] = ICE_GRID_LOAD;
+ keywordMap["activation"] = ICE_GRID_ACTIVATION;
+ keywordMap["object"] = ICE_GRID_OBJECT;
+ keywordMap["find"] = ICE_GRID_FIND;
+ keywordMap["show"] = ICE_GRID_SHOW;
+ keywordMap["copying"] = ICE_GRID_COPYING;
+ keywordMap["warranty"] = ICE_GRID_WARRANTY;
+ keywordMap["diff"] = ICE_GRID_DIFF;
+ keywordMap["update"] = ICE_GRID_UPDATE;
+ keywordMap["instantiate"] = ICE_GRID_INSTANTIATE;
+ keywordMap["template"] = ICE_GRID_TEMPLATE;
+ keywordMap["service"] = ICE_GRID_SERVICE;
+ keywordMap["enable"] = ICE_GRID_ENABLE;
+ keywordMap["disable"] = ICE_GRID_DISABLE;
+}
+
+}