# 文法のまとめ(Summary of the Grammar)

最終更新日: 2024/6/23\
原文: <https://docs.swift.org/swift-book/ReferenceManual/zzSummaryOfTheGrammar.html>

## Lexical Structure(構文の構造)

> Grammar of whitespace:
>
> *whitespace* → *whitespace-item* *whitespace?*\
> \&#xNAN;*whitespace-item* → *line-break*\
> \&#xNAN;*whitespace-item* → *inline-space*\
> \&#xNAN;*whitespace-item* → *comment*\
> \&#xNAN;*whitespace-item* → *multiline-comment*\
> \&#xNAN;*whitespace-item* → U+0000, U+000B, または U+000C
>
> *line-break* → U+000A\
> \&#xNAN;*line-break* → U+000D\
> \&#xNAN;*line-break* → U+000A の前のU+000D
>
> *inline-spaces* → *inline-space* *inline-spaces?*\
> \&#xNAN;*inline-space* → U+0009 または U+0020
>
> *comment* → **`//`** *comment-text* *line-break*\
> \&#xNAN;*multiline-comment* → **`/*`** *multiline-comment-text* **`*/`**
>
> *comment-text* → *comment-text-item* *comment-text?*\
> \&#xNAN;*comment-text-item* → U+000A または U+000D を除く任意のUnicodeスカラ値
>
> *multiline-comment-text* → *multiline-comment-text-item* *multiline-comment-text?*\
> \&#xNAN;*multiline-comment-text-item* → *multiline-comment*\
> \&#xNAN;*multiline-comment-text-item* → *comment-text-item*\
> \&#xNAN;*multiline-comment-text-item* → **`/*`** または **`*/`** を除く任意のUnicodeスカラ値

> Grammar of an identifier:
>
> *identifier* → *identifier-head* *identifier-characters?*\
> \&#xNAN;*identifier* → **`` ` ``** *identifier-head* *identifier-characters?* **`` ` ``**\
> \&#xNAN;*identifier* → *implicit-parameter-name*\
> \&#xNAN;*identifier* → *property-wrapper-projection*\
> \&#xNAN;*identifier-list* → *identifier* | *identifier* **`,`** *identifier-list*
>
> *identifier-head* → 大文字または小文字の A \~ Z\
> \&#xNAN;*identifier-head* → **`_`**\
> \&#xNAN;*identifier-head* → U+00A8, U+00AA, U+00AD, U+00AF, U+00B2–U+00B5, または U+00B7–U+00BA\
> \&#xNAN;*identifier-head* → U+00BC–U+00BE, U+00C0–U+00D6, U+00D8–U+00F6, または U+00F8–U+00FF\
> \&#xNAN;*identifier-head* → U+0100–U+02FF, U+0370–U+167F, U+1681–U+180D, または U+180F–U+1DBF\
> \&#xNAN;*identifier-head* → U+1E00–U+1FFF\
> \&#xNAN;*identifier-head* → U+200B–U+200D, U+202A–U+202E, U+203F–U+2040, U+2054, または U+2060–U+206F\
> \&#xNAN;*identifier-head* → U+2070–U+20CF, U+2100–U+218F, U+2460–U+24FF, または U+2776–U+2793\
> \&#xNAN;*identifier-head* → U+2C00–U+2DFF または U+2E80–U+2FFF\
> \&#xNAN;*identifier-head* → U+3004–U+3007, U+3021–U+302F, U+3031–U+303F, または U+3040–U+D7FF\
> \&#xNAN;*identifier-head* → U+F900–U+FD3D, U+FD40–U+FDCF, U+FDF0–U+FE1F, または U+FE30–U+FE44\
> \&#xNAN;*identifier-head* → U+FE47–U+FFFD\
> \&#xNAN;*identifier-head* → U+10000–U+1FFFD, U+20000–U+2FFFD, U+30000–U+3FFFD, または U+40000–U+4FFFD\
> \&#xNAN;*identifier-head* → U+50000–U+5FFFD, U+60000–U+6FFFD, U+70000–U+7FFFD, または U+80000–U+8FFFD\
> \&#xNAN;*identifier-head* → U+90000–U+9FFFD, U+A0000–U+AFFFD, U+B0000–U+BFFFD, または U+C0000–U+CFFFD\
> \&#xNAN;*identifier-head* → U+D0000–U+DFFFD または U+E0000–U+EFFFD
>
> *identifier-character* → 数値 0 \~ 9\
> \&#xNAN;*identifier-character* → U+0300–U+036F, U+1DC0–U+1DFF, U+20D0–U+20FF, または U+FE20–U+FE2F\
> \&#xNAN;*identifier-character* → *identifier-head*\
> \&#xNAN;*identifier-characters* → *identifier-character* *identifier-characters?*
>
> *implicit-parameter-name* → **`$`** *decimal-digits*\
> \&#xNAN;*property-wrapper-projection* → **`$`** *identifier-characters*

> Grammar of a literal:
>
> *literal* → *numeric-literal* | *string-literal* | *regular-expression-literal* | *boolean-literal* | *nil-literal*
>
> *numeric-literal* → **`-`***?* *integer-literal* | **`-`***?* *floating-point-literal*\
> \&#xNAN;*boolean-literal* → **`true`** | **`false`**\
> \&#xNAN;*nil-literal* → **`nil`**

> Grammar of an integer literal:
>
> *integer-literal* → *binary-literal*\
> \&#xNAN;*integer-literal* → *octal-literal*\
> \&#xNAN;*integer-literal* → *decimal-literal*\
> \&#xNAN;*integer-literal* → *hexadecimal-literal*
>
> *binary-literal* → **`0b`** *binary-digit* *binary-literal-characters?*\
> \&#xNAN;*binary-digit* → 数値 0 または 1\
> \&#xNAN;*binary-literal-character* → *binary-digit* | **`_`**\
> \&#xNAN;*binary-literal-characters* → *binary-literal-character* *binary-literal-characters?*
>
> *octal-literal* → **`0o`** *octal-digit* *octal-literal-characters?*\
> \&#xNAN;*octal-digit* → 数値 0 \~ 7\
> \&#xNAN;*octal-literal-character* → *octal-digit* | **`_`**\
> \&#xNAN;*octal-literal-characters* → *octal-literal-character* *octal-literal-characters?*
>
> *decimal-literal* → *decimal-digit* *decimal-literal-characters?*\
> \&#xNAN;*decimal-digit* → 数値 0 \~ 9\
> \&#xNAN;*decimal-digits* → *decimal-digit* *decimal-digits?*\
> \&#xNAN;*decimal-literal-character* → *decimal-digit* | **`_`**\
> \&#xNAN;*decimal-literal-characters* → *decimal-literal-character* *decimal-literal-characters?*
>
> *hexadecimal-literal* → **`0x`** *hexadecimal-digit* *hexadecimal-literal-characters?*\
> \&#xNAN;*hexadecimal-digit* → 数値 0 \~ 9, a \~ f、または A \~ F\
> \&#xNAN;*hexadecimal-literal-character* → *hexadecimal-digit* | **`_`**\
> \&#xNAN;*hexadecimal-literal-characters* → *hexadecimal-literal-character* *hexadecimal-literal-characters?*

> Grammar of a floating-point literal:
>
> *floating-point-literal* → *decimal-literal* *decimal-fraction?* *decimal-exponent?*\
> \&#xNAN;*floating-point-literal* → *hexadecimal-literal* *hexadecimal-fraction?* *hexadecimal-exponent*
>
> *decimal-fraction* → **`.`** *decimal-literal*\
> \&#xNAN;*decimal-exponent* → *floating-point-e* *sign?* *decimal-literal*
>
> *hexadecimal-fraction* → **`.`** *hexadecimal-digit* *hexadecimal-literal-characters?*\
> \&#xNAN;*hexadecimal-exponent* → *floating-point-p* *sign?* *decimal-literal*
>
> *floating-point-e* → **`e`** | **`E`**\
> \&#xNAN;*floating-point-p* → **`p`** | **`P`**\
> \&#xNAN;*sign* → **`+`** | **`-`**

