mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Delete libSyntax
This commit is contained in:
@@ -32,9 +32,8 @@
|
||||
#include "swift/Parse/Token.h"
|
||||
#include "swift/Parse/ParserPosition.h"
|
||||
#include "swift/Parse/ParserResult.h"
|
||||
#include "swift/Parse/SyntaxParsingContext.h"
|
||||
#include "swift/Syntax/References.h"
|
||||
#include "swift/Config.h"
|
||||
#include "llvm/ADT/IntrusiveRefCntPtr.h"
|
||||
|
||||
namespace llvm {
|
||||
template <typename... PTs> class PointerUnion;
|
||||
@@ -47,7 +46,6 @@ namespace swift {
|
||||
class DiagnosticEngine;
|
||||
class Expr;
|
||||
class Lexer;
|
||||
class ParsedTypeSyntax;
|
||||
class PersistentParserState;
|
||||
class RequirementRepr;
|
||||
class SILParserStateBase;
|
||||
@@ -57,11 +55,6 @@ namespace swift {
|
||||
class TypeLoc;
|
||||
|
||||
struct EnumElementInfo;
|
||||
|
||||
namespace syntax {
|
||||
class RawSyntax;
|
||||
enum class SyntaxKind : uint16_t;
|
||||
}// end of syntax namespace
|
||||
|
||||
/// Different contexts in which BraceItemList are parsed.
|
||||
enum class BraceItemListKind {
|
||||
@@ -222,14 +215,6 @@ public:
|
||||
/// This is the current token being considered by the parser.
|
||||
Token Tok;
|
||||
|
||||
/// Leading trivia for \c Tok.
|
||||
/// Always empty if !SF.shouldBuildSyntaxTree().
|
||||
StringRef LeadingTrivia;
|
||||
|
||||
/// Trailing trivia for \c Tok.
|
||||
/// Always empty if !SF.shouldBuildSyntaxTree().
|
||||
StringRef TrailingTrivia;
|
||||
|
||||
/// The receiver to collect all consumed tokens.
|
||||
ConsumeTokenReceiver *TokReceiver;
|
||||
|
||||
@@ -382,27 +367,17 @@ public:
|
||||
|
||||
public:
|
||||
Parser(unsigned BufferID, SourceFile &SF, DiagnosticEngine* LexerDiags,
|
||||
SILParserStateBase *SIL, PersistentParserState *PersistentState,
|
||||
std::shared_ptr<SyntaxParseActions> SPActions = nullptr);
|
||||
SILParserStateBase *SIL, PersistentParserState *PersistentState);
|
||||
Parser(unsigned BufferID, SourceFile &SF, SILParserStateBase *SIL,
|
||||
PersistentParserState *PersistentState = nullptr,
|
||||
std::shared_ptr<SyntaxParseActions> SPActions = nullptr);
|
||||
PersistentParserState *PersistentState = nullptr);
|
||||
Parser(std::unique_ptr<Lexer> Lex, SourceFile &SF,
|
||||
SILParserStateBase *SIL = nullptr,
|
||||
PersistentParserState *PersistentState = nullptr,
|
||||
std::shared_ptr<SyntaxParseActions> SPActions = nullptr);
|
||||
PersistentParserState *PersistentState = nullptr);
|
||||
~Parser();
|
||||
|
||||
/// Returns true if the buffer being parsed is allowed to contain SIL.
|
||||
bool isInSILMode() const;
|
||||
|
||||
/// Calling this function to finalize libSyntax tree creation without destroying
|
||||
/// the parser instance.
|
||||
OpaqueSyntaxNode finalizeSyntaxTree() {
|
||||
assert(Tok.is(tok::eof) && "not done parsing yet");
|
||||
return SyntaxContext->finalizeRoot();
|
||||
}
|
||||
|
||||
/// Retrieve the token receiver from the parser once it has finished parsing.
|
||||
std::unique_ptr<ConsumeTokenReceiver> takeTokenReceiver() {
|
||||
assert(Tok.is(tok::eof) && "not done parsing yet");
|
||||
@@ -415,7 +390,7 @@ public:
|
||||
// Routines to save and restore parser state.
|
||||
|
||||
ParserPosition getParserPosition() {
|
||||
return ParserPosition(L->getStateForBeginningOfToken(Tok, LeadingTrivia),
|
||||
return ParserPosition(L->getStateForBeginningOfToken(Tok),
|
||||
PreviousLoc);
|
||||
}
|
||||
|
||||
@@ -425,14 +400,14 @@ public:
|
||||
|
||||
void restoreParserPosition(ParserPosition PP, bool enableDiagnostics = false) {
|
||||
L->restoreState(PP.LS, enableDiagnostics);
|
||||
L->lex(Tok, LeadingTrivia, TrailingTrivia);
|
||||
L->lex(Tok);
|
||||
PreviousLoc = PP.PreviousLoc;
|
||||
}
|
||||
|
||||
void backtrackToPosition(ParserPosition PP) {
|
||||
assert(PP.isValid());
|
||||
L->backtrackToState(PP.LS);
|
||||
L->lex(Tok, LeadingTrivia, TrailingTrivia);
|
||||
L->lex(Tok);
|
||||
PreviousLoc = PP.PreviousLoc;
|
||||
}
|
||||
|
||||
@@ -447,9 +422,6 @@ public:
|
||||
Parser &P;
|
||||
ParserPosition PP;
|
||||
DiagnosticTransaction DT;
|
||||
/// This context immediately deconstructed with transparent accumulation
|
||||
/// on cancelBacktrack().
|
||||
llvm::Optional<SyntaxParsingContext> SynContext;
|
||||
bool Backtrack = true;
|
||||
|
||||
/// A token receiver used by the parser in the back tracking scope. This
|
||||
@@ -483,9 +455,7 @@ public:
|
||||
|
||||
BacktrackingScopeImpl(Parser &P)
|
||||
: P(P), PP(P.getParserPosition()), DT(P.Diags),
|
||||
TempReceiver(P.TokReceiver) {
|
||||
SynContext.emplace(P.SyntaxContext);
|
||||
}
|
||||
TempReceiver(P.TokReceiver) { }
|
||||
|
||||
public:
|
||||
~BacktrackingScopeImpl();
|
||||
@@ -495,18 +465,14 @@ public:
|
||||
/// A backtracking scope that will always backtrack when destructed.
|
||||
class BacktrackingScope final : public BacktrackingScopeImpl {
|
||||
public:
|
||||
BacktrackingScope(Parser &P) : BacktrackingScopeImpl(P) {
|
||||
SynContext->disable();
|
||||
}
|
||||
BacktrackingScope(Parser &P) : BacktrackingScopeImpl(P) { }
|
||||
};
|
||||
|
||||
/// A backtracking scope whose backtracking can be disabled by calling
|
||||
/// \c cancelBacktrack.
|
||||
class CancellableBacktrackingScope final : public BacktrackingScopeImpl {
|
||||
public:
|
||||
CancellableBacktrackingScope(Parser &P) : BacktrackingScopeImpl(P) {
|
||||
SynContext->setBackTracking();
|
||||
}
|
||||
CancellableBacktrackingScope(Parser &P) : BacktrackingScopeImpl(P) { }
|
||||
|
||||
void cancelBacktrack();
|
||||
};
|
||||
@@ -570,10 +536,6 @@ public:
|
||||
return consumeToken();
|
||||
}
|
||||
|
||||
SourceLoc leadingTriviaLoc() {
|
||||
return Tok.getLoc().getAdvancedLoc(-LeadingTrivia.size());
|
||||
}
|
||||
|
||||
SourceLoc consumeIdentifier(Identifier &Result, bool diagnoseDollarPrefix) {
|
||||
assert(Tok.isAny(tok::identifier, tok::kw_self, tok::kw_Self));
|
||||
assert(Result.empty());
|
||||
@@ -718,13 +680,6 @@ public:
|
||||
/// Skip over any attribute.
|
||||
void skipAnyAttribute();
|
||||
|
||||
/// If the parser is generating only a syntax tree, try loading the current
|
||||
/// node from a previously generated syntax tree.
|
||||
/// Returns \c true if the node has been loaded and inserted into the current
|
||||
/// syntax tree. In this case the parser should behave as if the node has
|
||||
/// successfully been created.
|
||||
bool loadCurrentSyntaxNodeFromCache();
|
||||
|
||||
/// Parse an #endif.
|
||||
bool parseEndIfDirective(SourceLoc &Loc);
|
||||
|
||||
@@ -746,8 +701,7 @@ public:
|
||||
/// parsed if the parser is generating only a syntax tree or if the user has
|
||||
/// passed the `-enable-experimental-concurrency` flag to the frontend.
|
||||
bool shouldParseExperimentalConcurrency() const {
|
||||
return Context.LangOpts.EnableExperimentalConcurrency ||
|
||||
Context.LangOpts.ParseForSyntaxTreeOnly;
|
||||
return Context.LangOpts.EnableExperimentalConcurrency;
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -916,13 +870,11 @@ public:
|
||||
ParseListItemResult
|
||||
parseListItem(ParserStatus &Status, tok RightK, SourceLoc LeftLoc,
|
||||
SourceLoc &RightLoc, bool AllowSepAfterLast,
|
||||
SyntaxKind ElementKind,
|
||||
llvm::function_ref<ParserStatus()> callback);
|
||||
|
||||
/// Parse a comma separated list of some elements.
|
||||
ParserStatus parseList(tok RightK, SourceLoc LeftLoc, SourceLoc &RightLoc,
|
||||
bool AllowSepAfterLast, Diag<> ErrorDiag,
|
||||
syntax::SyntaxKind Kind,
|
||||
llvm::function_ref<ParserStatus()> callback);
|
||||
|
||||
void consumeTopLevelDecl(ParserPosition BeginParserPosition,
|
||||
@@ -1788,7 +1740,7 @@ public:
|
||||
ParserStatus parseExprList(tok leftTok, tok rightTok, bool isArgumentList,
|
||||
SourceLoc &leftLoc,
|
||||
SmallVectorImpl<ExprListElt> &elts,
|
||||
SourceLoc &rightLoc, SyntaxKind Kind);
|
||||
SourceLoc &rightLoc);
|
||||
|
||||
/// Parse an object literal.
|
||||
///
|
||||
@@ -2036,14 +1988,6 @@ DeclNameRef formDeclNameRef(ASTContext &ctx,
|
||||
/// Whether a given token can be the start of a decl.
|
||||
bool isKeywordPossibleDeclStart(const Token &Tok);
|
||||
|
||||
/// Lex and return a vector of `TokenSyntax` tokens, which include
|
||||
/// leading and trailing trivia.
|
||||
std::vector<
|
||||
std::pair<const syntax::RawSyntax *, syntax::AbsoluteOffsetPosition>>
|
||||
tokenizeWithTrivia(const LangOptions &LangOpts, const SourceManager &SM,
|
||||
unsigned BufferID, const RC<SyntaxArena> &Arena,
|
||||
unsigned Offset = 0, unsigned EndOffset = 0,
|
||||
DiagnosticEngine *Diags = nullptr);
|
||||
} // end namespace swift
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user