1 | //
|
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
|
---|
3 | //
|
---|
4 | // The contents of this file are covered under the licence agreement in the
|
---|
5 | // file "LICENCE" distributed with Cforall.
|
---|
6 | //
|
---|
7 | // ParseNode.h --
|
---|
8 | //
|
---|
9 | // Author : Rodolfo G. Esteves
|
---|
10 | // Created On : Sat May 16 13:28:16 2015
|
---|
11 | // Last Modified By : Rob Schluntz
|
---|
12 | // Last Modified On : Mon Jul 20 14:28:54 2015
|
---|
13 | // Update Count : 93
|
---|
14 | //
|
---|
15 |
|
---|
16 | #ifndef PARSENODE_H
|
---|
17 | #define PARSENODE_H
|
---|
18 |
|
---|
19 | #include <string>
|
---|
20 | #include <list>
|
---|
21 | #include <iterator>
|
---|
22 |
|
---|
23 | #include "utility.h"
|
---|
24 | #include "Parser/LinkageSpec.h"
|
---|
25 | #include "SynTree/Type.h"
|
---|
26 | //#include "SynTree/Declaration.h"
|
---|
27 | #include "UniqueName.h"
|
---|
28 |
|
---|
29 | class ExpressionNode;
|
---|
30 | class CompositeExprNode;
|
---|
31 | class CommaExprNode;
|
---|
32 | class StatementNode;
|
---|
33 | class CompoundStmtNode;
|
---|
34 | class DeclarationNode;
|
---|
35 | class InitializerNode;
|
---|
36 |
|
---|
37 | // Builder
|
---|
38 | class ParseNode {
|
---|
39 | public:
|
---|
40 | ParseNode();
|
---|
41 | ParseNode( const std::string * );
|
---|
42 | virtual ~ParseNode();
|
---|
43 |
|
---|
44 | ParseNode *get_link() const;
|
---|
45 | ParseNode *get_last();
|
---|
46 | ParseNode *set_link( ParseNode * );
|
---|
47 | void set_next( ParseNode *newlink ) { next = newlink; }
|
---|
48 |
|
---|
49 | virtual ParseNode *clone() const { return 0; };
|
---|
50 |
|
---|
51 | const std::string &get_name() const { return *name; }
|
---|
52 | virtual void print( std::ostream &, int indent = 0 ) const;
|
---|
53 | virtual void printList( std::ostream &, int indent = 0 ) const;
|
---|
54 |
|
---|
55 | ParseNode &operator,( ParseNode &);
|
---|
56 | protected:
|
---|
57 | const std::string *name;
|
---|
58 | ParseNode *next;
|
---|
59 | static int indent_by;
|
---|
60 | };
|
---|
61 |
|
---|
62 | ParseNode *mkList( ParseNode & );
|
---|
63 |
|
---|
64 | class ExpressionNode : public ParseNode {
|
---|
65 | public:
|
---|
66 | ExpressionNode();
|
---|
67 | ExpressionNode( const std::string * );
|
---|
68 | ExpressionNode( const ExpressionNode &other );
|
---|
69 | virtual ~ExpressionNode() {} // cannot delete asArgName because it might be referenced elsewhere
|
---|
70 |
|
---|
71 | virtual ExpressionNode *clone() const = 0;
|
---|
72 |
|
---|
73 | virtual CommaExprNode *add_to_list( ExpressionNode * );
|
---|
74 |
|
---|
75 | ExpressionNode *get_argName() const { return argName; }
|
---|
76 | ExpressionNode *set_asArgName( const std::string *aName );
|
---|
77 | ExpressionNode *set_asArgName( ExpressionNode *aDesignator );
|
---|
78 |
|
---|
79 | virtual void print( std::ostream &, int indent = 0) const = 0;
|
---|
80 | virtual void printOneLine( std::ostream &, int indent = 0) const = 0;
|
---|
81 |
|
---|
82 | virtual Expression *build() const = 0;
|
---|
83 | protected:
|
---|
84 | void printDesignation ( std::ostream &, int indent = 0) const;
|
---|
85 | private:
|
---|
86 | ExpressionNode *argName;
|
---|
87 | };
|
---|
88 |
|
---|
89 | // NullExprNode is used in tuples as a place-holder where a tuple component is omitted e.g., [ 2, , 3 ]
|
---|
90 | class NullExprNode : public ExpressionNode {
|
---|
91 | public:
|
---|
92 | NullExprNode();
|
---|
93 |
|
---|
94 | virtual NullExprNode *clone() const;
|
---|
95 |
|
---|
96 | virtual void print( std::ostream &, int indent = 0) const;
|
---|
97 | virtual void printOneLine( std::ostream &, int indent = 0) const;
|
---|
98 |
|
---|
99 | virtual Expression *build() const;
|
---|
100 | };
|
---|
101 |
|
---|
102 | class ConstantNode : public ExpressionNode {
|
---|
103 | public:
|
---|
104 | enum Type { Integer, Float, Character, String };
|
---|
105 |
|
---|
106 | ConstantNode( Type, std::string * );
|
---|
107 |
|
---|
108 | virtual ConstantNode *clone() const { return new ConstantNode( *this ); }
|
---|
109 | Type get_type( void ) const { return type; }
|
---|
110 | virtual void print( std::ostream &, int indent = 0) const;
|
---|
111 | virtual void printOneLine( std::ostream &, int indent = 0) const;
|
---|
112 |
|
---|
113 | const std::string &get_value() const { return value; }
|
---|
114 | ConstantNode *appendstr( const std::string *newValue );
|
---|
115 |
|
---|
116 | Expression *build() const;
|
---|
117 | private:
|
---|
118 | Type type;
|
---|
119 | BasicType::Kind btype;
|
---|
120 | std::string &value;
|
---|
121 | };
|
---|
122 |
|
---|
123 | class VarRefNode : public ExpressionNode {
|
---|
124 | public:
|
---|
125 | VarRefNode();
|
---|
126 | VarRefNode( const std::string *, bool isLabel = false );
|
---|
127 | VarRefNode( const VarRefNode &other );
|
---|
128 |
|
---|
129 | virtual Expression *build() const ;
|
---|
130 |
|
---|
131 | virtual VarRefNode *clone() const { return new VarRefNode( *this ); }
|
---|
132 |
|
---|
133 | virtual void print( std::ostream &, int indent = 0 ) const;
|
---|
134 | virtual void printOneLine( std::ostream &, int indent = 0 ) const;
|
---|
135 | private:
|
---|
136 | bool isLabel;
|
---|
137 | };
|
---|
138 |
|
---|
139 | class TypeValueNode : public ExpressionNode {
|
---|
140 | public:
|
---|
141 | TypeValueNode( DeclarationNode * );
|
---|
142 | TypeValueNode( const TypeValueNode &other );
|
---|
143 |
|
---|
144 | DeclarationNode *get_decl() const { return decl; }
|
---|
145 |
|
---|
146 | virtual Expression *build() const ;
|
---|
147 |
|
---|
148 | virtual TypeValueNode *clone() const { return new TypeValueNode( *this ); }
|
---|
149 |
|
---|
150 | virtual void print( std::ostream &, int indent = 0) const;
|
---|
151 | virtual void printOneLine( std::ostream &, int indent = 0) const;
|
---|
152 | private:
|
---|
153 | DeclarationNode *decl;
|
---|
154 | };
|
---|
155 |
|
---|
156 | class OperatorNode : public ExpressionNode {
|
---|
157 | public:
|
---|
158 | enum Type { TupleC, Comma, TupleFieldSel,
|
---|
159 | Cond, NCond,
|
---|
160 | SizeOf, AlignOf, Attr, CompLit, Plus, Minus, Mul, Div, Mod, Or, And,
|
---|
161 | BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq,
|
---|
162 | Assign, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn,
|
---|
163 | ERAssn, OrAssn, Index, FieldSel, PFieldSel, Range,
|
---|
164 | UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost, LabelAddress,
|
---|
165 | Ctor, Dtor,
|
---|
166 | };
|
---|
167 |
|
---|
168 | OperatorNode( Type t );
|
---|
169 | OperatorNode( const OperatorNode &other );
|
---|
170 | virtual ~OperatorNode();
|
---|
171 |
|
---|
172 | virtual OperatorNode *clone() const { return new OperatorNode( *this ); }
|
---|
173 |
|
---|
174 | Type get_type() const;
|
---|
175 | const char *get_typename() const;
|
---|
176 |
|
---|
177 | virtual void print( std::ostream &, int indent = 0) const;
|
---|
178 | virtual void printOneLine( std::ostream &, int indent = 0) const;
|
---|
179 |
|
---|
180 | virtual Expression *build() const { return 0; }
|
---|
181 | private:
|
---|
182 | Type type;
|
---|
183 | static const char *OpName[];
|
---|
184 | };
|
---|
185 |
|
---|
186 |
|
---|
187 | class CompositeExprNode : public ExpressionNode {
|
---|
188 | public:
|
---|
189 | CompositeExprNode();
|
---|
190 | CompositeExprNode( const std::string * );
|
---|
191 | CompositeExprNode( ExpressionNode *f, ExpressionNode *args = 0 );
|
---|
192 | CompositeExprNode( ExpressionNode *f, ExpressionNode *arg1, ExpressionNode *arg2 );
|
---|
193 | CompositeExprNode( const CompositeExprNode &other );
|
---|
194 | virtual ~CompositeExprNode();
|
---|
195 |
|
---|
196 | virtual CompositeExprNode *clone() const { return new CompositeExprNode( *this ); }
|
---|
197 | virtual Expression *build() const;
|
---|
198 |
|
---|
199 | virtual void print( std::ostream &, int indent = 0) const;
|
---|
200 | virtual void printOneLine( std::ostream &, int indent = 0) const;
|
---|
201 |
|
---|
202 | void set_function( ExpressionNode * );
|
---|
203 | void set_args( ExpressionNode * );
|
---|
204 |
|
---|
205 | void add_arg( ExpressionNode * );
|
---|
206 |
|
---|
207 | ExpressionNode *get_function() const;
|
---|
208 | ExpressionNode *get_args() const;
|
---|
209 | private:
|
---|
210 | ExpressionNode *function;
|
---|
211 | ExpressionNode *arguments;
|
---|
212 | };
|
---|
213 |
|
---|
214 | class CommaExprNode : public CompositeExprNode {
|
---|
215 | public:
|
---|
216 | CommaExprNode();
|
---|
217 | CommaExprNode( ExpressionNode * );
|
---|
218 | CommaExprNode( ExpressionNode *, ExpressionNode * );
|
---|
219 | CommaExprNode( const CommaExprNode &other );
|
---|
220 |
|
---|
221 | virtual CommaExprNode *add_to_list( ExpressionNode * );
|
---|
222 | virtual CommaExprNode *clone() const { return new CommaExprNode( *this ); }
|
---|
223 | };
|
---|
224 |
|
---|
225 | class ForCtlExprNode : public ExpressionNode {
|
---|
226 | public:
|
---|
227 | ForCtlExprNode( ParseNode *, ExpressionNode *, ExpressionNode * ) throw ( SemanticError );
|
---|
228 | ForCtlExprNode( const ForCtlExprNode &other );
|
---|
229 | ~ForCtlExprNode();
|
---|
230 |
|
---|
231 | StatementNode *get_init() const { return init; }
|
---|
232 | ExpressionNode *get_condition() const { return condition; }
|
---|
233 | ExpressionNode *get_change() const { return change; }
|
---|
234 |
|
---|
235 | virtual ForCtlExprNode *clone() const { return new ForCtlExprNode( *this ); }
|
---|
236 | virtual Expression *build() const;
|
---|
237 |
|
---|
238 | virtual void print( std::ostream &, int indent = 0 ) const;
|
---|
239 | virtual void printOneLine( std::ostream &, int indent = 0 ) const;
|
---|
240 | private:
|
---|
241 | StatementNode *init;
|
---|
242 | ExpressionNode *condition;
|
---|
243 | ExpressionNode *change;
|
---|
244 | };
|
---|
245 |
|
---|
246 | class ValofExprNode : public ExpressionNode {
|
---|
247 | public:
|
---|
248 | ValofExprNode();
|
---|
249 | ValofExprNode( StatementNode *s = 0 );
|
---|
250 | ValofExprNode( const ValofExprNode &other );
|
---|
251 | ~ValofExprNode();
|
---|
252 |
|
---|
253 | virtual ValofExprNode *clone() const { return new ValofExprNode( *this ); }
|
---|
254 |
|
---|
255 | StatementNode *get_body() const { return body; }
|
---|
256 | void print( std::ostream &, int indent = 0 ) const;
|
---|
257 | void printOneLine( std::ostream &, int indent = 0 ) const;
|
---|
258 | Expression *build() const;
|
---|
259 |
|
---|
260 | private:
|
---|
261 | StatementNode *body;
|
---|
262 | };
|
---|
263 |
|
---|
264 | class TypeData;
|
---|
265 |
|
---|
266 | class DeclarationNode : public ParseNode {
|
---|
267 | public:
|
---|
268 | enum Qualifier { Const, Restrict, Volatile, Lvalue, Atomic };
|
---|
269 | enum StorageClass { Extern, Static, Auto, Register, Inline, Fortran, Noreturn, Threadlocal, NoStorageClass, };
|
---|
270 | enum BasicType { Char, Int, Float, Double, Void, Bool, Complex, Imaginary };
|
---|
271 | enum Modifier { Signed, Unsigned, Short, Long };
|
---|
272 | enum Aggregate { Struct, Union, Context };
|
---|
273 | enum TypeClass { Type, Dtype, Ftype };
|
---|
274 |
|
---|
275 | static const char *storageName[];
|
---|
276 | static const char *qualifierName[];
|
---|
277 | static const char *basicTypeName[];
|
---|
278 | static const char *modifierName[];
|
---|
279 | static const char *aggregateName[];
|
---|
280 | static const char *typeClassName[];
|
---|
281 |
|
---|
282 | static DeclarationNode *newFunction( std::string *name, DeclarationNode *ret, DeclarationNode *param,
|
---|
283 | StatementNode *body, bool newStyle = false );
|
---|
284 | static DeclarationNode *newQualifier( Qualifier );
|
---|
285 | static DeclarationNode *newStorageClass( StorageClass );
|
---|
286 | static DeclarationNode *newBasicType( BasicType );
|
---|
287 | static DeclarationNode *newModifier( Modifier );
|
---|
288 | static DeclarationNode *newForall( DeclarationNode *);
|
---|
289 | static DeclarationNode *newFromTypedef( std::string *);
|
---|
290 | static DeclarationNode *newAggregate( Aggregate kind, const std::string *name, ExpressionNode *actuals, DeclarationNode *fields );
|
---|
291 | static DeclarationNode *newEnum( std::string *name, DeclarationNode *constants );
|
---|
292 | static DeclarationNode *newEnumConstant( std::string *name, ExpressionNode *constant );
|
---|
293 | static DeclarationNode *newName( std::string *);
|
---|
294 | static DeclarationNode *newFromTypeGen( std::string *, ExpressionNode *params );
|
---|
295 | static DeclarationNode *newTypeParam( TypeClass, std::string *);
|
---|
296 | static DeclarationNode *newContext( std::string *name, DeclarationNode *params, DeclarationNode *asserts );
|
---|
297 | static DeclarationNode *newContextUse( std::string *name, ExpressionNode *params );
|
---|
298 | static DeclarationNode *newTypeDecl( std::string *name, DeclarationNode *typeParams );
|
---|
299 | static DeclarationNode *newPointer( DeclarationNode *qualifiers );
|
---|
300 | static DeclarationNode *newArray( ExpressionNode *size, DeclarationNode *qualifiers, bool isStatic );
|
---|
301 | static DeclarationNode *newVarArray( DeclarationNode *qualifiers );
|
---|
302 | static DeclarationNode *newBitfield( ExpressionNode *size );
|
---|
303 | static DeclarationNode *newTuple( DeclarationNode *members );
|
---|
304 | static DeclarationNode *newTypeof( ExpressionNode *expr );
|
---|
305 | static DeclarationNode *newAttr( std::string *, ExpressionNode *expr );
|
---|
306 | static DeclarationNode *newAttr( std::string *, DeclarationNode *type );
|
---|
307 |
|
---|
308 | DeclarationNode *addQualifiers( DeclarationNode *);
|
---|
309 | DeclarationNode *copyStorageClasses( DeclarationNode *);
|
---|
310 | DeclarationNode *addType( DeclarationNode *);
|
---|
311 | DeclarationNode *addTypedef();
|
---|
312 | DeclarationNode *addAssertions( DeclarationNode *);
|
---|
313 | DeclarationNode *addName( std::string *);
|
---|
314 | DeclarationNode *addBitfield( ExpressionNode *size );
|
---|
315 | DeclarationNode *addVarArgs();
|
---|
316 | DeclarationNode *addFunctionBody( StatementNode *body );
|
---|
317 | DeclarationNode *addOldDeclList( DeclarationNode *list );
|
---|
318 | DeclarationNode *addPointer( DeclarationNode *qualifiers );
|
---|
319 | DeclarationNode *addArray( DeclarationNode *array );
|
---|
320 | DeclarationNode *addNewPointer( DeclarationNode *pointer );
|
---|
321 | DeclarationNode *addNewArray( DeclarationNode *array );
|
---|
322 | DeclarationNode *addParamList( DeclarationNode *list );
|
---|
323 | DeclarationNode *addIdList( DeclarationNode *list ); // old-style functions
|
---|
324 | DeclarationNode *addInitializer( InitializerNode *init );
|
---|
325 |
|
---|
326 | DeclarationNode *cloneType( std::string *newName );
|
---|
327 | DeclarationNode *cloneType( DeclarationNode *existing );
|
---|
328 | DeclarationNode *cloneType( int ) { return cloneType( ( std::string *)0 ); }
|
---|
329 | DeclarationNode *cloneBaseType( std::string *newName );
|
---|
330 | DeclarationNode *cloneBaseType( DeclarationNode *newdecl );
|
---|
331 |
|
---|
332 | DeclarationNode *appendList( DeclarationNode * );
|
---|
333 |
|
---|
334 | DeclarationNode *clone() const;
|
---|
335 | void print( std::ostream &, int indent = 0 ) const;
|
---|
336 | void printList( std::ostream &, int indent = 0 ) const;
|
---|
337 |
|
---|
338 | Declaration *build() const;
|
---|
339 | ::Type *buildType() const;
|
---|
340 |
|
---|
341 | bool get_hasEllipsis() const;
|
---|
342 | const std::string &get_name() const { return name; }
|
---|
343 | LinkageSpec::Type get_linkage() const { return linkage; }
|
---|
344 | DeclarationNode *extractAggregate() const;
|
---|
345 |
|
---|
346 | DeclarationNode();
|
---|
347 | ~DeclarationNode();
|
---|
348 | private:
|
---|
349 | StorageClass buildStorageClass() const;
|
---|
350 | bool buildFuncSpecifier( StorageClass key ) const;
|
---|
351 |
|
---|
352 | TypeData *type;
|
---|
353 | std::string name;
|
---|
354 | std::list< StorageClass > storageClasses;
|
---|
355 | std::list< std::string > attributes;
|
---|
356 | ExpressionNode *bitfieldWidth;
|
---|
357 | InitializerNode *initializer;
|
---|
358 | bool hasEllipsis;
|
---|
359 | LinkageSpec::Type linkage;
|
---|
360 |
|
---|
361 | static UniqueName anonymous;
|
---|
362 | }; // DeclarationNode
|
---|
363 |
|
---|
364 | class StatementNode : public ParseNode {
|
---|
365 | public:
|
---|
366 | enum Type { Exp, If, Switch, Case, Default, Choose, Fallthru,
|
---|
367 | While, Do, For,
|
---|
368 | Goto, Continue, Break, Return, Throw,
|
---|
369 | Try, Catch, Finally, Asm,
|
---|
370 | Decl
|
---|
371 | };
|
---|
372 |
|
---|
373 | StatementNode();
|
---|
374 | StatementNode( const std::string * );
|
---|
375 | StatementNode( Type, ExpressionNode *e = 0, StatementNode *s = 0 );
|
---|
376 | StatementNode( Type, std::string *target );
|
---|
377 | StatementNode( DeclarationNode *decl );
|
---|
378 |
|
---|
379 |
|
---|
380 | ~StatementNode();
|
---|
381 |
|
---|
382 | static StatementNode *newCatchStmt( DeclarationNode *d = 0, StatementNode *s = 0, bool catchRestP = false );
|
---|
383 |
|
---|
384 | StatementNode *set_block( StatementNode *b ) { block = b; return this; }
|
---|
385 | StatementNode *get_block() const { return block; }
|
---|
386 |
|
---|
387 | void set_control( ExpressionNode *c ) { control = c; }
|
---|
388 | ExpressionNode *get_control() const { return control; }
|
---|
389 |
|
---|
390 | StatementNode::Type get_type() const { return type; }
|
---|
391 |
|
---|
392 | StatementNode *add_label( const std::string * );
|
---|
393 | const std::list<std::string> &get_labels() const { return labels; }
|
---|
394 |
|
---|
395 | void addDeclaration( DeclarationNode *newDecl ) { decl = newDecl; }
|
---|
396 | void setCatchRest( bool newVal ) { isCatchRest = newVal; }
|
---|
397 |
|
---|
398 | std::string get_target() const;
|
---|
399 |
|
---|
400 | StatementNode *add_controlexp( ExpressionNode * );
|
---|
401 | StatementNode *append_block( StatementNode * );
|
---|
402 | StatementNode *append_last_case( StatementNode * );
|
---|
403 |
|
---|
404 | void print( std::ostream &, int indent = 0) const;
|
---|
405 |
|
---|
406 | virtual StatementNode *clone() const;
|
---|
407 |
|
---|
408 | virtual Statement *build() const;
|
---|
409 | private:
|
---|
410 | static const char *StType[];
|
---|
411 | Type type;
|
---|
412 | ExpressionNode *control;
|
---|
413 | StatementNode *block;
|
---|
414 | std::list<std::string> labels;
|
---|
415 | std::string *target; // target label for jump statements
|
---|
416 | DeclarationNode *decl;
|
---|
417 |
|
---|
418 | bool isCatchRest;
|
---|
419 | }; // StatementNode
|
---|
420 |
|
---|
421 | class CompoundStmtNode : public StatementNode {
|
---|
422 | public:
|
---|
423 | CompoundStmtNode();
|
---|
424 | CompoundStmtNode( const std::string * );
|
---|
425 | CompoundStmtNode( StatementNode * );
|
---|
426 | ~CompoundStmtNode();
|
---|
427 |
|
---|
428 | void add_statement( StatementNode * );
|
---|
429 |
|
---|
430 | void print( std::ostream &, int indent = 0 ) const;
|
---|
431 |
|
---|
432 | virtual Statement *build() const;
|
---|
433 | private:
|
---|
434 | StatementNode *first, *last;
|
---|
435 | };
|
---|
436 |
|
---|
437 | class NullStmtNode : public CompoundStmtNode {
|
---|
438 | public:
|
---|
439 | Statement *build() const;
|
---|
440 | void print( std::ostream &, int indent = 0) const;
|
---|
441 | };
|
---|
442 |
|
---|
443 | class InitializerNode : public ParseNode {
|
---|
444 | public:
|
---|
445 | InitializerNode( ExpressionNode *, bool aggrp = false, ExpressionNode *des = 0 );
|
---|
446 | InitializerNode( InitializerNode *, bool aggrp = false, ExpressionNode *des = 0 );
|
---|
447 | ~InitializerNode();
|
---|
448 |
|
---|
449 | ExpressionNode *get_expression() const { return expr; }
|
---|
450 |
|
---|
451 | InitializerNode *set_designators( ExpressionNode *des ) { designator = des; return this; }
|
---|
452 | ExpressionNode *get_designators() const { return designator; }
|
---|
453 |
|
---|
454 | InitializerNode *next_init() const { return kids; }
|
---|
455 |
|
---|
456 | void print( std::ostream &, int indent = 0 ) const;
|
---|
457 | void printOneLine( std::ostream & ) const;
|
---|
458 |
|
---|
459 | virtual Initializer *build() const;
|
---|
460 | private:
|
---|
461 | ExpressionNode *expr;
|
---|
462 | bool aggregate;
|
---|
463 | ExpressionNode *designator; // may be list
|
---|
464 | InitializerNode *kids;
|
---|
465 | };
|
---|
466 |
|
---|
467 |
|
---|
468 |
|
---|
469 | template< typename SynTreeType, typename NodeType >
|
---|
470 | void buildList( const NodeType *firstNode, std::list< SynTreeType *> &outputList ) {
|
---|
471 | SemanticError errors;
|
---|
472 | std::back_insert_iterator< std::list< SynTreeType *> > out( outputList );
|
---|
473 | const NodeType *cur = firstNode;
|
---|
474 |
|
---|
475 | while ( cur ) {
|
---|
476 | try {
|
---|
477 | SynTreeType *result = dynamic_cast< SynTreeType *>( cur->build() );
|
---|
478 | if ( result ) {
|
---|
479 | *out++ = result;
|
---|
480 | } else {
|
---|
481 | } // if
|
---|
482 | } catch( SemanticError &e ) {
|
---|
483 | errors.append( e );
|
---|
484 | } // try
|
---|
485 | cur = dynamic_cast< NodeType *>( cur->get_link() );
|
---|
486 | } // while
|
---|
487 | if ( ! errors.isEmpty() ) {
|
---|
488 | throw errors;
|
---|
489 | } // if
|
---|
490 | }
|
---|
491 |
|
---|
492 | // in DeclarationNode.cc
|
---|
493 | void buildList( const DeclarationNode *firstNode, std::list< Declaration * > &outputList );
|
---|
494 | void buildList( const DeclarationNode *firstNode, std::list< DeclarationWithType *> &outputList );
|
---|
495 | void buildTypeList( const DeclarationNode *firstNode, std::list< Type * > &outputList );
|
---|
496 |
|
---|
497 | // in ExpressionNode.cc
|
---|
498 | ExpressionNode *flattenCommas( ExpressionNode *list );
|
---|
499 | ExpressionNode *tupleContents( ExpressionNode *tuple );
|
---|
500 |
|
---|
501 | #endif // PARSENODE_H
|
---|
502 |
|
---|
503 | // Local Variables: //
|
---|
504 | // tab-width: 4 //
|
---|
505 | // mode: c++ //
|
---|
506 | // compile-command: "make install" //
|
---|
507 | // End: //
|
---|