Commit Graph

15 Commits

Author SHA1 Message Date
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
Rintaro Ishizaki
8bbe4d20ef [libSyntax] Support TypeExpr (#13317)
Just for `Any` for now.
2017-12-07 11:40:05 -08:00
Xi Ge
5ace363dbc libSyntax: specialize As expression and Is expression. (#13179)
This patch also handles variants like "as!" and "as?".
2017-11-30 15:05:22 -08: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
Xi Ge
036321546b libSyntax: Support tuple expression.
Tuple expression essentially has the same underlying structure as
function call arguments in libSyntax. However, we separate them as
different libSyntax kinds for better usability.

Different from AST, libSyntax currently allows single-child,
label-free tuple expressions (represented as ParenExpr in AST). This is
subject to change if we need to adopt the same differentiation in
libSyntax in the future.
2017-11-27 16:40:30 -08:00
Xi Ge
588ac6b3e8 libSyntax: add several elementary nodes. (#13085)
They are SequenceExpr, AssignmentExpr, and BinaryOperatorExpr.
2017-11-27 13:15:39 -08:00
Xi Ge
a4a01f9121 libSyntax: parse ternary expression.
Along with starting to support ternary expressions, this commit also
slightly changes SyntaxParsingContext APIs as follows:

1. Previously, makeNode() only supports node creation by using the nodes
from the underlying syntax token array; this commit allows it to use the nodes from
the pending syntax list as well.

2. This commit strictly limits that the pending syntax list should never
contain token syntax node.

3. The node kind test shouldn't include unknown kinds. They are noisy.
2017-11-14 23:29:23 -08:00
Xi Ge
3d5eb6e062 libSyntax: parse boolean literal expression. (#12908) 2017-11-13 21:03:42 -08:00
Xi Ge
ea76f585b9 libSyntax: parse DiscardAssignmentExpr and NilLiteralExpr. (#12872) 2017-11-11 11:24:34 -08:00
Xi Ge
a71a03986e libSyntax: Start parsing simple identifier expression. (#12862) 2017-11-10 15:26:37 -08:00
Xi Ge
0d9745f6eb libSyntax: teach parser to parse dictionary and array literals. (#12821)
This commit also adds ArrayExpr and DictionaryExpr to the libSyntax nodes
family. Also, it refactors the original parser code for these two
expressions to better fit to the design of SyntaxParsingContext.

This commit has also fixed two crashers.
2017-11-09 09:00:43 -08:00
Harlan
ade67ca899 [Syntax] Swift libSyntax API (#11320)
* Create Swift libSyntax API

This patch is an initial implementation of the Swift libSyntax API. It
aims to provide all features of the C++ API but exposed to Swift.

It currently resides in SwiftExperimental and will likely exist in a
molten state for a while.

* Only build SwiftSyntax on macOS
2017-08-14 16:47:48 -07: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