<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd"
[
	<!ENTITY more "(_[0-9]++)*+">
	<!ENTITY int  "(0|[1-9][0-9]*+&more;)">
	<!ENTITY frac "\.[0-9]+&more;">
	<!ENTITY exp  "[eE][+-]?[0-9]+&more;">
	
	<!ENTITY offset   "[+-][0-9][0-9]:[0-9][0-9]">
	<!ENTITY time     "[0-9][0-9]:[0-9][0-9]:[0-9][0-9](\.[0-9]+)?">
	<!ENTITY datetime "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]([T ]&time;(&offset;|Z)?)?|&time;">
]>
<!-- https://github.com/toml-lang/toml -->
<!-- https://toml.io/en/v1.0.0 -->
<language name="TOML" section="Configuration" extensions="*.toml" mimetype="text/x-toml;application/toml" version="10" kateversion="5.0" author="flying-sheep@web.de" license="LGPLv2+">
<highlighting>
	<list name="bools">
		<item>true</item>
		<item>false</item>
	</list>

	<contexts>
		<context attribute="Error" lineEndContext="#stay" name="Toml">
			<DetectSpaces attribute="Whitespace"/>
			<Detect2Chars attribute="TableHeader" context="NestedTableHeader" char="[" char1="[" endRegion="Table"/>
			<DetectChar attribute="TableHeader" context="TableHeader" char="[" endRegion="Table"/>
			<DetectChar attribute="Assignment" context="Value" char="="/>
			<DetectChar char="#" attribute="Comment" context="Comment"/>
			<IncludeRules context="FindKey"/>
		</context>

		<context attribute="Key" lineEndContext="#stay" name="FindKey">
			<DetectChar attribute="TableHeader" char="."/>
			<RegExpr    attribute="Key" context="#stay" String="[A-Za-z0-9_-]+"/>
			<DetectChar attribute="Key" context="QuotedKey" char="&quot;"/>
			<DetectChar attribute="Key" context="LitQuotedKey" char="'"/>
		</context>


		<!-- table headers -->
		<context attribute="TableHeader" fallthrough="true" fallthroughContext="#pop" lineEndContext="#pop" name="TableHeader">
			<DetectChar attribute="TableHeader" context="#pop" char="]" beginRegion="Table"/>
			<IncludeRules context="TableHeaderCommon"/>
		</context>

		<context attribute="TableHeader" fallthrough="true" fallthroughContext="#pop" lineEndContext="#pop" name="NestedTableHeader">
			<Detect2Chars attribute="TableHeader" context="#pop" char="]" char1="]" beginRegion="Table"/>
			<IncludeRules context="TableHeaderCommon"/>
		</context>

		<context attribute="TableHeader" lineEndContext="#pop" name="TableHeaderCommon">
			<DetectSpaces attribute="Whitespace"/>
			<IncludeRules context="FindKey"/>
		</context>


		<!-- values -->
		<context attribute="Error" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop" name="Value">
			<DetectSpaces attribute="Whitespace"/>
			<keyword attribute="Bool" context="#pop" String="bools"/>
			<StringDetect attribute="String" context="#pop!MultilineString"    String="&quot;&quot;&quot;"/>
			<DetectChar   attribute="String" context="#pop!String"               char="&quot;"/>
			<StringDetect attribute="String" context="#pop!LitMultilineString" String="'''"/>
			<DetectChar   attribute="String" context="#pop!LitString"            char="'"/>
			<DetectChar attribute="Array" context="#pop!Array" char="["/>
			<DetectChar attribute="InlineTable" context="#pop!InlineTable" char="{"/>
			<RegExpr attribute="Date"  context="#pop" String="&datetime;"/>
			<RegExpr attribute="Int"   context="#pop" String="[+-]?(0x[0-9a-fA-F]+(_[0-9a-fA-F]+)*|0o[0-7]+(_[0-7]+)*|0b[01]+(_[01]+)*|&int;(?!(\.|[eE][+-]?)[0-9]))"/>
			<RegExpr attribute="Float" context="#pop" String="[+-]?(&int;(&frac;(&exp;)?|&exp;)|inf|nan)"/>
		</context>

		<context attribute="Comment" lineEndContext="#pop" name="Comment">
			<DetectSpaces/>
			<IncludeRules context="##Comments"/>
			<DetectIdentifier/>
		</context>


		<!-- Quoted keys and Strings-->
		<context attribute="Key" lineEndContext="#pop" name="QuotedKey">
			<DetectChar attribute="Key" context="#pop" char="&quot;"/>
			<IncludeRules context="FindEscapedChar"/>
		</context>

		<context attribute="String" lineEndContext="#pop" name="String">
			<DetectChar attribute="String" context="#pop" char="&quot;"/>
			<IncludeRules context="FindEscapedChar"/>
		</context>

		<context attribute="String" lineEndContext="#stay" name="MultilineString">
			<StringDetect attribute="String" context="#pop" String="&quot;&quot;&quot;&quot;&quot;"/>
			<StringDetect attribute="String" context="#pop" String="&quot;&quot;&quot;&quot;"/>
			<StringDetect attribute="String" context="#pop" String="&quot;&quot;&quot;"/>
			<LineContinue attribute="Escape" context="#stay"/>
			<IncludeRules context="FindEscapedChar"/>
		</context>

		<context attribute="String" lineEndContext="#pop" name="FindEscapedChar">
			<RegExpr attribute="Escape" String="\\[btnfr&quot;\\]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}" context="#stay"/>
			<RegExpr attribute="Error" String="\\[uU][0-9a-fA-F]*|\\." context="#stay"/>
		</context>

		<context attribute="Key" lineEndContext="#pop" name="LitQuotedKey">
			<DetectChar attribute="Key" context="#pop" char="'"/>
		</context>

		<context attribute="LitString" lineEndContext="#pop" name="LitString">
			<DetectChar attribute="String" context="#pop" char="'"/>
		</context>

		<context attribute="LitString" lineEndContext="#stay" name="LitMultilineString">
			<StringDetect attribute="String" context="#pop" String="'''''"/>
			<StringDetect attribute="String" context="#pop" String="''''"/>
			<StringDetect attribute="String" context="#pop" String="'''"/>
		</context>


		<!-- Arrays -->
		<context attribute="Array" lineEndContext="#stay" name="Array" fallthrough="true" fallthroughContext="InArray">
			<DetectSpaces attribute="Whitespace"/>
			<DetectChar context="#pop" attribute="Array" char="]"/>
			<DetectChar context="InArray" attribute="NextEntry" char=","/>
		</context>
		<context attribute="Error" lineEndContext="#stay" name="InArray">
			<DetectChar context="#pop#pop" attribute="Array" char="]"/>
			<DetectChar context="#stay" attribute="Error" char=","/>
			<DetectChar attribute="Comment" context="Comment" char="#"/>
			<IncludeRules context="Value"/>
		</context>

		<context attribute="InlineTable" lineEndContext="#stay" name="InlineTable">
			<DetectChar attribute="Assignment" context="Value" char="="/>
			<DetectChar char="#" attribute="Comment" context="Comment"/>
			<DetectChar context="#pop" attribute="InlineTable" char="}"/>
			<DetectChar context="#stay" attribute="NextEntry" char=","/>
			<IncludeRules context="FindKey"/>
		</context>

	</contexts>
	<itemDatas>
		<itemData name="Whitespace"  defStyleNum="dsNormal"/>
		<itemData name="Key"         defStyleNum="dsDataType"/>
		<itemData name="TableHeader" defStyleNum="dsKeyword"/>
		<itemData name="Assignment"  defStyleNum="dsOperator"/>
		<itemData name="Comment"     defStyleNum="dsComment"/>
		
		<itemData name="Date"        defStyleNum="dsBaseN"/>
		<itemData name="Float"       defStyleNum="dsFloat"/>
		<itemData name="Int"         defStyleNum="dsDecVal"/>
		<itemData name="Bool"        defStyleNum="dsConstant"/>
		<itemData name="String"      defStyleNum="dsString"/>
		<itemData name="LitString"   defStyleNum="dsVerbatimString"/>
		<itemData name="Escape"      defStyleNum="dsSpecialChar"/>
		<itemData name="Array"       defStyleNum="dsOperator"/>
		<itemData name="InlineTable" defStyleNum="dsOperator"/>
		<itemData name="NextEntry"   defStyleNum="dsOperator"/>

		<itemData name="Error"       defStyleNum="dsError"/>
	</itemDatas>
</highlighting>
<general>
	<comments>
		<comment name="singleLine" start="#" position="afterwhitespace"/>
	</comments>
</general>
</language>
<!-- kate: replace-tabs off; indent-width 2 -->
