Commit Graph

19 Commits

Author SHA1 Message Date
Alex Hoppen
73cece2803 [libSyntax] Make SyntaxFactory methods instance methods
This saves us from passing in the SyntaxArena every time a new node is
created.
2021-03-03 11:02:55 +01:00
Alex Hoppen
9ff88b2839 [libSyntax] Fix SwiftSyntaxTests broken due to change SyntaxFactory API
This fixes the SwiftSyntaxTests that were broken because the
SyntaxFactory API now requires an Arena in which the nodes should be
created.
2021-03-01 09:43:54 +01:00
Alex Hoppen
db3a520bc7 [libSyntax] Adjust tests for raw trivia being stored in RawSyntax 2021-02-05 08:15:54 +01:00
Rintaro Ishizaki
2e094a556d [Syntax] Update for braceless multiple trailing closure syntax 2020-05-06 01:56:41 -04: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
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
Xi Ge
ddd643fe89 syntax: perform rename to avoid name collision in syntax builder. NFC 2019-04-20 16:04:41 -07: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
e7cfae0ba9 [libSyntax] Support parsing type-identifier 2017-11-29 09:57:59 +09:00
Xi Ge
e560170a60 libSyntax: Parse member access expression. (#13119)
* libSyntax: Parse member access expression.

This patch uses createNodeInPlace from syntax parsing context API to
merge an expression with its suffix to create recursive nodes such as
member access expression.

Meanwhile, this patch breaks down a signed integer or float literal to a
prefix operator expression. This expression consists of two parts: an
operator and the following expression. This makes literals like "+1" or
"-1" no different from other prefix unary expressions such as "!true".
2017-11-28 16:29:50 -08:00
Harlan
a5098e6b69 Generate libSyntax API (#10926)
* Generate libSyntax API

This patch removes the hand-rolled libSyntax API and replaces it with an
API that's entirely automatically generated. This means the API is
guaranteed to be internally stylistically and functionally consistent.
2017-07-25 18:19:58 -07:00
Harlan
70089a7bcc [Syntax] Represent TokenSyntax as a Syntax node (#10606)
Previously, users of TokenSyntax would always deal with RC<TokenSyntax>
which is a subclass of RawSyntax. Instead, provide TokenSyntax as a
fully-realized Syntax node, that will always exist as a leaf in the
Syntax tree.

This hides the implementation detail of RawSyntax and SyntaxData
completely from clients of libSyntax, and paves the way for future
generation of Syntax nodes.
2017-06-27 11:08:10 -07:00
practicalswift
797c2d8118 [gardening] Fix end of namespace comments 2017-04-20 22:01:01 +02:00
practicalswift
431e5a1440 [gardening] Use consistent end of namespace comments 2017-04-20 13:47:10 +02:00
Harlan Haskins
25b6b77bce Change duplicate tests 2017-03-21 09:24:42 -07:00
Harlan Haskins
c2aeb55119 Add tests for IntegerLiteralExprSyntax.
This also fixes a typo in makePrefixOperator and implements
IntegerLiteralExprSyntax::withSign.
2017-03-21 09:24:42 -07:00
David Farler
7ce3b81001 Add generic Syntax collection for unbounded list of nodes
Just a little reusable collection type for things like argument lists,
statement lists, etc.
2017-03-02 17:02:50 -08:00
David Farler
c8bb2b8c32 [Syntax] Implement function-call-expression in lib/Syntax
Also includes for its substructure:
- function-call-argument
- function-call-argument-list
- symbolic-reference-expression (for the call target)

https://bugs.swift.org/browse/SR-4044
2017-02-27 13:57:27 -08:00
David Farler
c343298b8f [Syntax] Implement return-statement and integer-literal-expr
A return statement needs something to return, so implement
integer-literal-expression too. This necessarily also forced
UnknownExprSyntax, UnknownStmtSyntax, and UnknownDeclSyntax,
which are stand-in token buckets for when we don't know
how to transform/migrate an AST.

This commit also contains the core function for caching
SyntaxData children. This is highly tricky code, with some
detailed comments in SyntaxData.{h,cpp}. The gist is that
we have to atomically swap in a SyntaxData pointer into the
child field, so we can maintain pointer identity of SyntaxData
nodes, while still being able to cache them internally.

To prove that this works, there is a multithreaded test that
checks that two threads can ask for a child that hasn't been
cached yet without crashing or violating pointer identity.

https://bugs.swift.org/browse/SR-4010
2017-02-22 18:45:29 -08:00