Skip to content

Commit d587f5b

Browse files
committed
syntax: add initial support for Query and ForeginKey, fix some
1 parent a505ba5 commit d587f5b

File tree

1 file changed

+175
-73
lines changed

1 file changed

+175
-73
lines changed

syntaxes/cos.tmLanguage.json

Lines changed: 175 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"define-directives": {
9999
"patterns": [
100100
{
101-
"begin": "^\\s*(?i)(#define)\\s*",
101+
"begin": "^\\s*(?i)(#\\s*define)\\s+",
102102
"beginCaptures": {
103103
"1": {
104104
"name": "keyword.other.define.cos"
@@ -180,7 +180,7 @@
180180
}
181181
]
182182
},
183-
"dotted-attrs": {
183+
"dotted-attrs": { "comment": "WTF?",
184184
"match": "((%|\\w|\\.|#)+)",
185185
"captures": {
186186
"1": {
@@ -190,43 +190,28 @@
190190
},
191191
"statements": {
192192
"patterns": [
193-
{
194-
"include": "#properties"
195-
},
196-
{
197-
"include": "#parameters"
198-
},
199-
{
200-
"include": "#indices"
201-
},
202-
{
203-
"include": "#fks"
204-
},
205-
{
206-
"include": "#classes"
207-
},
208-
{
209-
"include": "#methods"
210-
},
211-
{
212-
"include": "#xml-data"
213-
},
214-
{
215-
"include": "#keywords"
216-
},
217-
{
218-
"include": "#variables"
219-
}
193+
{ "include": "#properties" },
194+
{ "include": "#parameters" },
195+
{ "include": "#indices"},
196+
{ "include": "#relationship" },
197+
{ "include": "#foreignkey" },
198+
{ "include": "#classes" },
199+
{ "include": "#methods" },
200+
{ "include": "#class-query" },
201+
{ "include": "#xml-data" },
202+
{ "include": "#keywords" },
203+
{ "include": "#variables" }
204+
220205
]
221206
},
222207
"properties": {
223208
"begin": "^\\s*(?i)(Property)\\s+(\\w+)",
224209
"beginCaptures": {
225210
"1": {
226-
"name": "entity.name.type.property.cos"
211+
"name": "storage.type.cos"
227212
},
228213
"2": {
229-
"name": "variable.other.cos"
214+
"name": "entity.name.cos"
230215
}
231216
},
232217
"end": "$",
@@ -243,10 +228,10 @@
243228
"begin": "^\\s*(?i)(Parameter)\\s+(\\w+)",
244229
"beginCaptures": {
245230
"1": {
246-
"name": "entity.name.type.property.cos"
231+
"name": "storage.type.cos"
247232
},
248233
"2": {
249-
"name": "variable.other.cos"
234+
"name": "entity.name.cos"
250235
}
251236
},
252237
"end": "$",
@@ -263,10 +248,10 @@
263248
"begin": "^\\s*(?i)(Index)\\s+(\\w+)",
264249
"beginCaptures": {
265250
"1": {
266-
"name": "entity.name.type.property.cos"
251+
"name": "storage.type.cos"
267252
},
268253
"2": {
269-
"name": "variable.other.cos"
254+
"name": "entity.name.cos"
270255
}
271256
},
272257
"end": "$",
@@ -284,14 +269,14 @@
284269
}
285270
]
286271
},
287-
"fks": {
272+
"relationship": {
288273
"begin": "^\\s*(?i)(Relationship)\\s+(\\w+)",
289274
"beginCaptures": {
290275
"1": {
291-
"name": "entity.name.type.property.cos"
276+
"name": "storage.type.cos"
292277
},
293278
"2": {
294-
"name": "variable.other.cos"
279+
"name": "entity.name.cos"
295280
}
296281
},
297282
"end": "$",
@@ -304,6 +289,50 @@
304289
}
305290
]
306291
},
292+
"foreignkey": {
293+
"begin": "^\\s*(?i)(ForeignKey)\\s+(\\w+)",
294+
"beginCaptures": {
295+
"1": {
296+
"name": "storage.type.cos"
297+
},
298+
"2": {
299+
"name": "entity.name.cos"
300+
}
301+
},
302+
"end": ";\\s*$",
303+
"patterns": [
304+
{ "comment": "FK props \"ForeignKey TestKey(Propeties)\"",
305+
"begin": "\\(", "end":"\\)",
306+
"patterns": [
307+
308+
{
309+
"match": "(\\w+)",
310+
"captures": {
311+
"1": { "name": "variable.parameter.cos" }
312+
}
313+
}
314+
]
315+
},
316+
{ "comment": "FK references",
317+
"begin": "(?i)(References)\\s+(\\w+)\\s*\\(", "end": "\\)",
318+
"beginCaptures": {
319+
"1": { "name": "storage.type.cos" },
320+
"2": { "name": "entity.name.cos" }
321+
},
322+
"patterns": [
323+
{
324+
"match": "(\\w+)",
325+
"captures": {
326+
"1": { "name": "variable.parameter.cos" }
327+
}
328+
}
329+
]
330+
}
331+
]
332+
},
333+
334+
335+
307336
"as-keywords": {
308337
"match": "\\b(?i)(As)\\b",
309338
"captures": {
@@ -313,13 +342,13 @@
313342
}
314343
},
315344
"classes": {
316-
"begin": "^\\s*(?i)(Class)\\s+(\\w+)",
345+
"begin": "^\\s*(?i)(Class)\\s+([%|A-Za-z][A-Za-z0-9.]+)",
317346
"beginCaptures": {
318347
"1": {
319-
"name": "entity.name.type.property.cos"
348+
"name": "storage.type.cos"
320349
},
321350
"2": {
322-
"name": "variable.other.cos"
351+
"name": "entity.name.cos"
323352
}
324353
},
325354
"end": "$",
@@ -336,45 +365,63 @@
336365
"include": "#dotted-attrs"
337366
},
338367
{
339-
"begin": "\\{",
340-
"end": "\\}",
368+
"begin": "\\{", "end": "\\}",
341369
"patterns": [
342-
{
343-
"include": "#statements"
344-
}
370+
{ "include": "#class-content" }
345371
]
346372
}
347373
]
348374
},
375+
"class-content": {
376+
"patterns": [
377+
{ "include": "#comments" },
378+
{ "include": "#properties" },
379+
{ "include": "#parameters" },
380+
{ "include": "#indices" },
381+
{ "include": "#relationship" },
382+
{ "include": "#foreignkey" },
383+
{ "include": "#methods" },
384+
{ "include": "#class-query" },
385+
{ "include": "#xml-data" },
386+
{ "include": "#keywords" },
387+
{ "include": "#variables" }
388+
]
389+
},
390+
349391
"methods": {
350392
"begin": "^\\s*(?i)(Method|ClassMethod|ClientMethod)\\s+(\\w+)",
351393
"beginCaptures": {
352394
"1": {
353-
"name": "entity.name.type.property.cos"
395+
"name": "storage.type.cos"
354396
},
355397
"2": {
356-
"name": "variable.other.cos"
398+
"name": "entity.name.cos"
357399
}
358400
},
359401
"end": "$",
360402
"patterns": [
361-
{
362-
"include": "#method-params"
363-
},
364-
{
365-
"include": "#as-keywords"
366-
},
367-
{
368-
"include": "#dotted-attrs"
369-
},
370-
{
371-
"begin": "\\{",
372-
"end": "\\}",
373-
"patterns": [
403+
{ "include": "#method-params" },
404+
{ "include": "#as-keywords" },
405+
{ "include": "#dotted-attrs" },
406+
{ "comment": "method options [SqlProc, etc...]",
407+
"begin": "\\[", "end": "\\]",
408+
"patterns":[
374409
{
375-
"include": "#statements"
410+
"match": "(\\w+)",
411+
"captures": {
412+
"1": { "name": "variable.other.cos" }
413+
}
376414
}
377415
]
416+
},
417+
{ "comment": "method body",
418+
"begin": "\\{", "end": "\\}",
419+
"patterns": [
420+
{ "include": "comments" },
421+
{ "include": "#keywords" },
422+
{ "include": "#variables" }
423+
424+
]
378425
}
379426
]
380427
},
@@ -423,6 +470,65 @@
423470
}
424471
]
425472
},
473+
474+
"class-query": {
475+
"comment": "query definition line",
476+
"begin": "^\\s*(?i)(Query)\\s+([%A-Za-z0-9.]+)", "end": "}",
477+
"beginCaptures": {
478+
"1": { "name": "storage.type.cos" },
479+
"2": { "name": "entity.name.cos" }
480+
},
481+
"patterns": [
482+
{ "comment": "query arguments \"(id as %String)\"",
483+
"begin": "\\(", "end": "\\)",
484+
"patterns":[
485+
486+
{ "comment": "query-argument. just name ",
487+
"match": "(\\w+)",
488+
"captures": {
489+
"1": { "name": "variable.parameter.cos" }
490+
}
491+
}
492+
493+
]
494+
},
495+
{ "comment": "query type \"As %SQLQuery\"",
496+
"match": "\\s+(?i)(As)\\s+([%A-Za-z0-9.]+)\\s*",
497+
"captures": {
498+
"1": { "name": "keyword.operator.as.cos" },
499+
"2": { "name": "variable.other.cos" }
500+
}
501+
},
502+
{ "comment": "query options \"(CONTAINID = 1, EXTENT = 1)\"",
503+
"begin": "\\(", "end": "\\)",
504+
"patterns": [
505+
{
506+
"match": "(\\w+)",
507+
"captures": {
508+
"1": { "name": "variable.parameter.cos" }
509+
}
510+
}
511+
]
512+
},
513+
{ "comment": "query properties \"[SqlName = test, SqlProc]\"",
514+
"begin": "\\[", "end": "\\]",
515+
"patterns": [
516+
{
517+
"match": "(\\w+)",
518+
"captures": {
519+
"1": { "name": "variable.other.cos" }
520+
}
521+
}
522+
]
523+
},
524+
{ "comment": "SQL Query block",
525+
"begin": "\\{", "end": "(?=})",
526+
"patterns": [{ "include": "#expressions" }]
527+
}
528+
529+
]
530+
},
531+
426532
"keywords": {
427533
"patterns": [
428534
{
@@ -491,10 +597,10 @@
491597
"match": "(##class)\\(((%|\\w|\\.|#)+)\\)",
492598
"captures": {
493599
"1": {
494-
"name": "entity.name.class.reference.cos"
600+
"name": "keyword.other.cos"
495601
},
496602
"2": {
497-
"name": "variable.parameter.function-argument.cos"
603+
"name": "entity.name.cos"
498604
}
499605
}
500606
},
@@ -509,25 +615,21 @@
509615
},
510616
"variables": {
511617
"patterns": [
512-
{
618+
{ "comment": "shortcut to this class members",
513619
"match": "\\.\\.\\w+",
514-
"name": "variable.other.property.cos"
515-
},
516-
{
517-
"match": "\\.\\.#\\w+",
518-
"name": "variable.other.parameter.cos"
620+
"name": "entity.name.cos"
519621
},
520622
{
521623
"match": "\\^\\w+",
522624
"name": "variable.other.global.cos"
523625
},
524626
{
525627
"match": "\\$\\w+(\\.\\w+)*",
526-
"name": "variable.other.system.cos"
628+
"name": "keyword.other.system.cos"
527629
},
528-
{
630+
{ "comment": "macros \"$$$SOME\" ",
529631
"match": "\\$\\$\\$\\w+",
530-
"name": "variable.other.macros.cos"
632+
"name": "constant.other.macros.cos"
531633
},
532634
{
533635
"include": "#strings"

0 commit comments

Comments
 (0)