Skip to content

Commit 8c64818

Browse files
committed
removed variable regex and added json output
1 parent f4a9b57 commit 8c64818

File tree

3 files changed

+789
-138
lines changed

3 files changed

+789
-138
lines changed

Syntaxes/Zig.YAML-tmLanguage

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,13 @@ repository:
264264
match: '((?:(?:\+|-|\*)\%?|/|%|<<|>>|&|\|(?=[^\|])|\^)?=)'
265265

266266
- name: keyword.operator.arithmetic.zig
267-
match: '((?:\+|-|\*)\%?|/(?!/)|%)'
267+
match: '((?:\+|-|(?<=\w)\s*\*)\%?|/(?!/)|%)'
268268

269269
- name: keyword.operator.bitwise.zig
270270
match: '(<<|>>|&(?=\W)|\|(?=[^\|])|\^|~)'
271271

272272
- name: keyword.operator.other.zig
273-
match: '(\+\+|\*\*|->|\.\?|\.\*|&(?=\w)|\*(?=\w)|\?|\|\||\.\.|\.\.\.)'
273+
match: '(\+\+|\*\*|->|\.\?|\.\*|&(?=\w)|\?|\|\||\.\.|\.\.\.)'
274274

275275
support:
276276
name: support.function.zig
@@ -311,20 +311,19 @@ repository:
311311
- name: punctuation.terminator.zig
312312
match: ';'
313313

314-
# TODO use a more restrictive regex?
315-
# - match: '(?:([a-zA-Z_]\w*|@\".+\")|(?<=\)))(?:(\.)|(,)|(;))(?=[a-zA-Z_]|@\"|\s)'
316-
- match: '(?:([a-zA-Z_]\w*|@\".+\")|(?<=\)))(?:(\.)|(,)|(;))'
317-
captures:
318-
'1':
319-
name: variable.other.zig
320-
'2':
321-
name: punctuation.accessor.zig
322-
'3':
323-
name: punctuation.separator.zig
324-
'4':
325-
name: punctuation.terminator.zig
326-
'5':
327-
name: variable.other.zig
314+
# TODO match variable names?
315+
# - match: '(?:([a-zA-Z_]\w*|@\".+\")|(?<=\)))(?:(\.)|(,)|(;))'
316+
# captures:
317+
# '1':
318+
# name: variable.other.zig
319+
# '2':
320+
# name: punctuation.accessor.zig
321+
# '3':
322+
# name: punctuation.separator.zig
323+
# '4':
324+
# name: punctuation.terminator.zig
325+
# '5':
326+
# name: variable.other.zig
328327

329328
- begin: '(\()'
330329
beginCaptures:
@@ -391,7 +390,10 @@ repository:
391390

392391
contentName: meta.function-call.zig
393392

394-
end: '(?<=\))'
393+
end: '(\))'
394+
endCaptures:
395+
'1':
396+
name: punctuation.section.parens.end.zig
395397

396398
patterns:
397399
- include: '#main'
@@ -404,22 +406,7 @@ repository:
404406

405407
main:
406408
patterns:
407-
- include: '#label'
408-
- include: '#punctuation'
409-
- include: '#storage_modifier'
410-
- include: '#container_decl'
411-
- include: '#constants'
412-
- include: '#comments'
413-
- include: '#strings'
414-
- include: '#keywords'
415-
- include: '#operators'
416-
- include: '#support'
417-
- include: '#storage'
418-
- include: '#field_decl'
419-
- include: '#block'
420-
- include: '#func_call'
421-
422-
- comment: function pointer types
409+
# function pointer types
423410
- begin: '\b(fn)(\()'
424411
beginCaptures:
425412
'1':
@@ -444,7 +431,7 @@ repository:
444431
'2':
445432
name: punctuation.separator.zig
446433

447-
- comment: function decalaration
434+
# function decalaration
448435
- begin: '\b(fn)\s+([a-zA-Z_][a-zA-Z0-9_.]*|@\".+\")(\()'
449436
beginCaptures:
450437
'1':
@@ -464,7 +451,7 @@ repository:
464451
patterns:
465452
- include: '#param_list'
466453

