Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

The_Swift_Programming_Language

.pdf
Скачиваний:
20
Добавлен:
18.03.2015
Размер:
4.75 Mб
Скачать
attributes opt

clause initializer-body

initializer-head → attributes opt convenience opt init initializer-body → code-block

G R A M M A R O F A D E I N I T I A L I Z E R D E C L A R A T I O N

deinitializer-declaration → attributes opt deinit code-block

G R A M M A R O F A N E X T E N S I O N D E C L A R A T I O N

extension-declarationextension type-identifier type-inheritance- clause opt extension-body

extension-body → { declarations opt }

G R A M M A R O F A S U B S C R I P T D E C L A R A T I O N

subscript-declarationsubscript-head subscript-result code-block subscript-declarationsubscript-head subscript-result getter-setter-block subscript-declarationsubscript-head subscript-result getter-setter-keyword-

block

subscript-headattributes opt subscript parameter-clause subscript-result-> type

G R A M M A R O F A N O P E R A T O R D E C L A R A T I O N

operator-declarationprefix-operator-declaration postfix-operator-declaration infix-operator-declaration

prefix-operator-declarationoperator prefix operator { } postfix-operator-declarationoperator postfix operator { } infix-operator-declarationoperator infix operator { infix-operator-attributes opt }

infix-operator-attributesprecedence-clause opt associativity-clause opt precedence-clauseprecedence precedence-level

precedence-levelDigit 0 through 255 associativity-clauseassociativity associativity associativity → left right none

Patterns

G R A M M A R O F A P A T T E R N

pattern → wildcard-pattern type-annotationopt pattern → identifier-pattern type-annotationopt pattern → value-binding-pattern

( balanced-tokens opt

pattern → tuple-pattern type-annotationopt pattern → enum-case-pattern

pattern → type-casting-pattern pattern → expression-pattern

G R A M M A R O F A W I L D C A R D P A T T E R N

wildcard-pattern → _

G R A M M A R O F A N I D E N T I F I E R P A T T E R N

identifier-pattern → identifier

G R A M M A R O F A V A L U E - B I N D I N G P A T T E R N

value-binding-pattern → var pattern let pattern

G R A M M A R O F A T U P L E P A T T E R N

tuple-pattern( tuple-pattern-element-list opt )

tuple-pattern-element-listtuple-pattern-element tuple-pattern-element , tuple- pattern-element-list

tuple-pattern-element → pattern

G R A M M A R O F A N E N U M E R A T I O N C A S E P A T T E R N

enum-case-patterntype-identifieropt . enum-case-name tuple-patternopt

G R A M M A R O F A T Y P E C A S T I N G P A T T E R N

type-casting-pattern → is-pattern as-pattern is-pattern → is type

as-pattern → pattern as type

G R A M M A R O F A N E X P R E S S I O N P A T T E R N

expression-pattern → expression

Attributes

G R A M M A R O F A N A T T R I B U T E

attribute → @ attribute-name attribute-argument-clause opt attribute-nameidentifier

attribute-argument-clause → ) attributes → attribute attributes opt

balanced-tokens balanced-token balanced-token balanced-token balanced-token balanced-token

balanced-token balanced-tokens opt

( balanced-tokens opt )

[ balanced-tokens opt ]

{ balanced-tokens opt }

Any identifier, keyword, literal, or operator

Any punctuation except ( , ) , [ , ] , { , or }

Expressions

G R A M M A R O F A N E X P R E S S I O N

expression → prefix-expression binary-expressions opt expression-listexpression expression , expression-list

G R A M M A R O F A P R E F I X E X P R E S S I O N

prefix-expressionprefix-operatoropt postfix-expression prefix-expressionin-out-expression

in-out-expression → & identifier

G R A M M A R O F A B I N A R Y E X P R E S S I O N

binary-expressionbinary-operator prefix-expression binary-expressionassignment-operator prefix-expression binary-expressionconditional-operator prefix-expression binary-expressiontype-casting-operator binary-expressionsbinary-expression binary-expressions opt

G R A M M A R O F A N A S S I G N M E N T O P E R A T O R

assignment-operator → =

G R A M M A R O F A C O N D I T I O N A L O P E R A T O R

conditional-operator → ? expression :

G R A M M A R O F A T Y P E - C A S T I N G O P E R A T O R

type-casting-operator → is type as ? opt type

G R A M M A R O F A P R I M A R Y E X P R E S S I O N

primary-expressionidentifier generic-argument-clause opt primary-expressionliteral-expression primary-expressionself-expression

primary-expression → superclass-expression