> Grammar of a string literal:
>
> *string-literal* → *static-string-literal* | *interpolated-string-literal*
>
> *string-literal-opening-delimiter* → *extended-string-literal-delimiter?* **`"`**\
> \&#xNAN;*string-literal-closing-delimiter* → **`"`** *extended-string-literal-delimiter?*
>
> *static-string-literal* → *string-literal-opening-delimiter* *quoted-text?* *string-literal-closing-delimiter*\
> \&#xNAN;*static-string-literal* → *multiline-string-literal-opening-delimiter* *multiline-quoted-text?* *multiline-string-literal-closing-delimiter*
>
> *multiline-string-literal-opening-delimiter* → *extended-string-literal-delimiter?* **`"""`**\
> \&#xNAN;*multiline-string-literal-closing-delimiter* → **`"""`** *extended-string-literal-delimiter?*\
> \&#xNAN;*extended-string-literal-delimiter* → **`#`** *extended-string-literal-delimiter?*
>
> *quoted-text* → *quoted-text-item* *quoted-text?*\
> \&#xNAN;*quoted-text-item* → *escaped-character*\
> \&#xNAN;*quoted-text-item* → **`"`**, **`\`**, U+000A、または U+000D を除く任意のUnicodeスカラ値
>
> *multiline-quoted-text* → *multiline-quoted-text-item* *multiline-quoted-text?*\
> \&#xNAN;*multiline-quoted-text-item* → *escaped-character*\
> \&#xNAN;*multiline-quoted-text-item* → **`\`** U+000A、または U+000D を除く任意のUnicodeスカラ値\
> \&#xNAN;*multiline-quoted-text-item* → *escaped-newline*
>
> *interpolated-string-literal* → *string-literal-opening-delimiter* *interpolated-text?* *string-literal-closing-delimiter*\
> \&#xNAN;*interpolated-string-literal* → *multiline-string-literal-opening-delimiter* *multiline-interpolated-text?* *multiline-string-literal-closing-delimiter*
>
> *interpolated-text* → *interpolated-text-item* *interpolated-text?*\
> \&#xNAN;*interpolated-text-item* → **`\(`** *expression* **`)`** | *quoted-text-item*
>
> *multiline-interpolated-text* → *multiline-interpolated-text-item* *multiline-interpolated-text?*\
> \&#xNAN;*multiline-interpolated-text-item* → **`\(`** *expression* **`)`** | *multiline-quoted-text-item*
>
> *escape-sequence* → **`\`** *extended-string-literal-delimiter*\
> \&#xNAN;*escaped-character* → *escape-sequence* **`0`** | *escape-sequence* **`\`** | *escape-sequence* **`t`** | *escape-sequence* **`n`** | *escape-sequence* **`r`** | *escape-sequence* **`"`** | *escape-sequence* **`'`**\
> \&#xNAN;*escaped-character* → *escape-sequence* **`u`** **`{`** *unicode-scalar-digits* **`}`**\
> \&#xNAN;*unicode-scalar-digits* → 1桁から8桁の16進数
>
> *escaped-newline* → *escape-sequence* *inline-spaces?* *line-break*

> Grammar of a regular expression literal:
>
> *regular-expression-literal* → *regular-expression-literal-opening-delimiter* *regular-expression* *regular-expression-literal-closing-delimiter*\
> \&#xNAN;*regular-expression* → 任意の正規表現
>
> *regular-expression-literal-opening-delimiter* → *extended-regular-expression-literal-delimiter?* **`/`**\
> \&#xNAN;*regular-expression-literal-closing-delimiter* → **`/`** *extended-regular-expression-literal-delimiter?*
>
> *extended-regular-expression-literal-delimiter* → **`#`** *extended-regular-expression-literal-delimiter?*

> Grammar of operators:
>
> *operator* → *operator-head* *operator-characters?*\
> \&#xNAN;*operator* → *dot-operator-head* *dot-operator-characters*
>
> *operator-head* → **`/`** | **`=`** | **`-`** | **`+`** | **`!`** | **`*`** | **`%`** | **`<`** | **`>`** | **`&`** | **`|`** | **`^`** | **`~`** | **`?`**\
> \&#xNAN;*operator-head* → U+00A1–U+00A7\
> \&#xNAN;*operator-head* → U+00A9 または U+00AB\
> \&#xNAN;*operator-head* → U+00AC または U+00AE\
> \&#xNAN;*operator-head* → U+00B0–U+00B1\
> \&#xNAN;*operator-head* → U+00B6, U+00BB, U+00BF, U+00D7, または U+00F7\
> \&#xNAN;*operator-head* → U+2016–U+2017\
> \&#xNAN;*operator-head* → U+2020–U+2027\
> \&#xNAN;*operator-head* → U+2030–U+203E\
> \&#xNAN;*operator-head* → U+2041–U+2053\
> \&#xNAN;*operator-head* → U+2055–U+205E\
> \&#xNAN;*operator-head* → U+2190–U+23FF\
> \&#xNAN;*operator-head* → U+2500–U+2775\
> \&#xNAN;*operator-head* → U+2794–U+2BFF\
> \&#xNAN;*operator-head* → U+2E00–U+2E7F\
> \&#xNAN;*operator-head* → U+3001–U+3003\
> \&#xNAN;*operator-head* → U+3008–U+3020\
> \&#xNAN;*operator-head* → U+3030
>
> *operator-character* → *operator-head*\
> \&#xNAN;*operator-character* → U+0300–U+036F\
> \&#xNAN;*operator-character* → U+1DC0–U+1DFF\
> \&#xNAN;*operator-character* → U+20D0–U+20FF\
> \&#xNAN;*operator-character* → U+FE00–U+FE0F\
> \&#xNAN;*operator-character* → U+FE20–U+FE2F\
> \&#xNAN;*operator-character* → U+E0100–U+E01EF\
> \&#xNAN;*operator-characters* → *operator-character* *operator-characters?*
>
> *dot-operator-head* → **`.`**\
> \&#xNAN;*dot-operator-character* → **`.`** | *operator-character*\
> \&#xNAN;*dot-operator-characters* → *dot-operator-character* *dot-operator-characters?*
>
> *infix-operator* → *operator*\
> \&#xNAN;*prefix-operator* → *operator*\
> \&#xNAN;*postfix-operator* → *operator*

## Types(型)

> Grammar of a type:
>
> *type* → *function-type*\
> \&#xNAN;*type* → *array-type*\
> \&#xNAN;*type* → *dictionary-type*\
> \&#xNAN;*type* → *type-identifier*\
> \&#xNAN;*type* → *tuple-type*\
> \&#xNAN;*type* → *optional-type*\
> \&#xNAN;*type* → *implicitly-unwrapped-optional-type*\
> \&#xNAN;*type* → *protocol-composition-type*\
> \&#xNAN;*type* → *opaque-type*\
> \&#xNAN;*type* → *metatype-type*\
> \&#xNAN;*type* → *any-type*\
> \&#xNAN;*type* → *self-type*\
> \&#xNAN;*type* → **`(`** *type* **`)`**

> Grammar of a type identifier:
>
> *type-identifier* → *type-name* *generic-argument-clause?* | *type-name* *generic-argument-clause?* **`.`** *type-identifier*\
> \&#xNAN;*type-name* → *identifier*

> Grammar of a tuple type:
>
> *tuple-type* → **`(`** **`)`** | **`(`** *tuple-type-element* **`,`** *tuple-type-element-list* **`)`**\
> \&#xNAN;*tuple-type-element-list* → *tuple-type-element* | *tuple-type-element* **`,`** *tuple-type-element-list*\
> \&#xNAN;*tuple-type-element* → *element-name* *type-annotation* | *type*\
> \&#xNAN;*element-name* → *identifier*

