libSyntax: create a basic infrastructure for generating libSyntax entities by using Parser.

This commit is contained in:
Xi Ge
2017-10-18 17:02:00 -07:00
committed by GitHub
parent b1bbe48b44
commit ee7a06276d
16 changed files with 473 additions and 39 deletions

View File

@@ -20,7 +20,7 @@
#include "swift/AST/Identifier.h"
#include "swift/Basic/LangOptions.h"
#include "swift/Basic/SourceManager.h"
#include "swift/Syntax/TokenSyntax.h"
#include "swift/Syntax/SyntaxParsingContext.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -737,11 +737,12 @@ static bool rangeContainsPlaceholderEnd(const char *CurPtr,
return false;
}
RC<syntax::RawTokenSyntax> Lexer::fullLex() {
syntax::RawTokenInfo Lexer::fullLex() {
if (NextToken.isEscapedIdentifier()) {
LeadingTrivia.push_back(syntax::TriviaPiece::backtick());
TrailingTrivia.push_front(syntax::TriviaPiece::backtick());
}
auto Loc = NextToken.getLoc();
auto Result = syntax::RawTokenSyntax::make(NextToken.getKind(),
OwnedString(NextToken.getText()).copy(),
syntax::SourcePresence::Present,
@@ -751,7 +752,7 @@ RC<syntax::RawTokenSyntax> Lexer::fullLex() {
if (NextToken.isNot(tok::eof)) {
lexImpl();
}
return Result;
return {Loc, Result};
}
/// lexOperatorIdentifier - Match identifiers formed out of punctuation.