|
| 1 | +# Copyright 2023 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +$schema: 'https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json' |
| 16 | +fileTypes: |
| 17 | + - pdl |
| 18 | +scopeName: source.pdl |
| 19 | +name: PDL |
| 20 | +foldingStartMarker: '\{\s*$' |
| 21 | +foldingStopMarker: '^\s*\}' |
| 22 | +patterns: |
| 23 | + - include: '#main' |
| 24 | +repository: |
| 25 | + main: |
| 26 | + patterns: |
| 27 | + - include: '#comments' |
| 28 | + - include: '#endianness' |
| 29 | + - include: '#declaration' |
| 30 | + - match: '([^\s])' |
| 31 | + name: invalid.illegal.pdl |
| 32 | + comments: |
| 33 | + patterns: |
| 34 | + - include: '#multi_line_comment' |
| 35 | + - match: (//).* |
| 36 | + name: comment.line.double-slash.pdl |
| 37 | + captures: |
| 38 | + '1': {name: punctuation.definition.comment.pdl} |
| 39 | + endianness: |
| 40 | + patterns: |
| 41 | + - match: \b(little_endian_packets|big_endian_packets)\b |
| 42 | + name: keyword.pdl |
| 43 | + declaration: |
| 44 | + patterns: |
| 45 | + - name: meta.enum.pdl |
| 46 | + begin: '(enum)\s+([a-zA-Z][a-zA-Z0-9_]*)\s*(:)\s*([0-9]+)\s*(\{)' |
| 47 | + beginCaptures: |
| 48 | + '1': {name: storage.type.enum.pdl} |
| 49 | + '2': {name: entity.name.type.enum.pdl} |
| 50 | + '3': {name: punctuation.separator.pdl} |
| 51 | + '4': {name: constant.numeric.decimal.pdl} |
| 52 | + '5': {name: punctuation.section.braces.begin.pdl} |
| 53 | + end: '(\})' |
| 54 | + endCaptures: |
| 55 | + '1': {name: punctuation.section.braces.end.pdl} |
| 56 | + patterns: |
| 57 | + - include: '#enum_body' |
| 58 | + - name: meta.enum.pdl |
| 59 | + begin: '(enum)\s+([a-zA-Z][a-zA-Z0-9_]*)\s*(:)\s*(0[xX][0-9a-fA-F]+)\s*(\{)' |
| 60 | + beginCaptures: |
| 61 | + '1': {name: storage.type.enum.pdl} |
| 62 | + '2': {name: entity.name.type.enum.pdl} |
| 63 | + '3': {name: punctuation.separator.pdl} |
| 64 | + '4': {name: constant.numeric.hex.pdl} |
| 65 | + '5': {name: punctuation.section.braces.begin.pdl} |
| 66 | + end: '(\})' |
| 67 | + endCaptures: |
| 68 | + '1': {name: punctuation.section.braces.end.pdl} |
| 69 | + patterns: |
| 70 | + - include: '#enum_body' |
| 71 | + - name: meta.packet.pdl |
| 72 | + begin: '(packet)\s+([a-zA-Z][a-zA-Z0-9_]*)\s*(\{)' |
| 73 | + beginCaptures: |
| 74 | + '1': {name: storage.type.packet.pdl} |
| 75 | + '2': {name: entity.name.type.packet.pdl} |
| 76 | + '3': {name: punctuation.section.braces.begin.pdl} |
| 77 | + end: '(\})' |
| 78 | + endCaptures: |
| 79 | + '1': {name: punctuation.section.braces.end.pdl} |
| 80 | + patterns: |
| 81 | + - include: '#field_list' |
| 82 | + - name: meta.packet.pdl |
| 83 | + begin: '(packet)\s+([a-zA-Z][a-zA-Z0-9_]*)\s*(:)\s*([a-zA-Z][a-zA-Z0-9_]*)\s*(\{)' |
| 84 | + beginCaptures: |
| 85 | + '1': {name: storage.type.packet.pdl} |
| 86 | + '2': {name: entity.name.type.packet.pdl} |
| 87 | + '3': {name: punctuation.separator.pdl} |
| 88 | + '4': {name: entity.name.type.packet.pdl} |
| 89 | + '5': {name: punctuation.section.braces.begin.pdl} |
| 90 | + end: '(\})' |
| 91 | + endCaptures: |
| 92 | + '1': {name: punctuation.section.braces.end.pdl} |
| 93 | + patterns: |
| 94 | + - include: '#field_list' |
| 95 | + - name: meta.struct.pdl |
| 96 | + begin: '(struct)\s+([a-zA-Z][a-zA-Z0-9_]*)\s*(\{)' |
| 97 | + beginCaptures: |
| 98 | + '1': {name: storage.type.struct.pdl} |
| 99 | + '2': {name: entity.name.type.struct.pdl} |
| 100 | + '3': {name: punctuation.section.braces.begin.pdl} |
| 101 | + end: '(\})' |
| 102 | + endCaptures: |
| 103 | + '1': {name: punctuation.section.braces.end.pdl} |
| 104 | + patterns: |
| 105 | + - include: '#field_list' |
| 106 | + - name: meta.struct.pdl |
| 107 | + begin: '(struct)\s+([a-zA-Z][a-zA-Z0-9_]*)\s*(:)\s*([a-zA-Z][a-zA-Z0-9_]*)\s*(\{)' |
| 108 | + beginCaptures: |
| 109 | + '1': {name: storage.type.struct.pdl} |
| 110 | + '2': {name: entity.name.type.struct.pdl} |
| 111 | + '3': {name: punctuation.separator.pdl} |
| 112 | + '4': {name: entity.name.type.struct.pdl} |
| 113 | + '5': {name: punctuation.section.braces.begin.pdl} |
| 114 | + end: '(\})' |
| 115 | + endCaptures: |
| 116 | + '1': {name: punctuation.section.braces.end.pdl} |
| 117 | + patterns: |
| 118 | + - include: '#field_list' |
| 119 | + - name: meta.group.pdl |
| 120 | + begin: '(group)\s+([a-zA-Z][a-zA-Z0-9_]*)\s*(\{)' |
| 121 | + beginCaptures: |
| 122 | + '1': {name: storage.type.group.pdl} |
| 123 | + '2': {name: entity.name.type.group.pdl} |
| 124 | + '3': {name: punctuation.section.braces.begin.pdl} |
| 125 | + end: '(\})' |
| 126 | + endCaptures: |
| 127 | + '1': {name: punctuation.section.braces.end.pdl} |
| 128 | + patterns: |
| 129 | + - include: '#field_list' |
| 130 | + - name: meta.checksum.pdl |
| 131 | + match: '(checksum)\s+([a-zA-Z][a-zA-Z0-9_]*)\s*(:)\s*([0-9]+)\s*(")([^\"]*)(")' |
| 132 | + captures: |
| 133 | + '1': {name: storage.type.checksum.pdl} |
| 134 | + '2': {name: entity.name.type.checksum.pdl} |
| 135 | + '3': {name: punctuation.separator.pdl} |
| 136 | + '4': {name: constant.numeric.decimal.pdl} |
| 137 | + '5': {name: punctuation.definition.string.begin.aidl} |
| 138 | + '6': {name: string.quoted.double.aidl} |
| 139 | + '7': {name: punctuation.definition.string.end.aidl} |
| 140 | + - name: meta.checksum.pdl |
| 141 | + match: '(checksum)\s+([a-zA-Z][a-zA-Z0-9_]*)\s*(:)\s*(0[xX][0-9a-fA-F]+)\s*(")([^\"]*)(")' |
| 142 | + captures: |
| 143 | + '1': {name: storage.type.checksum.pdl} |
| 144 | + '2': {name: entity.name.type.checksum.pdl} |
| 145 | + '3': {name: punctuation.separator.pdl} |
| 146 | + '4': {name: constant.numeric.hex.pdl} |
| 147 | + '5': {name: punctuation.definition.string.begin.aidl} |
| 148 | + '6': {name: string.quoted.double.aidl} |
| 149 | + '7': {name: punctuation.definition.string.end.aidl} |
| 150 | + enum_body: |
| 151 | + patterns: |
| 152 | + - include: '#comments' |
| 153 | + - match: = |
| 154 | + name: keyword.operator.assignment.pdl |
| 155 | + - include: '#integer' |
| 156 | + - match: , |
| 157 | + name: punctuation.separator.pdl |
| 158 | + - match: '[a-zA-Z][a-zA-Z0-9_]*' |
| 159 | + name: entity.name.constant.ddl |
| 160 | + field_list: |
| 161 | + patterns: |
| 162 | + - include: '#comments' |
| 163 | + - match: ':' |
| 164 | + name: punctuation.separator.pdl |
| 165 | + - match: (\[)\s*(\+)\s*([0-9]+)(\]) # SIZE_MODIFIER |
| 166 | + captures: |
| 167 | + '1': {name: punctuation.pdl} |
| 168 | + '2': {name: keyword.operator.arithmetic.pdl} |
| 169 | + '3': {name: constant.numeric.decimal.pdl} |
| 170 | + '4': {name: punctuation.pdl} |
| 171 | + - match: (\[)([0-9]+)(\]) |
| 172 | + captures: |
| 173 | + '1': {name: punctuation.pdl} |
| 174 | + '2': {name: constant.numeric.decimal.pdl} |
| 175 | + '3': {name: punctuation.pdl} |
| 176 | + - match: (\[)(0[xX][0-9a-fA-F]+)(\]) |
| 177 | + captures: |
| 178 | + '1': {name: punctuation.pdl} |
| 179 | + '2': {name: constant.numeric.hex.pdl} |
| 180 | + '3': {name: punctuation.pdl} |
| 181 | + - begin: '(\{)' |
| 182 | + beginCaptures: |
| 183 | + '1': {name: punctuation.section.braces.begin.pdl} |
| 184 | + end: '(\})' |
| 185 | + endCaptures: |
| 186 | + '1': {name: punctuation.section.braces.end.pdl} |
| 187 | + patterns: |
| 188 | + - include: '#constraint_list' |
| 189 | + - match: '(_size_)\s*(\()\s*(_payload_|_body_)\s*(\))\s*(:)' |
| 190 | + captures: |
| 191 | + '1': {name: keyword.pdl} |
| 192 | + '2': {name: punctuation.begin.pdl} |
| 193 | + '3': {name: keyword.pdl} |
| 194 | + '4': {name: punctuation.end.pdl} |
| 195 | + '5': {name: punctuation.separator.pdl} |
| 196 | + - match: '(_size_|_count_)\s*(\()\s*([a-zA-Z][a-zA-Z0-9_]*)\s*(\))\s*(:)' |
| 197 | + captures: |
| 198 | + '1': {name: keyword.pdl} |
| 199 | + '2': {name: punctuation.begin.pdl} |
| 200 | + '3': {name: entity.name.pdl} |
| 201 | + '4': {name: punctuation.end.pdl} |
| 202 | + '5': {name: punctuation.separator.pdl} |
| 203 | + - match: '(_payload_)\s*(:)\s*(\[)\s*(\+)\s*([0-9]+)([\]])' |
| 204 | + captures: |
| 205 | + '1': {name: keyword.pdl} |
| 206 | + '2': {name: punctuation.separator.pdl} |
| 207 | + '3': {name: punctuation.begin.pdl} |
| 208 | + '4': {name: keyword.operator.arithmetic.pdl} |
| 209 | + '5': {name: constant.numeric.decimal.pdl} |
| 210 | + '6': {name: punctuation.end.pdl} |
| 211 | + - match: _body_ |
| 212 | + name: keyword.pdl |
| 213 | + - match: '[a-zA-Z][a-zA-Z0-9_]*' |
| 214 | + name: entity.name.pdl |
| 215 | + - include: '#integer' |
| 216 | + integer: |
| 217 | + patterns: |
| 218 | + - match: '0[xX][0-9a-fA-F]+' |
| 219 | + name: constant.numeric.hex.pdl |
| 220 | + - match: '[0-9]+' |
| 221 | + name: constant.numeric.decimal.pdl |
| 222 | + multi_line_comment: |
| 223 | + patterns: |
| 224 | + - begin: (/\*\*) |
| 225 | + beginCaptures: |
| 226 | + '1': {name: punctuation.definition.comment.aidl} |
| 227 | + name: comment.block.documentation.aidl |
| 228 | + end: (\*/) |
| 229 | + endCaptures: |
| 230 | + '1': {name: punctuation.definition.comment.aidl} |
| 231 | + - begin: (/\*) |
| 232 | + beginCaptures: |
| 233 | + '1': {name: punctuation.definition.comment.aidl} |
| 234 | + name: comment.block.aidl |
| 235 | + end: (\*/) |
| 236 | + endCaptures: |
| 237 | + '1': {name: punctuation.definition.comment.aidl} |
0 commit comments