467-
- comment: variable/constant declaration
454+
# variable/constant declaration
468455
- match: '\b(const|var)\s+([a-zA-Z_][a-zA-Z0-9_.]*|@\".+\")\s*(:)\s*([a-zA-Z_][a-zA-Z0-9_.]*|@\".+\")\s*(=)'
469456
captures:
470457
'1':
@@ -478,3 +465,18 @@ repository:
478465
'5':
479466
name: keyword.operator.assignment.zig
480467

468+
- include: '#func_call'
469+
- include: '#label'
470+
- include: '#punctuation'
471+
- include: '#storage_modifier'
472+
- include: '#container_decl'
473+
- include: '#constants'
474+
- include: '#comments'
475+
- include: '#strings'
476+
- include: '#keywords'
477+
- include: '#operators'
478+
- include: '#support'
479+
- include: '#storage'
480+
- include: '#field_decl'
481+
- include: '#block'
482+

Syntaxes/Zig.tmLanguage

Lines changed: 67 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,15 @@
463463
<key>contentName</key>
464464
<string>meta.function-call.zig</string>
465465
<key>end</key>
466-
<string>(?&lt;=\))</string>
466+
<string>(\))</string>
467+
<key>endCaptures</key>
468+
<dict>
469+
<key>1</key>
470+
<dict>
471+
<key>name</key>
472+
<string>punctuation.section.parens.end.zig</string>
473+
</dict>
474+
</dict>
467475
<key>patterns</key>
468476
<array>
469477
<dict>
@@ -586,66 +594,6 @@
586594
<dict>
587595
<key>patterns</key>
588596
<array>
589-
<dict>
590-
<key>include</key>
591-
<string>#label</string>
592-
</dict>
593-
<dict>
594-
<key>include</key>
595-
<string>#punctuation</string>
596-
</dict>
597-
<dict>
598-
<key>include</key>
599-
<string>#storage_modifier</string>
600-
</dict>
601-
<dict>
602-
<key>include</key>
603-
<string>#container_decl</string>
604-
</dict>
605-
<dict>
606-
<key>include</key>
607-
<string>#constants</string>
608-
</dict>
609-
<dict>
610-
<key>include</key>
611-
<string>#comments</string>
612-
</dict>
613-
<dict>
614-
<key>include</key>
615-
<string>#strings</string>
616-
</dict>
617-
<dict>
618-
<key>include</key>
619-
<string>#keywords</string>
620-
</dict>
621-
<dict>
622-
<key>include</key>
623-
<string>#operators</string>
624-
</dict>
625-
<dict>
626-
<key>include</key>
627-
<string>#support</string>
628-
</dict>
629-
<dict>
630-
<key>include</key>
631-
<string>#storage</string>
632-
</dict>
633-
<dict>
634-
<key>include</key>
635-
<string>#field_decl</string>
636-
</dict>
637-
<dict>
638-
<key>include</key>
639-
<string>#block</string>
640-
</dict>
641-
<dict>
642-
<key>include</key>
643-
<string>#func_call</string>
644-
</dict>
645-
<dict>
646-
<key>comment</key>
647-
<string>function pointer types</string>
648-
</dict>
649597
<dict>
650598
<key>begin</key>
651599
<string>\b(fn)(\()</string>
@@ -700,10 +648,6 @@
700648
</dict>
701649
</array>
702650
</dict>
703-
<dict>
704-
<key>comment</key>
705-
<string>function decalaration</string>
706-
</dict>
707651
<dict>
708652
<key>begin</key>
709653
<string>\b(fn)\s+([a-zA-Z_][a-zA-Z0-9_.]*|@\".+\")(\()</string>
@@ -745,10 +689,6 @@
745689
</dict>
746690
</array>
747691
</dict>
748-
<dict>
749-
<key>comment</key>
750-
<string>variable/constant declaration</string>
751-
</dict>
752692
<dict>
753693
<key>captures</key>
754694
<dict>
@@ -781,6 +721,62 @@
781721
<key>match</key>
782722
<string>\b(const|var)\s+([a-zA-Z_][a-zA-Z0-9_.]*|@\".+\")\s*(:)\s*([a-zA-Z_][a-zA-Z0-9_.]*|@\".+\")\s*(=)</string>
783723
</dict>
724+
<dict>
725+
<key>include</key>
726+
<string>#func_call</string>
727+
</dict>
728+
<dict>
729+
<key>include</key>
730+
<string>#label</string>
731+
</dict>
732+
<dict>
733+
<key>include</key>
734+
<string>#punctuation</string>
735+
</dict>
736+
<dict>
737+
<key>include</key>
738+
<string>#storage_modifier</string>
739+
</dict>
740+
<dict>
741+
<key>include</key>
742+
<string>#container_decl</string>
743+
</dict>
744+
<dict>
745+
<key>include</key>
746+
<string>#constants</string>
747+
</dict>
748+
<dict>
749+
<key>include</key>
750+
<string>#comments</string>
751+
</dict>
752+
<dict>
753+
<key>include</key>
754+
<string>#strings</string>
755+
</dict>
756+
<dict>
757+
<key>include</key>
758+
<string>#keywords</string>
759+
</dict>
760+
<dict>
761+
<key>include</key>
762+
<string>#operators</string>
763+
</dict>
764+
<dict>
765+
<key>include</key>
766+
<string>#support</string>
767+
</dict>
768+
<dict>
769+
<key>include</key>
770+
<string>#storage</string>
771+
</dict>
772+
<dict>
773+
<key>include</key>
774+
<string>#field_decl</string>
775+
</dict>
776+
<dict>
777+
<key>include</key>
778+
<string>#block</string>
779+
</dict>
784780
</array>
785781
</dict>
786782
<key>operators</key>
@@ -813,7 +809,7 @@
813809
</dict>
814810
<dict>
815811
<key>match</key>
816-
<string>((?:\+|-|\*)\%?|/(?!/)|%)</string>
812+
<string>((?:\+|-|(?&lt;=\w)\s*\*)\%?|/(?!/)|%)</string>
817813
<key>name</key>
818814
<string>keyword.operator.arithmetic.zig</string>
819815
</dict>
@@ -825,7 +821,7 @@
825821
</dict>
826822
<dict>
827823
<key>match</key>
828-
<string>(\+\+|\*\*|-&gt;|\.\?|\.\*|&amp;(?=\w)|\*(?=\w)|\?|\|\||\.\.|\.\.\.)</string>
824+
<string>(\+\+|\*\*|-&gt;|\.\?|\.\*|&amp;(?=\w)|\?|\|\||\.\.|\.\.\.)</string>
829825
<key>name</key>
830826
<string>keyword.operator.other.zig</string>
831827
</dict>
@@ -894,38 +890,6 @@
894890
<key>name</key>
895891
<string>punctuation.terminator.zig</string>
896892
</dict>
897-
<dict>
898-
<key>captures</key>
899-
<dict>
900-
<key>1</key>
901-
<dict>
902-
<key>name</key>
903-
<string>variable.other.zig</string>
904-
</dict>
905-
<key>2</key>
906-
<dict>
907-
<key>name</key>
908-
<string>punctuation.accessor.zig</string>
909-
</dict>
910-
<key>3</key>
911-
<dict>
912-
<key>name</key>
913-
<string>punctuation.separator.zig</string>
914-
</dict>
915-
<key>4</key>
916-
<dict>
917-
<key>name</key>
918-
<string>punctuation.terminator.zig</string>
919-
</dict>
920-
<key>5</key>
921-
<dict>
922-
<key>name</key>
923-
<string>variable.other.zig</string>
924-
</dict>
925-
</dict>
926-
<key>match</key>
927-
<string>(?:([a-zA-Z_]\w*|@\".+\")|(?&lt;=\)))(?:(\.)|(,)|(;))</string>
928-
</dict>
929893
<dict>
930894
<key>begin</key>
931895
<string>(\()</string>

0 commit comments

Comments
 (0)