Changeset 028e512 for src/Parser/DeclarationNode.h
- Timestamp:
- Apr 19, 2023, 11:58:01 AM (16 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 45e753c
- Parents:
- a5ea261
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.h
ra5ea261 r028e512 177 177 } 178 178 179 template<typename NodeType> 180 NodeType * strict_next( NodeType * node ) { 181 ParseNode * next = node->get_next(); 182 if ( nullptr == next ) return nullptr; 183 if ( NodeType * ret = dynamic_cast<NodeType *>( next ) ) return ret; 184 SemanticError( next->location, "internal error, non-homogeneous nodes founds in buildList processing." ); 185 } 186 179 187 // This generic buildList is here along side its overloads. 180 188 template<typename AstType, typename NodeType, … … 184 192 SemanticErrorException errors; 185 193 std::back_insert_iterator<Container<ast::ptr<AstType>, Args...>> out( output ); 186 NodeType * cur = firstNode; 187 188 while ( cur ) { 194 195 for ( NodeType * cur = firstNode ; cur ; cur = strict_next( cur ) ) { 189 196 try { 190 if ( auto result = dynamic_cast<AstType *>( maybeBuild( cur ) ) ) { 191 *out++ = result; 192 } else { 193 assertf(false, __PRETTY_FUNCTION__ ); 194 SemanticError( cur->location, "type specifier declaration in forall clause is currently unimplemented." ); 195 } // if 196 } catch( SemanticErrorException & e ) { 197 AstType * node = dynamic_cast<AstType *>( maybeBuild( cur ) ); 198 assertf( node, "buildList: Did not build node of correct type." ); 199 *out++ = node; 200 } catch ( SemanticErrorException & e ) { 197 201 errors.append( e ); 198 202 } // try 199 ParseNode * temp = cur->get_next(); 200 // Should not return nullptr, then it is non-homogeneous: 201 cur = dynamic_cast<NodeType *>( temp ); 202 if ( !cur && temp ) { 203 SemanticError( temp->location, "internal error, non-homogeneous nodes founds in buildList processing." ); 204 } // if 205 } // while 203 } // for 206 204 if ( ! errors.isEmpty() ) { 207 205 throw errors;
Note: See TracChangeset
for help on using the changeset viewer.