super . init
super [
, opt

primary-expression → closure-expression primary-expression → parenthesized-expression primary-expression → implicit-member-expression primary-expression → wildcard-expression

G R A M M A R O F A L I T E R A L E X P R E S S I O N

literal-expression → literal

literal-expressionarray-literal dictionary-literal

literal-expression__FILE__ __LINE__ __COLUMN__ __FUNCTION__

array-literal[ array-literal-items opt ]

array-literal-itemsarray-literal-item , opt array-literal-item , array-literal-items array-literal-itemexpression

dictionary-literal → [ dictionary-literal-items ] [ : ] dictionary-literal-items → dictionary-literal-item dictionary-literal-

item , dictionary-literal-items dictionary-literal-itemexpression : expression

G R A M M A R O F A S E L F E X P R E S S I O N

self-expressionself self-expressionself . identifier self-expressionself [ expression ] self-expressionself . init

G R A M M A R O F A S U P E R C L A S S E X P R E S S I O N

superclass-expressionsuperclass-method-expression superclass-subscript- expression superclass-initializer-expression

superclass-method-expression → super . identifier superclass-subscript-expression → expression ] superclass-initializer-expression →

G R A M M A R O F A C L O S U R E E X P R E S S I O N

closure-expression{ closure-signature opt statements }

closure-signatureparameter-clause function-result opt in closure-signatureidentifier-list function-result opt in closure-signaturecapture-list parameter-clause function-result opt in closure-signaturecapture-list identifier-list function-result opt in closure-signaturecapture-list in

capture-list[ capture-specifier expression ]

capture-specifierweak unowned unowned(safe) unowned(unsafe)

G R A M M A R O F A I M P L I C I T M E M B E R E X P R E S S I O N

implicit-member-expression → . identifier

G R A M M A R O F A P A R E N T H E S I Z E D E X P R E S S I O N

parenthesized-expression → ( expression-element-list opt ) expression-element-list → expression-element expression-element , expression-

element-list

expression-elementexpression identifier : expression

G R A M M A R O F A W I L D C A R D E X P R E S S I O N

wildcard-expression → _

G R A M M A R O F A P O S T F I X E X P R E S S I O N

postfix-expression → primary-expression postfix-expression → postfix-expression postfix-operator postfix-expression → function-call-expression postfix-expression → initializer-expression postfix-expression → explicit-member-expression postfix-expression → postfix-self-expression postfix-expression → dynamic-type-expression postfix-expression → subscript-expression postfix-expression → forced-value-expression postfix-expression → optional-chaining-expression

G R A M M A R O F A F U N C T I O N C A L L E X P R E S S I O N

function-call-expressionpostfix-expression parenthesized-expression function-call-expressionpostfix-expression parenthesized-expressionopt trailing-

closure

trailing-closure → closure-expression

G R A M M A R O F A N I N I T I A L I Z E R E X P R E S S I O N

initializer-expression → postfix-expression . init

G R A M M A R O F A N E X P L I C I T M E M B E R E X P R E S S I O N

explicit-member-expressionpostfix-expression . decimal-digit explicit-member-expressionpostfix-expression . identifier generic-argument-

clause opt

G R A M M A R O F A S E L F E X P R E S S I O N

postfix-self-expression → postfix-expression . self

G R A M M A R O F A D Y N A M I C T Y P E E X P R E S S I O N

dynamic-type-expression → postfix-expression . dynamicType

G R A M M A R O F A S U B S C R I P T E X P R E S S I O N

subscript-expressionpostfix-expression [ expression-list ]

G R A M M A R O F A F O R C E D - V A L U E E X P R E S S I O N

forced-value-expression → postfix-expression !

G R A M M A R O F A N O P T I O N A L- C H A I N I N G E X P R E S S I O N

optional-chaining-expression → postfix-expression ?

Lexical Structure

G R A M M A R O F A N I D E N T I F I E R

identifier → identifier-head identifier-characters opt identifier → ` identifier-head identifier-characters opt ` identifier → implicit-parameter-name

identifier-listidentifier identifier , identifier-list

identifier-headUpperor lowercase letter A through Z

identifier-headU+00A8, U+00AA, U+00AD, U+00AF, U+00B2–U+00B5, or U+00B7–U+00BA

identifier-headU+00BC–U+00BE, U+00C0–U+00D6, U+00D8–U+00F6, or U+00F8–U+00FF

identifier-headU+0100–U+02FF, U+0370–U+167F, U+1681–U+180D, or U+180F–U+1DBF

identifier-head → U+1E00–U+1FFF

identifier-headU+200B–U+200D, U+202A–U+202E, U+203F–U+2040, U+2054, or U+2060–U+206F

identifier-headU+2070–U+20CF, U+2100–U+218F, U+2460–U+24FF, or U+2776–U+2793

identifier-headU+2C00–U+2DFF or U+2E80–U+2FFF

identifier-headU+3004–U+3007, U+3021–U+302F, U+3031–U+303F, or U+3040–U+D7FF

identifier-headU+F900–U+FD3D, U+FD40–U+FDCF, U+FDF0–U+FE1F, or U+FE30–U+FE44

identifier-head → U+FE47–U+FFFD

identifier-headU+10000–U+1FFFD, U+20000–U+2FFFD, U+30000–U+3FFFD, or U+40000–U+4FFFD

identifier-headU+50000–U+5FFFD, U+60000–U+6FFFD, U+70000–U+7FFFD, or U+80000–U+8FFFD

