|
| 1 | +# B. Appendix: Grammar Summary |
| 2 | + |
| 3 | +SourceCharacter :: "Any Unicode code point" |
| 4 | + |
| 5 | + |
| 6 | +## Ignored Tokens |
| 7 | + |
| 8 | +Ignored :: |
| 9 | + - WhiteSpace |
| 10 | + - LineTerminator |
| 11 | + - Comment |
| 12 | + - Comma |
| 13 | + |
| 14 | +WhiteSpace :: |
| 15 | + - "Horizontal Tab (U+0009)" |
| 16 | + - "Vertical Tab (U+000B)" |
| 17 | + - "Form Feed (U+000C)" |
| 18 | + - "Space (U+0020)" |
| 19 | + - "No-break Space (U+00A0)" |
| 20 | + |
| 21 | +LineTerminator :: |
| 22 | + - "New Line (U+000A)" |
| 23 | + - "Carriage Return (U+000D)" |
| 24 | + - "Line Separator (U+2028)" |
| 25 | + - "Paragraph Separator (U+2029)" |
| 26 | + |
| 27 | +Comment :: |
| 28 | + - `#` CommentChar* |
| 29 | + |
| 30 | +CommentChar :: SourceCharacter but not LineTerminator |
| 31 | + |
| 32 | +Comma :: , |
| 33 | + |
| 34 | + |
| 35 | +## Lexical Tokens |
| 36 | + |
| 37 | +Token :: |
| 38 | + - Punctuator |
| 39 | + - Name |
| 40 | + - IntValue |
| 41 | + - FloatValue |
| 42 | + - StringValue |
| 43 | + |
| 44 | +Punctuator :: one of ! $ ( ) ... : = @ [ ] { | } |
| 45 | + |
| 46 | +Name :: /[_A-Za-z][_0-9A-Za-z]*/ |
| 47 | + |
| 48 | +IntValue :: IntegerPart |
| 49 | + |
| 50 | +IntegerPart :: |
| 51 | + - NegativeSign? 0 |
| 52 | + - NegativeSign? NonZeroDigit Digit* |
| 53 | + |
| 54 | +NegativeSign :: - |
| 55 | + |
| 56 | +Digit :: one of 0 1 2 3 4 5 6 7 8 9 |
| 57 | + |
| 58 | +NonZeroDigit :: Digit but not `0` |
| 59 | + |
| 60 | +FloatValue :: |
| 61 | + - IntegerPart FractionalPart |
| 62 | + - IntegerPart ExponentPart |
| 63 | + - IntegerPart FractionalPart ExponentPart |
| 64 | + |
| 65 | +FractionalPart :: . Digit+ |
| 66 | + |
| 67 | +ExponentPart :: ExponentIndicator Sign? Digit+ |
| 68 | + |
| 69 | +ExponentIndicator :: one of `e` `E` |
| 70 | + |
| 71 | +Sign :: one of + - |
| 72 | + |
| 73 | +StringValue :: |
| 74 | + - `""` |
| 75 | + - `"` StringCharacter+ `"` |
| 76 | + |
| 77 | +StringCharacter :: |
| 78 | + - SourceCharacter but not `"` or \ or LineTerminator |
| 79 | + - \ EscapedUnicode |
| 80 | + - \ EscapedCharacter |
| 81 | + |
| 82 | +EscapedUnicode :: u /[0-9A-Fa-f]{4}/ |
| 83 | + |
| 84 | +EscapedCharacter :: one of `"` \ `/` b f n r t |
| 85 | + |
| 86 | + |
| 87 | +## Query Document |
| 88 | + |
| 89 | +Document : Definition+ |
| 90 | + |
| 91 | +Definition : |
| 92 | + - OperationDefinition |
| 93 | + - FragmentDefinition |
| 94 | + |
| 95 | +OperationDefinition : |
| 96 | + - SelectionSet |
| 97 | + - OperationType Name VariableDefinitions? Directives? SelectionSet |
| 98 | + |
| 99 | +OperationType : one of query mutation |
| 100 | + |
| 101 | +SelectionSet : { Selection+ } |
| 102 | + |
| 103 | +Selection : |
| 104 | + - Field |
| 105 | + - FragmentSpread |
| 106 | + - InlineFragment |
| 107 | + |
| 108 | +Field : Alias? Name Arguments? Directives? SelectionSet? |
| 109 | + |
| 110 | +Alias : Name : |
| 111 | + |
| 112 | +Arguments : ( Argument+ ) |
| 113 | + |
| 114 | +Argument : Name : Value |
| 115 | + |
| 116 | +FragmentSpread : ... FragmentName Directives? |
| 117 | + |
| 118 | +InlineFragment : ... on TypeCondition Directives? SelectionSet |
| 119 | + |
| 120 | +FragmentDefinition : fragment FragmentName on TypeCondition Directives? SelectionSet |
| 121 | + |
| 122 | +FragmentName : Name but not `on` |
| 123 | + |
| 124 | +TypeCondition : NamedType |
| 125 | + |
| 126 | +Value[Const] : |
| 127 | + - [~Const] Variable |
| 128 | + - IntValue |
| 129 | + - FloatValue |
| 130 | + - StringValue |
| 131 | + - BooleanValue |
| 132 | + - EnumValue |
| 133 | + - ArrayValue[?Const] |
| 134 | + - ObjectValue[?Const] |
| 135 | + |
| 136 | +BooleanValue : one of `true` `false` |
| 137 | + |
| 138 | +EnumValue : Name but not `true`, `false` or `null` |
| 139 | + |
| 140 | +ArrayValue[Const] : |
| 141 | + - [ ] |
| 142 | + - [ Value[?Const]+ ] |
| 143 | + |
| 144 | +ObjectValue[Const] : |
| 145 | + - { } |
| 146 | + - { ObjectField[?Const]+ } |
| 147 | + |
| 148 | +ObjectField[Const] : Name : Value[?Const] |
| 149 | + |
| 150 | +VariableDefinitions : ( VariableDefinition+ ) |
| 151 | + |
| 152 | +VariableDefinition : Variable : Type DefaultValue? |
| 153 | + |
| 154 | +Variable : $ Name |
| 155 | + |
| 156 | +DefaultValue : = Value[Const] |
| 157 | + |
| 158 | +Type : |
| 159 | + - NamedType |
| 160 | + - ListType |
| 161 | + - NonNullType |
| 162 | + |
| 163 | +NamedType : Name |
| 164 | + |
| 165 | +ListType : [ Type ] |
| 166 | + |
| 167 | +NonNullType : |
| 168 | + - NamedType ! |
| 169 | + - ListType ! |
| 170 | + |
| 171 | +Directives : Directive+ |
| 172 | + |
| 173 | +Directive : @ Name Arguments? |
0 commit comments