Commit Graph

79 Commits

Author SHA1 Message Date
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
Xi Ge
1015a6024d Syntax: use child name instead of type name for gyb-generated functions
ParsedSyntaxBuilder has a convenient function to add member to a syntax-collection
child. The function name uses the type name of the collection's members,
which can lead to name collision. This patch renames it.
2019-04-19 18:16:13 -07:00
bannzai
f425c39e60 Add FunctionParameterWithEllipsis test case 2019-01-30 02:26:33 +09:00
Saleem Abdulrasool
e07c00c652 Syntax: correct implementation for removing
`llvm::ArrayRef<T>` does not define `erase`.  However, since the intent
here is to remove the last n elements, we can use `drop_back` instead.
Furthermore, replace the direct use of `Layout` with `getLayout()`.
This was identified by gcc 8.2.
2018-10-29 11:39:31 -07:00
Alex Hoppen
705f5b79a2 [libSyntax] Rename getAbsolutePosition-related methods for more clarity 2018-07-19 09:15:53 -07:00
Alex Hoppen
1b3baf908f [incrParse] Add error nodes to the end of a CodeBlockItem
Creating a new CodeBlockItem meant that when doing an edit in the error
nodes, the prefix gets reused and thus the code is parsed as invalid
although it is not.
2018-05-22 09:07:55 -07:00
Xi Ge
5a8053e7ef libSyntax: add getAbsoluteEndPosition() method to syntax nodes.
This implementation uses sibling's absolute start position to help
populate caches while getting the end position.
2018-05-01 12:06:41 -07:00
Alex Hoppen
3e9ae802c2 [libSyntax] Make parsing of attribute arguments more structured
This also fixes several issues where attribute arguments could not be
parsed as a TokenList since some of its arguments already had structure
and were not tokens
2018-04-24 13:18:15 -07:00
Rintaro Ishizaki
66d400eb1b [Syntax] Parse 'enum' and 'case' declaration (#15704) 2018-04-04 08:38:08 +09:00
swift-ci
8d3b02d58f Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-02-07 17:37:55 -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
swift-ci
d3df4417c3 Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-02-05 18:57:56 -08:00
Rintaro Ishizaki
ba58a2994d [Syntax] Parse associatedtype declaration
Also, added generic where clause to typealias declaration.
2018-02-06 09:33:12 +09:00
swift-ci
bfaad1d49b Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-02-01 18:18:09 -08:00
Rintaro Ishizaki
057254dbc1 [Syntax] Bump allocate and cache/reuse RawSyntax
Introduced SyntaxArena for managing memory and cache.

SyntaxArena holds BumpPtrAllocator as a allocation storage.
RawSyntax is now able to be constructed with normal heap allocation, or
by SyntaxArena. RawSyntax has ManualMemory flag which indicates it's managed by
SyntaxArena. If the flag is true, its Retain()/Release() is no-op thus it's
never destructed by IntrusiveRefCntPtr.
This speedups the memory allocation for RawSyntax.

Also, in Syntax parsing, "token" RawSyntax is reused if:
a) It's not string literal with >16 length; and
b) It doesn't contain random text trivia (e.g. comment).
This reduces the overall allocation cost.
2018-02-02 01:27:06 +09:00
swift-ci
19aa5ea6d2 Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-01-22 14:51:20 -08:00
Rintaro Ishizaki
98fc073e2e [Syntax] Don't rebuild Syntax with RawSyntax in SyntaxVisitor (#14057)
We don't guarantee RawSyntax nodes as unique object in the tree, while
we do that for SyntaxData. We shouldn't recreate SyntaxData once it was
built.
2018-01-22 14:24:20 -08:00
swift-ci
85cef29e2b Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-01-17 23:24:08 -08:00
Rintaro Ishizaki
0780c529c4 [Syntax] Unify RawSyntax and RawTokenSyntax using union and TrailingObjects
It better matches with SwiftSyntax model.