identifier-headU+90000–U+9FFFD, U+A0000–U+AFFFD, U+B0000–U+BFFFD, or U+C0000–U+CFFFD

identifier-headU+D0000–U+DFFFD or U+E0000–U+EFFFD

identifier-character → Digit 0 through 9

identifier-characterU+0300–U+036F, U+1DC0–U+1DFF, U+20D0–U+20FF, or U+FE20–U+FE2F

identifier-character → identifier-head

identifier-charactersidentifier-character identifier-characters opt

implicit-parameter-name → $ decimal-digits

G R A M M A R O F A L I T E R A L

literal → integer-literal floating-point-literal string-literal

G R A M M A R O F A N I N T E G E R L I T E R A L

integer-literal → binary-literal integer-literal → octal-literal integer-literal → decimal-literal integer-literal → hexadecimal-literal

binary-literal0b binary-digit binary-literal-characters opt binary-digitDigit 0 or 1

binary-literal-character → binary-digit _

binary-literal-charactersbinary-literal-character binary-literal-characters opt

octal-literal0o octal-digit octal-literal-characters opt octal-digitDigit 0 through 7

octal-literal-character → octal-digit _

octal-literal-charactersoctal-literal-character octal-literal-characters opt

decimal-literaldecimal-digit decimal-literal-characters opt decimal-digitDigit 0 through 9

decimal-digitsdecimal-digit decimal-digits opt decimal-literal-characterdecimal-digit _

decimal-literal-charactersdecimal-literal-character decimal-literal-characters opt

hexadecimal-literal0x hexadecimal-digit hexadecimal-literal-characters opt hexadecimal-digitDigit 0 through 9, a through f, or A through F hexadecimal-literal-characterhexadecimal-digit _

hexadecimal-literal-charactershexadecimal-literal-character hexadecimal-literal- characters opt

G R A M M A R O F A F L O A T I N G - P O I N T L I T E R A L

floating-point-literaldecimal-literal decimal-fractionopt decimal-exponent opt floating-point-literalhexadecimal-literal hexadecimal-fractionopt hexadecimal-

exponent

decimal-fraction → . decimal-literal

decimal-exponentfloating-point-e signopt decimal-literal

hexadecimal-fraction → . hexadecimal-literal opt hexadecimal-exponent → floating-point-p signopt hexadecimal-literal

floating-point-e → e E floating-point-p → p P sign → + -

G R A M M A R O F A S T R I N G L I T E R A L

string-literal → " quoted-text "

quoted-textquoted-text-item quoted-text opt quoted-text-itemescaped-character quoted-text-item\( expression )

quoted-text-itemAny Unicode extended grapheme cluster except " , \ , U+000A, or U+000D

escaped-character → \0 \\ \t \n \r \" \' escaped-character → \x hexadecimal-digit hexadecimal-digit

escaped-character\u hexadecimal-digit hexadecimal-digit hexadecimaldigit hexadecimal-digit

escaped-character\U hexadecimal-digit hexadecimal-digit hexadecimaldigit hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimaldigit hexadecimal-digit

G R A M M A R O F O P E R A T O R S

operator → operator-character operatoropt operator-character/ = - + ! * % < > & | ^ ~ .

binary-operator → operator prefix-operator → operator postfix-operator → operator

Types

G R A M M A R O F A T Y P E

type → array-type function-type type-identifier tuple-type optional-type implicitly-unwrapped-optional-type protocol-composition-type metatype-type

G R A M M A R O F A T Y P E A N N O T A T I O N

type-annotation → : attributes opt type

G R A M M A R O F A T Y P E I D E N T I F I E R

type-identifiertype-name generic-argument-clause opt type-name generic- argument-clause opt . type-identifier

type-name → identifier

G R A M M A R O F A T U P L E T Y P E

tuple-type( tuple-type-body opt ) tuple-type-bodytuple-type-element-list ... opt

tuple-type-element-listtuple-type-element tuple-type-element , tuple-type- element-list

tuple-type-elementattributes opt inout opt type inout opt element-name typeannotation

element-name → identifier

G R A M M A R O F A F U N C T I O N T Y P E

function-type → type -> type

G R A M M A R O F A N A R R A Y T Y P E

array-typetype [ ] array-type [ ]

G R A M M A R O F A N O P T I O N A L T Y P E

optional-type → type ?

G R A M M A R O F A N I M P L I C I T LY U N W R A P P E D O P T I O N A L T Y P E

implicitly-unwrapped-optional-type → type !

G R A M M A R O F A P R O T O C O L C O M P O S I T I O N T Y P E

protocol-composition-type → protocol < protocol-identifier-list opt > protocol-identifier-list → protocol-identifier protocol-identifier , protocol-identifier-

list

protocol-identifier → type-identifier

G R A M M A R O F A M E T A T Y P E T Y P E

metatype-typetype . Type type . Protocol

G R A M M A R O F A T Y P E I N H E R I T A N C E C L A U S E

type-inheritance-clause → : type-inheritance-list

type-inheritance-listtype-identifier type-identifier , type-inheritance-list

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]