source: src/Parser/ParseNode.h@ 6152c81

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox 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 6152c81 was a7c90d4, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

change StorageClass to bitset, support _Thread_local as separate storage-class

  • Property mode set to 100644
File size: 18.8 KB
RevLine 
[b87a5ed]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//
[974906e2]7// ParseNode.h --
[b87a5ed]8//
9// Author : Rodolfo G. Esteves
10// Created On : Sat May 16 13:28:16 2015
[e04ef3a]11// Last Modified By : Peter A. Buhr
[a7c90d4]12// Last Modified On : Tue Mar 7 08:10:53 2017
13// Update Count : 726
[b87a5ed]14//
15
[51b73452]16#ifndef PARSENODE_H
17#define PARSENODE_H
18
19#include <string>
20#include <list>
[dd020c0]21#include <bitset>
[51b73452]22#include <iterator>
[e04ef3a]23#include <memory>
[51b73452]24
[68cd1ce]25#include "Parser/LinkageSpec.h"
[59db689]26#include "SynTree/Type.h"
[e04ef3a]27#include "SynTree/Expression.h"
[2f22cc4]28#include "SynTree/Statement.h"
[0f8e4ac]29#include "SynTree/Label.h"
[7880579]30#include "Common/utility.h"
31#include "Common/UniqueName.h"
[51b73452]32
33class StatementNode;
34class CompoundStmtNode;
35class DeclarationNode;
[d1625f8]36class ExpressionNode;
[51b73452]37class InitializerNode;
[44a81853]38class Attribute;
[51b73452]39
[7880579]40//##############################################################################
41
[a7c90d4]42extern char * yyfilename;
[294647b]43extern int yylineno;
44
[51b73452]45class ParseNode {
[bdd516a]46 public:
[99cad3aa]47 ParseNode() {};
[2298f728]48 virtual ~ParseNode() { delete next; delete name; };
[b6424d9]49 virtual ParseNode * clone() const = 0;
[51b73452]50
[b6424d9]51 ParseNode * get_next() const { return next; }
52 ParseNode * set_next( ParseNode * newlink ) { next = newlink; return this; }
[1b772749]53
[b6424d9]54 ParseNode * get_last() {
55 ParseNode * current;
[2298f728]56 for ( current = this; current->get_next() != nullptr; current = current->get_next() );
[99cad3aa]57 return current;
58 }
[b6424d9]59 ParseNode * set_last( ParseNode * newlast ) {
[2298f728]60 if ( newlast != nullptr ) get_last()->set_next( newlast );
[99cad3aa]61 return this;
62 }
[51b73452]63
[7880579]64 virtual void print( std::ostream &os, int indent = 0 ) const {}
[0da3e2c]65 virtual void printList( std::ostream &os, int indent = 0 ) const {}
[1b772749]66
[b87a5ed]67 static int indent_by;
[7880579]68
[b6424d9]69 ParseNode * next = nullptr;
[2298f728]70 std::string * name = nullptr;
[294647b]71 CodeLocation location = { yyfilename, yylineno };
[7880579]72}; // ParseNode
[51b73452]73
[7bf7fb9]74//##############################################################################
75
[d1625f8]76class InitializerNode : public ParseNode {
77 public:
[2298f728]78 InitializerNode( ExpressionNode *, bool aggrp = false, ExpressionNode * des = nullptr );
79 InitializerNode( InitializerNode *, bool aggrp = false, ExpressionNode * des = nullptr );
[d1625f8]80 ~InitializerNode();
[a7741435]81 virtual InitializerNode * clone() const { assert( false ); return nullptr; }
[d1625f8]82
[b6424d9]83 ExpressionNode * get_expression() const { return expr; }
[d1625f8]84
[b6424d9]85 InitializerNode * set_designators( ExpressionNode * des ) { designator = des; return this; }
86 ExpressionNode * get_designators() const { return designator; }
[d1625f8]87
[b6424d9]88 InitializerNode * set_maybeConstructed( bool value ) { maybeConstructed = value; return this; }
[d1625f8]89 bool get_maybeConstructed() const { return maybeConstructed; }
90
[b6424d9]91 InitializerNode * next_init() const { return kids; }
[d1625f8]92
93 void print( std::ostream &os, int indent = 0 ) const;
94 void printOneLine( std::ostream & ) const;
95
[b6424d9]96 virtual Initializer * build() const;
[d1625f8]97 private:
[b6424d9]98 ExpressionNode * expr;
[d1625f8]99 bool aggregate;
[b6424d9]100 ExpressionNode * designator; // may be list
101 InitializerNode * kids;
[d1625f8]102 bool maybeConstructed;
[c1c1112]103}; // InitializerNode
[d1625f8]104
105//##############################################################################
106
[ac71a86]107class ExpressionNode final : public ParseNode {
[bdd516a]108 public:
[d1625f8]109 ExpressionNode( Expression * expr = nullptr ) : expr( expr ) {}
[b87a5ed]110 ExpressionNode( const ExpressionNode &other );
[d1625f8]111 virtual ~ExpressionNode() {}
[6a0d4d61]112 virtual ExpressionNode * clone() const override { return expr ? new ExpressionNode( expr->clone() ) : nullptr; }
[51b73452]113
[e04ef3a]114 bool get_extension() const { return extension; }
[b6424d9]115 ExpressionNode * set_extension( bool exten ) { extension = exten; return this; }
[51b73452]116
[62e5546]117 virtual void print( std::ostream &os, int indent = 0 ) const override {}
[ac71a86]118 void printOneLine( std::ostream &os, int indent = 0 ) const {}
119
120 template<typename T>
121 bool isExpressionType() const {
122 return nullptr != dynamic_cast<T>(expr.get());
123 }
[51b73452]124
[a7c90d4]125 Expression * build() const { return const_cast<ExpressionNode *>(this)->expr.release(); }
[bdd516a]126 private:
[e04ef3a]127 bool extension = false;
[ac71a86]128 std::unique_ptr<Expression> expr;
[c1c1112]129}; // ExpressionNode
[e04ef3a]130
131template< typename T >
[7880579]132struct maybeBuild_t< Expression, T > {
[b6424d9]133 static inline Expression * doit( const T * orig ) {
[e04ef3a]134 if ( orig ) {
[b6424d9]135 Expression * p = orig->build();
[e04ef3a]136 p->set_extension( orig->get_extension() );
137 return p;
138 } else {
[7880579]139 return nullptr;
[e04ef3a]140 } // if
141 }
[51b73452]142};
143
[d9e2280]144enum class OperKinds {
145 // diadic
[7bf7fb9]146 SizeOf, AlignOf, OffsetOf, Plus, Minus, Mul, Div, Mod, Or, And,
[d9e2280]147 BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq,
[a839867]148 Assign, AtAssn, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,
[d9e2280]149 Index, Range,
150 // monadic
151 UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost, LabelAddress,
152 Ctor, Dtor,
[c1c1112]153}; // OperKinds
[51b73452]154
[e82aa9df]155struct LabelNode {
156 std::list< Label > labels;
157};
158
[b6424d9]159Expression * build_constantInteger( const std::string &str );
160Expression * build_constantFloat( const std::string &str );
161Expression * build_constantChar( const std::string &str );
[4cb935e]162Expression * build_constantZeroOne( const std::string &str );
[b6424d9]163ConstantExpr * build_constantStr( const std::string &str );
[8780e30]164Expression * build_field_name_FLOATINGconstant( const std::string & str );
165Expression * build_field_name_fraction_constants( Expression * fieldName, ExpressionNode * fracts );
166Expression * build_field_name_REALFRACTIONconstant( const std::string & str );
167Expression * build_field_name_REALDECIMALconstant( const std::string & str );
[b6424d9]168
169NameExpr * build_varref( const std::string * name, bool labelp = false );
170Expression * build_typevalue( DeclarationNode * decl );
171
172Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
[fd782b2]173Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member );
174Expression * build_pfieldSel( ExpressionNode * expr_node, Expression * member );
[b6424d9]175Expression * build_addressOf( ExpressionNode * expr_node );
176Expression * build_sizeOfexpr( ExpressionNode * expr_node );
177Expression * build_sizeOftype( DeclarationNode * decl_node );
178Expression * build_alignOfexpr( ExpressionNode * expr_node );
179Expression * build_alignOftype( DeclarationNode * decl_node );
180Expression * build_offsetOf( DeclarationNode * decl_node, NameExpr * member );
181Expression * build_and( ExpressionNode * expr_node1, ExpressionNode * expr_node2 );
182Expression * build_and_or( ExpressionNode * expr_node1, ExpressionNode * expr_node2, bool kind );
183Expression * build_unary_val( OperKinds op, ExpressionNode * expr_node );
184Expression * build_unary_ptr( OperKinds op, ExpressionNode * expr_node );
185Expression * build_binary_val( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 );
186Expression * build_binary_ptr( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 );
187Expression * build_cond( ExpressionNode * expr_node1, ExpressionNode * expr_node2, ExpressionNode * expr_node3 );
188Expression * build_comma( ExpressionNode * expr_node1, ExpressionNode * expr_node2 );
189Expression * build_attrexpr( NameExpr * var, ExpressionNode * expr_node );
190Expression * build_attrtype( NameExpr * var, DeclarationNode * decl_node );
[2298f728]191Expression * build_tuple( ExpressionNode * expr_node = nullptr );
[b6424d9]192Expression * build_func( ExpressionNode * function, ExpressionNode * expr_node );
193Expression * build_range( ExpressionNode * low, ExpressionNode * high );
194Expression * build_asmexpr( ExpressionNode * inout, ConstantExpr * constraint, ExpressionNode * operand );
195Expression * build_valexpr( StatementNode * s );
196Expression * build_compoundLiteral( DeclarationNode * decl_node, InitializerNode * kids );
[51b73452]197
[7bf7fb9]198//##############################################################################
199
[62e5546]200struct TypeData;
[51b73452]201
[bdd516a]202class DeclarationNode : public ParseNode {
203 public:
[5b639ee]204 // These must remain in the same order as the corresponding DeclarationNode names.
[c0aa336]205
[a7c90d4]206 enum StorageClass { Extern, Static, Auto, Register, Threadlocal, NoStorageClass,
207 ExternClass = 1 << Extern, StaticClass = 1 << Static, AutoClass = 1 << Auto, RegisterClass = 1 << Register, ThreadlocalClass = 1 << Threadlocal };
[dd020c0]208 enum FuncSpecifier { Inline, Noreturn, Fortran, NoFuncSpecifier,
[a7c90d4]209 InlineSpec = 1 << Inline, NoreturnSpec = 1 << Noreturn, FortranSpec = 1 << Fortran };
210 enum TypeQualifier { Const, Restrict, Volatile, Lvalue, Mutex, Atomic, NoTypeQualifier };
[5b639ee]211 enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType };
212 enum ComplexType { Complex, Imaginary, NoComplexType };
213 enum Signedness { Signed, Unsigned, NoSignedness };
214 enum Length { Short, Long, LongLong, NoLength };
[faddbd8]215 enum Aggregate { Struct, Union, Trait, NoAggregate };
[8f60f0b]216 enum TypeClass { Otype, Dtype, Ftype, Ttype, NoTypeClass };
[148f7290]217 enum BuiltinType { Valist, Zero, One, NoBuiltinType };
[b87a5ed]218
[dd020c0]219 static const char * storageClassNames[];
220 static const char * funcSpecifierNames[];
221 static const char * typeQualifierNames[];
222 static const char * basicTypeNames[];
223 static const char * complexTypeNames[];
224 static const char * signednessNames[];
225 static const char * lengthNames[];
226 static const char * aggregateNames[];
227 static const char * typeClassNames[];
228 static const char * builtinTypeNames[];
[b6424d9]229
230 static DeclarationNode * newStorageClass( StorageClass );
[dd020c0]231 static DeclarationNode * newFuncSpecifier( FuncSpecifier );
232 static DeclarationNode * newTypeQualifier( TypeQualifier );
[b6424d9]233 static DeclarationNode * newBasicType( BasicType );
[5b639ee]234 static DeclarationNode * newComplexType( ComplexType );
[dd020c0]235 static DeclarationNode * newSignedNess( Signedness );
236 static DeclarationNode * newLength( Length );
[b6424d9]237 static DeclarationNode * newBuiltinType( BuiltinType );
[dd020c0]238 static DeclarationNode * newForall( DeclarationNode * );
[2298f728]239 static DeclarationNode * newFromTypedef( std::string * );
[dd020c0]240 static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle = false );
[b6424d9]241 static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );
[ca1a547]242 static DeclarationNode * newEnum( std::string * name, DeclarationNode * constants, bool body );
[b6424d9]243 static DeclarationNode * newEnumConstant( std::string * name, ExpressionNode * constant );
[2298f728]244 static DeclarationNode * newName( std::string * );
[b6424d9]245 static DeclarationNode * newFromTypeGen( std::string *, ExpressionNode * params );
[2298f728]246 static DeclarationNode * newTypeParam( TypeClass, std::string * );
247 static DeclarationNode * newTrait( const std::string * name, DeclarationNode * params, DeclarationNode * asserts );
248 static DeclarationNode * newTraitUse( const std::string * name, ExpressionNode * params );
[b6424d9]249 static DeclarationNode * newTypeDecl( std::string * name, DeclarationNode * typeParams );
250 static DeclarationNode * newPointer( DeclarationNode * qualifiers );
251 static DeclarationNode * newArray( ExpressionNode * size, DeclarationNode * qualifiers, bool isStatic );
252 static DeclarationNode * newVarArray( DeclarationNode * qualifiers );
253 static DeclarationNode * newBitfield( ExpressionNode * size );
254 static DeclarationNode * newTuple( DeclarationNode * members );
255 static DeclarationNode * newTypeof( ExpressionNode * expr );
[44a81853]256 static DeclarationNode * newAttr( std::string *, ExpressionNode * expr ); // @ attributes
257 static DeclarationNode * newAttr( std::string *, DeclarationNode * type ); // @ attributes
258 static DeclarationNode * newAttribute( std::string *, ExpressionNode * expr = nullptr ); // gcc attributes
[e994912]259 static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement
[b87a5ed]260
[7880579]261 DeclarationNode();
262 ~DeclarationNode();
[6a0d4d61]263 DeclarationNode * clone() const override;
[7880579]264
[2298f728]265 DeclarationNode * addQualifiers( DeclarationNode * );
[413ad05]266 void checkQualifiers( const TypeData *, const TypeData * );
[a7c90d4]267 void checkSpecifiers( DeclarationNode * );
268 DeclarationNode * copySpecifiers( DeclarationNode * );
[2298f728]269 DeclarationNode * addType( DeclarationNode * );
[b6424d9]270 DeclarationNode * addTypedef();
[2298f728]271 DeclarationNode * addAssertions( DeclarationNode * );
272 DeclarationNode * addName( std::string * );
[c0aa336]273 DeclarationNode * addAsmName( DeclarationNode * );
[b6424d9]274 DeclarationNode * addBitfield( ExpressionNode * size );
275 DeclarationNode * addVarArgs();
276 DeclarationNode * addFunctionBody( StatementNode * body );
277 DeclarationNode * addOldDeclList( DeclarationNode * list );
[c0aa336]278 DeclarationNode * setBase( TypeData * newType );
279 DeclarationNode * copyAttribute( DeclarationNode * attr );
[b6424d9]280 DeclarationNode * addPointer( DeclarationNode * qualifiers );
281 DeclarationNode * addArray( DeclarationNode * array );
282 DeclarationNode * addNewPointer( DeclarationNode * pointer );
283 DeclarationNode * addNewArray( DeclarationNode * array );
284 DeclarationNode * addParamList( DeclarationNode * list );
285 DeclarationNode * addIdList( DeclarationNode * list ); // old-style functions
286 DeclarationNode * addInitializer( InitializerNode * init );
287
288 DeclarationNode * cloneType( std::string * newName );
289 DeclarationNode * cloneBaseType( DeclarationNode * newdecl );
290
291 DeclarationNode * appendList( DeclarationNode * node ) {
[99cad3aa]292 return (DeclarationNode *)set_last( node );
293 }
[b87a5ed]294
[62e5546]295 virtual void print( std::ostream &os, int indent = 0 ) const override;
296 virtual void printList( std::ostream &os, int indent = 0 ) const override;
[b87a5ed]297
[b6424d9]298 Declaration * build() const;
[a7c90d4]299 Type * buildType() const;
[b87a5ed]300
301 bool get_hasEllipsis() const;
[8b7ee09]302 LinkageSpec::Spec get_linkage() const { return linkage; }
[b6424d9]303 DeclarationNode * extractAggregate() const;
[4f147cc]304 bool has_enumeratorValue() const { return (bool)enumeratorValue; }
[a7c90d4]305 ExpressionNode * consume_enumeratorValue() const { return const_cast<DeclarationNode *>(this)->enumeratorValue.release(); }
[b87a5ed]306
[7305915]307 bool get_extension() const { return extension; }
[b6424d9]308 DeclarationNode * set_extension( bool exten ) { extension = exten; return this; }
[c1c1112]309 public:
[28307be]310 struct Variable_t {
[faddbd8]311// const std::string * name;
[28307be]312 DeclarationNode::TypeClass tyClass;
313 DeclarationNode * assertions;
314 };
315 Variable_t variable;
316
317 struct Attr_t {
[faddbd8]318// const std::string * name;
[28307be]319 ExpressionNode * expr;
320 DeclarationNode * type;
321 };
322 Attr_t attr;
323
[8f6f47d7]324 BuiltinType builtin;
325
[b6424d9]326 TypeData * type;
[dd020c0]327
[a7c90d4]328 typedef std::bitset< DeclarationNode::NoStorageClass > StorageClasses;
329 StorageClasses storageClasses;
330 static void print_StorageClass( std::ostream & output, StorageClasses storageClasses );
331
332 typedef std::bitset< DeclarationNode::NoFuncSpecifier > FuncSpecifiers;
333 FuncSpecifiers funcSpecs;
334 static void print_FuncSpec( std::ostream & output, FuncSpecifiers funcSpecs );
[dd020c0]335
[b6424d9]336 ExpressionNode * bitfieldWidth;
[4f147cc]337 std::unique_ptr<ExpressionNode> enumeratorValue;
[b87a5ed]338 bool hasEllipsis;
[8b7ee09]339 LinkageSpec::Spec linkage;
[58dd019]340 ConstantExpr *asmName;
[44a81853]341 std::list< Attribute * > attributes;
[58dd019]342 InitializerNode * initializer;
[7305915]343 bool extension = false;
[13e3b50]344 std::string error;
[e994912]345 StatementNode * asmStmt;
[b87a5ed]346
347 static UniqueName anonymous;
[1db21619]348}; // DeclarationNode
[51b73452]349
[b6424d9]350Type * buildType( TypeData * type );
[d1625f8]351
[b6424d9]352static inline Type * maybeMoveBuildType( const DeclarationNode * orig ) {
[a7c90d4]353 Type * ret = orig ? orig->buildType() : nullptr;
[4f147cc]354 delete orig;
355 return ret;
356}
357
[7bf7fb9]358//##############################################################################
359
[ac71a86]360class StatementNode final : public ParseNode {
[bdd516a]361 public:
[e82aa9df]362 StatementNode() { stmt = nullptr; }
[b6424d9]363 StatementNode( Statement * stmt ) : stmt( stmt ) {}
364 StatementNode( DeclarationNode * decl );
[e82aa9df]365 virtual ~StatementNode() {}
[51b73452]366
[b6424d9]367 virtual StatementNode * clone() const final { assert( false ); return nullptr; }
[a7c90d4]368 Statement * build() const { return const_cast<StatementNode *>(this)->stmt.release(); }
[2f22cc4]369
[44a81853]370 virtual StatementNode * add_label( const std::string * name, DeclarationNode * attr = nullptr ) {
371 stmt->get_labels().emplace_back( * name, nullptr, attr ? std::move( attr->attributes ) : std::list< Attribute * > {} );
372 delete attr;
[ac71a86]373 delete name;
[2f22cc4]374 return this;
375 }
376
[b6424d9]377 virtual StatementNode * append_last_case( StatementNode * );
[1d4580a]378
[62e5546]379 virtual void print( std::ostream &os, int indent = 0 ) const override {}
380 virtual void printList( std::ostream &os, int indent = 0 ) const override {}
[2f22cc4]381 private:
[ac71a86]382 std::unique_ptr<Statement> stmt;
[2f22cc4]383}; // StatementNode
384
[b6424d9]385Statement * build_expr( ExpressionNode * ctl );
[1d4580a]386
[2f22cc4]387struct ForCtl {
[b6424d9]388 ForCtl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) :
[e82aa9df]389 init( new StatementNode( build_expr( expr ) ) ), condition( condition ), change( change ) {}
[b6424d9]390 ForCtl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) :
[e82aa9df]391 init( new StatementNode( decl ) ), condition( condition ), change( change ) {}
[2f22cc4]392
[b6424d9]393 StatementNode * init;
394 ExpressionNode * condition;
395 ExpressionNode * change;
[2f22cc4]396};
397
[b6424d9]398Statement * build_if( ExpressionNode * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
399Statement * build_switch( ExpressionNode * ctl, StatementNode * stmt );
400Statement * build_case( ExpressionNode * ctl );
401Statement * build_default();
402Statement * build_while( ExpressionNode * ctl, StatementNode * stmt, bool kind = false );
403Statement * build_for( ForCtl * forctl, StatementNode * stmt );
404Statement * build_branch( BranchStmt::Type kind );
405Statement * build_branch( std::string * identifier, BranchStmt::Type kind );
406Statement * build_computedgoto( ExpressionNode * ctl );
407Statement * build_return( ExpressionNode * ctl );
408Statement * build_throw( ExpressionNode * ctl );
409Statement * build_try( StatementNode * try_stmt, StatementNode * catch_stmt, StatementNode * finally_stmt );
410Statement * build_catch( DeclarationNode * decl, StatementNode * stmt, bool catchAny = false );
411Statement * build_finally( StatementNode * stmt );
412Statement * build_compound( StatementNode * first );
[2298f728]413Statement * build_asmstmt( bool voltile, ConstantExpr * instruction, ExpressionNode * output = nullptr, ExpressionNode * input = nullptr, ExpressionNode * clobber = nullptr, LabelNode * gotolabels = nullptr );
[7f5566b]414
[7bf7fb9]415//##############################################################################
416
[aefcc3b]417template< typename SynTreeType, typename NodeType, template< typename, typename...> class Container, typename... Args >
418void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > &outputList ) {
[b87a5ed]419 SemanticError errors;
[aefcc3b]420 std::back_insert_iterator< Container< SynTreeType *, Args... > > out( outputList );
[b6424d9]421 const NodeType * cur = firstNode;
[b87a5ed]422
423 while ( cur ) {
424 try {
[b6424d9]425 SynTreeType * result = dynamic_cast< SynTreeType * >( maybeBuild< typename std::pointer_traits< decltype(cur->build())>::element_type >( cur ) );
[b87a5ed]426 if ( result ) {
[294647b]427 result->location = cur->location;
[b6424d9]428 * out++ = result;
[b87a5ed]429 } // if
430 } catch( SemanticError &e ) {
[294647b]431 e.set_location( cur->location );
[b87a5ed]432 errors.append( e );
433 } // try
[7880579]434 cur = dynamic_cast< NodeType * >( cur->get_next() );
[b87a5ed]435 } // while
[a32b204]436 if ( ! errors.isEmpty() ) {
[b87a5ed]437 throw errors;
438 } // if
[51b73452]439}
440
441// in DeclarationNode.cc
[b6424d9]442void buildList( const DeclarationNode * firstNode, std::list< Declaration * > &outputList );
443void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > &outputList );
444void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > &outputList );
[51b73452]445
[7ecbb7e]446template< typename SynTreeType, typename NodeType >
[b6424d9]447void buildMoveList( const NodeType * firstNode, std::list< SynTreeType * > &outputList ) {
[3a5131ed]448 buildList( firstNode, outputList );
[7ecbb7e]449 delete firstNode;
450}
451
[c8dfcd3]452// in ParseNode.cc
453std::ostream & operator<<( std::ostream & out, const ParseNode * node );
[7ecbb7e]454
[bdd516a]455#endif // PARSENODE_H
[51b73452]456
457// Local Variables: //
[b87a5ed]458// tab-width: 4 //
459// mode: c++ //
460// compile-command: "make install" //
[51b73452]461// End: //
Note: See TracBrowser for help on using the repository browser.