Updated Python highlighter files and highlighter bugfix.

This commit is contained in:
Matthias Koefferlein 2018-11-23 07:20:55 +01:00
parent f4b2a015dc
commit 72127a302d
3 changed files with 258 additions and 125 deletions

View File

@ -32,7 +32,7 @@
#include <QDomDocument>
// #define DEBUG_HIGHLIGHTER
// #define DEBUG_HIGHLIGHTER
/**
* @brief Provide a compare operator for QList<QString> because Qt doesn't
@ -907,20 +907,31 @@ GenericSyntaxHighlighterAttributes::GenericSyntaxHighlighterAttributes (const Ge
: mp_basic_attributes (basic_attributes)
{
if (! basic_attributes) {
add (QString::fromUtf8 ("Normal"), dsNormal, false, false, false, false, 0, 0, 0, 0);
add (QString::fromUtf8 ("Alert"), dsAlert, true, false, false, false, "#BF0303", "#9C0D0D", "#F7E7E7", 0);
add (QString::fromUtf8 ("Base-N Integer"), dsBaseN, false, false, false, false, "#B07E00", "#FFDD00", 0, 0);
add (QString::fromUtf8 ("Character"), dsChar, false, false, false, false, "#FF80E0", "#FF80E0", 0, 0);
add (QString::fromUtf8 ("Comment"), dsComment, false, true, false, false, "#888786", "#A6C2E4", 0, 0);
add (QString::fromUtf8 ("Data Type"), dsDataType, false, false, false, false, "#0057AE", "#00316E", 0, 0);
add (QString::fromUtf8 ("Decimal/Value"), dsDecVal, false, false, false, false, "#B07E00", "#FFDD00", 0, 0);
add (QString::fromUtf8 ("Error"), dsError, false, false, true, false, "#BF0303", "#9C0D0D", 0, 0);
add (QString::fromUtf8 ("Floating Point"), dsFloat, false, false, false, false, "#B07E00", "#FFDD00", 0, 0);
add (QString::fromUtf8 ("Function"), dsFunction, false, false, false, false, "#442886", "#442886", 0, 0);
add (QString::fromUtf8 ("Keyword"), dsKeyword, true, false, false, false, 0, 0, 0, 0);
add (QString::fromUtf8 ("Others"), dsOthers, false, false, false, false, "#006E26", "#80FF80", 0, 0);
add (QString::fromUtf8 ("Region Marker"), dsRegionMarker, false, false, false, false, "#0057AE", "#00316E", "#E1EAF8", 0);
add (QString::fromUtf8 ("String"), dsString, false, false, false, false, "#BF0303", "#9C0D0D", 0, 0);
add (QString::fromUtf8 ("Normal"), dsNormal, false, false, false, false, 0, 0, 0, 0);
add (QString::fromUtf8 ("Alert"), dsAlert, true, false, false, false, "#BF0303", "#9C0D0D", "#F7E7E7", 0);
add (QString::fromUtf8 ("Base-N Integer"), dsBaseN, false, false, false, false, "#B07E00", "#FFDD00", 0, 0);
add (QString::fromUtf8 ("Character"), dsChar, false, false, false, false, "#FF80E0", "#FF80E0", 0, 0);
add (QString::fromUtf8 ("Comment"), dsComment, false, true, false, false, "#888786", "#A6C2E4", 0, 0);
add (QString::fromUtf8 ("Data Type"), dsDataType, false, false, false, false, "#0057AE", "#00316E", 0, 0);
add (QString::fromUtf8 ("Decimal/Value"), dsDecVal, false, false, false, false, "#B07E00", "#FFDD00", 0, 0);
add (QString::fromUtf8 ("Error"), dsError, false, false, true, false, "#BF0303", "#9C0D0D", 0, 0);
add (QString::fromUtf8 ("Floating Point"), dsFloat, false, false, false, false, "#B07E00", "#FFDD00", 0, 0);
add (QString::fromUtf8 ("Function"), dsFunction, false, false, false, false, "#442886", "#442886", 0, 0);
add (QString::fromUtf8 ("Keyword"), dsKeyword, true, false, false, false, 0, 0, 0, 0);
add (QString::fromUtf8 ("Others"), dsOthers, false, false, false, false, "#006E26", "#80FF80", 0, 0);
add (QString::fromUtf8 ("Region Marker"), dsRegionMarker, false, false, false, false, "#0057AE", "#00316E", "#E1EAF8", 0);
add (QString::fromUtf8 ("String"), dsString, false, false, false, false, "#BF0303", "#9C0D0D", 0, 0);
add (QString::fromUtf8 ("Operator"), dsOperator, false, false, false, false, "#1F1C1B", 0, 0, 0);
add (QString::fromUtf8 ("Control Flow"), dsControlFlow, true, false, false, false, "#1F1C1B", 0, 0, 0);
add (QString::fromUtf8 ("Built-in"), dsBuiltIn, true, false, false, false, "#644A9B", "#452886", 0, 0);
add (QString::fromUtf8 ("Variable"), dsVariable, false, false, false, false, "#0057AE", "#00316e", 0, 0);
add (QString::fromUtf8 ("Extension"), dsExtension, false, false, false, false, "#0095FF", 0, 0, 0);
add (QString::fromUtf8 ("Preprocessor"), dsPreprocessor, false, false, false, false, "#006E28", "#006e28", 0, 0);
add (QString::fromUtf8 ("Import"), dsImport, false, false, false, false, "#FF5500", "#FF5500", 0, 0);
add (QString::fromUtf8 ("Verbatim String"), dsVerbatimString, false, false, false, false, "#BF0303", "#9C0E0E", 0, 0);
add (QString::fromUtf8 ("Special String"), dsSpecialString, false, false, false, false, "#FF5500", "#FF5500", 0, 0);
add (QString::fromUtf8 ("Special Character"), dsSpecialChar, false, false, false, false, "#3DAEE9", "#FCFCFC", 0, 0);
add (QString::fromUtf8 ("Attribute"), dsAttribute, false, false, false, false, "#0057AE", "#00316E", 0, 0);
}
}
@ -1416,7 +1427,7 @@ parse_rule (QDomElement e, GenericSyntaxHighlighterContexts &contexts, std::map<
}
static GenericSyntaxHighlighterContext
parse_context (QDomElement e, GenericSyntaxHighlighterContexts &contexts, std::map<QString, GenericSyntaxHighlighterRuleStringList> &lists, GenericSyntaxHighlighterAttributes &attributes)
parse_context (QDomElement e, const std::map<QString, QDomElement> &contexts_by_name, GenericSyntaxHighlighterContexts &contexts, std::map<QString, GenericSyntaxHighlighterRuleStringList> &lists, GenericSyntaxHighlighterAttributes &attributes)
{
GenericSyntaxHighlighterContext context;
@ -1424,7 +1435,11 @@ parse_context (QDomElement e, GenericSyntaxHighlighterContexts &contexts, std::m
if (n.isElement()) {
QDomElement ee = n.toElement();
if (ee.tagName () == QString::fromUtf8 ("IncludeRules")) {
context.include (contexts.context (ee.attributeNode (QString::fromUtf8 ("context")).value ()));
QString included_name = ee.attributeNode (QString::fromUtf8 ("context")).value ();
std::map<QString, QDomElement>::const_iterator c2n = contexts_by_name.find (included_name);
if (c2n != contexts_by_name.end ()) {
context.include (parse_context (c2n->second, contexts_by_name, contexts, lists, attributes));
}
} else {
context.add_rule (parse_rule (ee, contexts, lists, attributes));
}
@ -1498,6 +1513,18 @@ parse_item_data (QDomElement e, GenericSyntaxHighlighterAttributes &attributes)
else if (s == QString::fromUtf8 ("dsOthers")) { ds = dsOthers; }
else if (s == QString::fromUtf8 ("dsRegionMarker")) { ds = dsRegionMarker; }
else if (s == QString::fromUtf8 ("dsString")) { ds = dsString; }
else if (s == QString::fromUtf8 ("dsOperator")) { ds = dsOperator; }
else if (s == QString::fromUtf8 ("dsControlFlow")) { ds = dsControlFlow; }
else if (s == QString::fromUtf8 ("dsBuiltIn")) { ds = dsBuiltIn; }
else if (s == QString::fromUtf8 ("dsVariable")) { ds = dsVariable; }
else if (s == QString::fromUtf8 ("dsExtension")) { ds = dsExtension; }
else if (s == QString::fromUtf8 ("dsPreprocessor")) { ds = dsPreprocessor; }
else if (s == QString::fromUtf8 ("dsImport")) { ds = dsImport; }
else if (s == QString::fromUtf8 ("dsVerbatimString")) { ds = dsVerbatimString; }
else if (s == QString::fromUtf8 ("dsSpecialString")) { ds = dsSpecialString; }
else if (s == QString::fromUtf8 ("dsSpecialString")) { ds = dsSpecialString; }
else if (s == QString::fromUtf8 ("dsSpecialChar")) { ds = dsSpecialChar; }
else if (s == QString::fromUtf8 ("dsAttribute")) { ds = dsAttribute; }
}
attributes.set_styles (attribute_id, ds, format);
@ -1534,12 +1561,26 @@ GenericSyntaxHighlighter::GenericSyntaxHighlighter (QObject *parent, QIODevice &
} else if (e.tagName () == QString::fromUtf8 ("contexts")) {
// first analyze the list of contexts and their dependencies
std::map<QString, QDomElement> contexts_by_name;
for (QDomNode nn = e.firstChild(); !nn.isNull(); nn = nn.nextSibling()) {
if (nn.isElement()) {
QDomElement ee = nn.toElement ();
if (ee.tagName () == QString::fromUtf8 ("context")) {
QString context_name = ee.attributeNode (QString::fromUtf8 ("name")).value ();
m_contexts.insert (context_name, parse_context (ee, m_contexts, m_lists, *mp_attributes));
contexts_by_name[context_name] = ee;
}
}
}
for (QDomNode nn = e.firstChild(); !nn.isNull(); nn = nn.nextSibling()) {
if (nn.isElement()) {
QDomElement ee = nn.toElement ();
if (ee.tagName () == QString::fromUtf8 ("context")) {
QString context_name = ee.attributeNode (QString::fromUtf8 ("name")).value ();
m_contexts.insert (context_name, parse_context (ee, contexts_by_name, m_contexts, m_lists, *mp_attributes));
}
}
}

View File

@ -562,6 +562,17 @@ enum def_style {
dsOthers,
dsRegionMarker,
dsString,
dsOperator,
dsControlFlow,
dsBuiltIn,
dsVariable,
dsExtension,
dsPreprocessor,
dsImport,
dsVerbatimString,
dsSpecialString,
dsSpecialChar,
dsAttribute,
dsLast
};

View File

@ -13,9 +13,10 @@
<!-- v2.06 decorator names can (and often do) contain periods -->
<!-- v2.07 add support for %prog and co, see bug 142832 -->
<!-- v2.08 add missing overloaders, new Python 3 statements, builtins, and keywords -->
<language name="Python" version="2.22" style="python" kateversion="2.4" section="Scripts" extensions="*.py;*.pyw;SConstruct;SConscript" mimetype="application/x-python;text/x-python" casesensitive="1" author="Michael Bueker" license="">
<!-- v2.29 recognize escape sequenzes correctly -->
<language name="Python" version="4" style="python" kateversion="5.0" section="Scripts" extensions="*.py;*.pyw;SConstruct;SConscript" mimetype="application/x-python;text/x-python" casesensitive="1" author="Michael Bueker" license="">
<highlighting>
<list name="prep">
<list name="import">
<item> import </item>
<item> from </item>
<item> as </item>
@ -52,6 +53,8 @@
<item> while </item>
<item> with </item>
<item> yield </item>
<item> async </item>
<item> await </item>
</list>
<list name="builtinfuncs">
<item> __import__ </item>
@ -248,6 +251,11 @@
<item>__format__</item>
<item>__next__</item>
<item>__dir__</item>
<item>__await__</item>
<item>__aiter__</item>
<item>__anext__</item>
<item>__aenter__</item>
<item>__aexit__</item>
</list>
<list name="exceptions">
<!--
@ -323,17 +331,17 @@
</list>
<contexts>
<context name="Normal" attribute="Normal Text" lineEndContext="#stay">
<keyword attribute="Preprocessor" String="prep" context="#stay"/>
<keyword attribute="Import" String="import" context="#stay"/>
<keyword attribute="Definition Keyword" String="defs" context="#stay"/>
<keyword attribute="Operator" String="operators" context="#stay"/>
<keyword attribute="Command Keyword" String="commands" context="#stay"/>
<keyword attribute="Operator Keyword" String="operators" context="#stay"/>
<keyword attribute="Flow Control Keyword" String="flow" context="#stay"/>
<keyword attribute="Builtin Function" String="builtinfuncs" context="#stay"/>
<keyword attribute="Special Variable" String="specialvars" context="#stay"/>
<keyword attribute="Extensions" String="bindings" context="#stay"/>
<keyword attribute="Exceptions" String="exceptions" context="#stay"/>
<keyword attribute="Overloaders" String="overloaders" context="#stay"/>
<RegExpr attribute="Normal" String="[a-zA-Z_][a-zA-Z_0-9]{2,}" context="#stay"/>
<RegExpr attribute="ClassNames" String="[A-Z][a-zA-Z_0-9]+" context="#stay"/>
<RegExpr attribute="Normal Text" String="[a-z_][a-zA-Z_][a-zA-Z_0-9]+" context="#stay"/>
<RegExpr attribute="Complex" String=" ((([0-9]*\.[0-9]+|[0-9]+\.)|([0-9]+|([0-9]*\.[0-9]+|[0-9]+\.))[eE](\+|-)?[0-9]+)|[0-9]+)[jJ]" context="#stay"/>
<Float attribute="Float" context="#stay" />
@ -353,15 +361,15 @@
<IncludeRules context="StringVariants" />
<AnyChar attribute="Operator" String="+*/%\|=;\!&lt;&gt;!^&amp;~-" context="#stay"/>
<RegExpr attribute="Decorator" String="@[_a-zA-Z][\._a-zA-Z0-9]*" firstNonSpace="true"/>
<AnyChar attribute="Operator" String="+*/%\|=;\!&lt;&gt;!^&amp;~-@" context="#stay"/>
</context>
<context name="#CheckForString" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
<DetectSpaces/>
<LineContinue attribute="Normal Text" context="CheckForStringNext"/>
</context>
<context name="CheckForStringNext" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
<DetectSpaces/>
<LineContinue attribute="Normal Text" context="CheckForStringNext"/>
@ -370,60 +378,40 @@
<context name="StringVariants" attribute="Normal Text" lineEndContext="#stay">
<DetectSpaces/>
<!-- ''' -->
<StringDetect attribute="String" String="'''" context="Tripple A-string" beginRegion="Tripple A-region"/>
<StringDetect attribute="String" String="u'''" insensitive="true" context="Tripple A-string" beginRegion="Tripple A-region"/>
<!-- """ -->
<StringDetect attribute="String" String="&quot;&quot;&quot;" context="Tripple Q-string" beginRegion="Tripple Q-region"/>
<StringDetect attribute="String" String="u&quot;&quot;&quot;" insensitive="true" context="Tripple Q-string" beginRegion="Tripple Q-region"/>
<!-- ' -->
<DetectChar attribute="String" char="'" context="Single A-string"/>
<Detect2Chars attribute="String" char="u" char1="'" insensitive="true" context="Single A-string"/>
<!-- " -->
<DetectChar attribute="String" char="&quot;" context="Single Q-string"/>
<Detect2Chars attribute="String" char="u" char1="&quot;" insensitive="true" context="Single Q-string"/>
<!-- ''' -->
<StringDetect attribute="Raw String" String="r'''" insensitive="true" context="Raw Tripple A-string" beginRegion="Tripple A-region"/>
<StringDetect attribute="Raw String" String="ur'''" insensitive="true" context="Raw Tripple A-string" beginRegion="Tripple A-region"/>
<!-- """ -->
<StringDetect attribute="Raw String" String="r&quot;&quot;&quot;" insensitive="true" context="Raw Tripple Q-string" beginRegion="Tripple Q-region"/>
<StringDetect attribute="Raw String" String="ur&quot;&quot;&quot;" insensitive="true" context="Raw Tripple Q-string" beginRegion="Tripple Q-region"/>
<!-- ' -->
<StringDetect attribute="Raw String" String="r'" insensitive="true" context="Raw A-string"/>
<StringDetect attribute="Raw String" String="ur'" insensitive="true" context="Raw A-string"/>
<!-- " -->
<StringDetect attribute="Raw String" String="r&quot;" insensitive="true" context="Raw Q-string"/>
<StringDetect attribute="Raw String" String="ur&quot;" insensitive="true" context="Raw Q-string"/>
<RegExpr attribute="String" String="u?'''" insensitive="true" context="Triple A-string" beginRegion="Triple A-region"/>
<RegExpr attribute="String" String="u?&quot;&quot;&quot;" insensitive="true" context="Triple Q-string" beginRegion="Triple Q-region"/>
<RegExpr attribute="String" String="u?'" insensitive="true" context="Single A-string"/>
<RegExpr attribute="String" String="u?&quot;" insensitive="true" context="Single Q-string"/>
<RegExpr attribute="Raw String" String="(u?r|ru)'''" insensitive="true" context="Raw Triple A-string" beginRegion="Triple A-region"/>
<RegExpr attribute="Raw String" String="(u?r|ru)&quot;&quot;&quot;" insensitive="true" context="Raw Triple Q-string" beginRegion="Triple Q-region"/>
<RegExpr attribute="Raw String" String="(u?r|ru)'" insensitive="true" context="Raw A-string"/>
<RegExpr attribute="Raw String" String="(u?r|ru)&quot;" insensitive="true" context="Raw Q-string"/>
<StringDetect attribute="F-String" String="f'''" insensitive="true" context="Triple A-F-String" beginRegion="Triple A-region"/>
<StringDetect attribute="F-String" String="f&quot;&quot;&quot;" insensitive="true" context="Triple Q-F-String" beginRegion="Triple Q-region"/>
<StringDetect attribute="F-String" String="f'" insensitive="true" context="Single A-F-String"/>
<StringDetect attribute="F-String" String="f&quot;" insensitive="true" context="Single Q-F-String"/>
<RegExpr attribute="Raw F-String" String="(fr|rf)'''" insensitive="true" context="Raw Triple A-F-String" beginRegion="Triple A-region"/>
<RegExpr attribute="Raw F-String" String="(fr|rf)&quot;&quot;&quot;" insensitive="true" context="Raw Triple Q-F-String" beginRegion="Triple Q-region"/>
<RegExpr attribute="Raw F-String" String="(fr|rf)'" insensitive="true" context="Raw A-F-String"/>
<RegExpr attribute="Raw F-String" String="(fr|rf)&quot;" insensitive="true" context="Raw Q-F-String"/>
</context>
<context name="CommentVariants" attribute="Normal Text" lineEndContext="#stay">
<DetectSpaces/>
<!-- ''' -->
<StringDetect attribute="Comment" String="'''" firstNonSpace="true" context="Tripple A-comment" beginRegion="Tripple A-region"/>
<StringDetect attribute="Comment" String="u'''" insensitive="true" firstNonSpace="true" context="Tripple A-comment" beginRegion="Tripple A-region"/>
<!-- """ -->
<StringDetect attribute="Comment" String="&quot;&quot;&quot;" firstNonSpace="true" context="Tripple Q-comment" beginRegion="Tripple Q-region"/>
<StringDetect attribute="Comment" String="u&quot;&quot;&quot;" insensitive="true" firstNonSpace="true" context="Tripple Q-comment" beginRegion="Tripple Q-region"/>
<!-- ' -->
<DetectChar attribute="Comment" char="'" firstNonSpace="true" context="Single A-comment"/>
<Detect2Chars attribute="Comment" char="u" char1="'" insensitive="true" firstNonSpace="true" context="Single A-comment"/>
<!-- " -->
<DetectChar attribute="Comment" char="&quot;" firstNonSpace="true" context="Single Q-comment"/>
<Detect2Chars attribute="Comment" char="u" char1="&quot;" insensitive="true" firstNonSpace="true" context="Single Q-comment"/>
<!-- ''' -->
<StringDetect attribute="Comment" String="r'''" insensitive="true" firstNonSpace="true" context="Tripple A-comment" beginRegion="Tripple A-region"/>
<StringDetect attribute="Comment" String="ur'''" insensitive="true" firstNonSpace="true" context="Tripple A-comment" beginRegion="Tripple A-region"/>
<!-- """ -->
<StringDetect attribute="Comment" String="r&quot;&quot;&quot;" insensitive="true" firstNonSpace="true" context="Tripple Q-comment" beginRegion="Tripple Q-region"/>
<StringDetect attribute="Comment" String="ur&quot;&quot;&quot;" insensitive="true" firstNonSpace="true" context="Tripple Q-comment" beginRegion="Tripple Q-region"/>
<!-- ' -->
<StringDetect attribute="Comment" String="r'" insensitive="true" firstNonSpace="true" context="Single A-comment"/>
<StringDetect attribute="Comment" String="ur'" insensitive="true" firstNonSpace="true" context="Single A-comment"/>
<!-- " -->
<StringDetect attribute="Comment" String="r&quot;" insensitive="true" firstNonSpace="true" context="Single Q-comment"/>
<StringDetect attribute="Comment" String="ur&quot;" insensitive="true" firstNonSpace="true" context="Single Q-comment"/>
<RegExpr attribute="Comment" String="u?'''" insensitive="true" firstNonSpace="true" context="Triple A-comment" beginRegion="Triple A-region"/>
<RegExpr attribute="Comment" String="u?&quot;&quot;&quot;" insensitive="true" firstNonSpace="true" context="Triple Q-comment" beginRegion="Triple Q-region"/>
<RegExpr attribute="Comment" String="u?'" insensitive="true" firstNonSpace="true" context="Single A-comment"/>
<RegExpr attribute="Comment" String="u?&quot;" insensitive="true" firstNonSpace="true" context="Single Q-comment"/>
<RegExpr attribute="Comment" String="(u?r|ru)'''" insensitive="true" firstNonSpace="true" context="Triple A-comment" beginRegion="Triple A-region"/>
<RegExpr attribute="Comment" String="(u?r|ru)&quot;&quot;&quot;" insensitive="true" firstNonSpace="true" context="Triple Q-comment" beginRegion="Triple Q-region"/>
<RegExpr attribute="Comment" String="(u?r|ru)'" insensitive="true" firstNonSpace="true" context="Single A-comment"/>
<RegExpr attribute="Comment" String="(u?r|ru)&quot;" insensitive="true" firstNonSpace="true" context="Single Q-comment"/>
</context>
<context name="Dictionary" attribute="Normal Text" lineEndContext="#stay" noIndentationBasedFolding="true">
@ -432,14 +420,14 @@
<IncludeRules context="StringVariants" />
<IncludeRules context="Normal" />
</context>
<context name="List" attribute="Normal Text" lineEndContext="#stay" noIndentationBasedFolding="true">
<DetectSpaces/>
<DetectChar attribute="Normal Text" char="]" context="#pop" endRegion="List"/>
<IncludeRules context="StringVariants" />
<IncludeRules context="Normal" />
</context>
<context name="Tuple" attribute="Normal Text" lineEndContext="#stay" noIndentationBasedFolding="true">
<DetectSpaces/>
<DetectChar attribute="Normal Text" char=")" context="#pop" endRegion="Tuple"/>
@ -454,14 +442,14 @@
<IncludeRules context="##Modelines" />
</context>
<context name="Tripple A-comment" attribute="Comment" lineEndContext="#stay" noIndentationBasedFolding="true">
<StringDetect attribute="Comment" String="'''" context="#pop" endRegion="Tripple A-region"/>
<context name="Triple A-comment" attribute="Comment" lineEndContext="#stay" noIndentationBasedFolding="true">
<StringDetect attribute="Comment" String="'''" context="#pop" endRegion="Triple A-region"/>
<IncludeRules context="##Alerts_indent" />
</context>
<context name="Tripple Q-comment" attribute="Comment" lineEndContext="#stay" noIndentationBasedFolding="true">
<context name="Triple Q-comment" attribute="Comment" lineEndContext="#stay" noIndentationBasedFolding="true">
<HlCChar attribute="Comment" context="#stay"/>
<StringDetect attribute="Comment" String="&quot;&quot;&quot;" context="#pop" endRegion="Tripple Q-region"/>
<StringDetect attribute="Comment" String="&quot;&quot;&quot;" context="#pop" endRegion="Triple Q-region"/>
<IncludeRules context="##Alerts_indent" />
</context>
@ -493,89 +481,176 @@
-->
<RegExpr attribute="String Substitution" String="%((\([a-zA-Z0-9_]+\))?[#0\- +]?([1-9][0-9]*|\*)?(\.([1-9][0-9]*|\*))?[hlL]?[crsdiouxXeEfFgG%]|prog|default)" context="#stay"/>
<!-- http://docs.python.org/2/library/string.html#format-string-syntax:
replacement_field ::= "{" field_name ["!" conversion] [":" format_spec] "}"
field_name ::= (identifier | integer) ("." attribute_name | "[" element_index "]")*
attribute_name ::= identifier
element_index ::= integer | index_string
index_string ::= <any source character except "]"> +
conversion ::= "r" | "s"
format_spec ::= [[fill]align][sign][#][0][width][.precision][type]
fill ::= <a character other than '}'>
align ::= "<" | ">" | "=" | "^"
sign ::= "+" | "-" | " "
width ::= integer
precision ::= integer
type ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"
replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}"
field_name ::= arg_name ("." attribute_name | "[" element_index "]")*
arg_name ::= [identifier | integer]
attribute_name ::= identifier
element_index ::= integer | index_string
index_string ::= <any source character except "]"> +
conversion ::= "r" | "s"
format_spec ::= [[fill]align][sign][#][0][width][,][.precision][type]
fill ::= <any character>
align ::= "<" | ">" | "=" | "^"
sign ::= "+" | "-" | " "
width ::= integer
precision ::= integer
type ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"
-->
<RegExpr attribute="String Substitution" String="\{([a-zA-Z0-9_]+|[0-9]+)(\.[a-zA-Z0-9_]+|\[[^ \]]+\])*(![rs])?(:([^}]?[&lt;&gt;=^])?[ +-]?#?0?[0-9]*(\.[0-9]+)?[bcdeEfFgGnosxX%]?)?\}" context="#stay"/>
<RegExpr attribute="String Substitution" String="\{(([a-zA-Z0-9_]+|[0-9]+)(\.[a-zA-Z0-9_]+|\[[^ \]]+\])*)?(![rs])?(:([^}]?[&lt;&gt;=^])?[ +-]?#?0?[0-9]*(\.[0-9]+)?[bcdeEfFgGnosxX%]?)?\}" context="#stay"/>
<Detect2Chars attribute="String Substitution" char="{" char1="{" context="#stay" />
<Detect2Chars attribute="String Substitution" char="}" char1="}" context="#stay" />
</context>
<context name="Tripple A-string" attribute="String" lineEndContext="#stay" noIndentationBasedFolding="true">
<HlCStringChar attribute="String Char" context="#stay"/>
<IncludeRules context="stringformat"/>
<StringDetect attribute="String" String="'''" context="#pop#CheckForString" endRegion="Tripple A-region"/>
<!-- escape characters -->
<context name="stringescape" attribute="String Char" lineEndContext="#stay">
<!-- As this highlighting style is for both, Python 2 and 3,
we do not know if a normal string is “unicode” or not. So we
-->
<RegExpr attribute="String Char" String="\\[\\'&quot;abfnrtv]" context="#stay"/>
<RegExpr attribute="String Char" String="\\[0-7]{1,3}" context="#stay"/>
<RegExpr attribute="String Char" String="\\x[0-9A-Fa-f]{2}" context="#stay"/>
<RegExpr attribute="String Char" String="\\u[0-9A-Fa-f]{4}" context="#stay"/>
<RegExpr attribute="String Char" String="\\U[0-9A-Fa-f]{8}" context="#stay"/>
<RegExpr attribute="String Char" String="\\N\{[a-zA-Z0-9\- ]+\}" context="#stay"/>
</context>
<context name="Raw Tripple A-string" attribute="Raw String" lineEndContext="#stay" noIndentationBasedFolding="true">
<!-- f-literals -->
<context name="stringinterpolation" attribute="F-String" lineEndContext="#stay">
<Detect2Chars attribute="String Char" char="{" char1="{" context="#stay"/>
<DetectChar attribute="String Substitution" char="{" context="String Interpolation"/>
</context>
<context name="String Interpolation" attribute="String Substitution" lineEndContext="#stay">
<DetectChar attribute="Error" char="\" context="#pop"/>
<RegExpr attribute="String Substitution" String="(![rs])?(:([^}]?[&lt;&gt;=^])?[ +-]?#?0?[0-9]*(\.[0-9]+)?[bcdeEfFgGnosxX%]?)?\}" context="#pop"/>
<IncludeRules context="Normal"/> <!-- TODO: create expression context instead -->
</context>
<!--
It follows a Binary tree of string kinds (not even touching byte literals).
The levels are:
1. triple- vs. single-quoted
2. apostrophe vs. quotation mark
3. static vs. interpolated (f-literal)
4. escaped vs. raw
Adding byte literals wouldnt make the current 2⁴ into 2⁵ contexts, as there are no byte f-literals
-->
<!-- Triple-quoted A-strings -->
<context name="Triple A-string" attribute="String" lineEndContext="#stay" noIndentationBasedFolding="true">
<IncludeRules context="stringescape"/>
<IncludeRules context="stringformat"/>
<StringDetect attribute="String" String="'''" context="#pop#CheckForString" endRegion="Triple A-region"/>
</context>
<context name="Raw Triple A-string" attribute="Raw String" lineEndContext="#stay" noIndentationBasedFolding="true">
<HlCStringChar attribute="Raw String" context="#stay"/>
<IncludeRules context="stringformat"/>
<StringDetect attribute="String" String="'''" context="#pop#CheckForString" endRegion="Tripple A-region"/>
<StringDetect attribute="Raw String" String="'''" context="#pop#CheckForString" endRegion="Triple A-region"/>
</context>
<context name="Tripple Q-string" attribute="String" lineEndContext="#stay" noIndentationBasedFolding="true">
<HlCStringChar attribute="String Char" context="#stay"/>
<context name="Triple A-F-String" attribute="F-String" lineEndContext="#stay" noIndentationBasedFolding="true">
<IncludeRules context="stringescape"/>
<IncludeRules context="stringinterpolation"/>
<StringDetect attribute="F-String" String="'''" context="#pop#CheckForString" endRegion="Triple A-region"/>
</context>
<context name="Raw Triple A-F-String" attribute="Raw F-String" lineEndContext="#stay" noIndentationBasedFolding="true">
<HlCStringChar attribute="Raw F-String" context="#stay"/>
<IncludeRules context="stringinterpolation"/>
<StringDetect attribute="Raw F-String" String="'''" context="#pop#CheckForString" endRegion="Triple A-region"/>
</context>
<!-- Triple-quoted Q-strings -->
<context name="Triple Q-string" attribute="String" lineEndContext="#stay" noIndentationBasedFolding="true">
<IncludeRules context="stringescape"/>
<IncludeRules context="stringformat"/>
<StringDetect attribute="String" String="&quot;&quot;&quot;" context="#pop#CheckForString" endRegion="Tripple Q-region"/>
<StringDetect attribute="String" String="&quot;&quot;&quot;" context="#pop#CheckForString" endRegion="Triple Q-region"/>
</context>
<context name="Raw Tripple Q-string" attribute="Raw String" lineEndContext="#stay" noIndentationBasedFolding="true">
<context name="Raw Triple Q-string" attribute="Raw String" lineEndContext="#stay" noIndentationBasedFolding="true">
<HlCStringChar attribute="Raw String" context="#stay"/>
<IncludeRules context="stringformat"/>
<StringDetect attribute="String" String="&quot;&quot;&quot;" context="#pop#CheckForString" endRegion="Tripple Q-region"/>
<StringDetect attribute="Raw String" String="&quot;&quot;&quot;" context="#pop#CheckForString" endRegion="Triple Q-region"/>
</context>
<context name="Triple Q-F-String" attribute="F-String" lineEndContext="#stay" noIndentationBasedFolding="true">
<IncludeRules context="stringescape"/>
<IncludeRules context="stringinterpolation"/>
<StringDetect attribute="F-String" String="&quot;&quot;&quot;" context="#pop#CheckForString" endRegion="Triple Q-region"/>
</context>
<context name="Raw Triple Q-F-String" attribute="Raw F-String" lineEndContext="#stay" noIndentationBasedFolding="true">
<HlCStringChar attribute="Raw F-String" context="#stay"/>
<IncludeRules context="stringinterpolation"/>
<StringDetect attribute="Raw F-String" String="&quot;&quot;&quot;" context="#pop#CheckForString" endRegion="Triple Q-region"/>
</context>
<!-- Single-quoted A-strings -->
<context name="Single A-string" attribute="String" lineEndContext="#stay">
<HlCStringChar attribute="String Char" context="#stay"/>
<IncludeRules context="stringescape"/>
<IncludeRules context="stringformat"/>
<DetectChar attribute="String" char="'" context="#pop#CheckForString"/>
</context>
<context name="Single Q-string" attribute="String" lineEndContext="#stay">
<HlCStringChar attribute="String Char" context="#stay"/>
<IncludeRules context="stringformat"/>
<DetectChar attribute="String" char="&quot;" context="#pop#CheckForString"/>
</context>
<context name="Raw A-string" attribute="Raw String" lineEndContext="#stay">
<HlCStringChar attribute="Raw String" context="#stay"/>
<IncludeRules context="stringformat"/>
<DetectChar attribute="Raw String" char="'" context="#pop#CheckForString"/>
</context>
<context name="Single A-F-String" attribute="F-String" lineEndContext="#stay">
<IncludeRules context="stringescape"/>
<IncludeRules context="stringinterpolation"/>
<DetectChar attribute="F-String" char="'" context="#pop#CheckForString"/>
</context>
<context name="Raw A-F-String" attribute="Raw F-String" lineEndContext="#stay">
<HlCStringChar attribute="Raw F-String" context="#stay"/>
<IncludeRules context="stringinterpolation"/>
<DetectChar attribute="Raw F-String" char="'" context="#pop#CheckForString"/>
</context>
<!-- Single-quoted Q-strings -->
<context name="Single Q-string" attribute="String" lineEndContext="#stay">
<IncludeRules context="stringescape"/>
<IncludeRules context="stringformat"/>
<DetectChar attribute="String" char="&quot;" context="#pop#CheckForString"/>
</context>
<context name="Raw Q-string" attribute="Raw String" lineEndContext="#stay">
<HlCStringChar attribute="Raw String" context="#stay"/>
<IncludeRules context="stringformat"/>
<DetectChar attribute="Raw String" char="&quot;" context="#pop#CheckForString"/>
</context>
<context name="Single Q-F-String" attribute="F-String" lineEndContext="#stay">
<IncludeRules context="stringescape"/>
<IncludeRules context="stringinterpolation"/>
<DetectChar attribute="F-String" char="&quot;" context="#pop#CheckForString"/>
</context>
<context name="Raw Q-F-String" attribute="Raw F-String" lineEndContext="#stay">
<HlCStringChar attribute="Raw F-String" context="#stay"/>
<IncludeRules context="stringinterpolation"/>
<DetectChar attribute="Raw F-String" char="&quot;" context="#pop#CheckForString"/>
</context>
</contexts>
<itemDatas>
<itemData name="Normal Text" defStyleNum="dsNormal" spellChecking="false"/>
<itemData name="Definition Keyword" defStyleNum="dsKeyword" spellChecking="false"/>
<itemData name="Operator" defStyleNum="dsNormal" bold="1" spellChecking="false"/>
<itemData name="String Substitution" defStyleNum="dsOthers" color="#0057ae" selColor="#0057ae" spellChecking="false"/>
<itemData name="Command Keyword" defStyleNum="dsKeyword" spellChecking="false"/>
<itemData name="Flow Control Keyword" defStyleNum="dsKeyword" spellChecking="false"/>
<itemData name="Builtin Function" defStyleNum="dsDataType" spellChecking="false"/>
<itemData name="Special Variable" defStyleNum="dsOthers" spellChecking="false"/>
<itemData name="Extensions" defStyleNum="dsOthers" color="#0095ff" selColor="#0095ff" bold="1" italic="0" spellChecking="false"/>
<itemData name="Exceptions" defStyleNum="dsOthers" color="#054d00" selColor="#054d00" bold="1" italic="0" spellChecking="false"/>
<itemData name="Overloaders" defStyleNum="dsOthers" color="#000e52" selColor="#000e52" bold="1" italic="0" spellChecking="false"/>
<itemData name="Preprocessor" defStyleNum="dsChar" spellChecking="false"/>
<itemData name="String Char" defStyleNum="dsChar" spellChecking="false"/>
<itemData name="Operator" defStyleNum="dsOperator" spellChecking="false"/>
<itemData name="Operator Keyword" defStyleNum="dsKeyword" spellChecking="false"/>
<itemData name="Flow Control Keyword" defStyleNum="dsControlFlow" spellChecking="false"/>
<itemData name="Builtin Function" defStyleNum="dsBuiltIn" spellChecking="false"/>
<itemData name="Special Variable" defStyleNum="dsVariable" spellChecking="false"/>
<itemData name="Extensions" defStyleNum="dsExtension" spellChecking="false"/>
<itemData name="Exceptions" defStyleNum="dsPreprocessor" spellChecking="false"/>
<itemData name="Overloaders" defStyleNum="dsFunction" spellChecking="false"/>
<itemData name="Import" defStyleNum="dsImport" spellChecking="false"/>
<itemData name="Float" defStyleNum="dsFloat" spellChecking="false"/>
<itemData name="Int" defStyleNum="dsDecVal" spellChecking="false"/>
<itemData name="Hex" defStyleNum="dsBaseN" spellChecking="false"/>
@ -583,8 +658,14 @@
<itemData name="Complex" defStyleNum="dsOthers" spellChecking="false"/>
<itemData name="Comment" defStyleNum="dsComment"/>
<itemData name="String" defStyleNum="dsString"/>
<itemData name="Raw String" defStyleNum="dsString"/>
<itemData name="Decorator" defStyleNum="dsOthers" color="#8f6b32" selColor="#8f6b32" italic="0" spellChecking="false"/>
<itemData name="ClassNames" defStyleNum="dsOthers" color="#FCAD3D" selColor="#ffffff" bold="1" italic="0" spellChecking="false"/>
<itemData name="Raw String" defStyleNum="dsVerbatimString"/>
<itemData name="F-String" defStyleNum="dsSpecialString"/>
<itemData name="Raw F-String" defStyleNum="dsVerbatimString"/>
<itemData name="String Char" defStyleNum="dsChar" spellChecking="false"/>
<itemData name="String Substitution" defStyleNum="dsSpecialChar" spellChecking="false"/>
<itemData name="Decorator" defStyleNum="dsAttribute" spellChecking="false"/>
<itemData name="Error" defStyleNum="dsError"/>
</itemDatas>
</highlighting>
<general>