Goose  Diff

Differences From Artifact [7f65098766]:

  • File bs/parse/parser.cpp — part of check-in [086a58a7a3] at 2020-07-05 20:15:49 on branch trunk — Implemented reference parsing. (user: achavasse size: 9739)

To Artifact [c8ba389518]:

  • File bs/parse/parser.cpp — part of check-in [0345b9f807] at 2021-01-02 18:00:11 on branch trunk — Some more renaming. (user: achavasse size: 9724)

209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243

    // If the identifier is preceded by a TExpr or a Type,
    // then this becomes a TDecl or a Decl, respectively.
    if( IsTExpr( *leftVal ) )
    {
        auto loc = Location::CreateSpanningLocation( leftVal->locationId(), nameTerm->second );

        auto texpr = ValueToIRExpr( *popType() );
        pushValue( ToValue( TNamedDecl( move( texpr ), *name ) ).setLocationId( loc ) );
        return true;
    }
    else if( IsType( *leftVal ) )
    {
        auto loc = Location::CreateSpanningLocation( leftVal->locationId(), nameTerm->second );

        auto type = ValueToIRExpr( *popType() );
        pushValue( ToValue( Decl( move( type ), *name ) ).setLocationId( loc ) );
        return true;
    }

    return parsePrefix( strid, prec );
}

bool Parser::parsePrefix( const pvec& vec, uint32_t prec )
{
    auto t = *m_resolver->lookAhead();

    auto val = ValueFromIRExpr( t.first );
    if( !val )
        return false;

    if( val->isPoison() )
        DiagnosticsManager::GetInstance().setCurrentVerbosityLevel( Verbosity::Silent );

    // If the term is a prefix rule value, invoke its parsePrefix() function.







|







|











|







209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243

    // If the identifier is preceded by a TExpr or a Type,
    // then this becomes a TDecl or a Decl, respectively.
    if( IsTExpr( *leftVal ) )
    {
        auto loc = Location::CreateSpanningLocation( leftVal->locationId(), nameTerm->second );

        auto texpr = ValueToEIR( *popType() );
        pushValue( ToValue( TNamedDecl( move( texpr ), *name ) ).setLocationId( loc ) );
        return true;
    }
    else if( IsType( *leftVal ) )
    {
        auto loc = Location::CreateSpanningLocation( leftVal->locationId(), nameTerm->second );

        auto type = ValueToEIR( *popType() );
        pushValue( ToValue( Decl( move( type ), *name ) ).setLocationId( loc ) );
        return true;
    }

    return parsePrefix( strid, prec );
}

bool Parser::parsePrefix( const pvec& vec, uint32_t prec )
{
    auto t = *m_resolver->lookAhead();

    auto val = ValueFromEIR( t.first );
    if( !val )
        return false;

    if( val->isPoison() )
        DiagnosticsManager::GetInstance().setCurrentVerbosityLevel( Verbosity::Silent );

    // If the term is a prefix rule value, invoke its parsePrefix() function.
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268

    m_resolver->consume();
    return ( *rule )->parsePrefix( *this, t.second, prec );
}

optional< uint32_t > Parser::getPrecedence( const Term& t, const pvec& vec )
{
    auto val = ValueFromIRExpr( t );
    if( !val )
        return nullopt;

    if( val->type() == GetValueType< ptr< OverloadSet > >() )
    {
        if( !peekLastValue() )
            return nullopt;







|







254
255
256
257
258
259
260
261
262
263
264
265
266
267
268

    m_resolver->consume();
    return ( *rule )->parsePrefix( *this, t.second, prec );
}

optional< uint32_t > Parser::getPrecedence( const Term& t, const pvec& vec )
{
    auto val = ValueFromEIR( t );
    if( !val )
        return nullopt;

    if( val->type() == GetValueType< ptr< OverloadSet > >() )
    {
        if( !peekLastValue() )
            return nullopt;
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
    return ( *rule )->getPrecedence( *this );
}

bool Parser::parseInfix( const pvec& vec, uint32_t prec )
{
    auto t = *m_resolver->lookAhead();

    auto val = ValueFromIRExpr( t.first );
    if( !val )
        return false;

    if( val->isPoison() )
        DiagnosticsManager::GetInstance().setCurrentVerbosityLevel( Verbosity::Silent );

    if( val->type() == GetValueType< ptr< OverloadSet > >() )







|







284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
    return ( *rule )->getPrecedence( *this );
}

bool Parser::parseInfix( const pvec& vec, uint32_t prec )
{
    auto t = *m_resolver->lookAhead();

    auto val = ValueFromEIR( t.first );
    if( !val )
        return false;

    if( val->isPoison() )
        DiagnosticsManager::GetInstance().setCurrentVerbosityLevel( Verbosity::Silent );

    if( val->type() == GetValueType< ptr< OverloadSet > >() )