Commit Graph

691 Commits

Author SHA1 Message Date
Rintaro Ishizaki
0e8010d8b9 Revert "Merge pull request #27592 from rintaro/syntaxparse-exprtuple"
This reverts commit cdfd1ab2cf, reversing
changes made to eb02f20f99.
2019-10-14 12:15:48 -07:00
Rintaro Ishizaki
ebbc9c837f [SyntaxParse] Don't update PreviousLoc when ignoring token.
So that the last token in Syntax and PreviousLoc match.
2019-10-09 14:48:47 -07:00
Rintaro Ishizaki
0d4cf76ed0 [SyntaxParse] Renew parseListSyntax()
Optimize for libSyntax parsing.
The new 'parseListSyntax()' receives a vector storage, passes element
builder to the callback for populating the elements, then automatically
parses trailing commas. Also, it performs automatic recovery if the
element has an error (e.g. Skip until ',' or ')').
2019-10-08 23:11:08 -07:00
Rintaro Ishizaki
f42f60f233 [Syntax] Consolidate 'TupleElement' and 'FunctionCallArgument' kinds
into 'TupleExprElement'. They had exact the same layout.
2019-10-07 20:52:11 -07:00
Rintaro Ishizaki
9f26b5615f [SyntaxParse] Remove unused overload of parseMatchingTokenSyntax() 2019-10-03 14:52:55 -07:00
Rintaro Ishizaki
c022ff23e8 [SyntaxParse] Adjust parseMatchingToken() 2019-10-03 13:48:57 -07:00
Nathan Hawes
e89efa8f81 [parser] Fix tuple type round-tripping issue
`public init(a: (b || c))` became `public init(a: )(b || c)` after
round-tripping.

Resolves rdar://problem/55280477
2019-09-20 19:04:41 -07:00
Rintaro Ishizaki
f919b2ddd8 [SyntaxParse] Parse generic parameter clause and generic where clause 2019-09-19 23:09:58 -07:00
Rintaro Ishizaki
b09f87594a Merge pull request #27230 from rintaro/syntaxparsse-rdar55421369
[SyntaxParse] Re-apply move-only ParsedRawSyntaxNode
2019-09-19 07:36:14 +02:00
Jordan Rose
8d7f1b7c5d [AST] Separate SourceFile from FileUnit.h
Like the last commit, SourceFile is used a lot by Parse and Sema, but
less so by the ClangImporter and (de)Serialization. Split it out to
cut down on recompilation times when something changes.

This commit does /not/ split the implementation of SourceFile out of
Module.cpp, which is where most of it lives. That might also be a
reasonable change, but the reason I was reluctant to is because a
number of SourceFile members correspond to the entry points in
ModuleDecl. Someone else can pick this up later if they decide it's a
good idea.

No functionality change.
2019-09-17 17:54:41 -07:00
Jordan Rose
853caa66d4 [AST] Split FileUnit and its subclasses out of Module.h
Most of AST, Parse, and Sema deal with FileUnits regularly, but SIL
and IRGen certainly don't. Split FileUnit out into its own header to
cut down on recompilation times when something changes.

No functionality change.
2019-09-17 17:54:41 -07:00
Rintaro Ishizaki
9f642f0bc1 Revert "Merge pull request #27203 from CodaFi/movin-on-up"
This reverts commit 387d2a9aee, reversing
changes made to bf1ab6c29d.
2019-09-17 16:42:44 -07:00
Robert Widmann
d8aaf29617 Revert "Merge pull request #27132 from rintaro/syntaxparse-parsedrawsyntax-moveonly"
This reverts commit e675c4947d, reversing
changes made to 73315ba01e.
2019-09-16 15:10:33 -07:00
Rintaro Ishizaki
80085e0d27 [SyntaxParse] Make ParsedRawSyntaxNode move-only
So that we can easily detect 'ParsedSyntaxNode' leaking. When it's
moved, the original node become "null" node. In the destructor of
'ParsedSyntaxNode', assert the node is not "recorded" node.
2019-09-11 16:33:49 -07:00
Rintaro Ishizaki
da95961de2 [SyntaxParse] Fix a crash in TokenReceiver
rdar://problem/55267292
2019-09-11 10:51:07 -07:00
Rintaro Ishizaki
a7d6612813 Merge pull request #27046 from rintaro/syntaxparse-refactor-type
[SyntaxParse] Refactor parsing facilities
2019-09-11 06:43:42 +02:00
Rintaro Ishizaki
a9af910664 [SyntaxParse] Add ignoreToken() function to ignore tokens 2019-09-10 10:29:02 -07:00
Rintaro Ishizaki
8edea315cd [Syntax] Abolish 'backtick' trivia
- Stop producing 'backtick' trivia for escaping identifier token. '`'s
  are now parts of the token text