> Grammar of a function type:
>
> *function-type* → *attributes?* *function-type-argument-clause* **`async`***?* *throws-clause?* **`->`** *type*
>
> *function-type-argument-clause* → **`(`** **`)`**\
> \&#xNAN;*function-type-argument-clause* → **`(`** *function-type-argument-list* **`...`***?* **`)`**
>
> *function-type-argument-list* → *function-type-argument* | *function-type-argument* **`,`** *function-type-argument-list*\
> \&#xNAN;*function-type-argument* → *attributes?* **`inout`***?* *type* | *argument-label* *type-annotation*\
> \&#xNAN;*argument-label* → *identifier*
>
> *throws-clause* → **`throws`** | **`throws`** **`(`** *type* **`)`**

> Grammar of an array type:
>
> *array-type* → **`[`** *type* **`]`**

> Grammar of a dictionary type:
>
> *dictionary-type* → **`[`** *type* **`:`** *type* **`]`**

> Grammar of an optional type:
>
> *optional-type* → *type* **`?`**

> Grammar of an implicitly unwrapped optional type:
>
> *implicitly-unwrapped-optional-type* → *type* **`!`**

> Grammar of a protocol composition type:
>
> *protocol-composition-type* → *type-identifier* **`&`** *protocol-composition-continuation*\
> \&#xNAN;*protocol-composition-continuation* → *type-identifier* | *protocol-composition-type*

> Grammar of an opaque type:
>
> *opaque-type* → **`some`** *type*

> Grammar of a boxed protocol type:
>
> *boxed-protocol-type* → **`any`** *type*

> Grammar of a metatype type:
>
> *metatype-type* → *type* **`.`** **`Type`** | *type* **`.`** **`Protocol`**

> Grammar of an Any type:
>
> *any-type* → **`Any`**

> Grammar of a Self type:
>
> *self-type* → **`Self`**

> Grammar of a type inheritance clause:
>
> *type-inheritance-clause* → **`:`** *type-inheritance-list*\
> \&#xNAN;*type-inheritance-list* → *attributes?* *type-identifier* | *attributes?* *type-identifier* **`,`** *type-inheritance-list*

## Expressions(式)

> Grammar of an expression:
>
> *expression* → *try-operator?* *await-operator?* *prefix-expression* *infix-expressions?* \\

> Grammar of a prefix expression:
>
> *prefix-expression* → *prefix-operator?* *postfix-expression*\
> \&#xNAN;*prefix-expression* → *in-out-expression*

> Grammar of an in-out expression:
>
> *in-out-expression* → **`&`** *primary-expression*

> Grammar of a try expression:
>
> *try-operator* → **`try`** | **`try`** **`?`** | **`try`** **`!`**

> Grammar of an await expression:
>
> *await-operator* → **`await`**

> Grammar of an infix expression:
>
> *infix-expression* → *infix-operator* *prefix-expression*\
> \&#xNAN;*infix-expression* → *assignment-operator* *try-operator?* *prefix-expression*\
> \&#xNAN;*infix-expression* → *conditional-operator* *try-operator?* *prefix-expression*\
> \&#xNAN;*infix-expression* → *type-casting-operator*\
> \&#xNAN;*infix-expressions* → *infix-expression* *infix-expressions?*

> Grammar of an assignment operator:
>
> *assignment-operator* → **`=`**

> Grammar of a conditional operator:
>
> *conditional-operator* → **`?`** *expression* **`:`**

> Grammar of a type-casting operator:
>
> *type-casting-operator* → **`is`** *type*\
> \&#xNAN;*type-casting-operator* → **`as`** *type*\
> \&#xNAN;*type-casting-operator* → **`as`** **`?`** *type*\
> \&#xNAN;*type-casting-operator* → **`as`** **`!`** *type*

> Grammar of a primary expression:
>
> *primary-expression* → *identifier* *generic-argument-clause?*\
> \&#xNAN;*primary-expression* → *literal-expression*\
> \&#xNAN;*primary-expression* → *self-expression*\
> \&#xNAN;*primary-expression* → *superclass-expression*\
> \&#xNAN;*primary-expression* → *conditional-expression*\
> \&#xNAN;*primary-expression* → *closure-expression*\
> \&#xNAN;*primary-expression* → *parenthesized-expression*\
> \&#xNAN;*primary-expression* → *tuple-expression*\
> \&#xNAN;*primary-expression* → *implicit-member-expression*\
> \&#xNAN;*primary-expression* → *wildcard-expression*\
> \&#xNAN;*primary-expression* → *macro-expansion-expression*\
> \&#xNAN;*primary-expression* → *key-path-expression*\
> \&#xNAN;*primary-expression* → *selector-expression*\
> \&#xNAN;*primary-expression* → *key-path-string-expression*

> Grammar of a literal expression:
>
> *literal-expression* → *literal*\
> \&#xNAN;*literal-expression* → *array-literal* | *dictionary-literal* | *playground-literal*
>
> *array-literal* → **`[`** *array-literal-items?* **`]`**\
> \&#xNAN;*array-literal-items* → *array-literal-item* **`,`***?* | *array-literal-item* **`,`** *array-literal-items*\
> \&#xNAN;*array-literal-item* → *expression*
>
> *dictionary-literal* → **`[`** *dictionary-literal-items* **`]`** | **`[`** **`:`** **`]`**\
> \&#xNAN;*dictionary-literal-items* → *dictionary-literal-item* **`,`***?* | *dictionary-literal-item* **`,`** *dictionary-literal-items*\
> \&#xNAN;*dictionary-literal-item* → *expression* **`:`** *expression*
>
> *playground-literal* → **`#colorLiteral`** **`(`** **`red`** **`:`** *expression* **`,`** **`green`** **`:`** *expression* **`,`** **`blue`** **`:`** *expression* **`,`** **`alpha`** **`:`** *expression* **`)`**\
> \&#xNAN;*playground-literal* → **`#fileLiteral`** **`(`** **`resourceName`** **`:`** *expression* **`)`**\
> \&#xNAN;*playground-literal* → **`#imageLiteral`** **`(`** **`resourceName`** **`:`** *expression* **`)`**

> Grammar of a self expression:
>
> *self-expression* → **`self`** | *self-method-expression* | *self-subscript-expression* | *self-initializer-expression*
>
> *self-method-expression* → **`self`** **`.`** *identifier*\
> \&#xNAN;*self-subscript-expression* → **`self`** **`[`** *function-call-argument-list* **`]`**\
> \&#xNAN;*self-initializer-expression* → **`self`** **`.`** **`init`**

> Grammar of a superclass expression:
>
> *superclass-expression* → *superclass-method-expression* | *superclass-subscript-expression* | *superclass-initializer-expression*
>
> *superclass-method-expression* → **`super`** **`.`** *identifier*\
> \&#xNAN;*superclass-subscript-expression* → **`super`** **`[`** *function-call-argument-list* **`]`**\
> \&#xNAN;*superclass-initializer-expression* → **`super`** **`.`** **`init`**

> Grammar of a conditional expression:
>
> *conditional-expression* → *if-expression* | *switch-expression*
>
> *if-expression* → **`if`** *condition-list* **`{`** *statement* **`}`** *if-expression-tail*\
> \&#xNAN;*if-expression-tail* → **`else`** *if-expression*\
> \&#xNAN;*if-expression-tail* → **`else`** **`{`** *statement* **`}`**
>
> *switch-expression* → **`switch`** *expression* **`{`** *switch-expression-cases* **`}`**\
> \&#xNAN;*switch-expression-cases* → *switch-expression-case* *switch-expression-cases?*\
> \&#xNAN;*switch-expression-case* → *case-label* *statement*\
> \&#xNAN;*switch-expression-case* → *default-label* *statement*

