Summary of the Grammar
文法の概要
Lexical Structure
語彙の構造
Grammar of whitespace
空白の文法
whitespace → whitespace-itemwhitespaceopt
whitespace-item → line-break
whitespace-item → comment
whitespace-item → multiline-comment
comment
→
//
comment-textline-break
multiline-comment
→
/*
multiline-comment-text*/
comment-text → comment-text-itemcomment-textopt
comment-text-item → Any Unicode scalar value except U+000A or U+000D 任意のユニコードスカラー値、 しかし U+000A または U+000D を除く
multiline-comment-text → multiline-comment-text-itemmultiline-comment-textopt
multiline-comment-text-item → multiline-comment
multiline-comment-text-item → comment-text-item
multiline-comment-text-item
→
Any Unicode scalar value except /*
or */
任意のユニコードスカラー値、 しかし/*
または */
を除く
Grammar of an identifier
識別子の文法
identifier → identifier-headidentifier-charactersopt
identifier
→
`
identifier-headidentifier-charactersopt`
identifier → implicit-parameter-name
identifier-list
→
identifier
identifier,
identifier-list
identifier-head → Upper- or lowercase letter A through Z 大文字または小文字のAからZ
identifier-head → U+00A8, U+00AA, U+00AD, U+00AF, U+00B2–U+00B5, or U+00B7–U+00BA
identifier-head → U+00BC–U+00BE, U+00C0–U+00D6, U+00D8–U+00F6, or U+00F8–U+00FF
identifier-head → U+0100–U+02FF, U+0370–U+167F, U+1681–U+180D, or U+180F–U+1DBF
identifier-head → U+1E00–U+1FFF
identifier-head → U+200B–U+200D, U+202A–U+202E, U+203F–U+2040, U+2054, or U+2060–U+206F
identifier-head → U+2070–U+20CF, U+2100–U+218F, U+2460–U+24FF, or U+2776–U+2793
identifier-head → U+2C00–U+2DFF or U+2E80–U+2FFF
identifier-head → U+3004–U+3007, U+3021–U+302F, U+3031–U+303F, or U+3040–U+D7FF
identifier-head → U+F900–U+FD3D, U+FD40–U+FDCF, U+FDF0–U+FE1F, or U+FE30–U+FE44
identifier-head → U+FE47–U+FFFD
identifier-head → U+10000–U+1FFFD, U+20000–U+2FFFD, U+30000–U+3FFFD, or U+40000–U+4FFFD
identifier-head → U+50000–U+5FFFD, U+60000–U+6FFFD, U+70000–U+7FFFD, or U+80000–U+8FFFD
identifier-head → U+90000–U+9FFFD, U+A0000–U+AFFFD, U+B0000–U+BFFFD, or U+C0000–U+CFFFD
identifier-character → Digit 0 through 9 アラビア数字の0から9
identifier-character → U+0300–U+036F, U+1DC0–U+1DFF, U+20D0–U+20FF, or U+FE20–U+FE2F
identifier-character → identifier-head
identifier-characters → identifier-characteridentifier-charactersopt
implicit-parameter-name
→
$
decimal-digits
Grammar of a literal
リテラルの文法
literal → numeric-literal string-literal boolean-literal nil-literal
numeric-literal
→
-
optinteger-literal
-
optfloating-point-literal
Grammar of an integer literal
整数リテラルの文法
integer-literal → binary-literal
integer-literal → octal-literal
integer-literal → decimal-literal
integer-literal → hexadecimal-literal
binary-literal
→
0b
binary-digitbinary-literal-charactersopt
binary-digit → Digit 0 or 1 アラビア数字の0または1
binary-literal-character
→
binary-digit
_
binary-literal-characters → binary-literal-characterbinary-literal-charactersopt
octal-literal
→
0o
octal-digitoctal-literal-charactersopt
octal-digit → Digit 0 through 7 アラビア数字の0から7
octal-literal-character
→
octal-digit
_
octal-literal-characters → octal-literal-characteroctal-literal-charactersopt
decimal-literal → decimal-digitdecimal-literal-charactersopt
decimal-digit → Digit 0 through 9 アラビア数字の0から9
decimal-digits → decimal-digitdecimal-digitsopt
decimal-literal-character
→
decimal-digit
_
decimal-literal-characters → decimal-literal-characterdecimal-literal-charactersopt
hexadecimal-literal
→
0x
hexadecimal-digithexadecimal-literal-charactersopt
hexadecimal-digit → Digit 0 through 9, a through f, or A through F アラビア数字の0から9、aからf、またはAからF
hexadecimal-literal-character
→
hexadecimal-digit
_
hexadecimal-literal-characters → hexadecimal-literal-characterhexadecimal-literal-charactersopt
Grammar of a floating-point literal
浮動小数点リテラルの文法
floating-point-literal → decimal-literaldecimal-fractionoptdecimal-exponentopt
floating-point-literal → hexadecimal-literalhexadecimal-fractionopthexadecimal-exponent
decimal-fraction
→
.
decimal-literal
decimal-exponent → floating-point-esignoptdecimal-literal
hexadecimal-fraction
→
.
hexadecimal-digithexadecimal-literal-charactersopt
hexadecimal-exponent → floating-point-psignoptdecimal-literal
Grammar of a string literal
文字列リテラルの文法
string-literal → static-string-literal interpolated-string-literal
static-string-literal
→
"
quoted-textopt"
static-string-literal
→
"""
multiline-quoted-textopt"""
quoted-text → quoted-text-itemquoted-textopt
quoted-text-item → escaped-character
quoted-text-item
→
Any Unicode scalar value except "
, \
, U+000A, or U+000D
何らかのユニコードスカラー値、しかし"
, \
、U+000A、またはU+000Dを除く
multiline-quoted-text → multiline-quoted-text-itemmultiline-quoted-textopt
multiline-quoted-text-item → escaped-character
multiline-quoted-text-item
→
Any Unicode scalar value except \
任意のユニコードスカラー値、しかし\
を除く
multiline-quoted-text-item → escaped-newline
interpolated-string-literal
→
"
interpolated-textopt"
interpolated-string-literal
→
"""
multiline-interpolated-textopt"""
interpolated-text → interpolated-text-iteminterpolated-textopt
interpolated-text-item
→
\(
expression)
quoted-text-item
multiline-interpolated-text → multiline-interpolated-text-itemmultiline-interpolated-textopt
multiline-interpolated-text-item
→
\(
expression)
multiline-quoted-text-item
escaped-character
→
\0
\\
\t
\n
\r
\"
\'
escaped-character
→
\u
{
unicode-scalar-digits}
unicode-scalar-digits → Between one and eight hexadecimal digits 1から8桁の16進数
escaped-newline
→
\
whitespaceoptline-break
Grammar of operators
演算子の文法
operator → operator-headoperator-charactersopt
operator → dot-operator-headdot-operator-characters
operator-head
→
/
=
-
+
!
*
%
<
>
&
|
^
~
?
operator-head → U+00A9 or U+00AB
operator-head → U+00AC or U+00AE
operator-head → U+00B0–U+00B1, U+00B6, U+00BB, U+00BF, U+00D7, or U+00F7
operator-character → operator-head
operator-character → U+0300–U+036F
operator-character → U+1DC0–U+1DFF
operator-character → U+20D0–U+20FF
operator-character → U+FE00–U+FE0F
operator-character → U+FE20–U+FE2F
operator-character → U+E0100–U+E01EF
operator-characters → operator-characteroperator-charactersopt
dot-operator-character
→
.
operator-character
dot-operator-characters → dot-operator-characterdot-operator-charactersopt
Types
型
Grammar of a type
型の文法
type → array-type
type → dictionary-type
type → function-type
type → type-identifier
type → tuple-type
type → optional-type
type → implicitly-unwrapped-optional-type
type → protocol-composition-type
type → metatype-type
type
→
(
type)
Grammar of a type annotation
型注釈の文法
type-annotation
→
:
attributesoptinout
opttype
Grammar of a type identifier
型識別子の文法
type-identifier
→
type-namegeneric-argument-clauseopt
type-namegeneric-argument-clauseopt.
type-identifier
type-name → identifier
Grammar of a tuple type
タプル型の文法
tuple-type
→
(
)
(
tuple-type-element,
tuple-type-element-list)
tuple-type-element-list
→
tuple-type-element
tuple-type-element,
tuple-type-element-list
tuple-type-element → element-nametype-annotation type
element-name → identifier
Grammar of a function type
関数型の文法
function-type
→
attributesoptfunction-type-argument-clausethrows
opt->
type
function-type
→
attributesoptfunction-type-argument-clauserethrows
->
type
function-type-argument-clause
→
(
)
function-type-argument-clause
→
(
function-type-argument-list...
opt)
function-type-argument-list
→
function-type-argument
function-type-argument,
function-type-argument-list
function-type-argument
→
attributesoptinout
opttype
argument-labeltype-annotation
argument-label → identifier
Grammar of an array type
配列型の文法
array-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
protocol-composition-continuation → type-identifier protocol-composition-type
Grammar of a type inheritance clause
型継承節の文法
type-inheritance-clause
→
:
type-inheritance-list
type-inheritance-list
→
type-identifier
type-identifier,
type-inheritance-list
Expressions
式
Grammar of an expression
式の文法
expression → try-operatoroptprefix-expressionbinary-expressionsopt
expression-list
→
expression
expression,
expression-list
Grammar of a prefix expression
接頭辞式の文法
prefix-expression → prefix-operatoroptpostfix-expression
prefix-expression → in-out-expression
in-out-expression
→
&
identifier
Grammar of a binary expression
二項式の文法
binary-expression → binary-operatorprefix-expression
binary-expression → assignment-operatortry-operatoroptprefix-expression
binary-expression → conditional-operatortry-operatoroptprefix-expression
binary-expression → type-casting-operator
binary-expressions → binary-expressionbinary-expressionsopt
Grammar of a conditional operator
条件演算子の文法
conditional-operator
→
?
expression:
Grammar of a type-casting operator
型キャスト演算子の文法
Grammar of a primary expression
基本式の文法
primary-expression → identifiergeneric-argument-clauseopt
primary-expression → literal-expression
primary-expression → self-expression
primary-expression → superclass-expression
primary-expression → closure-expression
primary-expression → parenthesized-expression
primary-expression → tuple-expression
primary-expression → implicit-member-expression
primary-expression → wildcard-expression
primary-expression → key-path-expression
primary-expression → selector-expression
primary-expression → key-path-string-expression
Grammar of a literal expression
リテラル式の文法
literal-expression → literal
literal-expression → array-literal dictionary-literal playground-literal
array-literal
→
[
array-literal-itemsopt]
array-literal-items
→
array-literal-item,
opt
array-literal-item,
array-literal-items
array-literal-item → expression
dictionary-literal
→
[
dictionary-literal-items]
[
:
]
dictionary-literal-items
→
dictionary-literal-item,
opt
dictionary-literal-item,
dictionary-literal-items
dictionary-literal-item
→
expression:
expression
playground-literal
→
#colorLiteral
(
red
:
expression,
green
:
expression,
blue
:
expression,
alpha
:
expression)
playground-literal
→
#fileLiteral
(
resourceName
:
expression)
playground-literal
→
#imageLiteral
(
resourceName
:
expression)
Grammar of a self expression
self式の文法
self-expression
→
self
self-method-expression
self-subscript-expression
self-initializer-expression
self-method-expression
→
self
.
identifier
self-subscript-expression
→
self
[
function-call-argument-list]
Grammar of a superclass expression
スーパークラス式の文法
superclass-expression → superclass-method-expression superclass-subscript-expression superclass-initializer-expression
superclass-method-expression
→
super
.
identifier
superclass-subscript-expression
→
super
[
function-call-argument-list]
Grammar of a closure expression
クロージャ式の文法
closure-expression
→
{
closure-signatureoptstatementsopt}
closure-signature
→
capture-listoptclosure-parameter-clausethrows
optfunction-resultoptin
closure-signature
→
capture-listin
closure-parameter-clause
→
(
)
(
closure-parameter-list)
identifier-list
closure-parameter-list
→
closure-parameter
closure-parameter,
closure-parameter-list
closure-parameter → closure-parameter-nametype-annotationopt
closure-parameter
→
closure-parameter-nametype-annotation...
closure-parameter-name → identifier
capture-list
→
[
capture-list-items]
capture-list-items
→
capture-list-item
capture-list-item,
capture-list-items
capture-list-item → capture-specifieroptexpression
capture-specifier
→
weak
unowned
unowned(safe)
unowned(unsafe)
Grammar of a implicit member expression
暗黙的メンバー式の文法
implicit-member-expression
→
.
identifier
Grammar of a parenthesized expression
丸括弧に入れられた式の文法
parenthesized-expression
→
(
expression)
Grammar of a tuple expression
タプル式の文法
tuple-expression
→
(
)
(
tuple-element,
tuple-element-list)
tuple-element-list
→
tuple-element
tuple-element,
tuple-element-list
tuple-element
→
expression
identifier:
expression
Grammar of a key-path expression
キーパス式の文法
key-path-expression
→
\
typeopt.
key-path-components
key-path-components
→
key-path-component
key-path-component.
key-path-components
key-path-component → identifierkey-path-postfixesopt key-path-postfixes
key-path-postfixes → key-path-postfixkey-path-postfixesopt
key-path-postfix
→
?
!
[
function-call-argument-list]
Grammar of a selector expression
セレクタ式の文法
selector-expression
→
#selector
(
expression)
selector-expression
→
#selector
(
getter:
expression)
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
postfix-expression → postfix-expressionpostfix-operator
postfix-expression → function-call-expression
postfix-expression → initializer-expression
postfix-expression → explicit-member-expression
postfix-expression → postfix-self-expression
postfix-expression → subscript-expression
postfix-expression → forced-value-expression
postfix-expression → optional-chaining-expression
Grammar of a function call expression
関数呼び出し式の文法
function-call-expression → postfix-expressionfunction-call-argument-clause
function-call-expression → postfix-expressionfunction-call-argument-clauseopttrailing-closure
function-call-argument-clause
→
(
)
(
function-call-argument-list)
function-call-argument-list
→
function-call-argument
function-call-argument,
function-call-argument-list
function-call-argument
→
expression
identifier:
expression
function-call-argument
→
operator
identifier:
operator
trailing-closure → closure-expression
Grammar of an initializer expression
イニシャライザ式の文法
initializer-expression
→
postfix-expression.
init
initializer-expression
→
postfix-expression.
init
(
argument-names)
Grammar of an explicit member expression
明示的メンバー式の文法
explicit-member-expression
→
postfix-expression.
decimal-digits
explicit-member-expression
→
postfix-expression.
identifiergeneric-argument-clauseopt
explicit-member-expression
→
postfix-expression.
identifier(
argument-names)
argument-names → argument-nameargument-namesopt
argument-name
→
identifier:
Grammar of a self expression
self式の文法
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;
opt
statement
→
declaration;
opt
statement
→
loop-statement;
opt
statement
→
branch-statement;
opt
statement
→
labeled-statement;
opt
statement
→
control-transfer-statement;
opt
statement
→
defer-statement;
opt
statement
→
do-statement;
opt
statement → compiler-control-statement
statements → statementstatementsopt
Grammar of a loop statement
ループ文の文法
loop-statement → for-in-statement
loop-statement → while-statement
loop-statement → repeat-while-statement
Grammar of a for-in statement
for-in文の文法
for-in-statement
→
for
case
optpatternin
expressionwhere-clauseoptcode-block
Grammar of a while statement
while文の文法
while-statement
→
while
condition-listcode-block
condition-list
→
condition
condition,
condition-list
condition → expression availability-condition case-condition optional-binding-condition
case-condition
→
case
patterninitializer
optional-binding-condition
→
let
patterninitializer
var
patterninitializer
Grammar of a repeat-while statement
repeat-while文の文法
repeat-while-statement
→
repeat
code-blockwhile
expression
Grammar of a branch statement
分岐文の文法
branch-statement → if-statement
branch-statement → guard-statement
branch-statement → switch-statement
Grammar of an if statement
if文の文法
if-statement
→
if
condition-listcode-blockelse-clauseopt
else-clause
→
else
code-block
else
if-statement
Grammar of a guard statement
guard文の文法
guard-statement
→
guard
condition-listelse
code-block
Grammar of a switch statement
switch文の文法
switch-statement
→
switch
expression{
switch-casesopt}
switch-cases → switch-caseswitch-casesopt
switch-case → case-labelstatements default-labelstatements
case-label
→
case
case-item-list:
case-item-list
→
patternwhere-clauseopt
patternwhere-clauseopt,
case-item-list
where-clause
→
where
where-expression
where-expression → expression
Grammar of a labeled statement
ラベルをつけられた文の文法
labeled-statement → statement-labelloop-statement
labeled-statement → statement-labelif-statement
labeled-statement → statement-labelswitch-statement
labeled-statement → statement-labeldo-statement
statement-label
→
label-name:
label-name → identifier
Grammar of a control transfer statement
制御移動文の文法
control-transfer-statement → break-statement
control-transfer-statement → continue-statement
control-transfer-statement → fallthrough-statement
control-transfer-statement → return-statement
control-transfer-statement → throw-statement
Grammar of a break statement
ブレーク文の文法
break-statement
→
break
label-nameopt
Grammar of a continue statement
継続文の文法
continue-statement
→
continue
label-nameopt
Grammar of a return statement
return文の文法
return-statement
→
return
expressionopt
Grammar of a throw statement
スロー文の文法
throw-statement
→
throw
expression
Grammar of a defer statement
defer文の文法
defer-statement
→
defer
code-block
Grammar of a do statement
do文の文法
do-statement
→
do
code-blockcatch-clausesopt
catch-clauses → catch-clausecatch-clausesopt
catch-clause
→
catch
patternoptwhere-clauseoptcode-block
Grammar of a compiler control statement
コンパイラ制御文の文法
compiler-control-statement → conditional-compilation-block
compiler-control-statement → line-control-statement
Grammar of a conditional compilation block
条件コンパイルプロックの文法
conditional-compilation-block → if-directive-clauseelseif-directive-clausesoptelse-directive-clauseoptendif-directive
if-directive-clause → if-directivecompilation-conditionstatementsopt
elseif-directive-clauses → elseif-directive-clauseelseif-directive-clausesopt
elseif-directive-clause → elseif-directivecompilation-conditionstatementsopt
else-directive-clause → else-directivestatementsopt
compilation-condition → platform-condition
compilation-condition → identifier
compilation-condition → boolean-literal
compilation-condition
→
(
compilation-condition)
compilation-condition
→
!
compilation-condition
compilation-condition
→
compilation-condition&&
compilation-condition
compilation-condition
→
compilation-condition||
compilation-condition
platform-condition
→
os
(
operating-system)
platform-condition
→
arch
(
architecture)
platform-condition
→
swift
(
>=
swift-version)
platform-condition
→
canImport
(
module-name)
platform-condition
→
targetEnvironment
(
environment)
operating-system
→
macOS
iOS
watchOS
tvOS
architecture
→
i386
x86_64
arm
arm64
swift-version → decimal-digitsswift-version-continuationopt
swift-version-continuation
→
.
decimal-digitsswift-version-continuationopt
module-name → identifier
Grammar of a line control statement
行制御文の文法
line-control-statement
→
#sourceLocation
(
file:
file-name,
line:
line-number)
line-control-statement
→
#sourceLocation
(
)
line-number → A decimal integer greater than zero 0より大きい10進法整数
file-name → static-string-literal
Grammar of an availability condition
有効性条件の文法
availability-condition
→
#available
(
availability-arguments)
availability-arguments
→
availability-argument
availability-argument,
availability-arguments
availability-argument → platform-nameplatform-version
platform-name
→
iOS
iOSApplicationExtension
platform-name
→
macOS
macOSApplicationExtension
platform-version → decimal-digits
platform-version
→
decimal-digits.
decimal-digits
platform-version
→
decimal-digits.
decimal-digits.
decimal-digits
Declarations
宣言
Grammar of a declaration
宣言の文法
declaration → import-declaration
declaration → constant-declaration
declaration → variable-declaration
declaration → typealias-declaration
declaration → function-declaration
declaration → enum-declaration
declaration → struct-declaration
declaration → class-declaration
declaration → protocol-declaration
declaration → initializer-declaration
declaration → deinitializer-declaration
declaration → extension-declaration
declaration → subscript-declaration
declaration → operator-declaration
declaration → precedence-group-declaration
declarations → declarationdeclarationsopt
Grammar of a top-level declaration
トップレベル宣言の文法
top-level-declaration → statementsopt
Grammar of a code block
コードブロックの文法
code-block
→
{
statementsopt}
Grammar of an import declaration
インポート宣言の文法
import-declaration
→
attributesoptimport
import-kindoptimport-path
import-kind
→
typealias
struct
class
enum
protocol
let
var
func
import-path
→
import-path-identifier
import-path-identifier.
import-path
import-path-identifier → identifier operator
Grammar of a constant declaration
定数宣言の文法
constant-declaration
→
attributesoptdeclaration-modifiersoptlet
pattern-initializer-list
pattern-initializer-list
→
pattern-initializer
pattern-initializer,
pattern-initializer-list
pattern-initializer → patterninitializeropt
initializer
→
=
expression
Grammar of a variable declaration
変数宣言の文法
variable-declaration → variable-declaration-headpattern-initializer-list
variable-declaration → variable-declaration-headvariable-nametype-annotationcode-block
variable-declaration → variable-declaration-headvariable-nametype-annotationgetter-setter-block
variable-declaration → variable-declaration-headvariable-nametype-annotationgetter-setter-keyword-block
variable-declaration → variable-declaration-headvariable-nameinitializerwillSet-didSet-block
variable-declaration → variable-declaration-headvariable-nametype-annotationinitializeroptwillSet-didSet-block
variable-declaration-head
→
attributesoptdeclaration-modifiersoptvar
variable-name → identifier
getter-setter-block → code-block
getter-setter-block
→
{
getter-clausesetter-clauseopt}
getter-setter-block
→
{
setter-clausegetter-clause}
getter-clause
→
attributesoptmutation-modifieroptget
code-block
setter-clause
→
attributesoptmutation-modifieroptset
setter-nameoptcode-block
setter-name
→
(
identifier)
getter-setter-keyword-block
→
{
getter-keyword-clausesetter-keyword-clauseopt}
getter-setter-keyword-block
→
{
setter-keyword-clausegetter-keyword-clause}
getter-keyword-clause
→
attributesoptmutation-modifieroptget
setter-keyword-clause
→
attributesoptmutation-modifieroptset
willSet-didSet-block
→
{
willSet-clausedidSet-clauseopt}
willSet-didSet-block
→
{
didSet-clausewillSet-clauseopt}
willSet-clause
→
attributesoptwillSet
setter-nameoptcode-block
didSet-clause
→
attributesoptdidSet
setter-nameoptcode-block
Grammar of a type alias declaration
型エイリアス宣言の文法
typealias-declaration
→
attributesoptaccess-level-modifieropttypealias
typealias-namegeneric-parameter-clauseopttypealias-assignment
typealias-name → identifier
typealias-assignment
→
=
type
Grammar of a function declaration
関数宣言の文法
function-declaration → function-headfunction-namegeneric-parameter-clauseoptfunction-signaturegeneric-where-clauseoptfunction-bodyopt
function-head
→
attributesoptdeclaration-modifiersoptfunc
function-name → identifier operator
function-signature
→
parameter-clausethrows
optfunction-resultopt
function-signature
→
parameter-clauserethrows
function-resultopt
function-result
→
->
attributesopttype
function-body → code-block
parameter-clause
→
(
)
(
parameter-list)
parameter-list
→
parameter
parameter,
parameter-list
parameter → external-parameter-nameoptlocal-parameter-nametype-annotationdefault-argument-clauseopt
parameter → external-parameter-nameoptlocal-parameter-nametype-annotation
parameter
→
external-parameter-nameoptlocal-parameter-nametype-annotation...
external-parameter-name → identifier
local-parameter-name → identifier
default-argument-clause
→
=
expression
Grammar of an enumeration declaration
列挙宣言の文法
enum-declaration → attributesoptaccess-level-modifieroptunion-style-enum
enum-declaration → attributesoptaccess-level-modifieroptraw-value-style-enum
union-style-enum
→
indirect
optenum
enum-namegeneric-parameter-clauseopttype-inheritance-clauseoptgeneric-where-clauseopt{
union-style-enum-membersopt}
union-style-enum-members → union-style-enum-memberunion-style-enum-membersopt
union-style-enum-member → declaration union-style-enum-case-clause compiler-control-statement
union-style-enum-case-clause
→
attributesoptindirect
optcase
union-style-enum-case-list
union-style-enum-case-list
→
union-style-enum-case
union-style-enum-case,
union-style-enum-case-list
union-style-enum-case → enum-case-nametuple-typeopt
enum-name → identifier
enum-case-name → identifier
raw-value-style-enum
→
enum
enum-namegeneric-parameter-clauseopttype-inheritance-clausegeneric-where-clauseopt{
raw-value-style-enum-members}
raw-value-style-enum-members → raw-value-style-enum-memberraw-value-style-enum-membersopt
raw-value-style-enum-member → declaration raw-value-style-enum-case-clause compiler-control-statement
raw-value-style-enum-case-clause
→
attributesoptcase
raw-value-style-enum-case-list
raw-value-style-enum-case-list
→
raw-value-style-enum-case
raw-value-style-enum-case,
raw-value-style-enum-case-list
raw-value-style-enum-case → enum-case-nameraw-value-assignmentopt
raw-value-assignment
→
=
raw-value-literal
raw-value-literal → numeric-literal static-string-literal boolean-literal
Grammar of a structure declaration
構造体宣言の文法
struct-declaration
→
attributesoptaccess-level-modifieroptstruct
struct-namegeneric-parameter-clauseopttype-inheritance-clauseoptgeneric-where-clauseoptstruct-body
struct-name → identifier
struct-body
→
{
struct-membersopt}
struct-members → struct-memberstruct-membersopt
struct-member → declaration compiler-control-statement
Grammar of a class declaration
クラス宣言の文法
class-declaration
→
attributesoptaccess-level-modifieroptfinal
optclass
class-namegeneric-parameter-clauseopttype-inheritance-clauseoptgeneric-where-clauseoptclass-body
class-declaration
→
attributesoptfinal
access-level-modifieroptclass
class-namegeneric-parameter-clauseopttype-inheritance-clauseoptgeneric-where-clauseoptclass-body
class-name → identifier
class-body
→
{
class-membersopt}
class-members → class-memberclass-membersopt
class-member → declaration compiler-control-statement
Grammar of a protocol declaration
プロトコル宣言の文法
protocol-declaration
→
attributesoptaccess-level-modifieroptprotocol
protocol-nametype-inheritance-clauseoptgeneric-where-clauseoptprotocol-body
protocol-name → identifier
protocol-body
→
{
protocol-membersopt}
protocol-members → protocol-memberprotocol-membersopt
protocol-member → protocol-member-declaration compiler-control-statement
protocol-member-declaration → protocol-property-declaration
protocol-member-declaration → protocol-method-declaration
protocol-member-declaration → protocol-initializer-declaration
protocol-member-declaration → protocol-subscript-declaration
protocol-member-declaration → protocol-associated-type-declaration
protocol-member-declaration → typealias-declaration
Grammar of a protocol property declaration
プロトコルプロパティ宣言の文法
protocol-property-declaration → variable-declaration-headvariable-nametype-annotationgetter-setter-keyword-block
Grammar of a protocol method declaration
プロトコルメソッド宣言の文法
protocol-method-declaration → function-headfunction-namegeneric-parameter-clauseoptfunction-signaturegeneric-where-clauseopt
Grammar of a protocol initializer declaration
プロトコル・イニシャライザ宣言の文法
protocol-initializer-declaration
→
initializer-headgeneric-parameter-clauseoptparameter-clausethrows
optgeneric-where-clauseopt
protocol-initializer-declaration
→
initializer-headgeneric-parameter-clauseoptparameter-clauserethrows
generic-where-clauseopt
Grammar of a protocol subscript declaration
プロトコル添え字宣言の文法
protocol-subscript-declaration → subscript-headsubscript-resultgeneric-where-clauseoptgetter-setter-keyword-block
Grammar of a protocol associated type declaration
プロトコル関連型宣言の文法
protocol-associated-type-declaration
→
attributesoptaccess-level-modifieroptassociatedtype
typealias-nametype-inheritance-clauseopttypealias-assignmentoptgeneric-where-clauseopt
Grammar of an initializer declaration
イニシャライザ宣言の文法
initializer-declaration
→
initializer-headgeneric-parameter-clauseoptparameter-clausethrows
optgeneric-where-clauseoptinitializer-body
initializer-declaration
→
initializer-headgeneric-parameter-clauseoptparameter-clauserethrows
generic-where-clauseoptinitializer-body
initializer-head
→
attributesoptdeclaration-modifiersoptinit
initializer-head
→
attributesoptdeclaration-modifiersoptinit
?
initializer-head
→
attributesoptdeclaration-modifiersoptinit
!
initializer-body → code-block
Grammar of a deinitializer declaration
デイニシャライザ宣言の文法
deinitializer-declaration
→
attributesoptdeinit
code-block
Grammar of an extension declaration
拡張宣言の文法
extension-declaration
→
attributesoptaccess-level-modifieroptextension
type-identifiertype-inheritance-clauseoptgeneric-where-clauseoptextension-body
extension-body
→
{
extension-membersopt}
extension-members → extension-memberextension-membersopt
extension-member → declaration compiler-control-statement
Grammar of a subscript declaration
添え字宣言の文法
subscript-declaration → subscript-headsubscript-resultgeneric-where-clauseoptcode-block
subscript-declaration → subscript-headsubscript-resultgeneric-where-clauseoptgetter-setter-block
subscript-declaration → subscript-headsubscript-resultgeneric-where-clauseoptgetter-setter-keyword-block
subscript-head
→
attributesoptdeclaration-modifiersoptsubscript
generic-parameter-clauseoptparameter-clause
subscript-result
→
->
attributesopttype
Grammar of an operator declaration
演算子宣言の文法
operator-declaration → prefix-operator-declaration postfix-operator-declaration infix-operator-declaration
prefix-operator-declaration
→
prefix
operator
operator
postfix-operator-declaration
→
postfix
operator
operator
infix-operator-declaration
→
infix
operator
operatorinfix-operator-groupopt
infix-operator-group
→
:
precedence-group-name
Grammar of a precedence group declaration
優先順位グループ宣言の文法
precedence-group-declaration
→
precedencegroup
precedence-group-name{
precedence-group-attributesopt}
precedence-group-attributes → precedence-group-attributeprecedence-group-attributesopt
precedence-group-attribute → precedence-group-relation
precedence-group-attribute → precedence-group-assignment
precedence-group-attribute → precedence-group-associativity
precedence-group-relation
→
higherThan
:
precedence-group-names
precedence-group-relation
→
lowerThan
:
precedence-group-names
precedence-group-assignment
→
assignment
:
boolean-literal
precedence-group-associativity
→
associativity
:
left
precedence-group-names
→
precedence-group-name
precedence-group-name,
precedence-group-names
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
declaration-modifier → access-level-modifier
declaration-modifier → mutation-modifier
declaration-modifiers → declaration-modifierdeclaration-modifiersopt
Attributes
属性
Grammar of an attribute
属性の文法
attribute
→
@
attribute-nameattribute-argument-clauseopt
attribute-name → identifier
attribute-argument-clause
→
(
balanced-tokensopt)
attributes → attributeattributesopt
balanced-tokens → balanced-tokenbalanced-tokensopt
balanced-token
→
(
balanced-tokensopt)
balanced-token
→
[
balanced-tokensopt]
balanced-token
→
{
balanced-tokensopt}
balanced-token → Any identifier, keyword, literal, or operator 任意の識別子、キーワード、リテラル、または演算子
balanced-token
→
Any punctuation except (
, )
, [
, ]
, {
, or }
任意の句読点、しかし(
、)
、[
、]
、{
、または}
を除く
Patterns
パターン
Grammar of a pattern
パターンの文法
pattern → wildcard-patterntype-annotationopt
pattern → identifier-patterntype-annotationopt
pattern → value-binding-pattern
pattern → tuple-patterntype-annotationopt
pattern → enum-case-pattern
pattern → optional-pattern
pattern → type-casting-pattern
pattern → expression-pattern
Grammar of an identifier pattern
識別子パターンの文法
identifier-pattern → identifier
Grammar of a tuple pattern
タプル・パターンの文法
tuple-pattern
→
(
tuple-pattern-element-listopt)
tuple-pattern-element-list
→
tuple-pattern-element
tuple-pattern-element,
tuple-pattern-element-list
tuple-pattern-element
→
pattern
identifier:
pattern
Grammar of an enumeration case pattern
列挙ケース節パターンの文法
enum-case-pattern
→
type-identifieropt.
enum-case-nametuple-patternopt
Grammar of an optional pattern
オプショナルパターンの文法
optional-pattern
→
identifier-pattern?
Grammar of a type casting pattern
型キャスト・パターンの文法
Grammar of an expression pattern
式パターンの文法
expression-pattern → expression
Generic Parameters and Arguments
総称体パラメータと引数
Grammar of a generic parameter clause
総称体パラメータ節の文法
generic-parameter-clause
→
<
generic-parameter-list>
generic-parameter-list
→
generic-parameter
generic-parameter,
generic-parameter-list
generic-parameter → type-name
generic-parameter
→
type-name:
type-identifier
generic-parameter
→
type-name:
protocol-composition-type
generic-where-clause
→
where
requirement-list
requirement-list
→
requirement
requirement,
requirement-list
requirement → conformance-requirement same-type-requirement
conformance-requirement
→
type-identifier:
type-identifier
conformance-requirement
→
type-identifier:
protocol-composition-type
same-type-requirement
→
type-identifier==
type
Grammar of a generic argument clause
総称体引数節の文法
generic-argument-clause
→
<
generic-argument-list>
generic-argument-list
→
generic-argument
generic-argument,
generic-argument-list
generic-argument → type
Generic Parameters and Arguments
総称体パラメータと引数
Copyright © 2018 Apple Inc. All rights reserved. Terms of Use | Privacy Policy | Updated: 2018-03-29