libSyntax: Root parsing context should hold a reference to the current token in the parser, NFC.

Since all parsing contexts need a reference to the current token of the
parser, we should pass the token reference to the root context. Therefore, the derived
sub-contexts can just copy it while being spawned.
This commit is contained in:
Xi Ge
2017-11-02 12:27:10 -07:00
parent 295c7f3158
commit 19caca7890
5 changed files with 15 additions and 14 deletions

View File

@@ -41,7 +41,7 @@ using namespace swift::syntax;
ParserResult<Expr> Parser::parseExprImpl(Diag<> Message, bool isExprBasic) {
// Start a context for creating expression syntax.
SyntaxParsingContextChild ExprParsingContext(SyntaxContext,
SyntaxContextKind::Expr, Tok);
SyntaxContextKind::Expr);
// If we are parsing a refutable pattern, check to see if this is the start
// of a let/var/is pattern. If so, parse it to an UnresolvedPatternExpr and
@@ -1806,7 +1806,7 @@ ParserResult<Expr> Parser::parseExprStringLiteral() {
SyntaxContext->addTokenSyntax(Tok.getLoc());
SyntaxContext->makeNode(SyntaxKind::StringLiteralExpr);
SyntaxParsingContextChild LocalContext(SyntaxContext,
SyntaxContextKind::Expr, Tok);
SyntaxContextKind::Expr);
// FIXME: Avoid creating syntax nodes for string interpolation.
LocalContext.disable();