165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
const auto& leftVal = peekLastValue();
if( !leftVal )
return nullopt;
// If leftVal is a type, this is a decl, so set the precedence to Application.
if( IsType( *leftVal ) || IsTExpr( *leftVal ) )
{
// If it is a regular decl (such a function parameters and variable declarations),
// it have the very high "Application" precedence.
// However, if the identifier is followed by a parent block,
// this is a function declaration, and it gets the "FuncDecl" precedence, which
// is set to be lower than the comma operator.
//
// The reason for this is that while we want to construct tuples of about anything just
// by separating things with commas (not only to build function parameters and function arguments
// but also for multiple return values and multiple variable declarations), we also
// want to be able to use a tuple of those things as the return type for a function,
// so the construction of the tuple (the comma oeprator) needs a higher precedence than
// the function declaration. In other words, we don't want the last type of a tuple of type to
// become the return type of a function subsequently added to the tuple.
auto next = m_resolver->lookAheadUnresolved( 1 );
if( !next )
return precedence::Application;
auto decomp = Decompose( next->first, Val< Delimiter >() );
if( !decomp || *decomp != Delimiter::OpenParen )
return precedence::Application;
return precedence::FuncDecl;
}
return nullopt;
}
|
|
|
|
|
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
const auto& leftVal = peekLastValue();
if( !leftVal )
return nullopt;
// If leftVal is a type, this is a decl, so set the precedence to Application.
if( IsType( *leftVal ) || IsTExpr( *leftVal ) )
{
// If it is a regular decl (such as function parameters and variable declarations),
// it have the very high "Application" precedence.
// However, if the identifier is followed by a parent block,
// this is a function declaration, and it gets the "FuncDecl" precedence, which
// is set to be lower than the comma operator.
//
// The reason for this is that while we want to construct tuples of about anything just
// by separating things with commas (not only to build function parameters and function arguments
// but also for multiple return values and multiple variable declarations), we also
// want to be able to use a tuple of those things as the return type for a function,
// so the construction of the tuple (the comma operator) needs a higher precedence than
// the function declaration. In other words, we don't want the last type of a tuple of type to
// become the return type of a function subsequently added to the tuple.
auto next = m_resolver->lookAheadUnresolved( 1 );
if( !next )
return precedence::Application;
auto decomp = Decompose( next->first, Val< Delimiter >() );
if( !decomp || *decomp != Delimiter::OpenParen )
return precedence::Decl;
return precedence::FuncDecl;
}
return nullopt;
}
|