Commit Graph

62 Commits

Author SHA1 Message Date
Jan Svoboda
b0f6168660 [libSyntax] Represent raw string delimiters 2019-05-15 09:15:03 +02:00
kitasuke
b583fef8e2 Consolidate StringInterpolationExpr to StringLiteralExpr 2019-05-12 11:23:00 +09:00
kitasuke
5debb929da Rename StringInterpolationSegments to StringLiteralSegments 2019-05-06 09:37:37 +08:00
kitasuke
94815fae26 Revert "Revert "SR-10469 Unknown syntax for interpolated string literal""
This reverts commit 18dd11ab21.
2019-04-30 22:35:29 +01:00
Mishal Shah
18dd11ab21 Revert "SR-10469 Unknown syntax for interpolated string literal" 2019-04-29 23:09:58 -07:00
kitasuke
790d359257 Set collection element name for ExpressionSegment's Expressions 2019-04-26 07:26:07 +02:00
kitasuke
81ed9cc2f9 Merge branch 'master' into SR-10469-func-call-args_list 2019-04-26 06:29:02 +02:00
Argyrios Kyrtzidis
3612cd3d72 [utils/gyb_syntax_support] Add collection_element_name for when specifying a Child
This is useful to provide `add<ELEMENT_NAME>` APIs for SwiftSyntax that are better named
and without having name conflicts.
2019-04-23 18:14:39 -07:00
kitasuke
abd6dcfece Change expression kind from Expr to FunctionCallArgumentList 2019-04-23 17:54:26 +09:00
Xi Ge
758e4a28c2 SyntaxNodes: subsume DotSelfExpr and ImplicitMemberExpr by MemberAccessExpr.
Per our discussion in another PR, having these three similar nodes at
the same time  may unnecessarily complicate client side.
2019-01-17 14:15:53 -08:00
Xi Ge
9c42e9737b SyntaxNodes: DotSelfExpr should have optional base expression. rdar://46935325 2019-01-16 12:02:52 -08:00
Pavol Vaskovic
53cd115b0e [Gardening] Fix W291 trailing whitespace 2018-11-28 16:57:23 +01:00
Alex Hoppen
8430eff670 [libSyntax] Add syntax coloring based on the syntax tree 2018-07-13 17:48:47 -07:00
Alex Hoppen
7bbb5fa87a [libSyntax] Fix parsing of key paths on specialised generics 2018-04-27 08:10:20 -07:00
Alex Hoppen
94b8a3545b [libSyntax] Fix parsing for KeyPath 2018-04-25 13:30:31 -07:00
Alex Hoppen
c52f4a8131 [libSyntax] Fix parsing of operators passed to higher order functions 2018-04-23 12:23:27 -07:00
Rintaro Ishizaki
338cedd6d5 [Syntax] Parse '#selector' expression syntax 2018-04-12 13:56:04 +09:00
Rintaro Ishizaki
93cd5bce15 [Syntax] Fix typo 2018-03-27 22:58:21 +09:00
Xi Ge
7c905d38af SwiftSyntax: add WithStatementsSyntax trait and make all names consistent. NFC (#14782) 2018-02-22 14:38:29 -08:00
Xi Ge
bdebd8a210 SwiftSyntax: add WithTrailingCommanSyntax trait and fix inconsistent naming. NFC 2018-02-20 12:02:30 -08:00
Xi Ge
f814309f2e SwiftSyntax: Add ParenthesizedSyntax trait and mark various syntax nodes for conformances. NFC 2018-02-19 19:21:59 -08:00
Xi Ge
1b81fcb2b6 SwiftSyntax: Add a trait for those statement nodes with code block as body. (#14726)
This patch also refactors SyntaxNodes code so that protocol conformances
are declared as extensions.
2018-02-19 18:49:07 -08:00
Xi Ge
2b61d4edbb SwiftSyntax: add a mechanism to define traits of syntax nodes to allow abstract access to popular child kinds. NFC (#14668)
Swift syntax APIs lack an abstract way of accessing children. The client has to
down-cast a syntax node to the leaf type to access any of its children. However,
some children are common among different syntax kinds, e.g.
DeclAttributeSyntax and DeclMembers. We should allow an abstract way to
access and modify them, so that clients can avoid logic duplication.

This patch adds a mechanism to define new traits and specify satisfied
traits in specific syntax nodes. A trait is a set of common children
and implemented in Swift as a protocol for syntax nodes to conform to.
As a proof-of-concept, we added two traits for now including DeclGroupSyntax
and BracedSyntax.

Resolves: SR-6931 and SR-6916
2018-02-15 16:41:20 -08:00
Rintaro Ishizaki
6c0af2a24f [Syntax] Introduce CodeBlockItem (#14458)
CodeBlockItem represents Decl, Stmt or Expr that optionally followed by
semi-colon.
SourceFile syntax holds a list of CodeBlockItem.
2018-02-08 10:31:01 +09:00
Rintaro Ishizaki
1eedcb7682 [Syntax] Parse '->' in sequence expression 2018-02-06 15:06:00 +09:00
Rintaro Ishizaki
5dc6b78457 [Syntax] Parse generic specialize expression 2018-02-06 15:05:59 +09:00
Rintaro Ishizaki
9bf4c8af05 [Syntax] Allow tok::dollarident (e.g. $0) for IdentifierExpr 2018-01-23 19:15:06 +09:00
Rintaro Ishizaki
46d681c614 [Syntax] Allow 'self' and 'Self' keyword for IdentifierExpr 2018-01-23 19:15:06 +09:00
Rintaro Ishizaki
7f9578e5f3 [Syntax] Parse "dot self" expression nodes 2018-01-23 19:15:06 +09:00
Xi Ge
6cd5d0bf5e libSyntax: parse several magic identifier expressions.
They include #column, #file, #function and #dsohandle.
2018-01-10 18:02:02 -08:00
Xi Ge
7e4e7ff0bc libSyntax: parser object literal expressions.
This includes color, image and file literals.
2018-01-10 15:38:11 -08:00
Xi Ge
95f09d057e libSyntax: parse editor placeholder expression. (#13840) 2018-01-09 17:23:42 -08:00
Xi Ge
21f4564877 libSyntax: parse key path expressions. (#13813) 2018-01-08 20:54:53 -08:00
Xi Ge
1170a4ff01 libSyntax: parse InOut expression. (#13815) 2018-01-08 18:00:33 -08:00
Xi Ge
cb4bc9eb69 libSyntax: allow SyntaxCollection to specify acceptable element kinds. NFC
Segments list in interpolated string literal accepts two syntax kinds as
elements: StringSegment and ExpressionSegment. This patch generates
factory methods to reject other kinds.
2018-01-04 13:35:39 -08:00
Xi Ge
7476677bb2 libSyntax: create separate node kinds for quote (") and multiline quote (""").
This allows us to serialize the quote tokens without serializing their
underlying text.
2018-01-04 09:08:21 -08:00
Xi Ge
22ce6934bd libSyntax: parse string interpolation expression. (#13708)
A string interpolation expression is composed of { OpenQuote, Segments,
CloseQuote }. To represent OpenQuote, CloseQuote and StringSegment, we have to
introduce new token kinds correspondingly.
2018-01-03 20:41:34 -08:00
Rintaro Ishizaki
2855c9e693 [Syntax] Add support for compound name in expressions (#13630) 2018-01-02 10:53:41 -08:00
Rintaro Ishizaki
8d33f763a4 [Syntax] Parse "implicit member expression " and its postfixes
Unlike libAST, parse '.foo(a)' as:
  <call><implicit-member>.foo</implicit-member><args>a</args></call>
2017-12-25 18:52:41 +09:00
Rintaro Ishizaki
b46bb721c6 [Syntax] Parse "super" and its postfix expressions 2017-12-25 17:47:36 +09:00
Rintaro Ishizaki
5d65b2f510 [Syntax] Parse several suffix expression nodes
* FunctionCallExpr
* SubscriptExpr
* OptionalChainingExpr
* ForcedValueExpr
* PostfixUnaryExpr
2017-12-25 17:21:05 +09:00
Rintaro Ishizaki
8830fdda34 [Syntax] Parse "do statement" syntax node 2017-12-21 17:16:03 +09:00
Xi Ge
b4da5a3c31 libSyntax: use node choice for dictionary expression.
This allows us to support empty dictionary literal.
2017-12-20 18:23:23 -08:00
Xi Ge
21fc2fb92b libSyntax: use node choices for closure parameters.
This is to incorporate two styles of closure parameters: "a, b, c" or "(a:
T1, b: T2, c: T3)".
2017-12-20 18:23:23 -08:00
Rintaro Ishizaki
89d9993f59 [Syntax] Parse matching pattern syntax node
Added support for ExprPattern and UnresolvedPatternExpr.
2017-12-20 19:47:32 +09:00
Rintaro Ishizaki
53b2e0fe14 [Syntax] Parse composition type node 2017-12-15 10:52:10 -08: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
Xi Ge
9e8d0aea81 libSyntax: create syntax node for closure capture list. (#13408) 2017-12-12 20:14:04 -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