Skip to content

Commit 5b30818

Browse files
committed
Rewrote fgd syntax to be less strict and allow multiple class definitions per file. Fixes #103
1 parent 3e53268 commit 5b30818

File tree

2 files changed

+41
-50
lines changed

2 files changed

+41
-50
lines changed

samples/fgd/test.fgd

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,25 @@
2222

2323
input InputExample(void) : "Description"
2424

25+
output OutputExample(void) : "Description"
26+
]
27+
28+
@PointClass base(TargetName, Origin) studio("path/mode)l.mdl")
29+
wirebox(0,10)
30+
= another_entity : "This is a test entity definition for syntax highlighting"
31+
[
32+
33+
KeyvalueExample1[engine](string) : "Keyvalue Display Name" : "Default" : "Description"
34+
KeyvalueExample2[!engine](string) : "Keyvalue Display Name" : 1 : "Description"
35+
KeyvalueExample3[P2, CSGO](string) : "Keyvalue Display Name" : "Default" : "Description"
36+
37+
spawnflags(flags) =
38+
[
39+
1 : "Flag" : 0
40+
2 : "Flag 2" : 0 [TF2]
41+
]
42+
KeyvalueExample4(string) : "Keyvalue Display Name" : "Default" : "Description"
43+
44+
input InputExample(void) : "Description"
2545
output OutputExample(void) : "Description"
2646
]

syntaxes/fgd.tmLanguage.json

Lines changed: 21 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
"name": "FGD",
44
"scopeName": "source.fgd",
55
"patterns": [
6-
{ "include": "#classDefinition" }
6+
{ "include": "#classDefinition" },
7+
{ "include": "#helper"},
8+
{ "include": "#classLabel" },
9+
{ "include": "#body" },
10+
{ "include": "source.kv#comment" }
711
],
812
"repository": {
913
"classDefinition": {
10-
"begin": "(\\@)(\\w+)",
11-
"beginCaptures": {
14+
"match": "(\\@)(\\w+)",
15+
"captures": {
1216
"1": { "name": "entity.name.type.fgd" },
1317
"2": {
1418
"patterns": [
@@ -18,54 +22,35 @@
1822
}
1923
]
2024
}
21-
},
22-
"end": "\\]",
23-
"patterns": [
24-
{ "include": "#helper" },
25-
{ "include": "#content" },
26-
{ "include": "source.kv#comment" }
27-
]
25+
}
2826
},
2927
"helper": {
3028
"begin": "(\\w+)\\(",
29+
"end": "\\)",
3130
"beginCaptures": {
32-
"1": { "name": "entity.other.attribute-name.fgd" }
31+
"1": { "name": "entity.name.function.fgd" }
3332
},
34-
"end": "\\)",
3533
"patterns": [
36-
{
37-
"match": "\\w+",
38-
"name": "string.unquoted.fgd"
39-
},
4034
{
4135
"match": "\\d+",
4236
"name": "constant.numeric.fgd"
4337
},
4438
{
45-
"begin": "\"",
46-
"end": "\"",
47-
"name": "string.quoted.double.fgd"
39+
"match": "\\w+",
40+
"name": "variable.parameter.fgd"
41+
},
42+
{
43+
"include": "source.kv#stringQuoted"
4844
}
4945
]
5046
},
51-
"content": {
52-
"begin": "=",
53-
"beginCaptures": {
54-
"0": { "name": "keyword.operator.fgd" }
55-
},
56-
"end": "\\]",
57-
"patterns": [
58-
{ "include": "#head" },
59-
{ "include": "#description" },
60-
{ "include": "#body" }
61-
]
62-
},
63-
"head": {
64-
"name": "meta.head.fgd",
65-
"match": "([\\w]+ *)(:)",
47+
"classLabel": {
48+
"match": "(=) *([\\w_]+) *(:) *(\\\"[\\w ]+\\\")",
6649
"captures": {
67-
"1": { "name": "entity.name.class.fgd" },
68-
"2": { "name": "keyword.operator.fgd" }
50+
"1": { "name": "keyword.operator.fgd" },
51+
"2": { "name": "entity.name.function.fgd" },
52+
"3": { "name": "keyword.operator.fgd" },
53+
"4": { "name": "string.quoted.double.fgd" }
6954
}
7055
},
7156
"body": {
@@ -114,20 +99,6 @@
11499
{ "include": "#preprocessorTag" }
115100
]
116101
},
117-
"description": {
118-
"name": "string.quoted.double.fgd",
119-
"begin": "\"",
120-
"end": "\"(\\s+)?",
121-
"endCaptures": {
122-
"1": { "name": "keyword.operator.fgd" }
123-
},
124-
"patterns": [
125-
{
126-
"match": "\\\\[a-z]",
127-
"name": "constant.character.escape.fgd"
128-
}
129-
]
130-
},
131102
"preprocessorTag": {
132103
"begin": "\\[",
133104
"end": "\\]",

0 commit comments

Comments
 (0)