> Grammar of a closure expression:
>
> *closure-expression* → **`{`** *attributes?* *closure-signature?* *statements?* **`}`**
>
> *closure-signature* → *capture-list?* *closure-parameter-clause* **`async`***?* *throws-clause?* *function-result?* **`in`**\
> \&#xNAN;*closure-signature* → *capture-list* **`in`**
>
> *closure-parameter-clause* → **`(`** **`)`** | **`(`** *closure-parameter-list* **`)`** | *identifier-list*\
> \&#xNAN;*closure-parameter-list* → *closure-parameter* | *closure-parameter* **`,`** *closure-parameter-list*\
> \&#xNAN;*closure-parameter* → *closure-parameter-name* *type-annotation?*\
> \&#xNAN;*closure-parameter* → *closure-parameter-name* *type-annotation* **`...`**\
> \&#xNAN;*closure-parameter-name* → *identifier*
>
> *capture-list* → **`[`** *capture-list-items* **`]`**\
> \&#xNAN;*capture-list-items* → *capture-list-item* | *capture-list-item* **`,`** *capture-list-items*\
> \&#xNAN;*capture-list-item* → *capture-specifier?* *identifier*\
> \&#xNAN;*capture-list-item* → *capture-specifier?* *identifier* **`=`** *expression*\
> \&#xNAN;*capture-list-item* → *capture-specifier?* *self-expression*\
> \&#xNAN;*capture-specifier* → **`weak`** | **`unowned`** | **`unowned(safe)`** | **`unowned(unsafe)`**

> Grammar of a implicit member expression:
>
> *implicit-member-expression* → **`.`** *identifier*\
> \&#xNAN;*implicit-member-expression* → **`.`** *identifier* **`.`** *postfix-expression*

> Grammar of a parenthesized expression:
>
> *parenthesized-expression* → **`(`** *expression* **`)`**

> Grammar of a tuple expression:
>
> *tuple-expression* → **`(`** **`)`** | **`(`** *tuple-element* **`,`** *tuple-element-list* **`)`**\
> \&#xNAN;*tuple-element-list* → *tuple-element* | *tuple-element* **`,`** *tuple-element-list*\
> \&#xNAN;*tuple-element* → *expression* | *identifier* **`:`** *expression*

> Grammar of a wildcard expression:
>
> *wildcard-expression* → **`_`**

> Grammar of a macro-expansion expression:
>
> *macro-expansion-expression* → **`#`** *identifier* *generic-argument-clause?* *function-call-argument-clause?* *trailing-closures?*

> Grammar of a key-path expression:
>
> *key-path-expression* → **`\`** *type?* **`.`** *key-path-components*\
> \&#xNAN;*key-path-components* → *key-path-component* | *key-path-component* **`.`** *key-path-components*\
> \&#xNAN;*key-path-component* → *identifier* *key-path-postfixes?* | *key-path-postfixes*
>
> *key-path-postfixes* → *key-path-postfix* *key-path-postfixes?*\
> \&#xNAN;*key-path-postfix* → **`?`** | **`!`** | **`self`** | **`[`** *function-call-argument-list* **`]`**

> Grammar of a selector expression:
>
> *selector-expression* → **`#selector`** **`(`** *expression* **`)`**\
> \&#xNAN;*selector-expression* → **`#selector`** **`(`** **`getter:`** *expression* **`)`**\
> \&#xNAN;*selector-expression* → **`#selector`** **`(`** **`setter:`** *expression* **`)`**

> Grammar of a key-path string expression:
>
> *key-path-string-expression* → **`#keyPath`** **`(`** *expression* **`)`**

> Grammar of a postfix expression:
>
> *postfix-expression* → *primary-expression*\
> \&#xNAN;*postfix-expression* → *postfix-expression* *postfix-operator*\
> \&#xNAN;*postfix-expression* → *function-call-expression*\
> \&#xNAN;*postfix-expression* → *initializer-expression*\
> \&#xNAN;*postfix-expression* → *explicit-member-expression*\
> \&#xNAN;*postfix-expression* → *postfix-self-expression*\
> \&#xNAN;*postfix-expression* → *subscript-expression*\
> \&#xNAN;*postfix-expression* → *forced-value-expression*\
> \&#xNAN;*postfix-expression* → *optional-chaining-expression*

> Grammar of a function call expression:
>
> *function-call-expression* → *postfix-expression* *function-call-argument-clause*\
> \&#xNAN;*function-call-expression* → *postfix-expression* *function-call-argument-clause?* *trailing-closures*
>
> *function-call-argument-clause* → **`(`** **`)`** | **`(`** *function-call-argument-list* **`)`**\
> \&#xNAN;*function-call-argument-list* → *function-call-argument* | *function-call-argument* **`,`** *function-call-argument-list*\
> \&#xNAN;*function-call-argument* → *expression* | *identifier* **`:`** *expression*\
> \&#xNAN;*function-call-argument* → *operator* | *identifier* **`:`** *operator*
>
> *trailing-closures* → *closure-expression* *labeled-trailing-closures?*\
> \&#xNAN;*labeled-trailing-closures* → *labeled-trailing-closure* *labeled-trailing-closures?*\
> \&#xNAN;*labeled-trailing-closure* → *identifier* **`:`** *closure-expression*

> Grammar of an initializer expression:
>
> *initializer-expression* → *postfix-expression* **`.`** **`init`**\
> \&#xNAN;*initializer-expression* → *postfix-expression* **`.`** **`init`** **`(`** *argument-names* **`)`**

> Grammar of an explicit member expression:
>
> *explicit-member-expression* → *postfix-expression* **`.`** *decimal-digits*\
> \&#xNAN;*explicit-member-expression* → *postfix-expression* **`.`** *identifier* *generic-argument-clause?*\
> \&#xNAN;*explicit-member-expression* → *postfix-expression* **`.`** *identifier* **`(`** *argument-names* **`)`**\
> \&#xNAN;*explicit-member-expression* → *postfix-expression* *conditional-compilation-block*
>
> *argument-names* → *argument-name* *argument-names?*\
> \&#xNAN;*argument-name* → *identifier* **`:`**

> Grammar of a postfix self expression:
>
> *postfix-self-expression* → *postfix-expression* **`.`** **`self`**

> Grammar of a subscript expression:
>
> *subscript-expression* → *postfix-expression* **`[`** *function-call-argument-list* **`]`**

> Grammar of a forced-value expression:
>
> *forced-value-expression* → *postfix-expression* **`!`**

> Grammar of an optional-chaining expression:
>
> *optional-chaining-expression* → *postfix-expression* **`?`**

## Statements(文)

> Grammar of a statement:
>
> *statement* → *expression* **`;`***?*\
> \&#xNAN;*statement* → *declaration* **`;`***?*\
> \&#xNAN;*statement* → *loop-statement* **`;`***?*\
> \&#xNAN;*statement* → *branch-statement* **`;`***?*\
> \&#xNAN;*statement* → *labeled-statement* **`;`***?*\
> \&#xNAN;*statement* → *control-transfer-statement* **`;`***?*\
> \&#xNAN;*statement* → *defer-statement* **`;`***?*\
> \&#xNAN;*statement* → *do-statement* **`;`***?*\
> \&#xNAN;*statement* → *compiler-control-statement*\
> \&#xNAN;*statements* → *statement* *statements?*

> Grammar of a loop statement:
>
> *loop-statement* → *for-in-statement*\
> \&#xNAN;*loop-statement* → *while-statement*\
> \&#xNAN;*loop-statement* → *repeat-while-statement*

> Grammar of a for-in statement:
>
> *for-in-statement* → **`for`** **`case`***?* *pattern* **`in`** *expression* *where-clause?* *code-block*

> Grammar of a while statement:
>
> *while-statement* → **`while`** *condition-list* *code-block*
>
> *condition-list* → *condition* | *condition* **`,`** *condition-list*\
> \&#xNAN;*condition* → *expression* | *availability-condition* | *case-condition* | *optional-binding-condition*
>
> *case-condition* → **`case`** *pattern* *initializer*\
> \&#xNAN;*optional-binding-condition* → **`let`** *pattern* *initializer?* | **`var`** *pattern* *initializer?*

