|
| 1 | +switch n { |
| 2 | +case let x where x > 0: |
| 3 | + print("positive") |
| 4 | +case let y where y < 0, 0: |
| 5 | + print("non-positive") |
| 6 | +default: |
| 7 | + print("other") |
| 8 | +} |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +sourceFile |
| 13 | + endOfFileToken: endOfFile |
| 14 | + statements: |
| 15 | + codeBlockItem |
| 16 | + item: |
| 17 | + expressionStmt |
| 18 | + expression: |
| 19 | + switchExpr |
| 20 | + leftBrace: { |
| 21 | + rightBrace: } |
| 22 | + cases: |
| 23 | + switchCase |
| 24 | + label: |
| 25 | + switchCaseLabel |
| 26 | + colon: : |
| 27 | + caseKeyword: case |
| 28 | + caseItems: |
| 29 | + switchCaseItem |
| 30 | + pattern: |
| 31 | + valueBindingPattern |
| 32 | + pattern: |
| 33 | + identifierPattern |
| 34 | + identifier: identifier "x" |
| 35 | + bindingSpecifier: let |
| 36 | + whereClause: |
| 37 | + whereClause |
| 38 | + condition: |
| 39 | + infixOperatorExpr |
| 40 | + operator: |
| 41 | + binaryOperatorExpr |
| 42 | + operator: binaryOperator ">" |
| 43 | + leftOperand: |
| 44 | + declReferenceExpr |
| 45 | + baseName: identifier "x" |
| 46 | + rightOperand: |
| 47 | + integerLiteralExpr |
| 48 | + literal: integerLiteral "0" |
| 49 | + whereKeyword: where |
| 50 | + statements: |
| 51 | + codeBlockItem |
| 52 | + item: |
| 53 | + functionCallExpr |
| 54 | + leftParen: ( |
| 55 | + rightParen: ) |
| 56 | + arguments: |
| 57 | + labeledExpr |
| 58 | + expression: |
| 59 | + stringLiteralExpr |
| 60 | + closingQuote: " |
| 61 | + openingQuote: " |
| 62 | + segments: |
| 63 | + stringSegment |
| 64 | + content: stringSegment "positive" |
| 65 | + additionalTrailingClosures: |
| 66 | + calledExpression: |
| 67 | + declReferenceExpr |
| 68 | + baseName: identifier "print" |
| 69 | + switchCase |
| 70 | + label: |
| 71 | + switchCaseLabel |
| 72 | + colon: : |
| 73 | + caseKeyword: case |
| 74 | + caseItems: |
| 75 | + switchCaseItem |
| 76 | + trailingComma: , |
| 77 | + pattern: |
| 78 | + valueBindingPattern |
| 79 | + pattern: |
| 80 | + identifierPattern |
| 81 | + identifier: identifier "y" |
| 82 | + bindingSpecifier: let |
| 83 | + whereClause: |
| 84 | + whereClause |
| 85 | + condition: |
| 86 | + infixOperatorExpr |
| 87 | + operator: |
| 88 | + binaryOperatorExpr |
| 89 | + operator: binaryOperator "<" |
| 90 | + leftOperand: |
| 91 | + declReferenceExpr |
| 92 | + baseName: identifier "y" |
| 93 | + rightOperand: |
| 94 | + integerLiteralExpr |
| 95 | + literal: integerLiteral "0" |
| 96 | + whereKeyword: where |
| 97 | + switchCaseItem |
| 98 | + pattern: |
| 99 | + expressionPattern |
| 100 | + expression: |
| 101 | + integerLiteralExpr |
| 102 | + literal: integerLiteral "0" |
| 103 | + statements: |
| 104 | + codeBlockItem |
| 105 | + item: |
| 106 | + functionCallExpr |
| 107 | + leftParen: ( |
| 108 | + rightParen: ) |
| 109 | + arguments: |
| 110 | + labeledExpr |
| 111 | + expression: |
| 112 | + stringLiteralExpr |
| 113 | + closingQuote: " |
| 114 | + openingQuote: " |
| 115 | + segments: |
| 116 | + stringSegment |
| 117 | + content: stringSegment "non-positive" |
| 118 | + additionalTrailingClosures: |
| 119 | + calledExpression: |
| 120 | + declReferenceExpr |
| 121 | + baseName: identifier "print" |
| 122 | + switchCase |
| 123 | + label: |
| 124 | + switchDefaultLabel |
| 125 | + colon: : |
| 126 | + defaultKeyword: default |
| 127 | + statements: |
| 128 | + codeBlockItem |
| 129 | + item: |
| 130 | + functionCallExpr |
| 131 | + leftParen: ( |
| 132 | + rightParen: ) |
| 133 | + arguments: |
| 134 | + labeledExpr |
| 135 | + expression: |
| 136 | + stringLiteralExpr |
| 137 | + closingQuote: " |
| 138 | + openingQuote: " |
| 139 | + segments: |
| 140 | + stringSegment |
| 141 | + content: stringSegment "other" |
| 142 | + additionalTrailingClosures: |
| 143 | + calledExpression: |
| 144 | + declReferenceExpr |
| 145 | + baseName: identifier "print" |
| 146 | + subject: |
| 147 | + declReferenceExpr |
| 148 | + baseName: identifier "n" |
| 149 | + switchKeyword: switch |
| 150 | + |
| 151 | +--- |
| 152 | + |
| 153 | +top_level |
| 154 | + body: |
| 155 | + block |
| 156 | + stmt: |
| 157 | + switch_expr |
| 158 | + value: |
| 159 | + name_expr |
| 160 | + identifier: identifier "n" |
| 161 | + case: |
| 162 | + switch_case |
| 163 | + pattern: |
| 164 | + conditional_pattern |
| 165 | + condition: |
| 166 | + binary_expr |
| 167 | + left: |
| 168 | + name_expr |
| 169 | + identifier: identifier "x" |
| 170 | + operator: infix_operator ">" |
| 171 | + right: int_literal "0" |
| 172 | + pattern: |
| 173 | + name_pattern |
| 174 | + identifier: identifier "x" |
| 175 | + body: |
| 176 | + block |
| 177 | + stmt: |
| 178 | + call_expr |
| 179 | + callee: |
| 180 | + name_expr |
| 181 | + identifier: identifier "print" |
| 182 | + argument: |
| 183 | + argument |
| 184 | + value: string_literal "\"positive\"" |
| 185 | + switch_case |
| 186 | + pattern: |
| 187 | + or_pattern |
| 188 | + pattern: |
| 189 | + conditional_pattern |
| 190 | + condition: |
| 191 | + binary_expr |
| 192 | + left: |
| 193 | + name_expr |
| 194 | + identifier: identifier "y" |
| 195 | + operator: infix_operator "<" |
| 196 | + right: int_literal "0" |
| 197 | + pattern: |
| 198 | + name_pattern |
| 199 | + identifier: identifier "y" |
| 200 | + expr_equality_pattern |
| 201 | + expr: int_literal "0" |
| 202 | + body: |
| 203 | + block |
| 204 | + stmt: |
| 205 | + call_expr |
| 206 | + callee: |
| 207 | + name_expr |
| 208 | + identifier: identifier "print" |
| 209 | + argument: |
| 210 | + argument |
| 211 | + value: string_literal "\"non-positive\"" |
| 212 | + switch_case |
| 213 | + body: |
| 214 | + block |
| 215 | + stmt: |
| 216 | + call_expr |
| 217 | + callee: |
| 218 | + name_expr |
| 219 | + identifier: identifier "print" |
| 220 | + argument: |
| 221 | + argument |
| 222 | + value: string_literal "\"other\"" |
0 commit comments