mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Parse: Stub out parsing of matching patterns using expr parser.
Add a parseMatchingPattern method that just calls down to the expr parser and shoves the expr in an ExprPattern. We'll augment the expr parser with matching pattern productions soon. Swift SVN r5833
This commit is contained in:
@@ -375,7 +375,7 @@ Optional<TuplePatternElt> Parser::parsePatternTupleElement(bool allowInitExpr) {
|
||||
/// Parse a tuple pattern.
|
||||
///
|
||||
/// pattern-tuple:
|
||||
//// '(' pattern-tuple-body? ')'
|
||||
/// '(' pattern-tuple-body? ')'
|
||||
/// pattern-tuple-body:
|
||||
/// pattern-tuple-element (',' pattern-tuple-body)*
|
||||
|
||||
@@ -422,3 +422,17 @@ NullablePtr<Pattern> Parser::parsePatternTuple(bool AllowInitExpr) {
|
||||
|
||||
return TuplePattern::create(Context, LPLoc, elts, RPLoc);
|
||||
}
|
||||
|
||||
NullablePtr<Pattern> Parser::parseMatchingPattern() {
|
||||
// TODO: Since we expect a pattern in this position, we should optimistically
|
||||
// parse pattern nodes for shared productions. For ease of initial
|
||||
// implementation, for now we always go through the expr parser and let name
|
||||
// binding determine what productions are really patterns.
|
||||
NullablePtr<Expr> subExpr = parseExpr(diag::expected_pattern);
|
||||
if (subExpr.isNull())
|
||||
return nullptr;
|
||||
|
||||
return new (Context) ExprPattern(subExpr.get(),
|
||||
/*isResolved*/ false,
|
||||
/*matchExpr*/ nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user