Commit Graph

359 Commits

Author SHA1 Message Date
Doug Gregor
7c199b7656 [Syntax] TypeAliasDecl's initializer is not optional 2022-07-13 21:49:23 -07:00
Doug Gregor
73debb48f3 [Syntax] Factor out the detail for a declaration modifier. 2022-07-13 21:49:23 -07:00
Doug Gregor
6552d86bfc [Syntax] The body of a deinitializer is optional 2022-07-13 21:49:23 -07:00
Doug Gregor
1b4197235f [Syntax] Use FunctionSignature for initializer declarations.
Initializer declarations were missing support for `async`, in part
because they deplicated most of the `FunctionSignature` production.
Instead, use `FunctionSignature` consistently and let the presence of a
result type be a semantic error.
2022-07-13 21:49:23 -07:00
Doug Gregor
2f5b638efd [Syntax] Update declaration modifiers list. 2022-07-13 21:49:23 -07:00
Doug Gregor
9b17cc4aae [Syntax] Split ActorDecl into its own syntax node apart from ClassDecl. 2022-07-13 21:49:23 -07:00
Robert Widmann
bad59e6c88 Merge pull request #59981 from CodaFi/shadow-play 2022-07-11 13:53:27 -07:00
Robert Widmann
d4f00f363c Make Initializer Clause of Optional Pattern Binding Optional
Make Initializer Clause of Optional Pattern Binding Optional