> Grammar of a repeat-while statement:
>
> *repeat-while-statement* → **`repeat`** *code-block* **`while`** *expression*

> Grammar of a branch statement:
>
> *branch-statement* → *if-statement*\
> \&#xNAN;*branch-statement* → *guard-statement*\
> \&#xNAN;*branch-statement* → *switch-statement*

> Grammar of an if statement:
>
> *if-statement* → **`if`** *condition-list* *code-block* *else-clause?*\
> \&#xNAN;*else-clause* → **`else`** *code-block* | **`else`** *if-statement*

> Grammar of a guard statement:
>
> *guard-statement* → **`guard`** *condition-list* **`else`** *code-block*

> Grammar of a switch statement:
>
> *switch-statement* → **`switch`** *expression* **`{`** *switch-cases?* **`}`**\
> \&#xNAN;*switch-cases* → *switch-case* *switch-cases?*\
> \&#xNAN;*switch-case* → *case-label* *statements*\
> \&#xNAN;*switch-case* → *default-label* *statements*\
> \&#xNAN;*switch-case* → *conditional-switch-case*
>
> *case-label* → *attributes?* **`case`** *case-item-list* **`:`**\
> \&#xNAN;*case-item-list* → *pattern* *where-clause?* | *pattern* *where-clause?* **`,`** *case-item-list*\
> \&#xNAN;*default-label* → *attributes?* **`default`** **`:`**
>
> *where-clause* → **`where`** *where-expression*\
> \&#xNAN;*where-expression* → *expression*
>
> *conditional-switch-case* → *switch-if-directive-clause* *switch-elseif-directive-clauses?* *switch-else-directive-clause?* *endif-directive*\
> \&#xNAN;*switch-if-directive-clause* → *if-directive* *compilation-condition* *switch-cases?*\
> \&#xNAN;*switch-elseif-directive-clauses* → *elseif-directive-clause* *switch-elseif-directive-clauses?*\
> \&#xNAN;*switch-elseif-directive-clause* → *elseif-directive* *compilation-condition* *switch-cases?*\
> \&#xNAN;*switch-else-directive-clause* → *else-directive* *switch-cases?*

> Grammar of a labeled statement:
>
> *labeled-statement* → *statement-label* *loop-statement*\
> \&#xNAN;*labeled-statement* → *statement-label* *if-statement*\
> \&#xNAN;*labeled-statement* → *statement-label* *switch-statement*\
> \&#xNAN;*labeled-statement* → *statement-label* *do-statement*
>
> *statement-label* → *label-name* **`:`**\
> \&#xNAN;*label-name* → *identifier*

> Grammar of a control transfer statement:
>
> *control-transfer-statement* → *break-statement*\
> \&#xNAN;*control-transfer-statement* → *continue-statement*\
> \&#xNAN;*control-transfer-statement* → *fallthrough-statement*\
> \&#xNAN;*control-transfer-statement* → *return-statement*\
> \&#xNAN;*control-transfer-statement* → *throw-statement*

> Grammar of a break statement:
>
> *break-statement* → **`break`** *label-name?*

> Grammar of a continue statement:
>
> *continue-statement* → **`continue`** *label-name?*

> Grammar of a fallthrough statement:
>
> *fallthrough-statement* → **`fallthrough`**

> Grammar of a return statement:
>
> *return-statement* → **`return`** *expression?*

> Grammar of a throw statement:
>
> *throw-statement* → **`throw`** *expression*

> Grammar of a defer statement:
>
> *defer-statement* → **`defer`** *code-block*

> Grammar of a do statement:
>
> *do-statement* → **`do`** *code-block* *catch-clauses?*\
> \&#xNAN;*catch-clauses* → *catch-clause* *catch-clauses?*\
> \&#xNAN;*catch-clause* → **`catch`** *catch-pattern-list?* *code-block*\
> \&#xNAN;*catch-pattern-list* → *catch-pattern* | *catch-pattern* **`,`** *catch-pattern-list*\
> \&#xNAN;*catch-pattern* → *pattern* *where-clause?*

> Grammar of a compiler control statement:
>
> *compiler-control-statement* → *conditional-compilation-block*\
> \&#xNAN;*compiler-control-statement* → *line-control-statement*\
> \&#xNAN;*compiler-control-statement* → *diagnostic-statement*

> Grammar of a conditional compilation block:
>
> *conditional-compilation-block* → *if-directive-clause* *elseif-directive-clauses?* *else-directive-clause?* *endif-directive*
>
> *if-directive-clause* → *if-directive* *compilation-condition* *statements?*\
> \&#xNAN;*elseif-directive-clauses* → *elseif-directive-clause* *elseif-directive-clauses?*\
> \&#xNAN;*elseif-directive-clause* → *elseif-directive* *compilation-condition* *statements?*\
> \&#xNAN;*else-directive-clause* → *else-directive* *statements?*\
> \&#xNAN;*if-directive* → **`#if`**\
> \&#xNAN;*elseif-directive* → **`#elseif`**\
> \&#xNAN;*else-directive* → **`#else`**\
> \&#xNAN;*endif-directive* → **`#endif`**
>
> *compilation-condition* → *platform-condition*\
> \&#xNAN;*compilation-condition* → *identifier*\
> \&#xNAN;*compilation-condition* → *boolean-literal*\
> \&#xNAN;*compilation-condition* → **`(`** *compilation-condition* **`)`**\
> \&#xNAN;*compilation-condition* → **`!`** *compilation-condition*\
> \&#xNAN;*compilation-condition* → *compilation-condition* **`&&`** *compilation-condition*\
> \&#xNAN;*compilation-condition* → *compilation-condition* **`||`** *compilation-condition*
>
> *platform-condition* → **`os`** **`(`** *operating-system* **`)`**\
> \&#xNAN;*platform-condition* → **`arch`** **`(`** *architecture* **`)`**\
> \&#xNAN;*platform-condition* → **`swift`** **`(`** **`>=`** *swift-version* **`)`** | **`swift`** **`(`** **`<`** *swift-version* **`)`**\
> \&#xNAN;*platform-condition* → **`compiler`** **`(`** **`>=`** *swift-version* **`)`** | **`compiler`** **`(`** **`<`** *swift-version* **`)`**\
> \&#xNAN;*platform-condition* → **`canImport`** **`(`** *import-path* **`)`**\
> \&#xNAN;*platform-condition* → **`targetEnvironment`** **`(`** *environment* **`)`**
>
> *operating-system* → **`macOS`** | **`iOS`** | **`watchOS`** | **`tvOS`** | **`visionOS`** | **`Linux`** | **`Windows`**\
> \&#xNAN;*architecture* → **`i386`** | **`x86_64`** | **`arm`** | **`arm64`**\
> \&#xNAN;*swift-version* → *decimal-digits* *swift-version-continuation?*\
> \&#xNAN;*swift-version-continuation* → **`.`** *decimal-digits* *swift-version-continuation?*\
> \&#xNAN;*environment* → **`simulator`** | **`macCatalyst`**

> Grammar of a line control statement:
>
> *line-control-statement* → **`#sourceLocation`** **`(`** **`file:`** *file-path* **`,`** **`line:`** *line-number* **`)`**\
> \&#xNAN;*line-control-statement* → **`#sourceLocation`** **`(`** **`)`**\
> \&#xNAN;*line-number* → A decimal integer greater than zero\
> \&#xNAN;*file-path* → *static-string-literal*

