Skip to content

Commit 51b7168

Browse files
committed
[Parse] Refactor get/set accessor parsing
* Use 'parseAbstractFunctionBody()' for accessors as well. This simplifies the implementation, and makes 'parseAbstractFunctionBody()' the single point of parsing body of every 'AbstructFunctionDecl' types.
1 parent 836ad07 commit 51b7168

File tree

6 files changed

+143
-214
lines changed

6 files changed

+143
-214
lines changed

include/swift/Parse/Parser.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -379,25 +379,14 @@ class Parser {
379379

380380
void restoreParserPosition(ParserPosition PP, bool enableDiagnostics = false) {
381381
L->restoreState(PP.LS, enableDiagnostics);
382-
383-
// We might be at tok::eof now, so ensure that consumeToken() does not
384-
// assert about lexing past eof.
385-
Tok.setKind(tok::unknown);
386-
consumeTokenWithoutFeedingReceiver();
387-
382+
L->lex(Tok, LeadingTrivia, TrailingTrivia);
388383
PreviousLoc = PP.PreviousLoc;
389384
}
390385

391386
void backtrackToPosition(ParserPosition PP) {
392387
assert(PP.isValid());
393-
394388
L->backtrackToState(PP.LS);
395-
396-
// We might be at tok::eof now, so ensure that consumeToken() does not
397-
// assert about lexing past eof.
398-
Tok.setKind(tok::unknown);
399-
consumeTokenWithoutFeedingReceiver();
400-
389+
L->lex(Tok, LeadingTrivia, TrailingTrivia);
401390
PreviousLoc = PP.PreviousLoc;
402391
}
403392

@@ -896,8 +885,6 @@ class Parser {
896885

897886
void consumeGetSetBody(AbstractFunctionDecl *AFD, SourceLoc LBLoc);
898887

899-
void parseAccessorAttributes(DeclAttributes &Attributes);
900-
901888
struct ParsedAccessors;
902889
bool parseGetSetImpl(ParseDeclOptions Flags,
903890
GenericParamList *GenericParams,

0 commit comments

Comments
 (0)