From 3c92b75a753aa2b05bd3c4b9cd53cdba37268f2a Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Tue, 31 Jan 2023 14:07:25 +0000 Subject: [PATCH] Support constraint lists in packets and structs. --- syntaxes/pdl.tmLanguage.YAML-tmLanguage | 36 ++++++++++- syntaxes/pdl.tmLanguage.json | 83 +++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 2 deletions(-) diff --git a/syntaxes/pdl.tmLanguage.YAML-tmLanguage b/syntaxes/pdl.tmLanguage.YAML-tmLanguage index da4fd3e..1e1d902 100644 --- a/syntaxes/pdl.tmLanguage.YAML-tmLanguage +++ b/syntaxes/pdl.tmLanguage.YAML-tmLanguage @@ -92,7 +92,19 @@ repository: '1': {name: punctuation.section.braces.end.pdl} patterns: - include: '#field_list' - # TODO: Packets with constraint lists. + - name: meta.packet.pdl + begin: '(packet)\s+([a-zA-Z][a-zA-Z0-9_]*)\s*(:)\s*([a-zA-Z][a-zA-Z0-9_]*)\s*(\()' + beginCaptures: + '1': {name: storage.type.packet.pdl} + '2': {name: entity.name.type.packet.pdl} + '3': {name: punctuation.separator.pdl} + '4': {name: entity.name.pdl} + '5': {name: punctuation.begin.pdl} + end: '(\))' + endCaptures: + '1': {name: punctuation.section.braces.end.pdl} + patterns: + - include: '#constraint_list' - name: meta.struct.pdl begin: '(struct)\s+([a-zA-Z][a-zA-Z0-9_]*)\s*(\{)' beginCaptures: @@ -117,7 +129,27 @@ repository: '1': {name: punctuation.section.braces.end.pdl} patterns: - include: '#field_list' - # TODO: Structs with constraint lists. + - name: meta.struct.pdl + begin: '(struct)\s+([a-zA-Z][a-zA-Z0-9_]*)\s*(:)\s*([a-zA-Z][a-zA-Z0-9_]*)\s*(\()' + beginCaptures: + '1': {name: storage.type.struct.pdl} + '2': {name: entity.name.type.struct.pdl} + '3': {name: punctuation.separator.pdl} + '4': {name: entity.name.pdl} + '5': {name: punctuation.begin.pdl} + end: '(\))' + endCaptures: + '1': {name: punctuation.section.braces.end.pdl} + patterns: + - include: '#constraint_list' + - begin: '(\{)' + beginCaptures: + '1': {name: punctuation.begin.pdl} + end: '(\})' + endCaptures: + '1': {name: punctuation.section.braces.end.pdl} + patterns: + - include: '#field_list' - name: meta.group.pdl begin: '(group)\s+([a-zA-Z][a-zA-Z0-9_]*)\s*(\{)' beginCaptures: diff --git a/syntaxes/pdl.tmLanguage.json b/syntaxes/pdl.tmLanguage.json index 61868c3..212bfba 100644 --- a/syntaxes/pdl.tmLanguage.json +++ b/syntaxes/pdl.tmLanguage.json @@ -178,6 +178,38 @@ } ] }, + { + "name": "meta.packet.pdl", + "begin": "(packet)\\s+([a-zA-Z][a-zA-Z0-9_]*)\\s*(:)\\s*([a-zA-Z][a-zA-Z0-9_]*)\\s*(\\()", + "beginCaptures": { + "1": { + "name": "storage.type.packet.pdl" + }, + "2": { + "name": "entity.name.type.packet.pdl" + }, + "3": { + "name": "punctuation.separator.pdl" + }, + "4": { + "name": "entity.name.pdl" + }, + "5": { + "name": "punctuation.begin.pdl" + } + }, + "end": "(\\))", + "endCaptures": { + "1": { + "name": "punctuation.section.braces.end.pdl" + } + }, + "patterns": [ + { + "include": "#constraint_list" + } + ] + }, { "name": "meta.struct.pdl", "begin": "(struct)\\s+([a-zA-Z][a-zA-Z0-9_]*)\\s*(\\{)", @@ -236,6 +268,57 @@ } ] }, + { + "name": "meta.struct.pdl", + "begin": "(struct)\\s+([a-zA-Z][a-zA-Z0-9_]*)\\s*(:)\\s*([a-zA-Z][a-zA-Z0-9_]*)\\s*(\\()", + "beginCaptures": { + "1": { + "name": "storage.type.struct.pdl" + }, + "2": { + "name": "entity.name.type.struct.pdl" + }, + "3": { + "name": "punctuation.separator.pdl" + }, + "4": { + "name": "entity.name.pdl" + }, + "5": { + "name": "punctuation.begin.pdl" + } + }, + "end": "(\\))", + "endCaptures": { + "1": { + "name": "punctuation.section.braces.end.pdl" + } + }, + "patterns": [ + { + "include": "#constraint_list" + } + ] + }, + { + "begin": "(\\{)", + "beginCaptures": { + "1": { + "name": "punctuation.begin.pdl" + } + }, + "end": "(\\})", + "endCaptures": { + "1": { + "name": "punctuation.section.braces.end.pdl" + } + }, + "patterns": [ + { + "include": "#field_list" + } + ] + }, { "name": "meta.group.pdl", "begin": "(group)\\s+([a-zA-Z][a-zA-Z0-9_]*)\\s*(\\{)",