> Grammar of an availability condition:
>
> *availability-condition* → **`#available`** **`(`** *availability-arguments* **`)`**\
> \&#xNAN;*availability-condition* → **`#unavailable`** **`(`** *availability-arguments* **`)`**\
> \&#xNAN;*availability-arguments* → *availability-argument* | *availability-argument* **`,`** *availability-arguments*\
> \&#xNAN;*availability-argument* → *platform-name* *platform-version*\
> \&#xNAN;*availability-argument* → **`*`**
>
> *platform-name* → **`iOS`** | **`iOSApplicationExtension`**\
> \&#xNAN;*platform-name* → **`macOS`** | **`macOSApplicationExtension`**\
> \&#xNAN;*platform-name* → **`macCatalyst`** | **`macCatalystApplicationExtension`**\
> \&#xNAN;*platform-name* → **`watchOS`** | **`watchOSApplicationExtension`**\
> \&#xNAN;*platform-name* → **`tvOS`** | **`tvOSApplicationExtension`**\
> \&#xNAN;*platform-name* → **`visionOS`** | **`visionOSApplicationExtension`**\
> \&#xNAN;*platform-version* → *decimal-digits*\
> \&#xNAN;*platform-version* → *decimal-digits* **`.`** *decimal-digits*\
> \&#xNAN;*platform-version* → *decimal-digits* **`.`** *decimal-digits* **`.`** *decimal-digits*

## Declarations(宣言)

> Grammar of a declaration:
>
> *declaration* → *import-declaration*\
> \&#xNAN;*declaration* → *constant-declaration*\
> \&#xNAN;*declaration* → *variable-declaration*\
> \&#xNAN;*declaration* → *typealias-declaration*\
> \&#xNAN;*declaration* → *function-declaration*\
> \&#xNAN;*declaration* → *enum-declaration*\
> \&#xNAN;*declaration* → *struct-declaration*\
> \&#xNAN;*declaration* → *class-declaration*\
> \&#xNAN;*declaration* → *actor-declaration*\
> \&#xNAN;*declaration* → *protocol-declaration*\
> \&#xNAN;*declaration* → *initializer-declaration*\
> \&#xNAN;*declaration* → *deinitializer-declaration*\
> \&#xNAN;*declaration* → *extension-declaration*\
> \&#xNAN;*declaration* → *subscript-declaration*\
> \&#xNAN;*declaration* → *operator-declaration*\
> \&#xNAN;*declaration* → *precedence-group-declaration* \\

> Grammar of a top-level declaration:
>
> *top-level-declaration* → *statements?*

> Grammar of a code block:
>
> *code-block* → **`{`** *statements?* **`}`**

> Grammar of an import declaration:
>
> *import-declaration* → *attributes?* **`import`** *import-kind?* *import-path*
>
> *import-kind* → **`typealias`** | **`struct`** | **`class`** | **`enum`** | **`protocol`** | **`let`** | **`var`** | **`func`**\
> \&#xNAN;*import-path* → *identifier* | *identifier* **`.`** *import-path*

> Grammar of a constant declaration:
>
> *constant-declaration* → *attributes?* *declaration-modifiers?* **`let`** *pattern-initializer-list*
>
> *pattern-initializer-list* → *pattern-initializer* | *pattern-initializer* **`,`** *pattern-initializer-list*\
> \&#xNAN;*pattern-initializer* → *pattern* *initializer?*\
> \&#xNAN;*initializer* → **`=`** *expression*

> Grammar of a variable declaration:
>
> *variable-declaration* → *variable-declaration-head* *pattern-initializer-list*\
> \&#xNAN;*variable-declaration* → *variable-declaration-head* *variable-name* *type-annotation* *code-block*\
> \&#xNAN;*variable-declaration* → *variable-declaration-head* *variable-name* *type-annotation* *getter-setter-block*\
> \&#xNAN;*variable-declaration* → *variable-declaration-head* *variable-name* *type-annotation* *getter-setter-keyword-block*\
> \&#xNAN;*variable-declaration* → *variable-declaration-head* *variable-name* *initializer* *willSet-didSet-block*\
> \&#xNAN;*variable-declaration* → *variable-declaration-head* *variable-name* *type-annotation* *initializer?* *willSet-didSet-block*
>
> *variable-declaration-head* → *attributes?* *declaration-modifiers?* **`var`**\
> \&#xNAN;*variable-name* → *identifier*
>
> *getter-setter-block* → *code-block*\
> \&#xNAN;*getter-setter-block* → **`{`** *getter-clause* *setter-clause?* **`}`**\
> \&#xNAN;*getter-setter-block* → **`{`** *setter-clause* *getter-clause* **`}`**\
> \&#xNAN;*getter-clause* → *attributes?* *mutation-modifier?* **`get`** *code-block*\
> \&#xNAN;*setter-clause* → *attributes?* *mutation-modifier?* **`set`** *setter-name?* *code-block*\
> \&#xNAN;*setter-name* → **`(`** *identifier* **`)`**
>
> *getter-setter-keyword-block* → **`{`** *getter-keyword-clause* *setter-keyword-clause?* **`}`**\
> \&#xNAN;*getter-setter-keyword-block* → **`{`** *setter-keyword-clause* *getter-keyword-clause* **`}`**\
> \&#xNAN;*getter-keyword-clause* → *attributes?* *mutation-modifier?* **`get`**\
> \&#xNAN;*setter-keyword-clause* → *attributes?* *mutation-modifier?* **`set`**
>
> *willSet-didSet-block* → **`{`** *willSet-clause* *didSet-clause?* **`}`**\
> \&#xNAN;*willSet-didSet-block* → **`{`** *didSet-clause* *willSet-clause?* **`}`**\
> \&#xNAN;*willSet-clause* → *attributes?* **`willSet`** *setter-name?* *code-block*\
> \&#xNAN;*didSet-clause* → *attributes?* **`didSet`** *setter-name?* *code-block*

> Grammar of a type alias declaration:
>
> *typealias-declaration* → *attributes?* *access-level-modifier?* **`typealias`** *typealias-name* *generic-parameter-clause?* *typealias-assignment*\
> \&#xNAN;*typealias-name* → *identifier*\
> \&#xNAN;*typealias-assignment* → **`=`** *type*

> Grammar of a function declaration:
>
> *function-declaration* → *function-head* *function-name* *generic-parameter-clause?* *function-signature* *generic-where-clause?* *function-body?*
>
> *function-head* → *attributes?* *declaration-modifiers?* **`func`**\
> \&#xNAN;*function-name* → *identifier* | *operator*
>
> *function-signature* → *parameter-clause* **`async`***?* *throws-clause?* *function-result?*\
> \&#xNAN;*function-signature* → *parameter-clause* **`async`***?* **`rethrows`** *function-result?*\
> \&#xNAN;*function-result* → **`->`** *attributes?* *type*\
> \&#xNAN;*function-body* → *code-block*
>
> *parameter-clause* → **`(`** **`)`** | **`(`** *parameter-list* **`)`**\
> \&#xNAN;*parameter-list* → *parameter* | *parameter* **`,`** *parameter-list*\
> \&#xNAN;*parameter* → *external-parameter-name?* *local-parameter-name* *type-annotation* *default-argument-clause?*\
> \&#xNAN;*parameter* → *external-parameter-name?* *local-parameter-name* *type-annotation*\
> \&#xNAN;*parameter* → *external-parameter-name?* *local-parameter-name* *type-annotation* **`...`**\
> \&#xNAN;*external-parameter-name* → *identifier*\
> \&#xNAN;*local-parameter-name* → *identifier*\
> \&#xNAN;*default-argument-clause* → **`=`** *expression*