Using TrailingObjects reduces the number of heap allocation which
gains 18% performance improvement.
2018-01-18 14:49:46 +09:00
swift-ci
f6817ef944 Merge remote-tracking branch 'origin/master' into master-next 2017-12-25 05:49:31 -08:00
Rintaro Ishizaki
5d65b2f510 [Syntax] Parse several suffix expression nodes
* FunctionCallExpr
* SubscriptExpr
* OptionalChainingExpr
* ForcedValueExpr
* PostfixUnaryExpr
2017-12-25 17:21:05 +09:00
swift-ci
734f1b8fb1 Merge remote-tracking branch 'origin/master' into master-next 2017-12-22 00:09:03 -08:00
omochimetaru
9b7f2502c4 [Syntax] line number counting for CRLF 2017-12-22 03:46:12 +09:00
swift-ci
ab66b86518 Merge remote-tracking branch 'origin/master' into master-next 2017-12-18 16:09:16 -08:00
Xi Ge
fe1a4ca0d2 libSyntax: create libSyntax node for var decl accessors. 2017-12-18 15:16:14 -08:00
swift-ci
bb16a84204 Merge remote-tracking branch 'origin/master' into master-next 2017-12-15 11:09:35 -08:00
Rintaro Ishizaki
53b2e0fe14 [Syntax] Parse composition type node 2017-12-15 10:52:10 -08:00
swift-ci
e3e6dc9c79 Merge remote-tracking branch 'origin/master' into master-next 2017-12-14 17:49:31 -08:00
Xi Ge
b4b638651d libSyntax: create syntax node for typealias declarations. (#13450) 2017-12-14 17:44:54 -08:00
swift-ci
6349dc9aa0 Merge remote-tracking branch 'origin/master' into master-next 2017-12-14 08:29:34 -08:00
Rintaro Ishizaki
e616b2ad37 [Syntax] Use initializer clause syntax node for function parameter (#13430) 2017-12-14 08:12:10 -08:00
swift-ci
c920a92bb1 Merge remote-tracking branch 'origin/master' into master-next 2017-12-14 01:09:50 -08:00
Rintaro Ishizaki
ef29650acd [Syntax] Parse: add support for TupleType and FunctionType
For now using SyntaxParsingContext.
2017-12-14 14:55:27 +09:00
swift-ci
12c6729768 Merge remote-tracking branch 'origin/master' into master-next 2017-12-13 16:49:36 -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
swift-ci
d1e377b947 Merge remote-tracking branch 'origin/master' into master-next 2017-12-08 14:08:50 -08: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
swift-ci
4d15d2f087 Merge remote-tracking branch 'origin/master' into master-next 2017-12-07 14:09:54 -08:00
Xi Ge
1b24d23c1e libSyntax: support function parameter nodes. (#13324) 2017-12-07 14:09:17 -08:00
Bob Wilson
390058972a [master-next] Use PRIVATE in target_link_libraries for executables
This is needed to work with LLVM r319840.
2017-12-06 21:55:22 -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
Xi Ge
1a7f1911b8 libSyntax: support declaration modifiers, like static, private, etc. (#13221)
Some declaration modifiers may have more details attached, like
"private(set)". This patch represents the detail part "(set)" as a token
list.
2017-12-04 13:03:02 -08:00
Xi Ge
68348944e2 libSyntax: parse declaration attribute list (@attributes). (#13212)
This commit starts to support syntax nodes for @ attributes list for
declarations. These attributes don't include modifiers like "static" or
access keywords. Along with the function change, the commit refactors
some existing code to reduce duplication.
2017-12-01 16:15:17 -08:00
Rintaro Ishizaki
d389a812e2 [libSyntax] Support parsing postfix type nodes
* OptionalType (?)
* ImplicitlyUnwrappedOptional (!)
* MetatypeType (.Type, .Protocol)
2017-11-30 14:31:21 +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
Harlan Haskins
0e61e50ebb Fix UnknownSyntaxTests. One test still fails. 2017-06-23 11:59:16 -07:00