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

The_Swift_Programming_Language

.pdf
Скачиваний:
24
Добавлен:
18.03.2015
Размер:
5 Мб
Скачать
☆
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-declaration → extension 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-declaration → subscript-head subscript-result code-block ​subscript-declaration → subscript-head subscript-result getter-setter-block ​subscript-declaration → subscript-head subscript-result getter-setter-keyword-

block

​subscript-head → attributes 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-declaration → prefix-operator-declaration postfix-operator-declaration infix-operator-declaration

​prefix-operator-declaration → operator prefix operator { } ​postfix-operator-declaration → operator postfix operator { } ​infix-operator-declaration → operator infix operator { infix-operator-attributes opt }

​infix-operator-attributes → precedence-clause opt associativity-clause opt ​precedence-clause → precedence precedence-level

​precedence-level → Digit 0 through 255 ​associativity-clause → associativity 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-list → tuple-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-pattern → type-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-name → identifier

​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-list → expression 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-expression → prefix-operatoropt postfix-expression ​prefix-expression → in-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-expression → binary-operator prefix-expression ​binary-expression → assignment-operator prefix-expression ​binary-expression → conditional-operator prefix-expression ​binary-expression → type-casting-operator ​binary-expressions → binary-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-expression → identifier generic-argument-clause opt ​primary-expression → literal-expression ​primary-expression → self-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-expression → array-literal dictionary-literal

​literal-expression → __FILE__ __LINE__ __COLUMN__ __FUNCTION__

​array-literal → [ array-literal-items opt ]

​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 dictionary-literal-

item , dictionary-literal-items ​dictionary-literal-item → expression : 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-expression → self ​self-expression → self . identifier ​self-expression → self [ expression ] ​self-expression → self . 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-expression → superclass-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-signature → parameter-clause function-result opt in ​closure-signature → identifier-list function-result opt in ​closure-signature → capture-list parameter-clause function-result opt in ​closure-signature → capture-list identifier-list function-result opt in ​closure-signature → capture-list in

​capture-list → [ capture-specifier expression ]

​capture-specifier → weak 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-element → expression 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-expression → postfix-expression parenthesized-expression ​function-call-expression → postfix-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-expression → postfix-expression . decimal-digit ​explicit-member-expression → postfix-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-expression → postfix-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-list → identifier identifier , identifier-list

​identifier-head → Upperor lowercase letter A through 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-head → U+D0000–U+DFFFD or U+E0000–U+EFFFD

​identifier-character → Digit 0 through 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-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-literal → 0b binary-digit binary-literal-characters opt ​binary-digit → Digit 0 or 1

​binary-literal-character → binary-digit _

​binary-literal-characters → binary-literal-character binary-literal-characters opt

​octal-literal → 0o octal-digit octal-literal-characters opt ​octal-digit → Digit 0 through 7

​octal-literal-character → octal-digit _

​octal-literal-characters → octal-literal-character octal-literal-characters opt

​decimal-literal → decimal-digit decimal-literal-characters opt ​decimal-digit → Digit 0 through 9

​decimal-digits → decimal-digit decimal-digits opt ​decimal-literal-character → decimal-digit _

​decimal-literal-characters → decimal-literal-character decimal-literal-characters opt

​hexadecimal-literal → 0x hexadecimal-digit hexadecimal-literal-characters opt ​hexadecimal-digit → Digit 0 through 9, a through f, or A through F ​hexadecimal-literal-character → hexadecimal-digit _

​hexadecimal-literal-characters → hexadecimal-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-literal → decimal-literal decimal-fractionopt decimal-exponent opt ​floating-point-literal → hexadecimal-literal hexadecimal-fractionopt hexadecimal-

exponent

​decimal-fraction → . decimal-literal

​decimal-exponent → floating-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-text → quoted-text-item quoted-text opt ​quoted-text-item → escaped-character ​quoted-text-item → \( expression )

​quoted-text-item → Any 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-identifier → type-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-body → tuple-type-element-list ... opt

​tuple-type-element-list → tuple-type-element tuple-type-element , tuple-type- element-list

​tuple-type-element → attributes 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-type → type [ ] 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-type → type . 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-list → type-identifier type-identifier , type-inheritance-list

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