Skip to content

Commit 032e9a3

Browse files
committed
Update go grammar and fix update script
Fixes microsoft#106798
1 parent 2a77a2f commit 032e9a3

2 files changed

Lines changed: 341 additions & 18 deletions

File tree

extensions/go/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"vscode": "*"
1010
},
1111
"scripts": {
12-
"update-grammar": "node ../../build/npm/update-grammar.js jeff-hykin/better-go-syntax source/generated.tmLanguage.json ./syntaxes/go.tmLanguage.json"
12+
"update-grammar": "node ../../build/npm/update-grammar.js jeff-hykin/better-go-syntax export/generated.tmLanguage.json ./syntaxes/go.tmLanguage.json"
1313
},
1414
"contributes": {
1515
"languages": [

extensions/go/syntaxes/go.tmLanguage.json

Lines changed: 340 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"information_for_contributors": [
3-
"This file has been converted from https://github.com/jeff-hykin/better-go-syntax/blob/master/source/generated.tmLanguage.json",
3+
"This file has been converted from https://github.com/jeff-hykin/better-go-syntax/blob/master/export/generated.tmLanguage.json",
44
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
55
"Once accepted there, we are happy to receive an update request."
66
],
7-
"version": "https://github.com/jeff-hykin/better-go-syntax/commit/302b427373ba8390786723a99f6cdf8e38833159",
7+
"version": "https://github.com/jeff-hykin/better-go-syntax/commit/6175663a7a0e23d58ccf9aab95054cb6e5c92aff",
88
"name": "Go",
99
"scopeName": "source.go",
1010
"patterns": [
@@ -673,22 +673,345 @@
673673
]
674674
},
675675
"numeric_literals": {
676-
"patterns": [
677-
{
678-
"include": "#float"
679-
},
680-
{
681-
"include": "#integer"
676+
"match": "(?<!\\w)\\.?\\d(?:(?:[0-9a-zA-Z_\\.])|(?<=[eEpP])[+-])*",
677+
"captures": {
678+
"0": {
679+
"patterns": [
680+
{
681+
"begin": "(?=.)",
682+
"end": "(?:\\n|$)",
683+
"patterns": [
684+
{
685+
"match": "(?:(?:(?:(?:(?:\\G(?=[0-9.])(?!0[xXbBoO])([0-9](?:[0-9]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)((?:(?<=[0-9])\\.|\\.(?=[0-9])))([0-9](?:[0-9]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)?(?:(?<!_)([eE])(\\+?)(\\-?)((?:[0-9](?:[0-9]|(?:(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)))?(i(?!\\w))?(?:\\n|$)|\\G(?=[0-9.])(?!0[xXbBoO])([0-9](?:[0-9]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)(?<!_)([eE])(\\+?)(\\-?)((?:[0-9](?:[0-9]|(?:(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*))(i(?!\\w))?(?:\\n|$))|\\G((?:(?<=[0-9])\\.|\\.(?=[0-9])))([0-9](?:[0-9]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)(?:(?<!_)([eE])(\\+?)(\\-?)((?:[0-9](?:[0-9]|(?:(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)))?(i(?!\\w))?(?:\\n|$))|(\\G0[xX])_?([0-9a-fA-F](?:[0-9a-fA-F]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)((?:(?<=[0-9a-fA-F])\\.|\\.(?=[0-9a-fA-F])))([0-9a-fA-F](?:[0-9a-fA-F]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)?(?<!_)([pP])(\\+?)(\\-?)((?:[0-9](?:[0-9]|(?:(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*))(i(?!\\w))?(?:\\n|$))|(\\G0[xX])_?([0-9a-fA-F](?:[0-9a-fA-F]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)(?<!_)([pP])(\\+?)(\\-?)((?:[0-9](?:[0-9]|(?:(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*))(i(?!\\w))?(?:\\n|$))|(\\G0[xX])((?:(?<=[0-9a-fA-F])\\.|\\.(?=[0-9a-fA-F])))([0-9a-fA-F](?:[0-9a-fA-F]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)(?<!_)([pP])(\\+?)(\\-?)((?:[0-9](?:[0-9]|(?:(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*))(i(?!\\w))?(?:\\n|$))",
686+
"captures": {
687+
"1": {
688+
"name": "constant.numeric.decimal.go",
689+
"patterns": [
690+
{
691+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
692+
"name": "punctuation.separator.constant.numeric.go"
693+
}
694+
]
695+
},
696+
"2": {
697+
"name": "punctuation.separator.constant.numeric.go"
698+
},
699+
"3": {
700+
"name": "constant.numeric.decimal.point.go"
701+
},
702+
"4": {
703+
"name": "constant.numeric.decimal.go",
704+
"patterns": [
705+
{
706+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
707+
"name": "punctuation.separator.constant.numeric.go"
708+
}
709+
]
710+
},
711+
"5": {
712+
"name": "punctuation.separator.constant.numeric.go"
713+
},
714+
"6": {
715+
"name": "keyword.other.unit.exponent.decimal.go"
716+
},
717+
"7": {
718+
"name": "keyword.operator.plus.exponent.decimal.go"
719+
},
720+
"8": {
721+
"name": "keyword.operator.minus.exponent.decimal.go"
722+
},
723+
"9": {
724+
"name": "constant.numeric.exponent.decimal.go",
725+
"patterns": [
726+
{
727+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
728+
"name": "punctuation.separator.constant.numeric.go"
729+
}
730+
]
731+
},
732+
"10": {
733+
"name": "keyword.other.unit.imaginary.go"
734+
},
735+
"11": {
736+
"name": "constant.numeric.decimal.go",
737+
"patterns": [
738+
{
739+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
740+
"name": "punctuation.separator.constant.numeric.go"
741+
}
742+
]
743+
},
744+
"12": {
745+
"name": "punctuation.separator.constant.numeric.go"
746+
},
747+
"13": {
748+
"name": "keyword.other.unit.exponent.decimal.go"
749+
},
750+
"14": {
751+
"name": "keyword.operator.plus.exponent.decimal.go"
752+
},
753+
"15": {
754+
"name": "keyword.operator.minus.exponent.decimal.go"
755+
},
756+
"16": {
757+
"name": "constant.numeric.exponent.decimal.go",
758+
"patterns": [
759+
{
760+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
761+
"name": "punctuation.separator.constant.numeric.go"
762+
}
763+
]
764+
},
765+
"17": {
766+
"name": "keyword.other.unit.imaginary.go"
767+
},
768+
"18": {
769+
"name": "constant.numeric.decimal.point.go"
770+
},
771+
"19": {
772+
"name": "constant.numeric.decimal.go",
773+
"patterns": [
774+
{
775+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
776+
"name": "punctuation.separator.constant.numeric.go"
777+
}
778+
]
779+
},
780+
"20": {
781+
"name": "punctuation.separator.constant.numeric.go"
782+
},
783+
"21": {
784+
"name": "keyword.other.unit.exponent.decimal.go"
785+
},
786+
"22": {
787+
"name": "keyword.operator.plus.exponent.decimal.go"
788+
},
789+
"23": {
790+
"name": "keyword.operator.minus.exponent.decimal.go"
791+
},
792+
"24": {
793+
"name": "constant.numeric.exponent.decimal.go",
794+
"patterns": [
795+
{
796+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
797+
"name": "punctuation.separator.constant.numeric.go"
798+
}
799+
]
800+
},
801+
"25": {
802+
"name": "keyword.other.unit.imaginary.go"
803+
},
804+
"26": {
805+
"name": "keyword.other.unit.hexadecimal.go"
806+
},
807+
"27": {
808+
"name": "constant.numeric.hexadecimal.go",
809+
"patterns": [
810+
{
811+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
812+
"name": "punctuation.separator.constant.numeric.go"
813+
}
814+
]
815+
},
816+
"28": {
817+
"name": "punctuation.separator.constant.numeric.go"
818+
},
819+
"29": {
820+
"name": "constant.numeric.hexadecimal.go"
821+
},
822+
"30": {
823+
"name": "constant.numeric.hexadecimal.go",
824+
"patterns": [
825+
{
826+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
827+
"name": "punctuation.separator.constant.numeric.go"
828+
}
829+
]
830+
},
831+
"31": {
832+
"name": "punctuation.separator.constant.numeric.go"
833+
},
834+
"32": {
835+
"name": "keyword.other.unit.exponent.hexadecimal.go"
836+
},
837+
"33": {
838+
"name": "keyword.operator.plus.exponent.hexadecimal.go"
839+
},
840+
"34": {
841+
"name": "keyword.operator.minus.exponent.hexadecimal.go"
842+
},
843+
"35": {
844+
"name": "constant.numeric.exponent.hexadecimal.go",
845+
"patterns": [
846+
{
847+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
848+
"name": "punctuation.separator.constant.numeric.go"
849+
}
850+
]
851+
},
852+
"36": {
853+
"name": "keyword.other.unit.imaginary.go"
854+
},
855+
"37": {
856+
"name": "keyword.other.unit.hexadecimal.go"
857+
},
858+
"38": {
859+
"name": "constant.numeric.hexadecimal.go",
860+
"patterns": [
861+
{
862+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
863+
"name": "punctuation.separator.constant.numeric.go"
864+
}
865+
]
866+
},
867+
"39": {
868+
"name": "punctuation.separator.constant.numeric.go"
869+
},
870+
"40": {
871+
"name": "keyword.other.unit.exponent.hexadecimal.go"
872+
},
873+
"41": {
874+
"name": "keyword.operator.plus.exponent.hexadecimal.go"
875+
},
876+
"42": {
877+
"name": "keyword.operator.minus.exponent.hexadecimal.go"
878+
},
879+
"43": {
880+
"name": "constant.numeric.exponent.hexadecimal.go",
881+
"patterns": [
882+
{
883+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
884+
"name": "punctuation.separator.constant.numeric.go"
885+
}
886+
]
887+
},
888+
"44": {
889+
"name": "keyword.other.unit.imaginary.go"
890+
},
891+
"45": {
892+
"name": "keyword.other.unit.hexadecimal.go"
893+
},
894+
"46": {
895+
"name": "constant.numeric.hexadecimal.go"
896+
},
897+
"47": {
898+
"name": "constant.numeric.hexadecimal.go",
899+
"patterns": [
900+
{
901+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
902+
"name": "punctuation.separator.constant.numeric.go"
903+
}
904+
]
905+
},
906+
"48": {
907+
"name": "punctuation.separator.constant.numeric.go"
908+
},
909+
"49": {
910+
"name": "keyword.other.unit.exponent.hexadecimal.go"
911+
},
912+
"50": {
913+
"name": "keyword.operator.plus.exponent.hexadecimal.go"
914+
},
915+
"51": {
916+
"name": "keyword.operator.minus.exponent.hexadecimal.go"
917+
},
918+
"52": {
919+
"name": "constant.numeric.exponent.hexadecimal.go",
920+
"patterns": [
921+
{
922+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
923+
"name": "punctuation.separator.constant.numeric.go"
924+
}
925+
]
926+
},
927+
"53": {
928+
"name": "keyword.other.unit.imaginary.go"
929+
}
930+
}
931+
},
932+
{
933+
"match": "(?:(?:(?:\\G(?=[0-9.])(?!0[xXbBoO])([0-9](?:[0-9]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)(i(?!\\w))?(?:\\n|$)|(\\G0[bB])_?([01](?:[01]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)(i(?!\\w))?(?:\\n|$))|(\\G0[oO]?)_?((?:[0-7]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))+)(i(?!\\w))?(?:\\n|$))|(\\G0[xX])_?([0-9a-fA-F](?:[0-9a-fA-F]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)(i(?!\\w))?(?:\\n|$))",
934+
"captures": {
935+
"1": {
936+
"name": "constant.numeric.decimal.go",
937+
"patterns": [
938+
{
939+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
940+
"name": "punctuation.separator.constant.numeric.go"
941+
}
942+
]
943+
},
944+
"2": {
945+
"name": "punctuation.separator.constant.numeric.go"
946+
},
947+
"3": {
948+
"name": "keyword.other.unit.imaginary.go"
949+
},
950+
"4": {
951+
"name": "keyword.other.unit.binary.go"
952+
},
953+
"5": {
954+
"name": "constant.numeric.binary.go",
955+
"patterns": [
956+
{
957+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
958+
"name": "punctuation.separator.constant.numeric.go"
959+
}
960+
]
961+
},
962+
"6": {
963+
"name": "punctuation.separator.constant.numeric.go"
964+
},
965+
"7": {
966+
"name": "keyword.other.unit.imaginary.go"
967+
},
968+
"8": {
969+
"name": "keyword.other.unit.octal.go"
970+
},
971+
"9": {
972+
"name": "constant.numeric.octal.go",
973+
"patterns": [
974+
{
975+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
976+
"name": "punctuation.separator.constant.numeric.go"
977+
}
978+
]
979+
},
980+
"10": {
981+
"name": "punctuation.separator.constant.numeric.go"
982+
},
983+
"11": {
984+
"name": "keyword.other.unit.imaginary.go"
985+
},
986+
"12": {
987+
"name": "keyword.other.unit.hexadecimal.go"
988+
},
989+
"13": {
990+
"name": "constant.numeric.hexadecimal.go",
991+
"patterns": [
992+
{
993+
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
994+
"name": "punctuation.separator.constant.numeric.go"
995+
}
996+
]
997+
},
998+
"14": {
999+
"name": "punctuation.separator.constant.numeric.go"
1000+
},
1001+
"15": {
1002+
"name": "keyword.other.unit.imaginary.go"
1003+
}
1004+
}
1005+
},
1006+
{
1007+
"match": "(?:(?:[0-9a-zA-Z_\\.])|(?<=[eEpP])[+-])+",
1008+
"name": "invalid.illegal.constant.numeric.go"
1009+
}
1010+
]
1011+
}
1012+
]
6821013
}
683-
]
684-
},
685-
"float": {
686-
"match": "(\\.\\d+([Ee][-+]\\d+)?i?)\\b|\\b\\d+\\.\\d*(([Ee][-+]\\d+)?i?\\b)?",
687-
"name": "constant.numeric.floating-point.go"
688-
},
689-
"integer": {
690-
"match": "\\b((0x[0-9a-fA-F]+)|(0[0-7]+i?)|(\\d+([Ee]\\d+)?i?)|(\\d+[Ee][-+]\\d+i?))\\b",
691-
"name": "constant.numeric.integer.go"
1014+
}
6921015
}
6931016
}
6941017
}

0 commit comments

Comments
 (0)