Skip to content

Commit 8dfdf37

Browse files
author
MattDMo
committed
Changed scope for regular_expressions, started working on string_formatting from #38
1 parent 5c62a46 commit 8dfdf37

File tree

1 file changed

+80
-2
lines changed

1 file changed

+80
-2
lines changed

PythonImproved.YAML-tmLanguage

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,8 +868,86 @@ repository:
868868

869869
regular_expressions:
870870
patterns:
871-
- include: source.regex.python
872-
comment: source.regexp.python is the default, this is the PI version
871+
- include: source.regexp.python.improved
872+
873+
string_formatting:
874+
comment: Attempt from @sprt to add support for new-style string formatting.
875+
match: |-
876+
(?x)
877+
(?<![^\{]\{)
878+
\{
879+
(?<fieldname>
880+
(
881+
(?<argname>
882+
(
883+
(?<identifier>([\p{Alpha}_][\p{Alnum}_]*)) |
884+
(?<integer>
885+
([1-9]\d* | 0) |
886+
(
887+
0
888+
(
889+
(?i:
890+
([o]?[0-7]+) |
891+
([x][0-9a-f]+) |
892+
([b][01]+)
893+
)
894+
)
895+
)
896+
)
897+
)
898+
)?
899+
)
900+
(
901+
(?<attributename>
902+
(\.\g<identifier>)
903+
) |
904+
\[
905+
(
906+
(?<elementindex>
907+
(
908+
(\g<integer>) |
909+
(?<indexstring>[^\]\}\{]+)
910+
)
911+
)
912+
)
913+
\]
914+
)*
915+
)?
916+
(
917+
((?<conversion>(\![rsa])))
918+
)?
919+
(
920+
(?<formatspec>
921+
(
922+
\:
923+
(
924+
(?<fill>.)?
925+
(?<align>([<>=\^]))
926+
)?
927+
(?<sign>([\ +-]))?
928+
\#?0?
929+
(?<width>
930+
(\g<integer>)
931+
)?
932+
,?
933+
(?<precision>
934+
\.
935+
(\g<integer>)
936+
)?
937+
(?<type>([bcdEeFfGgnosXx%]))?
938+
)?
939+
)
940+
)?
941+
\}
942+
(?!\}[^\}])
943+
captures:
944+
'6': {name: identifier}
945+
'8': {name: constant.numeric.integer.decimal.python}
946+
'11': {name: constant.numeric.integer.octal.python}
947+
'12': {name: constant.numeric.integer.hexadecimal.python}
948+
'13': {name: constant.numeric.integer.binary.python}
949+
'14': {name: attribute.name}
950+
'16': {name: attribute.identifier}
873951

874952
string_quoted_double:
875953
patterns:

0 commit comments

Comments
 (0)