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