The Open Protocol Notation Programming Guide 1 Document Version 1 (4/23/2018)



Download 1.37 Mb.
Page14/24
Date23.04.2018
Size1.37 Mb.
#46651
1   ...   10   11   12   13   14   15   16   17   ...   24

Patterns


Note that types and proper patterns are unified with one non-terminal operator, called Pattern, reflecting that types are subset of patterns.
      1. Composed Patterns


Pattern ::= ([|Expression|])? Pattern | ([|Expression|])? Pattern[1]

Pattern[1] ::= Pattern[1] & Pattern[2]

Pattern[2] ::= Pattern[2] + Pattern[3]
      1. Count Patterns


Pattern[3] ::= Pattern[4] *

Pattern[3] ::= Pattern[4] +

Pattern[3] ::= Pattern[4] #?

Pattern[3] ::= Pattern[4] # PatternCountValue

Pattern[3] ::= Pattern[4] # PatternCountValue .. PatternCountValue?

Pattern[3] ::= Pattern[4] #.. PatternCountValue

PatternCountValue ::= PrimaryExpression
      1. From (Decoding) Pattern


Pattern[3] ::= Pattern[4] from Reference
      1. Constraint Patterns


Pattern[4] ::= Pattern[5] Constraint

Constraint ::= where Expression
      1. Capture Patterns


Pattern[5] ::= Identifier : Pattern[6]

Pattern[5] ::= var Identifier

PrimaryPattern ::= Pattern[6]
      1. Not Patterns


Pattern[6] ::= ! Pattern[6]
      1. Nullable or Optional Patterns


Pattern[6] ::= Pattern[7] ?

Pattern[6] ::= optional ([|Expression|])? Pattern[7]

Note: in the context of a sequential pattern, this operator denotes 0 or 1 repetitions. In the context of a singleton pattern, it denotes nullable.


      1. Parenthesized Patterns


Pattern[7] ::= ( Pattern )
      1. Function Patterns


Pattern[7] ::= PrimaryPattern(( Pattern ( , Pattern )* )? )
      1. Reference Patterns


Pattern[7] ::= ReferencePattern

ReferencePattern ::= ReferencePatternIdentifier GenericArguments? TypeArguments?

TypeArguments ::= [ ( Expression ( , Expression )* )? ]

ReferencePatternWithoutArguments ::= ReferencePatternIdentifier GenericArguments?

ReferencePatternIdentifier ::= QualifiedIdentifier | PredefinedTypeIdentifier

PredefinedTypeIdentifier ::=

byte | sbyte | short | ushort | int | uint | long | ulong | float | double | decimal | guid | bool | char | string | binary | any | any aspect | any endpoint | any message | any type | array | set | map | | json | xml | treedata | void
      1. Literal and Expression Patterns


Pattern[7] ::= $ PrimaryExpression

Pattern[7] ::= Literal

Pattern[7] ::= regex BlockLiteral
      1. Range Patterns


Pattern[7] ::= $ PrimaryExpression .. PrimaryExpression

Pattern[7] ::= Literal .. Literal
      1. Membership Patterns


Pattern[7] ::= in Expression
      1. Compound Patterns


Pattern[7] ::= (\\ | \)? ReferencePattern FieldPatterns? ((\\ | \) ReferencePattern FieldPatterns?)* )

FieldPatterns ::= { (FieldPattern ( , FieldPattern )* )? }

FieldPattern ::= (Identifier | exception) is Pattern | Identifier == Expression | Expression
      1. Array Patterns


Pattern[7] ::= [ SequentialPattern? ]

SequentialPattern::= Pattern ( , Pattern )* ( , WildcardPattern? )?

WildcardPattern ::= ... ( Identifier )?
      1. Map Patterns


Pattern[7] ::= { ( EntryPattern ( , EntryPattern )* ( , WildcardPattern? )? )? }

EntryPattern ::= Expression -> Pattern
      1. Set Patterns


Pattern[7] ::= { SequentialPattern? }
      1. Enum Patterns


Pattern[7] ::= ( enum | flags ) EnumBase? { (EnumField ( , EnumField )* )? ,? }

EnumBase ::= ReferencePatternWithoutArguments

EnumField ::= Identifier ( = Expression)? Aspects?
      1. Reference Patterns with Capture


Pattern[7] ::= ReferencePatternWithCapture

ReferencePatternWithCapture ::= (Identifier:)? ReferencePattern


    1. Download 1.37 Mb.

      Share with your friends:
1   ...   10   11   12   13   14   15   16   17   ...   24




The database is protected by copyright ©ininet.org 2024
send message

    Main page