Goose  Diff

Differences From Artifact [6ed25d6b3d]:

  • File bs/parse/parser.cpp — part of check-in [d19a6bf065] at 2019-07-31 14:05:40 on branch trunk — Fixed some cyclic reference issues with cyclic CFGs:
    • Moved and renamed sema::CFGBuilder to llr::CFG.
    • llr::Func now owns a CFG pointer, rather than a pointer to its entry BB.
    • Branch and CondBranch now store weak pointers to their target BB.
    (user: achavasse size: 5572) [more...]

To Artifact [af828bfa2f]:

  • File bs/parse/parser.cpp — part of check-in [79a134aa8e] at 2019-08-01 21:11:51 on branch trunk — parser: implemented ComplexValue, which is a value bundled with a CFG whose execution or insertion is a prerequisite to use the value. (user: achavasse size: 5602)

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
        return parseInfix( content, precedence );
    }, t.content() );
}

bool Parser::parsePrefix( const APSInt& intlit, uint32_t )
{
    m_resolver->consume();
    pushValue( ToValue( intlit ) );
    return true;
}

bool Parser::parsePrefix( const string& strlit, uint32_t )
{
    m_resolver->consume();
    pushValue( ToValue( strlit ) );
    return true;
}

// Standalone (ie not part of a grammar construct that expects them such as a decl), unresolved identifiers
// end up here.
bool Parser::parsePrefix( const StringId& strid, uint32_t )
{







|






|







89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
        return parseInfix( content, precedence );
    }, t.content() );
}

bool Parser::parsePrefix( const APSInt& intlit, uint32_t )
{
    m_resolver->consume();
    pushSimpleValue( ToValue( intlit ) );
    return true;
}

bool Parser::parsePrefix( const string& strlit, uint32_t )
{
    m_resolver->consume();
    pushSimpleValue( ToValue( strlit ) );
    return true;
}

// Standalone (ie not part of a grammar construct that expects them such as a decl), unresolved identifiers
// end up here.
bool Parser::parsePrefix( const StringId& strid, uint32_t )
{
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177

    auto nameTerm = m_resolver->consume();
    const auto* name = get_if< StringId >( &nameTerm->content() );

    if( IsTExpr( *leftVal ) )
    {
        auto texpr = ValueToIRExpr( *popValue() );
        pushValue( ToValue( TNamedDecl( move( texpr ), *name ) ) );
        return true;
    }
    else if( leftVal->isType() )
    {
        auto type = ValueToIRExpr( *popValue() );
        pushValue( ToValue( Decl( move( type ), *name ) ) );
        return true;
    }

    return parsePrefix( strid, prec );
}

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

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

    // If the term is a prefix rule value, invoke its parsePrefix() function.
    auto rule = FromValue< Rule >( *val );
    if( !rule )
    {
        m_resolver->consume();
        pushValue( *val );
        return true;
    }

    if( !( *rule )->isPrefix() )
        return false;

    m_resolver->consume();







|





|



















|







137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177

    auto nameTerm = m_resolver->consume();
    const auto* name = get_if< StringId >( &nameTerm->content() );

    if( IsTExpr( *leftVal ) )
    {
        auto texpr = ValueToIRExpr( *popValue() );
        pushSimpleValue( ToValue( TNamedDecl( move( texpr ), *name ) ) );
        return true;
    }
    else if( leftVal->isType() )
    {
        auto type = ValueToIRExpr( *popValue() );
        pushSimpleValue( ToValue( Decl( move( type ), *name ) ) );
        return true;
    }

    return parsePrefix( strid, prec );
}

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

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

    // If the term is a prefix rule value, invoke its parsePrefix() function.
    auto rule = FromValue< Rule >( *val );
    if( !rule )
    {
        m_resolver->consume();
        pushSimpleValue( *val );
        return true;
    }

    if( !( *rule )->isPrefix() )
        return false;

    m_resolver->consume();