|
| 1 | +// SYNTAX TEST "source.swift.gyb" "Character struct" |
| 2 | + |
| 3 | +%{ |
| 4 | +// <- keyword.control.gyb |
| 5 | +// <~- punctuation.section.block.begin.gyb |
| 6 | + abilities = ['strength', 'perception', 'endurance', 'charisma', 'intelligence', 'agility', 'luck'] |
| 7 | +// ^ keyword.operator.assignment.python |
| 8 | +// ^ punctuation.definition.list.begin.python |
| 9 | +// ^ punctuation.definition.string.begin.python |
| 10 | +// ^^^^^^^^ string.quoted.single.python |
| 11 | +// ^ punctuation.definition.string.end.python |
| 12 | +// ^ punctuation.separator.element.python |
| 13 | +}% |
| 14 | +// <- punctuation.section.block.end.gyb |
| 15 | +// <~- keyword.control.gyb |
| 16 | + |
| 17 | +enum Hello {} |
| 18 | + |
| 19 | +% for ability in abilities: |
| 20 | +// <- keyword.control.flow.gyb |
| 21 | +// <~~--- keyword.control.flow.python |
| 22 | +// ^^ keyword.control.flow.python |
| 23 | +// ^ punctuation.separator.colon.gyb |
| 24 | +print("${ability}") |
| 25 | +// <----- support.function.swift |
| 26 | +// ^ punctuation.definition.arguments.begin.swift |
| 27 | +// ^ punctuation.definition.string.begin.swift |
| 28 | +// ^ variable.other.gyb |
| 29 | +// ^ punctuation.section.expression.begin.gyb |
| 30 | +// ^ punctuation.section.expression.end.gyb |
| 31 | +// ^ punctuation.definition.string.end.swift |
| 32 | +// ^ punctuation.definition.arguments.end.swift |
| 33 | +% end |
| 34 | +// <----- meta.embedded.control.end.gyb keyword.control.flow.gyb |
| 35 | + |
| 36 | +struct Character { |
| 37 | +// <------ storage.type.struct.swift |
| 38 | +// ^^^^^^^^^ entity.name.type.struct.swift |
| 39 | +// ^ punctuation.definition.type.begin.swift |
| 40 | + let name: String |
| 41 | +// ^^^ keyword.other.declaration-specifier.swift |
| 42 | +// ^^^^ meta.definition.type.body.swift |
| 43 | +// ^^^^^^ support.type.swift |
| 44 | + |
| 45 | + % for ability in abilities: |
| 46 | +// ^ keyword.control.flow.gyb |
| 47 | +// ^^^ keyword.control.flow.python |
| 48 | +// ^^ keyword.control.flow.python |
| 49 | +// ^ punctuation.separator.colon.gyb |
| 50 | + let ${ability}: Int |
| 51 | +// ^^^ keyword.other.declaration-specifier.swift |
| 52 | +// ^ variable.other.gyb |
| 53 | +// ^^ punctuation.section.expression.begin.gyb |
| 54 | +// ^ punctuation.section.expression.end.gyb |
| 55 | + % end |
| 56 | +// ^^^^^ meta.embedded.control.end.gyb keyword.control.flow.gyb |
| 57 | + |
| 58 | + %{ |
| 59 | +// ^ keyword.control.gyb |
| 60 | +// ^ punctuation.section.block.begin.gyb |
| 61 | + for i in range(10): |
| 62 | +// ^^^^^ support.function.builtin.python |
| 63 | + print(i) |
| 64 | + }% |
| 65 | +// ^ punctuation.section.block.end.gyb |
| 66 | +// ^ keyword.control.gyb |
| 67 | + |
| 68 | + enum Error { |
| 69 | + case notFound |
| 70 | + |
| 71 | + % for ability in abilities: |
| 72 | + case ${ability} |
| 73 | + % end |
| 74 | + } |
| 75 | +} |
| 76 | +// <- punctuation.definition.type.end.swift |
| 77 | + |
| 78 | +enum World {} |
| 79 | + |
| 80 | +% for ability in abilities: |
| 81 | +// <- keyword.control.flow.gyb |
| 82 | +// <~~--- keyword.control.flow.python |
| 83 | +// ^^ keyword.control.flow.python |
| 84 | +// ^ punctuation.separator.colon.gyb |
| 85 | +print("${ability}") |
| 86 | +// <----- support.function.swift |
| 87 | +// ^ punctuation.definition.arguments.begin.swift |
| 88 | +// ^ punctuation.definition.string.begin.swift |
| 89 | +// ^ variable.other.gyb |
| 90 | +// ^ punctuation.section.expression.begin.gyb |
| 91 | +// ^ punctuation.section.expression.end.gyb |
| 92 | +// ^ punctuation.definition.string.end.swift |
| 93 | +// ^ punctuation.definition.arguments.end.swift |
| 94 | +% end |
| 95 | +// <----- meta.embedded.control.end.gyb keyword.control.flow.gyb |
| 96 | + |
| 97 | +struct SimpleCharacter { |
| 98 | +// <------ storage.type.struct.swift |
| 99 | +// ^^^^^^^^^^^^^^^ entity.name.type.struct.swift |
| 100 | +// ^ punctuation.definition.type.begin.swift |
| 101 | + let name: String |
| 102 | +// ^^^ keyword.other.declaration-specifier.swift |
| 103 | +// ^^^^ meta.definition.type.body.swift |
| 104 | +// ^^^^^^ support.type.swift |
| 105 | + |
| 106 | + % for ability in abilities: |
| 107 | + let ${ability}: Int |
| 108 | + % end |
| 109 | +} |
| 110 | +// <- punctuation.definition.type.end.swift |
| 111 | + |
0 commit comments