> Grammar of an enumeration declaration:
>
> *enum-declaration* → *attributes?* *access-level-modifier?* *union-style-enum*\
> \&#xNAN;*enum-declaration* → *attributes?* *access-level-modifier?* *raw-value-style-enum*
>
> *union-style-enum* → **`indirect`***?* **`enum`** *enum-name* *generic-parameter-clause?* *type-inheritance-clause?* *generic-where-clause?* **`{`** *union-style-enum-members?* **`}`**\
> \&#xNAN;*union-style-enum-members* → *union-style-enum-member* *union-style-enum-members?*\
> \&#xNAN;*union-style-enum-member* → *declaration* | *union-style-enum-case-clause* | *compiler-control-statement*\
> \&#xNAN;*union-style-enum-case-clause* → *attributes?* **`indirect`***?* **`case`** *union-style-enum-case-list*\
> \&#xNAN;*union-style-enum-case-list* → *union-style-enum-case* | *union-style-enum-case* **`,`** *union-style-enum-case-list*\
> \&#xNAN;*union-style-enum-case* → *enum-case-name* *tuple-type?*\
> \&#xNAN;*enum-name* → *identifier*\
> \&#xNAN;*enum-case-name* → *identifier*
>
> *raw-value-style-enum* → **`enum`** *enum-name* *generic-parameter-clause?* *type-inheritance-clause* *generic-where-clause?* **`{`** *raw-value-style-enum-members* **`}`**\
> \&#xNAN;*raw-value-style-enum-members* → *raw-value-style-enum-member* *raw-value-style-enum-members?*\
> \&#xNAN;*raw-value-style-enum-member* → *declaration* | *raw-value-style-enum-case-clause* | *compiler-control-statement*\
> \&#xNAN;*raw-value-style-enum-case-clause* → *attributes?* **`case`** *raw-value-style-enum-case-list*\
> \&#xNAN;*raw-value-style-enum-case-list* → *raw-value-style-enum-case* | *raw-value-style-enum-case* **`,`** *raw-value-style-enum-case-list*\
> \&#xNAN;*raw-value-style-enum-case* → *enum-case-name* *raw-value-assignment?*\
> \&#xNAN;*raw-value-assignment* → **`=`** *raw-value-literal*\
> \&#xNAN;*raw-value-literal* → *numeric-literal* | *static-string-literal* | *boolean-literal*

> Grammar of a structure declaration:
>
> *struct-declaration* → *attributes?* *access-level-modifier?* **`struct`** *struct-name* *generic-parameter-clause?* *type-inheritance-clause?* *generic-where-clause?* *struct-body*\
> \&#xNAN;*struct-name* → *identifier*\
> \&#xNAN;*struct-body* → **`{`** *struct-members?* **`}`**
>
> *struct-members* → *struct-member* *struct-members?*\
> \&#xNAN;*struct-member* → *declaration* | *compiler-control-statement*

> Grammar of a class declaration:
>
> *class-declaration* → *attributes?* *access-level-modifier?* **`final`***?* **`class`** *class-name* *generic-parameter-clause?* *type-inheritance-clause?* *generic-where-clause?* *class-body*\
> \&#xNAN;*class-declaration* → *attributes?* **`final`** *access-level-modifier?* **`class`** *class-name* *generic-parameter-clause?* *type-inheritance-clause?* *generic-where-clause?* *class-body*\
> \&#xNAN;*class-name* → *identifier*\
> \&#xNAN;*class-body* → **`{`** *class-members?* **`}`**
>
> *class-members* → *class-member* *class-members?*\
> \&#xNAN;*class-member* → *declaration* | *compiler-control-statement*

> Grammar of an actor declaration:
>
> *actor-declaration* → *attributes?* *access-level-modifier?* **`actor`** *actor-name* *generic-parameter-clause?* *type-inheritance-clause?* *generic-where-clause?* *actor-body*\
> \&#xNAN;*actor-name* → *identifier*\
> \&#xNAN;*actor-body* → **`{`** *actor-members?* **`}`**
>
> *actor-members* → *actor-member* *actor-members?*\
> \&#xNAN;*actor-member* → *declaration* | *compiler-control-statement*

> Grammar of a protocol declaration:
>
> *protocol-declaration* → *attributes?* *access-level-modifier?* **`protocol`** *protocol-name* *type-inheritance-clause?* *generic-where-clause?* *protocol-body*\
> \&#xNAN;*protocol-name* → *identifier*\
> \&#xNAN;*protocol-body* → **`{`** *protocol-members?* **`}`**
>
> *protocol-members* → *protocol-member* *protocol-members?*\
> \&#xNAN;*protocol-member* → *protocol-member-declaration* | *compiler-control-statement*
>
> *protocol-member-declaration* → *protocol-property-declaration*\
> \&#xNAN;*protocol-member-declaration* → *protocol-method-declaration*\
> \&#xNAN;*protocol-member-declaration* → *protocol-initializer-declaration*\
> \&#xNAN;*protocol-member-declaration* → *protocol-subscript-declaration*\
> \&#xNAN;*protocol-member-declaration* → *protocol-associated-type-declaration*\
> \&#xNAN;*protocol-member-declaration* → *typealias-declaration*

> Grammar of a protocol property declaration:
>
> *protocol-property-declaration* → *variable-declaration-head* *variable-name* *type-annotation* *getter-setter-keyword-block*

> Grammar of a protocol method declaration:
>
> *protocol-method-declaration* → *function-head* *function-name* *generic-parameter-clause?* *function-signature* *generic-where-clause?*

> Grammar of a protocol initializer declaration:
>
> *protocol-initializer-declaration* → *initializer-head* *generic-parameter-clause?* *parameter-clause* *throws-clause?* *generic-where-clause?*\
> \&#xNAN;*protocol-initializer-declaration* → *initializer-head* *generic-parameter-clause?* *parameter-clause* **`rethrows`** *generic-where-clause?*

> Grammar of a protocol subscript declaration:
>
> *protocol-subscript-declaration* → *subscript-head* *subscript-result* *generic-where-clause?* *getter-setter-keyword-block*

> Grammar of a protocol associated type declaration:
>
> *protocol-associated-type-declaration* → *attributes?* *access-level-modifier?* **`associatedtype`** *typealias-name* *type-inheritance-clause?* *typealias-assignment?* *generic-where-clause?*

> Grammar of an initializer declaration:
>
> *initializer-declaration* → *initializer-head* *generic-parameter-clause?* *parameter-clause* **`async`***?* *throws-clause?* *generic-where-clause?* *initializer-body*\
> \&#xNAN;*initializer-declaration* → *initializer-head* *generic-parameter-clause?* *parameter-clause* **`async`***?* **`rethrows`** *generic-where-clause?* *initializer-body*\
> \&#xNAN;*initializer-head* → *attributes?* *declaration-modifiers?* **`init`**\
> \&#xNAN;*initializer-head* → *attributes?* *declaration-modifiers?* **`init`** **`?`**\
> \&#xNAN;*initializer-head* → *attributes?* *declaration-modifiers?* **`init`** **`!`**\
> \&#xNAN;*initializer-body* → *code-block*

> Grammar of a deinitializer declaration:
>
> *deinitializer-declaration* → *attributes?* **`deinit`** *code-block*

> Grammar of an extension declaration:
>
> *extension-declaration* → *attributes?* *access-level-modifier?* **`extension`** *type-identifier* *type-inheritance-clause?* *generic-where-clause?* *extension-body*\
> \&#xNAN;*extension-body* → **`{`** *extension-members?* **`}`**
>
> *extension-members* → *extension-member* *extension-members?*\
> \&#xNAN;*extension-member* → *declaration* | *compiler-control-statement*

> Grammar of a subscript declaration:
>
> *subscript-declaration* → *subscript-head* *subscript-result* *generic-where-clause?* *code-block*\
> \&#xNAN;*subscript-declaration* → *subscript-head* *subscript-result* *generic-where-clause?* *getter-setter-block*\
> \&#xNAN;*subscript-declaration* → *subscript-head* *subscript-result* *generic-where-clause?* *getter-setter-keyword-block*\
> \&#xNAN;*subscript-head* → *attributes?* *declaration-modifiers?* **`subscript`** *generic-parameter-clause?* *parameter-clause*\
> \&#xNAN;*subscript-result* → **`->`** *attributes?* *type*

> Grammar of a macro declaration:
>
> *macro-declaration* → *macro-head* *identifier* *generic-parameter-clause?* *macro-signature* *macro-definition?* *generic-where-clause*\
> \&#xNAN;*macro-head* → *attributes?* *declaration-modifiers?* **`macro`**\
> \&#xNAN;*macro-signature* → *parameter-clause* *macro-function-signature-result?*\
> \&#xNAN;*macro-function-signature-result* → **`->`** *type*\
> \&#xNAN;*macro-definition* → **`=`** *expression*

