Parser.h
Go to the documentation of this file.
1 // **********************************************************************
2 //
3 // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
4 //
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
7 //
8 // **********************************************************************
9 
10 #ifndef ICE_STORM_PARSER_H
11 #define ICE_STORM_PARSER_H
12 
13 #include <IceUtil/Handle.h>
14 #include <IceStorm/IceStorm.h>
15 #include <list>
16 #include <stdio.h>
17 
18 //
19 // Stuff for flex and bison
20 //
21 
22 #define YYSTYPE std::list<std::string>
23 #define YY_DECL int yylex(YYSTYPE* yylvalp)
25 int yyparse();
26 
27 //
28 // I must set the initial stack depth to the maximum stack depth to
29 // disable bison stack resizing. The bison stack resizing routines use
30 // simple malloc/alloc/memcpy calls, which do not work for the
31 // YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor,
32 // assignment operator, etc.
33 //
34 #define YYMAXDEPTH 10000
35 #define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above.
36 
37 //
38 // Newer bison versions allow to disable stack resizing by defining
39 // yyoverflow.
40 //
41 #define yyoverflow(a, b, c, d, e, f) yyerror(a)
42 
43 namespace IceStorm
44 {
45 
46  //
47  // Forward declaration.
48  //
49  class Parser;
50  typedef ::IceUtil::Handle<Parser> ParserPtr;
51 
52  class Parser : public ::IceUtil::SimpleShared
53  {
54  public:
55 
57  const std::map<Ice::Identity, TopicManagerPrx>&);
58 
59  void usage();
60 
61  void create(const std::list<std::string>&);
62  void destroy(const std::list<std::string>&);
63  void link(const std::list<std::string>&);
64  void unlink(const std::list<std::string>&);
65  void links(const std::list<std::string>&);
66  void topics(const std::list<std::string>&);
67  void replica(const std::list<std::string>&);
68  void subscribers(const std::list<std::string>&);
69  void current(const std::list<std::string>&);
70 
71  void showBanner();
72 
73  //
74  // With older flex version <= 2.5.35 YY_INPUT second
75  // paramenter is of type int&, in newer versions it
76  // changes to size_t&
77  //
78  void getInput(char*, int&, size_t);
79  void getInput(char*, size_t&, size_t);
80 
81  void continueLine();
82  const char* getPrompt();
83 
84  void error(const char*);
85  void error(const std::string&);
86 
87  void warning(const char*);
88  void warning(const std::string&);
89 
90  void invalidCommand(const std::string&);
91 
92  int parse(FILE*, bool);
93  int parse(const std::string&, bool);
94 
95  private:
96 
97  TopicManagerPrx findManagerById(const std::string&, std::string&) const;
98  TopicManagerPrx findManagerByCategory(const std::string&) const;
99  TopicPrx findTopic(const std::string&) const;
100 
101  Parser(const Ice::CommunicatorPtr&, const TopicManagerPrx&, const std::map<Ice::Identity, TopicManagerPrx>&);
102 
103  void exception(const Ice::Exception&, bool = false);
104 
105  const Ice::CommunicatorPtr _communicator;
106  TopicManagerPrx _defaultManager;
107  const std::map<Ice::Identity, TopicManagerPrx> _managers;
108  std::string _commands;
109  bool _continue;
110  int _errors;
111  };
112 
113  extern Parser* parser; // The current parser for bison/flex
114 
115 } // End namespace IceStorm
116 
117 #endif
IceStorm::Parser::create
void create(const std::list< std::string > &)
IceStorm
Definition: DBTypes.ice:22
IceStorm::Parser::getPrompt
const char * getPrompt()
IceStorm::Parser
Definition: Parser.h:52
YY_DECL
#define YY_DECL
Definition: Parser.h:23
IceStorm::ParserPtr
::IceUtil::Handle< Parser > ParserPtr
Definition: Parser.h:49
IceStorm::Parser::link
void link(const std::list< std::string > &)
IceStorm::Parser::parse
int parse(FILE *, bool)
IceStorm::Parser::invalidCommand
void invalidCommand(const std::string &)
IceStorm::Parser::unlink
void unlink(const std::list< std::string > &)
IceStorm::Parser::getInput
void getInput(char *, int &, size_t)
IceStorm::Parser::warning
void warning(const char *)
IceStorm::Parser::createParser
static ParserPtr createParser(const Ice::CommunicatorPtr &, const TopicManagerPrx &, const std::map< Ice::Identity, TopicManagerPrx > &)
IceStorm::Parser::current
void current(const std::list< std::string > &)
IceInternal::Handle< ::Ice::Communicator >
yyparse
int yyparse()
Definition: Grammar.cpp:1187
IceStorm::Parser::links
void links(const std::list< std::string > &)
IceStorm::Parser::subscribers
void subscribers(const std::list< std::string > &)
IceStorm::Parser::continueLine
void continueLine()
IceStorm::Parser::destroy
void destroy(const std::list< std::string > &)
IceStorm::Parser::usage
void usage()
IceStorm::Parser::topics
void topics(const std::list< std::string > &)
IceStorm::parser
Parser * parser
Definition: Parser.cpp:33
IceStorm::Parser::replica
void replica(const std::list< std::string > &)
IceUtil::Handle
Definition: forward_declarations.h:29
IceInternal::ProxyHandle< ::IceProxy::IceStorm::TopicManager >
IceStorm::Parser::error
void error(const char *)
IceStorm::Parser::showBanner
void showBanner()