Changeset 5546eee4 for src/Parser


Ignore:
Timestamp:
Dec 16, 2023, 1:01:44 AM (2 years ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
b7898ac
Parents:
0fa0201d (diff), 69ab896 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

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

Location:
src/Parser
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r0fa0201d r5546eee4  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jun 17 14:41:48 2023
    13 // Update Count     : 1405
     12// Last Modified On : Thu Dec 14 19:05:17 2023
     13// Update Count     : 1407
    1414//
    1515
     
    632632                                        dst->basictype = src->basictype;
    633633                                } else if ( src->basictype != DeclarationNode::NoBasicType )
    634                                         SemanticError( yylloc, string( "multiple declaration types \"" ) + DeclarationNode::basicTypeNames[ dst->basictype ] +
    635                                                                    "\" and \"" + DeclarationNode::basicTypeNames[ src->basictype ] + "\"." );
    636 
     634                                        SemanticError( yylloc, "multiple declaration types \"%s\" and \"%s\".",
     635                                                                   DeclarationNode::basicTypeNames[ dst->basictype ],
     636                                                                   DeclarationNode::basicTypeNames[ src->basictype ] );
    637637                                if ( dst->complextype == DeclarationNode::NoComplexType ) {
    638638                                        dst->complextype = src->complextype;
    639639                                } else if ( src->complextype != DeclarationNode::NoComplexType )
    640                                         SemanticError( yylloc, string( "multiple declaration types \"" ) + DeclarationNode::complexTypeNames[ src->complextype ] +
    641                                                                    "\" and \"" + DeclarationNode::complexTypeNames[ src->complextype ] + "\"." );
    642 
     640                                        SemanticError( yylloc, "multiple declaration types \"%s\" and \"%s\".",
     641                                                                   DeclarationNode::complexTypeNames[ src->complextype ],
     642                                                                   DeclarationNode::complexTypeNames[ src->complextype ] );
    643643                                if ( dst->signedness == DeclarationNode::NoSignedness ) {
    644644                                        dst->signedness = src->signedness;
    645645                                } else if ( src->signedness != DeclarationNode::NoSignedness )
    646                                         SemanticError( yylloc, string( "conflicting type specifier \"" ) + DeclarationNode::signednessNames[ dst->signedness ] +
    647                                                                    "\" and \"" + DeclarationNode::signednessNames[ src->signedness ] + "\"." );
    648 
     646                                        SemanticError( yylloc, "conflicting type specifier \"%s\" and \"%s\".",
     647                                                                   DeclarationNode::signednessNames[ dst->signedness ],
     648                                                                   DeclarationNode::signednessNames[ src->signedness ] );
    649649                                if ( dst->length == DeclarationNode::NoLength ) {
    650650                                        dst->length = src->length;
     
    652652                                        dst->length = DeclarationNode::LongLong;
    653653                                } else if ( src->length != DeclarationNode::NoLength )
    654                                         SemanticError( yylloc, string( "conflicting type specifier \"" ) + DeclarationNode::lengthNames[ dst->length ] +
    655                                                                    "\" and \"" + DeclarationNode::lengthNames[ src->length ] + "\"." );
     654                                        SemanticError( yylloc, "conflicting type specifier \"%s\" and \"%s\".",
     655                                                                   DeclarationNode::lengthNames[ dst->length ],
     656                                                                   DeclarationNode::lengthNames[ src->length ] );
    656657                        } // if
    657658                        break;
  • src/Parser/ExpressionNode.cc

    r0fa0201d r5546eee4  
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat May 16 13:17:07 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Apr  4 11:07:00 2023
    13 // Update Count     : 1083
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Dec 14 18:57:07 2023
     13// Update Count     : 1087
    1414//
    1515
     
    193193
    194194#if ! defined(__SIZEOF_INT128__)
    195         if ( type == 5 ) SemanticError( yylloc, "int128 constant is not supported on this target " + str );
     195        if ( type == 5 ) SemanticError( yylloc, "int128 constant is not supported on this target \"%s\"", str.c_str() );
    196196#endif // ! __SIZEOF_INT128__
    197197
     
    204204                        } else {                                                                        // hex int128 constant
    205205                                unsigned int len = str.length();
    206                                 if ( len > (2 + 16 + 16) ) SemanticError( yylloc, "128-bit hexadecimal constant to large " + str );
     206                                if ( len > (2 + 16 + 16) ) SemanticError( yylloc, "128-bit hexadecimal constant to large \"%s\"", str.c_str() );
    207207                                // hex digits < 2^64
    208208                                if ( len > (2 + 16) ) {
     
    219219                        unsigned int len = str.length();
    220220                        if ( type == 5 && len > 2 + 64 ) {
    221                                 if ( len > 2 + 64 + 64 ) SemanticError( yylloc, "128-bit binary constant to large " + str );
     221                                if ( len > 2 + 64 + 64 ) SemanticError( yylloc, "128-bit binary constant to large \"%s\".", str.c_str() );
    222222                                str2 = "0b" + str.substr( len - 64 );
    223223                                str = str.substr( 0, len - 64 );
     
    233233                        } else {                                                                        // octal int128 constant
    234234                                unsigned int len = str.length();
    235                                 if ( len > 1 + 43 || (len == 1 + 43 && str[0] > '3') ) SemanticError( yylloc, "128-bit octal constant to large " + str );
     235                                if ( len > 1 + 43 || (len == 1 + 43 && str[0] > '3') ) SemanticError( yylloc, "128-bit octal constant to large \"%s\"", str.c_str() );
    236236                                char buf[32];
    237237                                if ( len <= 1 + 21 ) {                                  // value < 21 octal digitis
     
    266266                        unsigned int len = str.length();
    267267                        if ( str.length() == 39 && str > (Unsigned ? "340282366920938463463374607431768211455" : "170141183460469231731687303715884105727") )
    268                                 SemanticError( yylloc, "128-bit decimal constant to large " + str );
     268                                SemanticError( yylloc, "128-bit decimal constant to large \"%s\".", str.c_str() );
    269269                        char buf[32];
    270270                        if ( len <= 19 ) {                                                      // value < 19 decimal digitis
     
    502502ast::Expr * build_field_name_FLOATING_FRACTIONconstant(
    503503                const CodeLocation & location, const string & str ) {
    504         if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) SemanticError( yylloc, "invalid tuple index " + str );
     504        if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) SemanticError( yylloc, "invalid tuple index \"%s\".", str.c_str() );
    505505        ast::Expr * ret = build_constantInteger( location,
    506506                *new string( str.substr(1) ) );
     
    511511ast::Expr * build_field_name_FLOATING_DECIMALconstant(
    512512                const CodeLocation & location, const string & str ) {
    513         if ( str[str.size() - 1] != '.' ) SemanticError( yylloc, "invalid tuple index " + str );
     513        if ( str[str.size() - 1] != '.' ) SemanticError( yylloc, "invalid tuple index \"%s\".", str.c_str() );
    514514        ast::Expr * ret = build_constantInteger(
    515515                location, *new string( str.substr( 0, str.size()-1 ) ) );
  • src/Parser/ParseNode.h

    r0fa0201d r5546eee4  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:28:16 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Apr  3 17:55:00 2023
    13 // Update Count     : 942
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Dec  9 17:39:34 2023
     13// Update Count     : 945
    1414//
    1515
     
    3737class ExpressionNode;
    3838struct StatementNode;
     39
    3940
    4041//##############################################################################
     
    9798std::ostream & operator<<( std::ostream & out, const ParseNode * node );
    9899
     100__attribute__((noreturn)) static inline void SemanticError( const ParseNode * obj, const std::string & error ) {
     101        SemanticError( obj->location, toString( error, obj ) );
     102}
     103
    99104// Local Variables: //
    100105// tab-width: 4 //
  • src/Parser/TypeData.cc

    r0fa0201d r5546eee4  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:12:51 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Apr  4 13:39:00 2023
    13 // Update Count     : 680
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Dec 14 18:59:12 2023
     13// Update Count     : 684
    1414//
    1515
     
    864864
    865865static string genTSError( string msg, DeclarationNode::BasicType basictype ) {
    866         SemanticError( yylloc, string( "invalid type specifier \"" ) + msg + "\" for type \"" + DeclarationNode::basicTypeNames[basictype] + "\"." );
     866        SemanticError( yylloc, "invalid type specifier \"%s\" for type \"%s\".", msg.c_str(), DeclarationNode::basicTypeNames[basictype] );
    867867} // genTSError
    868868
     
    14961496                                // type set => parameter name already transformed by a declaration names so there is a duplicate
    14971497                                // declaration name attempting a second transformation
    1498                                 if ( param->type ) SemanticError( param->location, string( "duplicate declaration name " ) + *param->name );
     1498                                if ( param->type ) SemanticError( param->location, "duplicate declaration name \"%s\".", param->name->c_str() );
    14991499                                // declaration type reset => declaration already transformed by a parameter name so there is a duplicate
    15001500                                // parameter name attempting a second transformation
    1501                                 if ( ! decl->type ) SemanticError( param->location, string( "duplicate parameter name " ) + *param->name );
     1501                                if ( ! decl->type ) SemanticError( param->location, "duplicate parameter name \"%s\".", param->name->c_str() );
    15021502                                param->type = decl->type;                               // set copy declaration type to parameter type
    15031503                                decl->type = nullptr;                                   // reset declaration type
     
    15071507                } // for
    15081508                // declaration type still set => type not moved to a matching parameter so there is a missing parameter name
    1509                 if ( decl->type ) SemanticError( decl->location, string( "missing name in parameter list " ) + *decl->name );
     1509                if ( decl->type ) SemanticError( decl->location, "missing name in parameter list %s", decl->name->c_str() );
    15101510        } // for
    15111511
  • src/Parser/parser.yy

    r0fa0201d r5546eee4  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Oct  3 17:14:12 2023
    13 // Update Count     : 6396
     12// Last Modified On : Sun Nov 26 13:18:06 2023
     13// Update Count     : 6398
    1414//
    1515
     
    260260                } // if
    261261        } else {
    262                 SemanticError( yylloc, "syntax error, loop-index name missing. Expression disallowed. ." ); return nullptr;
     262                SemanticError( yylloc, "syntax error, loop-index name missing. Expression disallowed." ); return nullptr;
    263263        } // if
    264264} // forCtrl
    265265
    266266static void IdentifierBeforeIdentifier( string & identifier1, string & identifier2, const char * kind ) {
    267         SemanticError( yylloc, ::toString( "syntax error, adjacent identifiers \"", identifier1, "\" and \"", identifier2, "\" are not meaningful in a", kind, ".\n"
    268                                    "Possible cause is misspelled type name or missing generic parameter." ) );
     267        SemanticError( yylloc, "syntax error, adjacent identifiers \"%s\" and \"%s\" are not meaningful in an %s.\n"
     268                                   "Possible cause is misspelled type name or missing generic parameter.",
     269                                   identifier1.c_str(), identifier2.c_str(), kind );
    269270} // IdentifierBeforeIdentifier
    270271
    271272static void IdentifierBeforeType( string & identifier, const char * kind ) {
    272         SemanticError( yylloc, ::toString( "syntax error, identifier \"", identifier, "\" cannot appear before a ", kind, ".\n"
    273                                    "Possible cause is misspelled storage/CV qualifier, misspelled typename, or missing generic parameter." ) );
     273        SemanticError( yylloc, "syntax error, identifier \"%s\" cannot appear before a %s.\n"
     274                                   "Possible cause is misspelled storage/CV qualifier, misspelled typename, or missing generic parameter.",
     275                                   identifier.c_str(), kind );
    274276} // IdentifierBeforeType
    275277
     
    689691        //      { SemanticError( yylloc, "Resume expression is currently unimplemented." ); $$ = nullptr; }
    690692        | IDENTIFIER IDENTIFIER                                                         // invalid syntax rule
    691                 { IdentifierBeforeIdentifier( *$1.str, *$2.str, "n expression" ); $$ = nullptr; }
     693                { IdentifierBeforeIdentifier( *$1.str, *$2.str, "expression" ); $$ = nullptr; }
    692694        | IDENTIFIER type_qualifier                                                     // invalid syntax rule
    693695                { IdentifierBeforeType( *$1.str, "type qualifier" ); $$ = nullptr; }
     
    11551157        | identifier_or_type_name ':' attribute_list_opt error // invalid syntax rule
    11561158                {
    1157                         SemanticError( yylloc, ::toString( "syntx error, label \"", *$1.str, "\" must be associated with a statement, "
    1158                                                                                            "where a declaration, case, or default is not a statement. "
    1159                                                                                            "Move the label or terminate with a semi-colon." ) );
     1159                        SemanticError( yylloc, "syntx error, label \"%s\" must be associated with a statement, "
     1160                                                   "where a declaration, case, or default is not a statement.\n"
     1161                                                   "Move the label or terminate with a semicolon.", $1.str->c_str() );
    11601162                        $$ = nullptr;
    11611163                }
     
    21012103        | sue_declaration_specifier invalid_types                       // invalid syntax rule
    21022104                {
    2103                         SemanticError( yylloc, ::toString( "syntax error, expecting ';' at end of ",
    2104                                 $1->type->enumeration.name ? "enum" : ast::AggregateDecl::aggrString( $1->type->aggregate.kind ),
    2105                                 " declaration." ) );
     2105                        SemanticError( yylloc, "syntax error, expecting ';' at end of \"%s\" declaration.",
     2106                                                   $1->type->enumeration.name ? "enum" : ast::AggregateDecl::aggrString( $1->type->aggregate.kind ) );
    21062107                        $$ = nullptr;
    21072108                }
     
    21612162type_qualifier:
    21622163        type_qualifier_name
    2163         | attribute                                                                                     // trick handles most atrribute locations
     2164        | attribute                                                                                     // trick handles most attribute locations
    21642165        ;
    21652166
     
    25852586        | type_specifier field_declaring_list_opt '}'           // invalid syntax rule
    25862587                {
    2587                         SemanticError( yylloc, ::toString( "syntax error, expecting ';' at end of previous declaration." ) );
     2588                        SemanticError( yylloc, "syntax error, expecting ';' at end of previous declaration." );
    25882589                        $$ = nullptr;
    25892590                }
Note: See TracChangeset for help on using the changeset viewer.