Changeset a16764a6 for src/Parser
- Timestamp:
- Feb 28, 2018, 4:48:22 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 446ffa3
- Parents:
- 6a8df56
- Location:
- src/Parser
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r6a8df56 ra16764a6 576 576 dst->basictype = src->basictype; 577 577 } else if ( src->basictype != DeclarationNode::NoBasicType ) 578 throwSemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::basicTypeNames[ src->basictype ] + " in type: " );578 SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::basicTypeNames[ src->basictype ] + " in type: " ); 579 579 580 580 if ( dst->complextype == DeclarationNode::NoComplexType ) { 581 581 dst->complextype = src->complextype; 582 582 } else if ( src->complextype != DeclarationNode::NoComplexType ) 583 throwSemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::complexTypeNames[ src->complextype ] + " in type: " );583 SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::complexTypeNames[ src->complextype ] + " in type: " ); 584 584 585 585 if ( dst->signedness == DeclarationNode::NoSignedness ) { 586 586 dst->signedness = src->signedness; 587 587 } else if ( src->signedness != DeclarationNode::NoSignedness ) 588 throwSemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::signednessNames[ src->signedness ] + " in type: " );588 SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::signednessNames[ src->signedness ] + " in type: " ); 589 589 590 590 if ( dst->length == DeclarationNode::NoLength ) { … … 593 593 dst->length = DeclarationNode::LongLong; 594 594 } else if ( src->length != DeclarationNode::NoLength ) 595 throwSemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::lengthNames[ src->length ] + " in type: " );595 SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::lengthNames[ src->length ] + " in type: " ); 596 596 } // if 597 597 break; … … 940 940 941 941 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > &outputList ) { 942 SemanticError errors;942 SemanticErrorException errors; 943 943 std::back_insert_iterator< std::list< Declaration * > > out( outputList ); 944 944 … … 960 960 * out++ = decl; 961 961 } // if 962 } catch( SemanticError &e ) {962 } catch( SemanticErrorException &e ) { 963 963 errors.append( e ); 964 964 } // try … … 971 971 972 972 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > &outputList ) { 973 SemanticError errors;973 SemanticErrorException errors; 974 974 std::back_insert_iterator< std::list< DeclarationWithType * > > out( outputList ); 975 975 … … 994 994 } // if 995 995 } // if 996 } catch( SemanticError &e ) {996 } catch( SemanticErrorException &e ) { 997 997 errors.append( e ); 998 998 } // try … … 1005 1005 1006 1006 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > &outputList ) { 1007 SemanticError errors;1007 SemanticErrorException errors; 1008 1008 std::back_insert_iterator< std::list< Type * > > out( outputList ); 1009 1009 const DeclarationNode * cur = firstNode; … … 1012 1012 try { 1013 1013 * out++ = cur->buildType(); 1014 } catch( SemanticError &e ) {1014 } catch( SemanticErrorException &e ) { 1015 1015 errors.append( e ); 1016 1016 } // try … … 1024 1024 1025 1025 Declaration * DeclarationNode::build() const { 1026 if ( ! error.empty() ) throwSemanticError( this, error + " in declaration of " );1026 if ( ! error.empty() ) SemanticError( this, error + " in declaration of " ); 1027 1027 1028 1028 if ( asmStmt ) { … … 1047 1047 // inline _Noreturn int i; // disallowed 1048 1048 if ( type->kind != TypeData::Function && funcSpecs.any() ) { 1049 throwSemanticError( this, "invalid function specifier for " );1049 SemanticError( this, "invalid function specifier for " ); 1050 1050 } // if 1051 1051 return buildDecl( type, name ? *name : string( "" ), storageClasses, maybeBuild< Expression >( bitfieldWidth ), funcSpecs, linkage, asmName, maybeBuild< Initializer >(initializer), attributes )->set_extension( extension ); … … 1057 1057 // inlne _Noreturn enum E { ... }; // disallowed 1058 1058 if ( funcSpecs.any() ) { 1059 throwSemanticError( this, "invalid function specifier for " );1059 SemanticError( this, "invalid function specifier for " ); 1060 1060 } // if 1061 1061 assertf( name, "ObjectDecl must a have name\n" ); -
src/Parser/ExpressionNode.cc
r6a8df56 ra16764a6 356 356 357 357 Expression * build_field_name_FLOATING_FRACTIONconstant( const string & str ) { 358 if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) throwSemanticError( yylloc, "invalid tuple index " + str );358 if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) SemanticError( yylloc, "invalid tuple index " + str ); 359 359 Expression * ret = build_constantInteger( *new string( str.substr(1) ) ); 360 360 delete &str; … … 363 363 364 364 Expression * build_field_name_FLOATING_DECIMALconstant( const string & str ) { 365 if ( str[str.size()-1] != '.' ) throwSemanticError( yylloc, "invalid tuple index " + str );365 if ( str[str.size()-1] != '.' ) SemanticError( yylloc, "invalid tuple index " + str ); 366 366 Expression * ret = build_constantInteger( *new string( str.substr( 0, str.size()-1 ) ) ); 367 367 delete &str; -
src/Parser/LinkageSpec.cc
r6a8df56 ra16764a6 34 34 return BuiltinC; 35 35 } else { 36 throwSemanticError( location, "Invalid linkage specifier " + *spec );36 SemanticError( location, "Invalid linkage specifier " + *spec ); 37 37 } // if 38 38 } … … 48 48 return old_spec; 49 49 } else { 50 throwSemanticError( location, "Invalid linkage specifier " + *cmd );50 SemanticError( location, "Invalid linkage specifier " + *cmd ); 51 51 } // if 52 52 } -
src/Parser/ParseNode.h
r6a8df56 ra16764a6 419 419 template< typename SynTreeType, typename NodeType, template< typename, typename...> class Container, typename... Args > 420 420 void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > &outputList ) { 421 SemanticError errors;421 SemanticErrorException errors; 422 422 std::back_insert_iterator< Container< SynTreeType *, Args... > > out( outputList ); 423 423 const NodeType * cur = firstNode; … … 432 432 assertf(false, "buildList unknown type"); 433 433 } // if 434 } catch( SemanticError &e ) {434 } catch( SemanticErrorException &e ) { 435 435 errors.append( e ); 436 436 } // try -
src/Parser/TypeData.cc
r6a8df56 ra16764a6 519 519 520 520 static string genTSError( string msg, DeclarationNode::BasicType basictype ) { 521 throwSemanticError( yylloc, string( "invalid type specifier \"" ) + msg + "\" for type \"" + DeclarationNode::basicTypeNames[basictype] + "\"." );521 SemanticError( yylloc, string( "invalid type specifier \"" ) + msg + "\" for type \"" + DeclarationNode::basicTypeNames[basictype] + "\"." ); 522 522 } // genTSError 523 523 … … 919 919 // type set => parameter name already transformed by a declaration names so there is a duplicate 920 920 // declaration name attempting a second transformation 921 if ( param->type ) throwSemanticError( param->location, string( "duplicate declaration name " ) + *param->name );921 if ( param->type ) SemanticError( param->location, string( "duplicate declaration name " ) + *param->name ); 922 922 // declaration type reset => declaration already transformed by a parameter name so there is a duplicate 923 923 // parameter name attempting a second transformation 924 if ( ! decl->type ) throwSemanticError( param->location, string( "duplicate parameter name " ) + *param->name );924 if ( ! decl->type ) SemanticError( param->location, string( "duplicate parameter name " ) + *param->name ); 925 925 param->type = decl->type; // set copy declaration type to parameter type 926 926 decl->type = nullptr; // reset declaration type … … 929 929 } // for 930 930 // declaration type still set => type not moved to a matching parameter so there is a missing parameter name 931 if ( decl->type ) throwSemanticError( decl->location, string( "missing name in parameter list " ) + *decl->name );931 if ( decl->type ) SemanticError( decl->location, string( "missing name in parameter list " ) + *decl->name ); 932 932 } // for 933 933 -
src/Parser/lex.ll
r6a8df56 ra16764a6 453 453 void yyerror( const char * errmsg ) { 454 454 cout << (yyfilename ? yyfilename : "*unknown file*") << ':' << yylineno << ':' << column - yyleng + 1 455 << ": " << SemanticError::error_str() << errmsg << " at token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << '"' << endl;455 << ": " << ErrorHelpers::error_str() << errmsg << " at token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << '"' << endl; 456 456 } 457 457 -
src/Parser/parser.yy
r6a8df56 ra16764a6 482 482 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); } 483 483 | type_name '.' no_attr_identifier // CFA, nested type 484 { throwSemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME484 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME 485 485 | type_name '.' '[' push field_list pop ']' // CFA, nested type / tuple field selector 486 { throwSemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME486 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME 487 487 | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11 488 { throwSemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } // FIX ME488 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } // FIX ME 489 489 ; 490 490 … … 780 780 { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); } 781 781 | unary_expression '=' '{' initializer_list comma_opt '}' 782 { throwSemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME782 { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME 783 783 ; 784 784 … … 850 850 | exception_statement 851 851 | enable_disable_statement 852 { throwSemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME852 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME 853 853 | asm_statement 854 854 ; … … 1067 1067 { $$ = new StatementNode( build_return( $2 ) ); } 1068 1068 | RETURN '{' initializer_list comma_opt '}' 1069 { throwSemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME1069 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME 1070 1070 | THROW assignment_expression_opt ';' // handles rethrow 1071 1071 { $$ = new StatementNode( build_throw( $2 ) ); } … … 1086 1086 mutex_statement: 1087 1087 MUTEX '(' argument_expression_list ')' statement 1088 { throwSemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } // FIX ME1088 { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } // FIX ME 1089 1089 ; 1090 1090 … … 1316 1316 static_assert: 1317 1317 STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11 1318 { throwSemanticError( yylloc, "Static assert is currently unimplemented." ); $$ = nullptr; } // FIX ME1318 { SemanticError( yylloc, "Static assert is currently unimplemented." ); $$ = nullptr; } // FIX ME 1319 1319 1320 1320 // C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function
Note:
See TracChangeset
for help on using the changeset viewer.