Skip to content

Commit 3e53268

Browse files
committed
Make fgd syntax more robust when dealing with keywords and match keywords case insentively. Fixes #104
1 parent 6874076 commit 3e53268

File tree

1 file changed

+41
-80
lines changed

1 file changed

+41
-80
lines changed

syntaxes/fgd.tmLanguage.json

Lines changed: 41 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,33 @@
33
"name": "FGD",
44
"scopeName": "source.fgd",
55
"patterns": [
6-
{
7-
"include": "#classDefinition"
8-
}
6+
{ "include": "#classDefinition" }
97
],
108
"repository": {
119
"classDefinition": {
12-
"begin": "(\\@)(PointClass|NPCClass|SolidClass|KeyFrameClass|MoveClass|FilterClass|BaseClass)",
10+
"begin": "(\\@)(\\w+)",
1311
"beginCaptures": {
14-
"1": {
15-
"name": "entity.name.type.fgd"
16-
},
12+
"1": { "name": "entity.name.type.fgd" },
1713
"2": {
18-
"name": "entity.name.type.fgd"
14+
"patterns": [
15+
{
16+
"match": "(?i)(PointClass|NPCClass|SolidClass|KeyFrameClass|MoveClass|FilterClass|BaseClass)(?-i)",
17+
"name": "entity.name.type.fgd"
18+
}
19+
]
1920
}
2021
},
2122
"end": "\\]",
2223
"patterns": [
23-
{
24-
"include": "#helper"
25-
},
26-
{
27-
"include": "#content"
28-
},
29-
{
30-
"include": "source.kv#comment"
31-
}
24+
{ "include": "#helper" },
25+
{ "include": "#content" },
26+
{ "include": "source.kv#comment" }
3227
]
3328
},
3429
"helper": {
3530
"begin": "(\\w+)\\(",
3631
"beginCaptures": {
37-
"1": {
38-
"name": "entity.other.attribute-name.fgd"
39-
}
32+
"1": { "name": "entity.other.attribute-name.fgd" }
4033
},
4134
"end": "\\)",
4235
"patterns": [
@@ -58,30 +51,21 @@
5851
"content": {
5952
"begin": "=",
6053
"beginCaptures": {
61-
"0": {
62-
"name": "keyword.operator.fgd"
63-
}
54+
"0": { "name": "keyword.operator.fgd" }
6455
},
6556
"end": "\\]",
6657
"patterns": [
67-
{
68-
"include": "#head"
69-
},
70-
{
71-
"include": "#description"
72-
},
73-
{
74-
"include": "#body"
75-
}
58+
{ "include": "#head" },
59+
{ "include": "#description" },
60+
{ "include": "#body" }
7661
]
7762
},
7863
"head": {
7964
"name": "meta.head.fgd",
80-
"match": "([\\w]+ *:)",
65+
"match": "([\\w]+ *)(:)",
8166
"captures": {
82-
"1": {
83-
"name": "entity.name.class.fgd"
84-
}
67+
"1": { "name": "entity.name.class.fgd" },
68+
"2": { "name": "keyword.operator.fgd" }
8569
}
8670
},
8771
"body": {
@@ -93,68 +77,49 @@
9377
"match": "(input|output)",
9478
"name": "storage.modifier"
9579
},
96-
{
97-
"include": "#array"
98-
},
99-
{
100-
"include": "source.kv#comment"
101-
},
102-
{
103-
"include": "source.kv#number"
104-
},
105-
{
106-
"include": "source.kv#stringQuoted"
107-
},
108-
{
109-
"include": "#keyvalueName"
110-
},
111-
{
112-
"include": "#description"
113-
}
80+
{ "include": "#array" },
81+
{ "include": "source.kv#comment" },
82+
{ "include": "source.kv#number" },
83+
{ "include": "source.kv#stringQuoted" },
84+
{ "include": "#keyvalueName" },
85+
{ "include": "#description" }
11486
]
11587
},
11688
"keyvalueName": {
11789
"begin": "\\w+",
11890
"beginCaptures": {
119-
"0": {
120-
"name": "entity.name.function.fgd"
121-
}
91+
"0": { "name": "entity.name.function.fgd" }
12292
},
123-
"end": "\\((axis|angle|angle_negative_pitch|color255|color1|filterclass|instance_file|instance_parm|instance_variable|material|node_dest|node_id|npcclass|origin|particlesystem|pointentityclass|scene|script|scriptlist|sidelist|sound|sprite|decal|studio|target_destination|target_name_or_class|target_source|vecline|vector|string|integer|float|boolean|choices|flags|void)\\)",
93+
"end": "\\((\\w+)\\)",
12494
"endCaptures": {
12595
"1": {
126-
"name": "variable.parameter.fgd"
96+
"patterns": [
97+
{
98+
"match": "(?i)(axis|angle|angle_negative_pitch|color255|color1|filterclass|instance_file|instance_parm|instance_variable|material|node_dest|node_id|npcclass|origin|particlesystem|pointentityclass|scene|script|scriptlist|sidelist|sound|sprite|decal|studio|target_destination|target_name_or_class|target_source|vecline|vector|string|integer|float|boolean|choices|flags|void)(?-i)",
99+
"name": "variable.parameter.fgd"
100+
}
101+
]
127102
}
128103
},
129104
"patterns": [
130-
{
131-
"include": "#preprocessorTag"
132-
}
105+
{ "include": "#preprocessorTag" }
133106
]
134107
},
135108
"array": {
136109
"begin": "\\[",
137110
"end": "\\]",
138111
"patterns": [
139-
{
140-
"include": "source.kv#number"
141-
},
142-
{
143-
"include": "source.kv#stringQuoted"
144-
},
145-
{
146-
"include": "#preprocessorTag"
147-
}
112+
{ "include": "source.kv#number" },
113+
{ "include": "source.kv#stringQuoted" },
114+
{ "include": "#preprocessorTag" }
148115
]
149116
},
150117
"description": {
151118
"name": "string.quoted.double.fgd",
152119
"begin": "\"",
153120
"end": "\"(\\s+)?",
154121
"endCaptures": {
155-
"1": {
156-
"name": "keyword.operator.fgd"
157-
}
122+
"1": { "name": "keyword.operator.fgd" }
158123
},
159124
"patterns": [
160125
{
@@ -167,14 +132,10 @@
167132
"begin": "\\[",
168133
"end": "\\]",
169134
"beginCaptures": {
170-
"0": {
171-
"name": "keyword.operator.fgd"
172-
}
135+
"0": { "name": "keyword.operator.fgd" }
173136
},
174137
"endCaptures": {
175-
"0": {
176-
"name": "keyword.operator.fgd"
177-
}
138+
"0": { "name": "keyword.operator.fgd" }
178139
},
179140
"patterns": [
180141
{

0 commit comments

Comments
 (0)