[Parser] Decouple the parser from AST creation (part 1)

Instead of creating the AST directly in the parser (and libSyntax or
SwiftSyntax via SyntaxParsingContext), make Parser to explicitly create
a tree of ParsedSyntaxNodes. Their OpaqueSyntaxNodes can be either
libSyntax or SwiftSyntax. If AST is needed, it can be generated from the
libSyntax tree.
This commit is contained in:
Jan Svoboda
2019-06-01 16:34:48 +02:00
parent b2fd31daa1
commit 44d7769238
23 changed files with 902 additions and 306 deletions

View File

@@ -155,6 +155,7 @@ private:
node.present = true;
}
public:
OpaqueSyntaxNode recordToken(tok tokenKind,
ArrayRef<ParsedTriviaPiece> leadingTrivia,
ArrayRef<ParsedTriviaPiece> trailingTrivia,
@@ -201,6 +202,10 @@ private:
auto result = NodeLookup(lexerOffset, ckind);
return {result.length, result.node};
}
OpaqueSyntaxNodeKind getOpaqueKind() override {
return OpaqueSyntaxNodeKind::SwiftSyntax;
}
};
static swiftparser_diagnostic_severity_t getSeverity(DiagnosticKind Kind) {