- Adjust and simplify C++ libSyntax APIs
- Add 'is_deprecated' property to Trivia.py to attribute SwiftSyntax
  APIs

rdar://problem/54810608
2019-09-09 11:49:25 -07:00
Doug Gregor
6d390e44d9 Allow delayed body parsing in parseDelayedDecl().
When performing delayed decl parsing (e.g., for code completion),
allow other function bodies to be delayed.
2019-09-03 11:41:19 -07:00
Doug Gregor
d7f6768a9d Eliminate DelayedParsingCallbacks.
DelayedParsingCallbacks only had one implementation, for code
completion, which is only used to determine which bodies to skip and
which to delay. Inline that logic into the parser's delay logic and
remove DelayedParsingCallbacks entirely.
2019-09-02 19:03:07 -07:00
Doug Gregor
d8b745db77 Add a request to lazily parse function bodies.
Rework the lazy function body parsing mechanism to use the
request-evaluator, so that asking for the body of a function will
initiate parsing. Clean up a number of callers to
AbstractFunctionDecl::getBody() that don't actually need the body, so
we don't perform unnecessary parsing.

This change does not delay parsing of function bodies in the general
case; rather, it sets up the infrastructure to always delay parsing of
function bodies.
2019-08-31 16:23:08 -07:00
eeckstein
903eeb220b Revert "Add a request to lazily parse function bodies." 2019-08-31 12:29:01 +02:00
Doug Gregor
2ab05a6835 Add a request to lazily parse function bodies.
Rework the lazy function body parsing mechanism to use the
request-evaluator, so that asking for the body of a function will
initiate parsing. Clean up a number of callers to
AbstractFunctionDecl::getBody() that don't actually need the body, so
we don't perform unnecessary parsing.

This change does not delay parsing of function bodies in the general
case; rather, it sets up the infrastructure to always delay parsing of
function bodies.
2019-08-30 16:48:23 -07:00
Doug Gregor
11969847c4 Simplify lazy parsing of nominal and extension members.
Lazy parsing for the members of nominal types and extensions depends
only on information already present in
`IterableDeclContext`. Eliminate the use of PersistentParserState as
an intermediary and have the member-parsing request construct a new
`Parser` instance itself to handle parsing. Make this possible even
for ill-formed nominal types/extensions to simplify the code path.

