Commit Graph

190 Commits

Author SHA1 Message Date
Xi Ge
f25925fc84 Parser: suppress diagnostics when parsing inside inactive code 2019-05-17 12:36:34 -07:00
Xi Ge
c8dd6a9ba1 Parser: avoid skipping inactive code if we are building syntax trees.
If syntax trees are requested, we shouldn't skip inactive code. Notice the
inactive code won't be skipped in SwiftSyntax because we always set
PerformConditionEvaluation false for the in-process parser.

This is mostly needed for testing purposes where we add -verify-syntax-tree
to regular compiler invocations.

rdar://50837165
2019-05-17 12:32:10 -07:00
Jan Svoboda
b0f6168660 [libSyntax] Represent raw string delimiters 2019-05-15 09:15:03 +02:00
kitasuke
9155ed88e0 Use StringLiteralExpr for invalid InterpolatedStringLiteralExpr 2019-05-12 11:23:16 +09:00
kitasuke
b583fef8e2 Consolidate StringInterpolationExpr to StringLiteralExpr 2019-05-12 11:23:00 +09:00
Xi Ge
24f5ba741a Syntax: add Syntax support for property delegate attributes
rdar://50056605
2019-05-02 09:50:40 -07: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
27cb9c4e0c Add test cases for multi expressions in ExpressionSegment 2019-04-27 21:05:55 +02:00
kitasuke
81ed9cc2f9 Merge branch 'master' into SR-10469-func-call-args_list 2019-04-26 06:29:02 +02:00
kitasuke
abd6dcfece Change expression kind from Expr to FunctionCallArgumentList 2019-04-23 17:54:26 +09:00
Xi Ge
644b5ecd53 libSyntax: add support for some type. rdar://49398494 2019-04-19 17:10:53 -07:00
Nathan Hawes
1060d1af1c Merge pull request #24073 from nathawes/inherit-default-values
[ParseableInterfaces] Support inheriting default arguments in module interfaces via '= super'
2019-04-18 22:21:35 -07:00
Nathan Hawes
1e1025291d Add test for the SwiftSyntax tree produced when parsing '= super' in a module interface 2019-04-16 15:21:26 -07:00
Xi Ge
746a88aec8 Syntax: synthesize right brace tokens if they are missing from nominal type decls. 2019-04-15 16:45:26 -07:00
Argyrios Kyrtzidis
7a2127ae39 [syntax parser] Fix another assertion hit related to invalid composition type
Found by the stress tester.
2019-03-17 23:10:04 -07:00
Argyrios Kyrtzidis
375bec4bd1 [syntax parser] Fix assertion hit with invalid type parsing 2019-03-16 22:50:43 -07:00
Xi Ge
a86f89da48 SwiftSyntax Parser: expose parser diagnostics via C API.
This allows SwiftSyntax to listen to emitted diagnostics during
parsing.

rdar://48439271
2019-03-01 15:22:21 -08:00
Xi Ge
d4ecf80cc4 Syntax: add a test for self as member to access. 2019-01-17 14:15:53 -08: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
Saleem Abdulrasool
93e610920f test: port Syntax test to Windows
Replace the inline sed commands with sed scripts to avoid the subshells
on Windows.  Additionally, the unicode handling on Windows causes
problems and using the scripts circumvents that problem.

Implement an inline dos2unix as the BSD sed does not support `-b` and on
Windows, sed will convert the line endings.
2019-01-15 15:37:55 -08:00
Argyrios Kyrtzidis
9c0403761d Merge pull request #21762 from akyrtzi/syntax-parser-clib
Introduce C parser library
2019-01-11 11:19:50 -08:00
Argyrios Kyrtzidis
1dc288fb23 Introduce C parser library
Add a shared library with a C API that provides access to the syntactic parser with callbacks for the inference of raw syntax nodes.
This is primarily intended to be used by SwiftSyntax to speed-up source code parsing for it.
2019-01-09 18:30:45 -08:00
Harlan Haskins
a98db347cd [Syntax] Use absolute path to stdlib in round_trip_stdlib test
This test was disabled for 2 years. Re-enable it, using the absolute
path to the stdlib instead of a relative path.

rdar://30606232
2019-01-08 15:57:22 -08:00
Rintaro Ishizaki
22652f9e88 [Parse] Eliminate backtracking in collection expression parsing
Parsing collection literal expression used to take exponential time
depending on the nesting level of the first element.

Stop using 'parseList()' because using it complicates libSyntax parsing.

rdar://problem/45221238 / https://bugs.swift.org/browse/SR-9220
rdar://problem/38913395 / https://bugs.swift.org/browse/SR-7283
2018-12-25 11:05:23 +09:00
Argyrios Kyrtzidis
cbad3492e4 [Parse/Syntax] Simplify how the final SourceFileSyntax root is formed
Instead of creating multiple CodeBlockItemList nodes, that need to get merged and discarded later on, do this:

