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)
27int 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
46namespace 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
103 Parser(const Ice::CommunicatorPtr&,
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
int yyparse()
Definition Grammar.cpp:1086
#define YY_DECL
Definition Parser.h:25
void replica(const std::list< std::string > &)
Definition Parser.cpp:282
const char * getPrompt()
Definition Parser.cpp:538
void create(const std::list< std::string > &)
Definition Parser.cpp:111
void destroy(const std::list< std::string > &)
Definition Parser.cpp:138
void unlink(const std::list< std::string > &)
Definition Parser.cpp:188
void subscribers(const std::list< std::string > &)
Definition Parser.cpp:363
void continueLine()
Definition Parser.cpp:532
void warning(const char *)
Definition Parser.cpp:567
void current(const std::list< std::string > &)
Definition Parser.cpp:390
void error(const char *)
Definition Parser.cpp:554
void links(const std::list< std::string > &)
Definition Parser.cpp:212
void error(const std::string &)
void invalidCommand(const std::string &)
Definition Parser.cpp:579
void showBanner()
Definition Parser.cpp:416
void getInput(char *, int &, size_t)
Definition Parser.cpp:427
void warning(const std::string &)
void topics(const std::list< std::string > &)
Definition Parser.cpp:249
void link(const std::list< std::string > &)
Definition Parser.cpp:163
static ParserPtr createParser(const Ice::CommunicatorPtr &, const TopicManagerPrx &, const std::map< Ice::Identity, TopicManagerPrx > &)
Definition Parser.cpp:83
int parse(FILE *, bool)
Definition Parser.cpp:585
::IceInternal::ProxyHandle<::IceProxy::IceStorm::Topic > TopicPrx
Definition IceManager.h:70
::IceUtil::Handle< Parser > ParserPtr
Definition Parser.h:53
Parser * parser
Definition Parser.cpp:34
::IceInternal::ProxyHandle<::IceProxy::IceStorm::TopicManager > TopicManagerPrx
Definition IceManager.h:69
::IceInternal::Handle<::Ice::Communicator > CommunicatorPtr
Definition IceManager.h:49