Commit Graph

12 Commits

Author SHA1 Message Date
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
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
bb4253e3d3 Convert generic-requirement-list to SyntaxCollection, implement function-declaration
This mostly wraps up the first cut of function-declaration.

https://bugs.swift.org/browse/SR-4043
2017-03-02 17:02:50 -08:00
David Farler
ceb3babbc6 [Syntax] Short diversion converting StmtListSyntax to a SyntaxCollection 2017-03-02 17:02:50 -08:00
David Farler
f900fbdcea Implement function-declaration in lib/Syntax
https://bugs.swift.org/browse/SR-4043
2017-03-02 17:02:50 -08:00
David Farler
18ee4e19a1 Implement declaration-modifier(s) in lib/Syntax
- declaration-modifier
  - DeclModifierSyntax
- declaration-modifiers
  - DeclModifierListSyntax

https://bugs.swift.org/browse/SR-4146
2017-03-02 17:02:50 -08:00
David Farler
288da665e3 Implement function-signature in lib/Syntax
Part of:
https://bugs.swift.org/browse/SR-4043
2017-03-02 17:02:50 -08:00
David Farler
e70a65882f [Syntax] function-parameter-list is now a SyntaxCollection
Removes some code duplication.
2017-03-02 17:02:50 -08:00
David Farler
cac51bd69b Implement function-parameter-list and friends in lib/Syntax
Implements the following grammar productions:

- function-parameter-list
- function-parameter

This is mostly reusable for other flavors of function declarations,
such as initializers and whatnot, but those will have separate
top-level syntax nodes.

https://bugs.swift.org/browse/SR-4067
2017-03-02 17:02:50 -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
David Farler
7ee42994c8 Start the Syntax library and optional full token lexing
Add an option to the lexer to go back and get a list of "full"
tokens, which include their leading and trailing trivia, which
we can index into from SourceLocs in the current AST.

This starts the Syntax sublibrary, which will support structured
editing APIs. Some skeleton support and basic implementations are
in place for types and generics in the grammar. Yes, it's slightly
redundant with what we have right now. lib/AST conflates syntax
and semantics in the same place(s); this is a first step in changing
that to separate the two concepts for clarity and also to get closer
to incremental parsing and type-checking. The goal is to eventually
extract all of the syntactic information from lib/AST and change that
to be more of a semantic/symbolic model.

Stub out a Semantics manager. This ought to eventually be used as a hub
for encapsulating lazily computed semantic information for syntax nodes.
For the time being, it can serve as a temporary place for mapping from
Syntax nodes to semantically full lib/AST nodes.

This is still in a molten state - don't get too close, wear appropriate
proximity suits, etc.
2017-02-17 12:57:04 -08:00