source: src/Parser/ParseNode.h@ d1ef1b0

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since d1ef1b0 was dae881f, checked in by Thierry Delisle <tdelisle@…>, 9 years ago

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

  • Property mode set to 100644
File size: 21.8 KB
Line 
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 : Peter A. Buhr
12// Last Modified On : Fri Aug 5 07:49:32 2016
13// Update Count : 288
14//
15
16#ifndef PARSENODE_H
17#define PARSENODE_H
18
19#include <string>
20#include <list>
21#include <iterator>
22#include <memory>
23
24#include "Common/utility.h"
25#include "Parser/LinkageSpec.h"
26#include "SynTree/Type.h"
27#include "SynTree/Expression.h"
28//#include "SynTree/Declaration.h"
29#include "Common/UniqueName.h"
30#include "SynTree/Label.h"
31
32class ExpressionNode;
33class CompositeExprNode;
34class CommaExprNode;
35class StatementNode;
36class CompoundStmtNode;
37class DeclarationNode;
38class InitializerNode;
39
40// Builder
41class ParseNode {
42 public:
43 ParseNode();
44 ParseNode( const std::string * );
45 ParseNode( const std::string & ); // for copy constructing subclasses
46 virtual ~ParseNode();
47
48 ParseNode *get_link() const { return next; }
49 ParseNode *get_last();
50 ParseNode *set_link( ParseNode * );
51 void set_next( ParseNode *newlink ) { next = newlink; }
52
53 virtual ParseNode *clone() const { return 0; };
54
55 const std::string &get_name() const { return name; }
56 void set_name( const std::string &newValue ) { name = newValue; }
57
58 virtual void print( std::ostream &, int indent = 0 ) const;
59 virtual void printList( std::ostream &, int indent = 0 ) const;
60
61 ParseNode &operator,( ParseNode &);
62 protected:
63 std::string name;
64 static int indent_by;
65 ParseNode *next;
66};
67
68ParseNode *mkList( ParseNode & );
69
70class ExpressionNode : public ParseNode {
71 public:
72 ExpressionNode();
73 ExpressionNode( const std::string * );
74 ExpressionNode( const ExpressionNode &other );
75 virtual ~ExpressionNode() { delete argName; } // cannot delete argName because it might be referenced elsewhere
76
77 virtual ExpressionNode *clone() const = 0;
78
79 // virtual CommaExprNode *add_to_list( ExpressionNode * );
80
81 ExpressionNode *get_argName() const { return argName; }
82 ExpressionNode *set_argName( const std::string *aName );
83 ExpressionNode *set_argName( ExpressionNode *aDesignator );
84 bool get_extension() const { return extension; }
85 ExpressionNode *set_extension( bool exten ) { extension = exten; return this; }
86
87 virtual void print( std::ostream &, int indent = 0) const = 0;
88 virtual void printOneLine( std::ostream &, int indent = 0) const = 0;
89
90 virtual Expression *build() const = 0;
91 protected:
92 void printDesignation ( std::ostream &, int indent = 0) const;
93 private:
94 ExpressionNode *argName = 0;
95 bool extension = false;
96};
97
98template< typename T >
99struct maybeBuild_t<Expression, T> {
100 static inline Expression * doit( const T *orig ) {
101 if ( orig ) {
102 Expression *p = orig->build();
103 p->set_extension( orig->get_extension() );
104 return p;
105 } else {
106 return 0;
107 } // if
108 }
109};
110
111// NullExprNode is used in tuples as a place-holder where a tuple component is omitted e.g., [ 2, , 3 ]
112class NullExprNode : public ExpressionNode {
113 public:
114 NullExprNode();
115
116 virtual NullExprNode *clone() const;
117
118 virtual void print( std::ostream &, int indent = 0) const;
119 virtual void printOneLine( std::ostream &, int indent = 0) const;
120
121 virtual Expression *build() const;
122};
123
124class ConstantNode : public ExpressionNode {
125 public:
126 enum Type { Integer, Float, Character, String };
127
128 ConstantNode( ConstantExpr * );
129 ConstantNode( const ConstantNode &other ) : expr( other.expr->clone() ) {};
130 ~ConstantNode() { delete expr; }
131
132 virtual ConstantNode *clone() const { return new ConstantNode( *this ); }
133 virtual void print( std::ostream &, int indent = 0) const;
134 virtual void printOneLine( std::ostream &, int indent = 0) const;
135
136 ConstantNode *appendstr( const std::string *newValue );
137
138 Expression *build() const;
139 private:
140 ConstantExpr *expr;
141};
142
143ConstantNode *makeConstantInteger( std::string & );
144ConstantNode *makeConstantFloat( std::string & );
145ConstantNode *makeConstantChar( std::string & );
146ConstantNode *makeConstantStr( std::string & );
147
148class VarRefNode : public ExpressionNode {
149 public:
150 VarRefNode();
151 VarRefNode( const std::string *, bool isLabel = false );
152 VarRefNode( const VarRefNode &other );
153
154 virtual Expression *build() const ;
155
156 virtual VarRefNode *clone() const { return new VarRefNode( *this ); }
157
158 virtual void print( std::ostream &, int indent = 0 ) const;
159 virtual void printOneLine( std::ostream &, int indent = 0 ) const;
160 private:
161 bool isLabel;
162};
163
164class DesignatorNode : public ExpressionNode {
165 public:
166 DesignatorNode( ExpressionNode *expr, bool isArrayIndex = false );
167 DesignatorNode( const DesignatorNode &other );
168
169 virtual Expression *build() const ;
170 virtual DesignatorNode *clone() const { return new DesignatorNode( *this ); }
171
172 virtual void print( std::ostream &, int indent = 0 ) const;
173 virtual void printOneLine( std::ostream &, int indent = 0 ) const;
174 private:
175 bool isArrayIndex;
176};
177
178class TypeValueNode : public ExpressionNode {
179 public:
180 TypeValueNode( DeclarationNode * );
181 TypeValueNode( const TypeValueNode &other );
182
183 DeclarationNode *get_decl() const { return decl; }
184
185 virtual Expression *build() const ;
186
187 virtual TypeValueNode *clone() const { return new TypeValueNode( *this ); }
188
189 virtual void print( std::ostream &, int indent = 0) const;
190 virtual void printOneLine( std::ostream &, int indent = 0) const;
191 private:
192 DeclarationNode *decl;
193};
194
195class OperatorNode : public ExpressionNode {
196 public:
197 enum Type { TupleC, Comma, TupleFieldSel, // n-adic
198 // triadic
199 Cond, NCond,
200 // diadic
201 SizeOf, AlignOf, OffsetOf, Attr, Plus, Minus, Mul, Div, Mod, Or, And,
202 BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq,
203 Assign, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,
204 Index, FieldSel, PFieldSel, Range,
205 // monadic
206 UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost, LabelAddress,
207 Ctor, Dtor,
208 };
209
210 OperatorNode( Type t );
211 OperatorNode( const OperatorNode &other );
212 virtual ~OperatorNode();
213
214 virtual OperatorNode *clone() const { return new OperatorNode( *this ); }
215
216 Type get_type() const;
217 const char *get_typename() const;
218
219 virtual void print( std::ostream &, int indent = 0) const;
220 virtual void printOneLine( std::ostream &, int indent = 0) const;
221
222 virtual Expression *build() const { return 0; }
223 private:
224 Type type;
225};
226
227Expression *build_cast( TypeValueNode * arg, ExpressionNode *expr_node );
228Expression *build_fieldSel( ExpressionNode *expr_node, VarRefNode *member );
229Expression *build_pfieldSel( ExpressionNode *expr_node, VarRefNode *member );
230Expression *build_addressOf( ExpressionNode *expr_node );
231Expression *build_sizeOf( ExpressionNode *expr_node );
232Expression *build_alignOf( ExpressionNode *expr_node );
233Expression *build_offsetOf( TypeValueNode * arg, VarRefNode *member );
234Expression *build_and( ExpressionNode *expr_node1, ExpressionNode *expr_node2 );
235Expression *build_and_or( ExpressionNode *expr_node1, ExpressionNode *expr_node2, bool kind );
236Expression *build_opr1( OperatorNode::Type op, ExpressionNode *expr_node );
237Expression *build_opr2( OperatorNode::Type op, ExpressionNode *expr_node1, ExpressionNode *expr_node2 );
238Expression *build_cond( ExpressionNode *expr_node1, ExpressionNode *expr_node2, ExpressionNode *expr_node3 );
239Expression *build_comma( ExpressionNode *expr_node1, ExpressionNode *expr_node2 );
240
241class CompositeExprNode2 : public ExpressionNode {
242 public:
243 CompositeExprNode2( Expression *expr );
244 CompositeExprNode2( const CompositeExprNode2 &other );
245 virtual ~CompositeExprNode2();
246
247 virtual CompositeExprNode2 *clone() const { return new CompositeExprNode2( *this ); }
248 virtual Expression *build() const { return expr->clone(); }
249
250 virtual void print( std::ostream &, int indent = 0) const;
251 virtual void printOneLine( std::ostream &, int indent = 0) const;
252 private:
253 Expression *expr;
254};
255
256class CompositeExprNode : public ExpressionNode {
257 public:
258 CompositeExprNode();
259 CompositeExprNode( const std::string * );
260 CompositeExprNode( ExpressionNode *f, ExpressionNode *args = 0 );
261 CompositeExprNode( ExpressionNode *f, ExpressionNode *arg1, ExpressionNode *arg2 );
262 CompositeExprNode( const CompositeExprNode &other );
263 virtual ~CompositeExprNode();
264
265 virtual CompositeExprNode *clone() const { return new CompositeExprNode( *this ); }
266 virtual Expression *build() const;
267
268 virtual void print( std::ostream &, int indent = 0) const;
269 virtual void printOneLine( std::ostream &, int indent = 0) const;
270
271 void set_function( ExpressionNode * );
272 void set_args( ExpressionNode * );
273
274 void add_arg( ExpressionNode * );
275
276 ExpressionNode *get_function() const;
277 ExpressionNode *get_args() const;
278 private:
279 ExpressionNode *function;
280 ExpressionNode *arguments;
281};
282
283class AsmExprNode : public ExpressionNode {
284 public:
285 AsmExprNode();
286 AsmExprNode( ExpressionNode *inout, ConstantNode *constraint, ExpressionNode *operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}
287 virtual ~AsmExprNode() { delete inout; delete constraint; delete operand; }
288
289 virtual AsmExprNode *clone() const { return new AsmExprNode( *this ); }
290 virtual Expression *build() const;
291
292 virtual void print( std::ostream &, int indent = 0) const;
293 virtual void printOneLine( std::ostream &, int indent = 0) const;
294
295 ExpressionNode *get_inout() const { return inout; };
296 void set_inout( ExpressionNode *newValue ) { inout = newValue; }
297
298 ConstantNode *get_constraint() const { return constraint; };
299 void set_constraint( ConstantNode *newValue ) { constraint = newValue; }
300
301 ExpressionNode *get_operand() const { return operand; };
302 void set_operand( ExpressionNode *newValue ) { operand = newValue; }
303 private:
304 ExpressionNode *inout;
305 ConstantNode *constraint;
306 ExpressionNode *operand;
307};
308
309class LabelNode : public ExpressionNode {
310 public:
311 virtual Expression *build() const { return NULL; }
312 virtual LabelNode *clone() const { return new LabelNode( *this ); }
313
314 virtual void print( std::ostream &, int indent = 0) const;
315 virtual void printOneLine( std::ostream &, int indent = 0) const;
316
317 const std::list< Label > &get_labels() const { return labels; };
318 void append_label( std::string *label ) { labels.push_back( *label ); delete label; }
319 private:
320 std::list< Label > labels;
321};
322
323class ForCtlExprNode : public ExpressionNode {
324 public:
325 ForCtlExprNode( ParseNode *, ExpressionNode *, ExpressionNode * ) throw ( SemanticError );
326 ForCtlExprNode( const ForCtlExprNode &other );
327 ~ForCtlExprNode();
328
329 StatementNode *get_init() const { return init; }
330 ExpressionNode *get_condition() const { return condition; }
331 ExpressionNode *get_change() const { return change; }
332
333 virtual ForCtlExprNode *clone() const { return new ForCtlExprNode( *this ); }
334 virtual Expression *build() const;
335
336 virtual void print( std::ostream &, int indent = 0 ) const;
337 virtual void printOneLine( std::ostream &, int indent = 0 ) const;
338 private:
339 StatementNode *init;
340 ExpressionNode *condition;
341 ExpressionNode *change;
342};
343
344class ValofExprNode : public ExpressionNode {
345 public:
346 ValofExprNode();
347 ValofExprNode( StatementNode *s = 0 );
348 ValofExprNode( const ValofExprNode &other );
349 ~ValofExprNode();
350
351 virtual ValofExprNode *clone() const { return new ValofExprNode( *this ); }
352
353 StatementNode *get_body() const { return body; }
354 void print( std::ostream &, int indent = 0 ) const;
355 void printOneLine( std::ostream &, int indent = 0 ) const;
356 Expression *build() const;
357
358 private:
359 StatementNode *body;
360};
361
362class TypeData;
363
364class DeclarationNode : public ParseNode {
365 public:
366 enum Qualifier { Const, Restrict, Volatile, Lvalue, Atomic };
367 enum StorageClass { Extern, Static, Auto, Register, Inline, Fortran, Noreturn, Threadlocal, NoStorageClass, };
368 enum BasicType { Char, Int, Float, Double, Void, Bool, Complex, Imaginary };
369 enum Modifier { Signed, Unsigned, Short, Long };
370 enum Aggregate { Struct, Union, Trait };
371 enum TypeClass { Type, Dtype, Ftype };
372 enum BuiltinType { Valist };
373
374 static const char *storageName[];
375 static const char *qualifierName[];
376 static const char *basicTypeName[];
377 static const char *modifierName[];
378 static const char *aggregateName[];
379 static const char *typeClassName[];
380 static const char *builtinTypeName[];
381
382 static DeclarationNode *newFunction( std::string *name, DeclarationNode *ret, DeclarationNode *param, StatementNode *body, bool newStyle = false );
383 static DeclarationNode *newQualifier( Qualifier );
384 static DeclarationNode *newStorageClass( StorageClass );
385 static DeclarationNode *newBasicType( BasicType );
386 static DeclarationNode *newModifier( Modifier );
387 static DeclarationNode *newForall( DeclarationNode *);
388 static DeclarationNode *newFromTypedef( std::string *);
389 static DeclarationNode *newAggregate( Aggregate kind, const std::string *name, ExpressionNode *actuals, DeclarationNode *fields, bool body );
390 static DeclarationNode *newEnum( std::string *name, DeclarationNode *constants );
391 static DeclarationNode *newEnumConstant( std::string *name, ExpressionNode *constant );
392 static DeclarationNode *newName( std::string *);
393 static DeclarationNode *newFromTypeGen( std::string *, ExpressionNode *params );
394 static DeclarationNode *newTypeParam( TypeClass, std::string *);
395 static DeclarationNode *newTrait( std::string *name, DeclarationNode *params, DeclarationNode *asserts );
396 static DeclarationNode *newTraitUse( std::string *name, ExpressionNode *params );
397 static DeclarationNode *newTypeDecl( std::string *name, DeclarationNode *typeParams );
398 static DeclarationNode *newPointer( DeclarationNode *qualifiers );
399 static DeclarationNode *newArray( ExpressionNode *size, DeclarationNode *qualifiers, bool isStatic );
400 static DeclarationNode *newVarArray( DeclarationNode *qualifiers );
401 static DeclarationNode *newBitfield( ExpressionNode *size );
402 static DeclarationNode *newTuple( DeclarationNode *members );
403 static DeclarationNode *newTypeof( ExpressionNode *expr );
404 static DeclarationNode *newAttr( std::string *, ExpressionNode *expr );
405 static DeclarationNode *newAttr( std::string *, DeclarationNode *type );
406 static DeclarationNode *newBuiltinType( BuiltinType );
407
408 DeclarationNode *addQualifiers( DeclarationNode *);
409 DeclarationNode *copyStorageClasses( DeclarationNode *);
410 DeclarationNode *addType( DeclarationNode *);
411 DeclarationNode *addTypedef();
412 DeclarationNode *addAssertions( DeclarationNode *);
413 DeclarationNode *addName( std::string *);
414 DeclarationNode *addBitfield( ExpressionNode *size );
415 DeclarationNode *addVarArgs();
416 DeclarationNode *addFunctionBody( StatementNode *body );
417 DeclarationNode *addOldDeclList( DeclarationNode *list );
418 DeclarationNode *addPointer( DeclarationNode *qualifiers );
419 DeclarationNode *addArray( DeclarationNode *array );
420 DeclarationNode *addNewPointer( DeclarationNode *pointer );
421 DeclarationNode *addNewArray( DeclarationNode *array );
422 DeclarationNode *addParamList( DeclarationNode *list );
423 DeclarationNode *addIdList( DeclarationNode *list ); // old-style functions
424 DeclarationNode *addInitializer( InitializerNode *init );
425
426 DeclarationNode *cloneType( std::string *newName );
427 DeclarationNode *cloneType( DeclarationNode *existing );
428 DeclarationNode *cloneType( int ) { return cloneType( ( std::string *)0 ); }
429 DeclarationNode *cloneBaseType( std::string *newName );
430 DeclarationNode *cloneBaseType( DeclarationNode *newdecl );
431
432 DeclarationNode *appendList( DeclarationNode * );
433
434 DeclarationNode *clone() const;
435 void print( std::ostream &, int indent = 0 ) const;
436 void printList( std::ostream &, int indent = 0 ) const;
437
438 Declaration *build() const;
439 ::Type *buildType() const;
440
441 bool get_hasEllipsis() const;
442 const std::string &get_name() const { return name; }
443 LinkageSpec::Type get_linkage() const { return linkage; }
444 DeclarationNode *extractAggregate() const;
445 ExpressionNode *get_enumeratorValue() const { return enumeratorValue; }
446
447 bool get_extension() const { return extension; }
448 DeclarationNode *set_extension( bool exten ) { extension = exten; return this; }
449
450 DeclarationNode();
451 ~DeclarationNode();
452 private:
453 StorageClass buildStorageClass() const;
454 bool buildFuncSpecifier( StorageClass key ) const;
455
456 TypeData *type;
457 std::string name;
458 std::list< StorageClass > storageClasses;
459 std::list< std::string > attributes;
460 ExpressionNode *bitfieldWidth;
461 ExpressionNode *enumeratorValue;
462 InitializerNode *initializer;
463 bool hasEllipsis;
464 LinkageSpec::Type linkage;
465 bool extension = false;
466
467 static UniqueName anonymous;
468}; // DeclarationNode
469
470class StatementNode : public ParseNode {
471 public:
472 enum Type { Exp, If, Switch, Case, Default, Choose, Fallthru,
473 While, Do, For,
474 Goto, Continue, Break, Return, Throw,
475 Try, Catch, Finally, Asm,
476 Decl
477 };
478
479 StatementNode();
480 StatementNode( const std::string *name );
481 StatementNode( Type t, ExpressionNode *control = 0, StatementNode *block = 0 );
482 StatementNode( Type t, std::string *target );
483 StatementNode( DeclarationNode *decl );
484
485 ~StatementNode();
486
487 static StatementNode *newCatchStmt( DeclarationNode *d = 0, StatementNode *s = 0, bool catchRestP = false );
488
489 StatementNode *set_block( StatementNode *b ) { block = b; return this; }
490 StatementNode *get_block() const { return block; }
491
492 void set_control( ExpressionNode *c ) { control = c; }
493 ExpressionNode *get_control() const { return control; }
494
495 StatementNode::Type get_type() const { return type; }
496
497 StatementNode *add_label( const std::string * );
498 const std::list<std::string> &get_labels() const { return labels; }
499
500 void addDeclaration( DeclarationNode *newDecl ) { decl = newDecl; }
501 void setCatchRest( bool newVal ) { isCatchRest = newVal; }
502
503 std::string get_target() const;
504
505 // StatementNode *add_controlexp( ExpressionNode * );
506 StatementNode *append_block( StatementNode * );
507 StatementNode *append_last_case( StatementNode * );
508
509 void print( std::ostream &, int indent = 0) const;
510 virtual StatementNode *clone() const;
511 virtual Statement *build() const;
512 private:
513 static const char *StType[];
514 Type type;
515 ExpressionNode *control;
516 StatementNode *block;
517 std::list<std::string> labels;
518 std::string *target; // target label for jump statements
519 DeclarationNode *decl;
520 bool isCatchRest;
521}; // StatementNode
522
523class CompoundStmtNode : public StatementNode {
524 public:
525 CompoundStmtNode();
526 CompoundStmtNode( const std::string * );
527 CompoundStmtNode( StatementNode * );
528 ~CompoundStmtNode();
529
530 void add_statement( StatementNode * );
531
532 void print( std::ostream &, int indent = 0 ) const;
533 virtual Statement *build() const;
534 private:
535 StatementNode *first, *last;
536};
537
538class AsmStmtNode : public StatementNode {
539 public:
540 AsmStmtNode( Type, bool voltile, ConstantNode *instruction, ExpressionNode *output = 0, ExpressionNode *input = 0, ConstantNode *clobber = 0, LabelNode *gotolabels = 0 );
541 ~AsmStmtNode();
542
543 void print( std::ostream &, int indent = 0 ) const;
544 Statement *build() const;
545 private:
546 bool voltile;
547 ConstantNode *instruction;
548 ExpressionNode *output, *input;
549 ConstantNode *clobber;
550 std::list< Label > gotolabels;
551};
552
553class InitializerNode : public ParseNode {
554 public:
555 InitializerNode( ExpressionNode *, bool aggrp = false, ExpressionNode *des = 0 );
556 InitializerNode( InitializerNode *, bool aggrp = false, ExpressionNode *des = 0 );
557 ~InitializerNode();
558
559 ExpressionNode *get_expression() const { return expr; }
560
561 InitializerNode *set_designators( ExpressionNode *des ) { designator = des; return this; }
562 ExpressionNode *get_designators() const { return designator; }
563
564 InitializerNode *set_maybeConstructed( bool value ) { maybeConstructed = value; return this; }
565 bool get_maybeConstructed() const { return maybeConstructed; }
566
567 InitializerNode *next_init() const { return kids; }
568
569 void print( std::ostream &, int indent = 0 ) const;
570 void printOneLine( std::ostream & ) const;
571
572 virtual Initializer *build() const;
573 private:
574 ExpressionNode *expr;
575 bool aggregate;
576 ExpressionNode *designator; // may be list
577 InitializerNode *kids;
578 bool maybeConstructed;
579};
580
581class CompoundLiteralNode : public ExpressionNode {
582 public:
583 CompoundLiteralNode( DeclarationNode *type, InitializerNode *kids );
584 CompoundLiteralNode( const CompoundLiteralNode &type );
585 ~CompoundLiteralNode();
586
587 virtual CompoundLiteralNode *clone() const;
588
589 DeclarationNode *get_type() const { return type; }
590 CompoundLiteralNode *set_type( DeclarationNode *t ) { type = t; return this; }
591
592 InitializerNode *get_initializer() const { return kids; }
593 CompoundLiteralNode *set_initializer( InitializerNode *k ) { kids = k; return this; }
594
595 void print( std::ostream &, int indent = 0 ) const;
596 void printOneLine( std::ostream &, int indent = 0 ) const;
597
598 virtual Expression *build() const;
599 private:
600 DeclarationNode *type;
601 InitializerNode *kids;
602};
603
604template< typename SynTreeType, typename NodeType >
605void buildList( const NodeType *firstNode, std::list< SynTreeType *> &outputList ) {
606 SemanticError errors;
607 std::back_insert_iterator< std::list< SynTreeType *> > out( outputList );
608 const NodeType *cur = firstNode;
609
610 while ( cur ) {
611 try {
612// SynTreeType *result = dynamic_cast< SynTreeType *>( maybeBuild<typename std::result_of<decltype(&NodeType::build)(NodeType)>::type>( cur ) );
613 SynTreeType *result = dynamic_cast< SynTreeType *>( maybeBuild<typename std::pointer_traits<decltype(cur->build())>::element_type>( cur ) );
614 if ( result ) {
615 *out++ = result;
616 } else {
617 } // if
618 } catch( SemanticError &e ) {
619 errors.append( e );
620 } // try
621 cur = dynamic_cast< NodeType *>( cur->get_link() );
622 } // while
623 if ( ! errors.isEmpty() ) {
624 throw errors;
625 } // if
626}
627
628// in DeclarationNode.cc
629void buildList( const DeclarationNode *firstNode, std::list< Declaration * > &outputList );
630void buildList( const DeclarationNode *firstNode, std::list< DeclarationWithType *> &outputList );
631void buildTypeList( const DeclarationNode *firstNode, std::list< Type * > &outputList );
632
633// in ExpressionNode.cc
634ExpressionNode *flattenCommas( ExpressionNode *list );
635ExpressionNode *tupleContents( ExpressionNode *tuple );
636
637#endif // PARSENODE_H
638
639// Local Variables: //
640// tab-width: 4 //
641// mode: c++ //
642// compile-command: "make install" //
643// End: //
Note: See TracBrowser for help on using the repository browser.