Commit Graph

3613 Commits

Author SHA1 Message Date
David Zarzycki
362d801472 [AST] NFC: Tail allocate CaptureListExpr entries 2017-12-20 09:35:15 -05:00
David Zarzycki
5a4e96fcc2 [AST] NFC: Tail allocate UnresolvedSpecializeExpr TypeLocs 2017-12-20 09:35:15 -05:00
swift-ci
bd764ec848 Merge pull request #13537 from nkcsgexi/lib-syntax-pattern-binding-decl 2017-12-19 13:17:37 -08:00
Xi Ge
e0d167f1dd libSyntax: create syntax nodes for variable declarations.
Variable declarations are declarations led by either 'var' or 'let'. It
can contain multiple pattern bindings as children.

For patterns, this patch only creates syntax nodes for simple identifier
patterns, e.g. 'a = 3'. The rest of the pattern kinds are still left
unknown (UnknownPattern).
2017-12-19 12:25:51 -08:00
David Zarzycki
60d2f5586e [AST] QoI: Track DictionaryExpr commas and tail allocate CollectionExpr comma locs 2017-12-19 13:33:09 -05:00
Rintaro Ishizaki
cc72a3b934 [Lexer] Use ContentStart position for hashbang trivia 2017-12-19 09:24:34 +09:00
Rintaro Ishizaki
2c06060165 [Syntax] Add CarriageReturn trivia kind
To distinguish '\r' from '\n'.
2017-12-19 09:24:34 +09:00
Rintaro Ishizaki
181333ce0f [Lexer] Lex conflict marker as a trivia 2017-12-19 09:24:33 +09:00
Rintaro Ishizaki
023379cde5 Merge pull request #13495 from omochi/lexer-refactor-skip-to-eol
[Parse] Refactor Lexer's skipToEndOfline
2017-12-19 09:12:07 +09:00
Xi Ge
fe1a4ca0d2 libSyntax: create libSyntax node for var decl accessors. 2017-12-18 15:16:14 -08:00
Rintaro Ishizaki
8e967adc0e [Syntax] Parse attributed type node 2017-12-18 08:28:24 -08:00
omochimetaru
5de598f34a [Parse] use skipHashbang in lexTrivia 2017-12-18 18:22:04 +09:00
omochimetaru
aeb9ba6f96 [Parse] use skipSlashSlashComment in lexTrivia 2017-12-18 18:22:04 +09:00
omochimetaru
f7136ae635 [Parse] delete skipUpToEndOfLine 2017-12-18 18:22:04 +09:00
omochimetaru
ed58c152bf [Parse] Improve Lexer's UTF-8 BOM handling (#13483)
* Add BOM handling testcases
* Add ContentStart to Lexer for BOM handling
2017-12-18 17:22:11 +09:00
Faiçal Tchirou
5e41098851 libSyntax: specialize class declaration syntax node. (#13485) 2017-12-16 11:36:58 -08:00
Rintaro Ishizaki
e3b9e3ea4c Merge pull request #13477 from rintaro/parse-placeholder-disablesyntax
[Parse] Disable token receiver while parsing types in editor placeholder
2017-12-16 11:12:13 +09:00
Rintaro Ishizaki
24c7ea15e7 [Parse] Disable token receiver while parsing types in editor placeholder
Otherwise, for `<#T##Type#>`, `TokReceiver` records
 `{'<#T##Type#>', 'Type'}`.
2017-12-16 10:48:12 +09:00
Xi Ge
df7db884cf libSyntax: create syntax nodes for IfConfigDecl. 2017-12-15 13:36:47 -08:00
Rintaro Ishizaki
53b2e0fe14 [Syntax] Parse composition type node 2017-12-15 10:52:10 -08:00
Xi Ge
b4b638651d libSyntax: create syntax node for typealias declarations. (#13450) 2017-12-14 17:44:54 -08:00
Xi Ge
a6b3559a8a libSyntax: specialize import declaration. (#13437) 2017-12-14 12:27:52 -08:00
Rintaro Ishizaki
e616b2ad37 [Syntax] Use initializer clause syntax node for function parameter (#13430) 2017-12-14 08:12:10 -08:00
Rintaro Ishizaki
fc5f31c6d9 [Syntax] Decompose TupleType when it turns out to be a part of FunctionType 2017-12-14 14:55:27 +09:00
Rintaro Ishizaki
ef29650acd [Syntax] Parse: add support for TupleType and FunctionType
For now using SyntaxParsingContext.
2017-12-14 14:55:27 +09:00
Xi Ge
796c51cb1f libSyntax: specialize closure expression. (#13421) 2017-12-13 18:25:44 -08:00
Xi Ge
9ddd60d4ef libSyntax: create syntax nodes for closure signature. (#13415)
This patch also refactors the structure of function signature node so
that closure signature can re-use parts of function signature. For
instance, we group arrow and return type to be "ReturnClause". And we
group parenthesized parameter list to be "ParamClause".

This structure of closure signature also calls for a good way to
represent either-or node in libSyntax APIs, since we've two ways to
specify parameters in closure: one is as regular function parameter and
the other is dot-separated simple names.
2017-12-13 16:48:24 -08:00
Ben Langmuir
68a454556f Merge pull request #13348 from benlangmuir/cc-generic-subscript
[parse] Recover better from malformed subscript decls for code-completion
2017-12-13 15:45:03 -08:00
Ben Langmuir
dc5888d887 [parse] Recover better from malformed subscript decls for code-completion
Code-completion of generic types expects to get a DeclContext for the
subscript, so make sure we recover well enough to produce a
SubscriptDecl.

rdar://35619175
2017-12-13 13:37:41 -08:00
Xi Ge
9e8d0aea81 libSyntax: create syntax node for closure capture list. (#13408) 2017-12-12 20:14:04 -08:00
swift-ci
6ea0e31a01 Merge pull request #13402 from nkcsgexi/lib-syntax-try-expr 2017-12-12 17:21:37 -08:00
Xi Ge
2a39598b4f libSyntax: specialize try expression.
Optional try, forced try and regular try expressions are handled in
this syntax node.
2017-12-12 16:17:48 -08:00
Rintaro Ishizaki
229f98462e [Parse] Slightly refactor TupleTypeRepr element parsing.
* Instead of consuming 'inout' unconditionally, use backtracking to
  determine it's obsolete usage of 'inout' position.
* parse '...' before '= <initializer>' because '(Int... = [1])' is more
  likely than '(Int = 1 ...)'. This improves diagnostics.
2017-12-12 21:46:05 +09:00
Xi Ge
fda8dfcfd3 libSyntax: specialize protocol declaration syntax. 2017-12-11 16:17:13 -08:00
Rintaro Ishizaki
a0f49ca935 Merge pull request #13339 from rintaro/syntax-parserposition
[Syntax] Fix roundtrip test
2017-12-11 09:49:21 +09:00
Rintaro Ishizaki
60bfa893b9 [Parse] Make PersistentParserState to hold ParserPosition
instead of PersistentParserState::ParserPos.
2017-12-09 13:58:50 +09:00
Rintaro Ishizaki
724052d266 [Parse] Rename Lexer::State to LexerState 2017-12-09 13:58:50 +09:00
Xi Ge
7901583833 libSyntax: create parameter list for function signatures without parameters.
If we don't create the empty parameter list, a 0-parameter function declaration
will not be well-formed.
2017-12-08 15:59:59 -08:00
Rintaro Ishizaki
ddac6ab1b9 Merge pull request #13301 from rintaro/lexer-lextrivia
[Syntax] Serveral improvements for Trivia lexing
2017-12-08 13:07:01 +09:00
Rintaro Ishizaki
5571e5cc76 [Lexer] Clear trivia at the top of lexImpl()
To make sure we only parse trivia for the current token.
2017-12-08 12:08:05 +09:00
Rintaro Ishizaki
9b32c62fbf [Lexer] Add TODO/FIXMEs for lexTrivia 2017-12-08 12:08:05 +09:00
Rintaro Ishizaki
2b1e316cf6 [Syntax] Add parsing hashbang (shebang) as a trivia.
Added GarbageText trivia kind for any skipped text.
2017-12-08 12:07:00 +09:00
Rintaro Ishizaki
e7a393f13f [Lexer] Lex vertical tab '\v' and form-feed '\t' trivias 2017-12-08 11:36:20 +09:00
Rintaro Ishizaki
d767dc39ba [Lexer] Improve implementation of lexTrivia 2017-12-08 11:36:20 +09:00
Xi Ge
f870087805 libSyntax: specialize function declaration syntax node. 2017-12-07 17:28:19 -08:00
Xi Ge
ec5232a359 libSyntax: support function signature. 2017-12-07 14:38:44 -08:00
Xi Ge
1b24d23c1e libSyntax: support function parameter nodes. (#13324) 2017-12-07 14:09:17 -08:00
Rintaro Ishizaki
8bbe4d20ef [libSyntax] Support TypeExpr (#13317)
Just for `Any` for now.
2017-12-07 11:40:05 -08:00
Xi Ge
c4604d700e libSyntax: specialize struct declaration syntax node. (#13307)
To construct struct syntax, this patch first specialized type
inheritance clause. For protocol's class requirement, we currently
treat it as an unknown type.

This patch also teaches SyntaxParsingContext to collect syntax nodes
from back in place. This is useful to squash multiple decl modifiers
for declarations like function. This is not used for struct declaration
because only accessibility modifier is allowed.
2017-12-06 14:12:12 -08:00
Xi Ge
fec040d95e libSyntax: support generic parameter clause. (#13286)
This patch also performs minor refactoring to align syntax parsing
context with the right scope. We start to support the generic clauses
because they are necessary pieces to construct struct or
function syntax node.
2017-12-05 19:34:55 -08:00