Eliminate `LazyMemberParser` and all of its uses, because it was only
present for lazy member parsing, which no longer needs it.
2019-08-30 08:29:43 -07:00
Rintaro Ishizaki
cb308b7e53 Revert "Revert "[Parser] Decouple the parser from AST creation (part 2)""
This reverts commit 8ad3cc8a82.
2019-08-27 14:36:41 -07:00
Rintaro Ishizaki
8ad3cc8a82 Revert "[Parser] Decouple the parser from AST creation (part 2)" 2019-08-27 12:28:48 -07:00
Jan Svoboda
77924c4b84 [Parser] Decouple the parser from AST creation (part 2)
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.
2019-08-26 19:10:51 +02:00
David Ungar
a40b694801 Use token start locations 2019-08-21 22:36:15 -07:00
David Ungar
d84d541e99 De-lazify 2019-08-21 12:02:25 -07:00
David Ungar
0dbf7e6ab6 Parser changes for lazy ASTScopes 2019-08-21 09:45:45 -07:00
David Ungar
fe5e4ee96f Correct comment for Parser::parseMatchingToken. 2019-08-13 09:54:54 -07:00
Rintaro Ishizaki
94f0c14675 [SyntaxParse] Return dedicated pointer from HiddenLibSyntaxAction
SyntaxParseActions::recordToken() et al. may return the same pointer
value for different nodes (e.g. `nullptr`). So we cannot use DenseMap to
associate the node from the explicit syntax parsing actions to libSyntax
node. Instead, use a structure that wraps them.
2019-07-31 16:14:32 -07:00
Jan Svoboda
f0395a469a Revert "Revert "[Parser] Decouple the parser from AST creation (part 1)"" 2019-07-30 04:34:09 +00:00
Brent Royal-Gordon
c66a8be4eb Revert "[Parser] Decouple the parser from AST creation (part 1)" 2019-07-09 14:07:43 -07:00
Jan Svoboda
5aee188716 Rename SyntaxTransformer to ASTGen 2019-07-08 17:16:35 +02:00
Jan Svoboda
44d7769238 [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.
2019-06-28 14:28:19 +02:00
Saleem Abdulrasool
731c31f9a5 MSVC: litter the code with llvm_unreachable (NFC)
Add `llvm_unreachable` to mark covered switches which MSVC does not
analyze correctly and believes that there exists a path through the
function without a return value.
2019-06-01 19:02:46 -07:00
Sam Lazarus
3d9b6396a1 Merge pull request #24059 from sl/sl/sr-10293
Allow var / let as parameter names but provide a warning and fixit to add backticks.
2019-04-26 09:30:23 -04:00
Sam Lazarus
ede8127adf Test: Add and update tests for allowing var and let as argument labels 2019-04-26 04:08:27 -04:00
Sam Lazarus
2a38b48eea Parse / AST: Allow let / var as argument labels with a warning.
The diagnostic is now a warning and the new message alerts the user that
though it is valid to have let and var as argument label names,
they are interpreted as argument labels, not keywords.
2019-04-26 04:08:01 -04:00
Doug Gregor
32b0245187 [Parser] Consistently use consumeIdentifier() for normal identifiers.
consumeIdentifier() provides the general way in which we consume an
identifier token and fill in an Identifier. Use it consistently in the
parser.
2019-04-23 11:31:58 -07:00
Harlan Haskins
f5fc6f0c57 [Lexer] Handle SwiftInterface files as well as SIL
Previously, the Lexer kept a single flag whether we’re lexing Swift or SIL. Instead, keep track if we’re parsing Swift, SIL, or a Swiftinterface file. .swiftinterface files allow $-prefixed identifiers anywhere.
2019-01-22 11:02:36 -08:00
Slava Pestov
83472bca29 Frontend: Only enable delayed member parsing for non-primary files 2019-01-18 00:15:53 -05:00
Slava Pestov
fb0fbc099b Parse: Rename DisableDelayedParsing to DelayBodyParsing and change polarity 2019-01-18 00:15:41 -05:00
Argyrios Kyrtzidis
c7ac859310 [Parse] Optimize syntax parsing: Speed-up Lexer::lexTrivia()
Introduce ParsedTrivia which is a more efficient structure to use during lexing than syntax::Trivia.
2019-01-17 12:10:27 -08:00
Xi Ge
6057a60aca [Parser] Expose a flag to allow users explicitly disable delayed parsing. NFC
Discussed with @dcci, this patch is necessary to fix an lldb test failure. rdar://38396444
2019-01-09 14:32:41 -08:00
Argyrios Kyrtzidis
4806fb1cef [ParsedRawSyntaxNode] Explicitely specify if a ParsedRawSyntaxNode is null using a DataKind
Avoid implicitely assuming 'null' node if its OpaqueSyntaxNode is null, there should be no interpretation
of OpaqueSyntaxNode values, a SyntaxParseActions implementation should be able to return null pointers as OpaqueSyntaxNode.
2019-01-07 19:56:37 -08:00
Argyrios Kyrtzidis
ab7427723e [Parse/Syntax] Refactoring to decouple the parser from syntax tree creation
Instead of creating syntax nodes directly, modify the parser to invoke an abstract interface 'SyntaxParseActions' while it is parsing the source code.
This decouples the act of parsing from the act of forming a syntax tree representation.
'SyntaxTreeCreator' is an implementation of SyntaxParseActions that handles the logic of creating a syntax tree.
To enforce the layering separation of parsing and syntax tree creation, a static library swiftSyntaxParse is introduced to compose the two.

This decoupling is important for introducing a syntax parser library for SwiftSyntax to directly access parsing.
2019-01-07 19:52:59 -08:00
Argyrios Kyrtzidis
66be4a58b4 [Parser] Introduce ParserUnit::parse() function to avoid duplication of code 2018-12-16 09:52:15 -08:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00