ProgramGraphParser.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Mon Jan 19 14:11:26 CET 2004 ProgramGraphParser.hpp
3 
4  ProgramGraphParser.hpp - description
5  -------------------
6  begin : Mon January 19 2004
7  copyright : (C) 2004 Peter Soetens
8  email : peter.soetens@mech.kuleuven.ac.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 #ifndef EXECUTION_PROGRAM_PARSER_HPP
39 #define EXECUTION_PROGRAM_PARSER_HPP
40 
41 #include "parser-types.hpp"
42 
43 #include "CommonParser.hpp"
44 #include "PeerParser.hpp"
45 #include "ConditionParser.hpp"
46 #include "ExpressionParser.hpp"
47 #include "../TaskContext.hpp"
48 #include "FunctionGraphBuilder.hpp"
49 #include "ValueChangeParser.hpp"
50 
51 #include <map>
52 #include <vector>
53 #include <string>
54 
55 
56 #include "ProgramService.hpp"
57 //namespace RTT {
58 // class ProgramService;
59 //}
60 
61 namespace RTT { namespace scripting
62 {
73  {
77 
83 
88 
93 
98 
100 
101  // The current function we are parsing.
103 
104  // The function we will call next
106 
107  // A map of all functions
108  typedef std::map<std::string, FunctionGraphPtr> funcmap;
109  funcmap mfuncs;
110 
111  // The return type of the current function.
112  std::string rettype;
113 
114  // The implicit termination condition we just got for the
115  // current command from the CommandParser..
117  std::vector<ConditionInterface*> implcond_v;
118  std::vector<base::DataSourceBase::shared_ptr> callfnargs;
119 
120  // last seen condition
122  // try-block condition
124 
125  void seencondition();
126 
127  void seencallfunclabel( iter_t begin, iter_t end );
128 
129  void seencontinue( );
130 
131  void skip_eol();
132  void noskip_eol();
133  void seenyield();
134  void seenstatement();
135  void seentrystatement();
136  void startcatchpart();
137  void seencatchpart();
138 
139  void seenvaluechange();
140 
141  void functiondef( iter_t begin, iter_t end );
142  void exportdef( );
143  void globaldef( );
144  void seenfunctionarg();
145  void seenfunctionend();
146  void seenvalidinput();
147 
148  void seenfuncidentifier( iter_t begin, iter_t end);
149  void seencallfuncstatement();
150  void seencallfuncargs();
151 
152  void seenreturnstatement();
153  void seenreturnlabel();
154  void seenreturnvalue();
155  void seenreturntype( iter_t begin, iter_t end );
156 
157  void seenifstatement();
158  void endifblock();
159  void endifstatement();
160 
161  void seenwhilestatement();
162  void endwhilestatement();
163 
164  void seenbreakstatement();
165 
166  void seenforstatement();
167  void seenforinit();
168  void seenforinit_expr();
169  void seenforincr();
170  void seenemptyforincr();
171  void endforstatement();
172 
173  void startofprogram();
174  void programdef( iter_t begin, iter_t end );
175  void seenprogramend();
176  void programtext(iter_t, iter_t);
177 
178  void setStack(Service::shared_ptr st);
180  void clearParseState();
181  void setup();
182  void setup2();
183  void cleanup(bool remove_service);
184 
191 
198 
199  boost::shared_ptr<FunctionGraphBuilder> program_builder;
200  std::vector< FunctionGraphPtr > program_list;
201 
203  std::stack<base::ActionInterface*> for_incr_command;
204  std::string program_text;
207  public:
208  ProgramGraphParser( iter_t& positer, TaskContext* context, ExecutionEngine* caller, CommonParser& cp);
210 
215  std::vector<ProgramInterfacePtr> parse( iter_t& begin, iter_t end );
216 
217  std::vector<ProgramInterfacePtr> parseFunction( iter_t& begin, iter_t end );
218 
223  void initBodyParser(const std::string& name, Service::shared_ptr stck, int offset);
224 
230  rule_t& bodyParser();
231 
236 
241 
250 
252 
257  bool parserUsed() const;
258  };
259 }}
260 
261 #endif
std::vector< base::DataSourceBase::shared_ptr > callfnargs
boost::shared_ptr< FunctionGraph > FunctionGraphPtr
std::vector< ConditionInterface * > implcond_v
void clearParseState()
Clears helper variables of parser.
This interface represents the concept of a condition which can be evaluated and return true or false...
void seenreturntype(iter_t begin, iter_t end)
boost::shared_ptr< FunctionGraphBuilder > program_builder
void programdef(iter_t begin, iter_t end)
A Parser for Orocos Program Scripts.
void seencallfunclabel(iter_t begin, iter_t end)
boost::shared_ptr< ProgramInterface > ProgramInterfacePtr
void initBodyParser(const std::string &name, Service::shared_ptr stck, int offset)
std::stack< base::ActionInterface * > for_incr_command
This class contains some very common parser definitions.
boost::shared_ptr< Service > shared_ptr
Definition: Service.hpp:101
ProgramGraphParser(iter_t &positer, TaskContext *context, ExecutionEngine *caller, CommonParser &cp)
position_iterator< our_iterator_t > our_pos_iter_t
Based on the software pattern &#39;command&#39;, this interface allows execution of action objects...
std::map< std::string, FunctionGraphPtr > funcmap
rule< scanner_t > rule_t
void setStack(Service::shared_ptr st)
FunctionGraphBuilder::ConditionEdge ConditionEdge
void seenfuncidentifier(iter_t begin, iter_t end)
std::vector< ProgramInterfacePtr > parse(iter_t &begin, iter_t end)
Tries to parse programs, returns the generated programs on success.
std::vector< ProgramInterfacePtr > parseFunction(iter_t &begin, iter_t end)
base::ActionInterface * for_init_command
std::vector< FunctionGraphPtr > program_list
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
our_pos_iter_t iter_t
void functiondef(iter_t begin, iter_t end)
FunctionGraphBuilder::Graph Graph
boost::adjacency_list< boost::vecS, boost::listS, boost::directedS, VertProperty, EdgeProperty > Graph
FunctionGraphBuilder::CommandNode CommandNode


rtt
Author(s): RTT Developers
autogenerated on Fri Oct 25 2019 03:59:34