* Ensure for libSyntax parsing that we parse the whole file
* Create top-level CodeBlockItem nodes that we just directly wrap with a single CodeBlockItemList node at the end

The importance of this change will become more obvious later on when we'll decouple syntax parsing from the formation of libSyntax tree nodes.
2018-12-10 13:37:15 -08:00
Marc Rasi
bf18697b4f parsing, typechecking, and SILGen for #assert
`#assert` is a new static assertion statement that will let us write
tests for the new constant evaluation infrastructure that we are working
on. `#assert` works by lowering to a `Builtin.poundAssert` SIL
instruction. The constant evaluation infrastructure will look for these
SIL instructions, const-evaluate their conditions, and emit errors if
the conditions are non-constant or false.

This commit implements parsing, typechecking and SILGen for `#assert`.
2018-11-07 16:34:17 -08:00
Mark Lacey
5e0cb1978a Fix libSyntax support for operator decl designated types. 2018-10-11 13:36:14 -07:00
John McCall
32c7e4bbfa Fix libSyntax support for yields with expression lists. 2018-10-09 15:34:54 -04:00
Rintaro Ishizaki
2a1ab7d8e2 Merge pull request #19046 from rintaro/parse-refactor-getsetdecl
[Parse] refactor get/set block parsing
2018-09-01 00:32:57 +09:00
Alex Hoppen
3801bb0e42 [SwiftSyntax] Remove SwiftSyntax from the main swift repository
It has moved to its own repository at https://github.com/apple/swift-syntax
2018-08-30 11:46:22 -07:00
Rintaro Ishizaki
51b7168d05 [Parse] Refactor get/set accessor parsing
* Use 'parseAbstractFunctionBody()' for accessors as well. This
  simplifies the implementation, and makes 'parseAbstractFunctionBody()'
  the single point of parsing body of every 'AbstructFunctionDecl' types.
2018-08-29 18:01:21 +09:00
Alex Hoppen
34a89d45e2 [libSyntax] Make the ByteTree format forwards-compatible 2018-08-22 12:07:57 -07:00
Alex Hoppen
32a3a31684 [libSyntax] Reenable caching of token nodes 2018-08-13 15:14:37 -07:00
Alex Hoppen
57196f8902 [libSyntax] Enable serialization of syntax trees for incremental transfer 2018-07-23 12:32:49 -07:00
Alex Hoppen
6568feb921 Merge pull request #18022 from ahoppen/invalid-type-fix
[libSyntax] Fix a crash that happened when parsing an invalid type
2018-07-18 17:18:20 -07:00
Alex Hoppen
53dfecd5fc [libSyntax] Fix a crash that happened when parsing an invalid type 2018-07-18 13:10:35 -07:00
Alex Hoppen
9d59cd286b [incrParse] Add a stable id to the syntax nodes
The id is meant to be stable across incremental parses
2018-07-13 16:56:03 -07:00
Alex Hoppen
bc528237e5 [libSyntax] Adjust tests for improved syntax parsing behaviour 2018-05-22 09:07:56 -07:00
Alex Hoppen
b2ebc96510 [incrParse] Reparse a node if the next leaf node has been modified 2018-05-22 09:07:55 -07:00
Alex Hoppen
082086c687 [libSyntax] Fix parsing of StringLiterals with invalid interpolation segments 2018-05-22 08:52:40 -07:00
Alex Hoppen
b904194998 [libSyntax] Add support for parsing #sourceLocation directives 2018-05-22 08:52:31 -07:00
Rintaro Ishizaki
9b182d108f [Syntax] Verify syntax tree only if we reached the real EOF
We used to verify the tree for every parseIntoSourceFile() invocation.
2018-05-08 16:38:11 +09:00
Rintaro Ishizaki
0480cc74aa [Syntax] Add test case for '-verify-syntax-tree' 2018-05-08 16:34:49 +09:00
Alex Hoppen
7bbb5fa87a [libSyntax] Fix parsing of key paths on specialised generics 2018-04-27 08:10:20 -07:00
Alex Hoppen
3fd922a9d5 [libSyntax] Accept non-standard accessor kinds 2018-04-27 08:10:20 -07:00
Alex Hoppen
00604fb3dc [libSyntax] Add -verify-syntax-tree frontend flag
This will parse the source file into a libSyntax tree and verify that no
unknown nodes exist within it
2018-04-27 07:51:08 -07:00
Xi Ge
e8c80878ed Merge pull request #16158 from nkcsgexi/synthesize-node
libSyntax: add a mechanism to synthesize syntax nodes in SyntaxParsingContext.
2018-04-26 11:24:50 -07:00
Xi Ge
a1a6c19959 libSyntax: add a mechanism to synthesize syntax nodes in SyntaxParsingContext.
To enhance the error-recovery of syntax parsing, this patch allows the
parser to synthesize missing nodes to satisfy the requirement of a
syntax node under parsing. As proof-of-concept, we synthesize r-braces
for function body to avoid regressing a function decl to an unknown
decl.
2018-04-26 10:48:57 -07:00