> Grammar of an operator declaration:
>
> *operator-declaration* → *prefix-operator-declaration* | *postfix-operator-declaration* | *infix-operator-declaration*
>
> *prefix-operator-declaration* → **`prefix`** **`operator`** *operator*\
> \&#xNAN;*postfix-operator-declaration* → **`postfix`** **`operator`** *operator*\
> \&#xNAN;*infix-operator-declaration* → **`infix`** **`operator`** *operator* *infix-operator-group?*
>
> *infix-operator-group* → **`:`** *precedence-group-name*

> Grammar of a precedence group declaration:
>
> *precedence-group-declaration* → **`precedencegroup`** *precedence-group-name* **`{`** *precedence-group-attributes?* **`}`**
>
> *precedence-group-attributes* → *precedence-group-attribute* *precedence-group-attributes?*\
> \&#xNAN;*precedence-group-attribute* → *precedence-group-relation*\
> \&#xNAN;*precedence-group-attribute* → *precedence-group-assignment*\
> \&#xNAN;*precedence-group-attribute* → *precedence-group-associativity*
>
> *precedence-group-relation* → **`higherThan`** **`:`** *precedence-group-names*\
> \&#xNAN;*precedence-group-relation* → **`lowerThan`** **`:`** *precedence-group-names*
>
> *precedence-group-assignment* → **`assignment`** **`:`** *boolean-literal*
>
> *precedence-group-associativity* → **`associativity`** **`:`** **`left`**\
> \&#xNAN;*precedence-group-associativity* → **`associativity`** **`:`** **`right`**\
> \&#xNAN;*precedence-group-associativity* → **`associativity`** **`:`** **`none`**
>
> *precedence-group-names* → *precedence-group-name* | *precedence-group-name* **`,`** *precedence-group-names*\
> \&#xNAN;*precedence-group-name* → *identifier*

> Grammar of a declaration modifier:
>
> *declaration-modifier* → **`class`** | **`convenience`** | **`dynamic`** | **`final`** | **`infix`** | **`lazy`** | **`optional`** | **`override`** | **`postfix`** | **`prefix`** | **`required`** | **`static`** | **`unowned`** | **`unowned`** **`(`** **`safe`** **`)`** | **`unowned`** **`(`** **`unsafe`** **`)`** | **`weak`**\
> \&#xNAN;*declaration-modifier* → *access-level-modifier*\
> \&#xNAN;*declaration-modifier* → *mutation-modifier*\
> \&#xNAN;*declaration-modifier* → *actor-isolation-modifier*\
> \&#xNAN;*declaration-modifiers* → *declaration-modifier* *declaration-modifiers?*
>
> *access-level-modifier* → **`private`** | **`private`** **`(`** **`set`** **`)`**\
> \&#xNAN;*access-level-modifier* → **`fileprivate`** | **`fileprivate`** **`(`** **`set`** **`)`**\
> \&#xNAN;*access-level-modifier* → **`internal`** | **`internal`** **`(`** **`set`** **`)`**\
> \&#xNAN;*access-level-modifier* → **`package`** | **`package`** **`(`** **`set`** **`)`**\
> \&#xNAN;*access-level-modifier* → **`public`** | **`public`** **`(`** **`set`** **`)`**\
> \&#xNAN;*access-level-modifier* → **`open`** | **`open`** **`(`** **`set`** **`)`**
>
> *mutation-modifier* → **`mutating`** | **`nonmutating`**
>
> *actor-isolation-modifier* → **`nonisolated`**

## Attributes(属性)

> Grammar of an attribute:
>
> *attribute* → **`@`** *attribute-name* *attribute-argument-clause?*\
> \&#xNAN;*attribute-name* → *identifier*\
> \&#xNAN;*attribute-argument-clause* → **`(`** *balanced-tokens?* **`)`**\
> \&#xNAN;*attributes* → *attribute* *attributes?*
>
> *balanced-tokens* → *balanced-token* *balanced-tokens?*\
> \&#xNAN;*balanced-token* → **`(`** *balanced-tokens?* **`)`**\
> \&#xNAN;*balanced-token* → **`[`** *balanced-tokens?* **`]`**\
> \&#xNAN;*balanced-token* → **`{`** *balanced-tokens?* **`}`**\
> \&#xNAN;*balanced-token* → Any identifier, keyword, literal, or operator\
> \&#xNAN;*balanced-token* → Any punctuation except **`(`**, **`)`**, **`[`**, **`]`**, **`{`**, または **`}`**

## Patterns(パターン)

> Grammar of a pattern:
>
> *pattern* → *wildcard-pattern* *type-annotation?*\
> \&#xNAN;*pattern* → *identifier-pattern* *type-annotation?*\
> \&#xNAN;*pattern* → *value-binding-pattern*\
> \&#xNAN;*pattern* → *tuple-pattern* *type-annotation?*\
> \&#xNAN;*pattern* → *enum-case-pattern*\
> \&#xNAN;*pattern* → *optional-pattern*\
> \&#xNAN;*pattern* → *type-casting-pattern*\
> \&#xNAN;*pattern* → *expression-pattern*

> Grammar of a wildcard pattern:
>
> *wildcard-pattern* → **`_`**

> Grammar of an identifier pattern:
>
> *identifier-pattern* → *identifier*

> Grammar of a value-binding pattern:
>
> *value-binding-pattern* → **`var`** *pattern* | **`let`** *pattern*

> Grammar of a tuple pattern:
>
> *tuple-pattern* → **`(`** *tuple-pattern-element-list?* **`)`**\
> \&#xNAN;*tuple-pattern-element-list* → *tuple-pattern-element* | *tuple-pattern-element* **`,`** *tuple-pattern-element-list*\
> \&#xNAN;*tuple-pattern-element* → *pattern* | *identifier* **`:`** *pattern*

> Grammar of an enumeration case pattern:
>
> *enum-case-pattern* → *type-identifier?* **`.`** *enum-case-name* *tuple-pattern?*

> Grammar of an optional pattern:
>
> *optional-pattern* → *identifier-pattern* **`?`**

> Grammar of a type casting pattern:
>
> *type-casting-pattern* → *is-pattern* | *as-pattern*\
> \&#xNAN;*is-pattern* → **`is`** *type*\
> \&#xNAN;*as-pattern* → *pattern* **`as`** *type*

> Grammar of an expression pattern:
>
> *expression-pattern* → *expression*

## Generic Parameters and Arguments(ジェネリックパラメータと引数)

> Grammar of a generic parameter clause:
>
> *generic-parameter-clause* → **`<`** *generic-parameter-list* **`>`**\
> \&#xNAN;*generic-parameter-list* → *generic-parameter* | *generic-parameter* **`,`** *generic-parameter-list*\
> \&#xNAN;*generic-parameter* → *type-name*\
> \&#xNAN;*generic-parameter* → *type-name* **`:`** *type-identifier*\
> \&#xNAN;*generic-parameter* → *type-name* **`:`** *protocol-composition-type*
>
> *generic-where-clause* → **`where`** *requirement-list*\
> \&#xNAN;*requirement-list* → *requirement* | *requirement* **`,`** *requirement-list*\
> \&#xNAN;*requirement* → *conformance-requirement* | *same-type-requirement*
>
> *conformance-requirement* → *type-identifier* **`:`** *type-identifier*\
> \&#xNAN;*conformance-requirement* → *type-identifier* **`:`** *protocol-composition-type*\
> \&#xNAN;*same-type-requirement* → *type-identifier* **`==`** *type*

> Grammar of a generic argument clause:
>
> *generic-argument-clause* → **`<`** *generic-argument-list* **`>`**\
> \&#xNAN;*generic-argument-list* → *generic-argument* | *generic-argument* **`,`** *generic-argument-list*\
> \&#xNAN;*generic-argument* → *type*