See [SE-0345](https://github.com/apple/swift-evolution/blob/main/proposals/0345-if-let-shorthand.md)
"'if let' shorthand for shadowing an existing optional variable"
2022-07-08 19:01:35 -07:00
Robert Widmann
003b362a65 Differentiate Shebang from Garbage
Add #! as an explicit kind of trivia.
2022-07-08 18:28:57 -07:00
Eugene Berdnikov
5742b1d59e Add leading space for left brace 2022-07-08 17:43:18 -07:00
Robert Widmann
e2bb54fcb5 Remove Modeling for Fully-Generic Primary Associated Type Syntax
Constraints in these positions were not accepted. Remove the modeling
for them.
2022-07-08 10:51:25 -07:00
Kim de Vos
0bb409e63c [SwiftSyntax] Add kind and self.element_name 2022-06-29 21:48:21 +02:00
Eugene Berdnikov
4d0054b672 Indentation and line breaks attributes for Switch/Case and Closure 2022-06-14 06:52:17 -07:00
Ben Barham
862f3fc420 [Parse] Set missing contextual keyword token kind for async
Resolves rdar://93080331.
2022-05-13 18:42:09 -07:00
Josh Soref
7bbe79dce3 spelling: specifier
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-23 22:10:33 -04:00
Josh Soref
8d67faf037 spelling: requirement
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-23 22:10:33 -04:00
Josh Soref
65822534b4 spelling: parenthesis
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-23 22:10:33 -04:00
Josh Soref
b7e90f37c1 spelling: omitted
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-23 22:10:33 -04:00
Josh Soref
35a2f8bf0d spelling: expression
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-23 22:10:33 -04:00
Josh Soref
354ee83d8e spelling: declname
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-23 22:10:33 -04:00
Josh Soref
9caa52a7ac spelling: consisting
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-23 22:10:33 -04:00
Josh Soref
d90fa77008 spelling: availability
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-23 22:04:33 -04:00
Daniel Duan
3dfc40898c [NFC] Remove Python 2 imports from __future__ (#42086)
The `__future__` we relied on is now,  where the 3 specific things are
all included [since Python 3.0](https://docs.python.org/3/library/__future__.html):

* absolute_import
* print_function
* unicode_literals
* division

These import statements are no-ops and are no longer necessary.
2022-04-13 14:01:30 -07:00
Allan Shortlidge
2a646dc438 Parse: Require a "before: " label in the first item of the list in the @_backDeploy attribute in order to match the pitched syntax for the attribute. Refactor existing comma separated list parsing code to take advantage of part of it in the attribute parsing. 2022-03-18 11:31:34 -07:00
Robert Widmann
cc0bc22dcb Correct The Parsing of Primary Associated Type Clauses in Protocols
The prior syntax tree did not take into account that the clause itself should own the angle brackets.
2022-03-16 17:28:45 -07:00
Alex Hoppen
7a1792ab4e [Parser] Support 'any' type in SwiftSyntax
Previously, SwiftSyntax wasn’t able to parse 'any' types. Add support for them now.

rdar://90077430
2022-03-15 10:52:05 +01:00
Slava Pestov
7dfc2a20fb Parse: New syntax for primary associated types 2022-03-03 00:08:00 -05:00
Erik Eckstein
f09dfc93a9 Swift SIL: escape effects for function arguments.
Store a list of argument effects in a function, which specify if and how arguments escape.
Such effects can be specified in the Swift source code (for details see docs/ReferenceGuides/UnderscoredAttributes.md) or derived in an optimization pass.

For details see the documentation in SwiftCompilerSources/Sources/SIL/Effects.swift.
2022-01-25 11:29:44 +01:00
Alex Hoppen
f3f2370d90 [gyb_syntax_support] Remove Python code specific to SwiftSyntaxBuilder
These functions/definitions have been migrated to the SwiftSyntax repository.
2022-01-05 19:34:18 +01:00
Hamish Knight
37f16520e6 Prototype regex literal AST and emission
With `-enable-experimental-string-processing`,
start lexing `'` delimiters as regex literals (this
is just a placeholder delimiter for now). The
contents of which gets passed to the libswift
library, which can return an error string to be
emitted, or null for success.

The libswift side isn't yet hooked up to the Swift
regex parser, so for now just emit a dummy
diagnostic for regexes starting with quantifiers.

If successful, build an AST node which will be
emitted as an implicit call to an
`init(_regexString:)` initializer of an in-scope
`Regex` decl (which will eventually be a known
stdlib decl).
2021-12-06 21:16:14 +00:00
Kim de Vos
030e129fd6 Add more types in protocol map 2021-12-05 16:15:48 +01:00
Kim de Vos
ba77a58d47 [SwiftSyntax] Remove default empty string in Token's text
https://github.com/apple/swift-syntax/pull/341
2021-12-02 19:53:08 +01:00
Kim de Vos
6d7d04b095 [SwiftSyntax] Add convenience initializer for BinaryOperatorExpr 2021-12-01 19:51:49 +01:00
Kim de Vos
e99976cbee Add convenience initializers for MemberDeclList 2021-11-29 14:34:51 +01:00
Kim de Vos
6cafe7c071 [SyntaxBuilder] Make String conform to ExpressibleBy protocols 2021-11-17 13:39:02 +01:00
Kim de Vos
3b307b7098 [SyntaxBuilder] Add default conformance to syntax collection elements 2021-11-16 22:43:58 +01:00
Alex Hoppen
3cbc3b96d3 Revert "[SwiftSyntax] Replace ExpressibleAs protocols by ExpressibleBy protocols" 2021-11-16 18:32:51 +01:00
Alex Hoppen
dd1e6cdf2f [SwiftSyntax] Replace ExpressibleAs protocols by ExpressibleBy protocols
The protocols in the standard library are called `ExpressibleBy*` and SwiftSyntax should follow the same naming convention.
2021-11-15 11:03:10 +01:00
Kim de Vos
5e0c6b6f77 Add leading and trailing spacing for SpacedBinaryOperator 2021-11-08 08:26:28 +01:00
Kim de Vos
f9998701ba [SwiftSyntaxBuilder] Add protocol conformance map 2021-10-26 09:23:05 +02:00
Arnold Schwaighofer
71f46a4f25 Add support to syntax tree 2021-10-06 04:54:41 -07:00
Rintaro Ishizaki
b455177f9e [Syntax] Make PostfixIfConfigExpr.base optional
For nested `#if ... #endf` in postfix if-config expression, like:

  baseExpr
    #if COND1
      #if COND2
        .member
      #endif
    #endif

Consider the inner `#if` be a postfix if-config with 'nil' base
expression.

https://bugs.swift.org/browse/SR-14929
2021-07-15 16:38:23 -07:00
Bruno Rocha
1fe3857735 [SE-0290] Add #unavailable 2021-07-02 13:35:11 +02:00
Kim de Vos
a76d71fc02 [SwiftSyntax] Use TokenSyntax
Moving to `TokenSyntax` as then we can use dot notation
2021-06-22 18:08:59 +02:00
Konrad `ktoso` Malawski
5ca4f7edf5 [Distributed] 'distributed' decl modifier for swift-syntax (#38020) 2021-06-22 20:11:40 +09:00
Kim de Vos
b7d4dec54e [SwiftSyntax] Add helper for default value in swift syntax builder inits 2021-06-07 08:49:54 +02:00
Argyrios Kyrtzidis
b6df8b4f4c Merge pull request #37566 from ahoppen/pr/main-actor-closure
[libSyntax] Parse attributes on closures
2021-05-24 10:32:29 -07:00
Alex Hoppen
209a5f4fe3 [libSyntax] Parse attributes on closures
8448e61b3a introduced attribtues on closures. Support them in libSyntax.

Fixes rdar://77923956
2021-05-21 14:58:03 +02:00
Kim de Vos
0b0e20b9af [SwiftSyntax] Added helper for swift buildables 2021-05-20 19:17:53 +02:00
Kim de Vos
779365cca2 [SwiftSyntax]: Use check for suffix instead of contains when checking for token
Syntax kind should end with token not contain it before it is considered as a token
2021-05-12 12:45:45 +02:00