<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language [
  <!ENTITY regexpr_identifier "([\w_-]+)">
  <!ENTITY regexpr_variable "(@&regexpr_identifier;)">
  <!ENTITY anychar_operator ":,!/*-+=&gt;&lt;()&#x0025;">
  <!ENTITY regexpr_number "(\-?((\d+(\.\d+)?)|(\.\d+))&#x0025;?)">
  <!ENTITY regexpr_color "((#[\dabcdefABCDEF]{3}|#[\dabcdefABCDEF]{6})(?=(\W|$)))">
]>
<!-- Syntax highlighting definition for CartoCSS MSS, see https://github.com/mapbox/carto
     CartoCSS defines two file formats: MML (Map Markup Language) and MSS (Map Stylesheet).
     This file provides syntax highlighting for MSS. MSS is similar in syntax to CSS,
     but completly different in its semantics. -->
<language name="CartoCSS MSS"
          version="6"
		  kateversion="5.0"
		  section="Markup"
		  extensions="*.mss"
		  author="Lukas Sommer"
		  license="CC0 Public Domain Dedication, version 1.0, as published by Creative Commons">


	<highlighting>

		<list name="list_colornames">
            <!-- This list is based on https://github.com/mapbox/carto/blob/35773a5f519b1ded0d88b14d53ac875cd610bb8c/build/vim-carto/syntax/carto.vim#L53
                 and https://github.com/mapbox/carto/blob/35773a5f519b1ded0d88b14d53ac875cd610bb8c/build/carto.tmbundle/Syntaxes/carto.tmLanguage#L279
            -->
			<item>aliceblue</item>
			<item>antiquewhite</item>
			<item>aqua</item>
			<item>aquamarine</item>
			<item>azure</item>
			<item>beige</item>
			<item>bisque</item>
			<item>black</item>
			<item>blanchedalmond</item>
			<item>blue</item>
			<item>blueviolet</item>
			<item>brown</item>
			<item>burlywood</item>
			<item>cadetblue</item>
			<item>chartreuse</item>
			<item>chocolate</item>
			<item>coral</item>
			<item>cornflowerblue</item>
			<item>cornsilk</item>
			<item>crimson</item>
			<item>cyan</item>
			<item>darkblue</item>
			<item>darkcyan</item>
			<item>darkgoldenrod</item>
			<item>darkgray</item>
			<item>darkgreen</item>
			<item>darkgrey</item>
			<item>darkkhaki</item>
			<item>darkmagenta</item>
			<item>darkolivegreen</item>
			<item>darkorange</item>
			<item>darkorchid</item>
			<item>darkred</item>
			<item>darksalmon</item>
			<item>darkseagreen</item>
			<item>darkslateblue</item>
			<item>darkslategrey</item>
			<item>darkturquoise</item>
			<item>darkviolet</item>
			<item>deeppink</item>
			<item>deepskyblue</item>
			<item>dimgray</item>
			<item>dimgrey</item>
			<item>dodgerblue</item>
			<item>firebrick</item>
			<item>floralwhite</item>
			<item>forestgreen</item>
			<item>fuchsia</item>
			<item>gainsboro</item>
			<item>ghostwhite</item>
			<item>gold</item>
			<item>goldenrod</item>
			<item>gray</item>
			<item>grey</item>
			<item>green</item>
			<item>greenyellow</item>
			<item>honeydew</item>
			<item>hotpink</item>
			<item>indianred</item>
			<item>indigo</item>
			<item>ivory</item>
			<item>khaki</item>
			<item>lavender</item>
			<item>lavenderblush</item>
			<item>lawngreen</item>
			<item>lemonchiffon</item>
			<item>lightblue</item>
			<item>lightcoral</item>
			<item>lightcyan</item>
			<item>lightgoldenrodyellow</item>
			<item>lightgray</item>
			<item>lightgreen</item>
			<item>lightgrey</item>
			<item>lightpink</item>
			<item>lightsalmon</item>
			<item>lightseagreen</item>
			<item>lightskyblue</item>
			<item>lightslategray</item>
			<item>lightslategrey</item>
			<item>lightsteelblue</item>
			<item>lightyellow</item>
			<item>lime</item>
			<item>limegreen</item>
			<item>linen</item>
			<item>magenta</item>
			<item>maroon</item>
			<item>mediumaquamarine</item>
			<item>mediumblue</item>
			<item>mediumorchid</item>
			<item>mediumpurple</item>
			<item>mediumseagreen</item>
			<item>mediumslateblue</item>
			<item>mediumspringgreen</item>
			<item>mediumturquoise</item>
			<item>mediumvioletred</item>
			<item>midnightblue</item>
			<item>mintcream</item>
			<item>mistyrose</item>
			<item>moccasin</item>
			<item>navajowhite</item>
			<item>navy</item>
			<item>oldlace</item>
			<item>olive</item>
			<item>olivedrab</item>
			<item>orange</item>
			<item>orangered</item>
			<item>orchid</item>
			<item>palegoldenrod</item>
			<item>palegreen</item>
			<item>paleturquoise</item>
			<item>palevioletred</item>
			<item>papayawhip</item>
			<item>peachpuff</item>
			<item>peru</item>
			<item>pink</item>
			<item>plum</item>
			<item>powderblue</item>
			<item>purple</item>
			<item>red</item>
			<item>rosybrown</item>
			<item>royalblue</item>
			<item>saddlebrown</item>
			<item>salmon</item>
			<item>sandybrown</item>
			<item>seagreen</item>
			<item>seashell</item>
			<item>sienna</item>
			<item>silver</item>
			<item>skyblue</item>
			<item>slateblue</item>
			<item>slategray</item>
			<item>slategrey</item>
			<item>snow</item>
			<item>springgreen</item>
			<item>steelblue</item>
			<item>tan</item>
			<item>teal</item>
			<item>thistle</item>
			<item>tomato</item>
			<item>turquoise</item>
			<item>violet</item>
			<item>wheat</item>
			<item>white</item>
			<item>whitesmoke</item>
			<item>yellow</item>
			<item>yellowgreen</item>
			<item>transparent</item>
		</list>

		<contexts>

			<context attribute="Mapnik Symbolizer Parameter" lineEndContext="#stay" name="context_default">
				<DetectSpaces/>
				<Detect2Chars attribute="Comment" context="context_comment_multiline" char="/" char1="*" lookAhead="true" beginRegion="region_comment"/>
				<Detect2Chars attribute="Comment" context="context_comment_singleline" char="/" char1="/" lookAhead="true"/>
				<DetectChar attribute="Operator" char="{" beginRegion="region_braces"/>
				<DetectChar attribute="Operator" char="}" endRegion="region_braces"/>
				<DetectChar attribute="Operator" char="[" context="context_filter_attribute"/> <!-- This rule must be _before_ the “Operator” rule to make sure it is working. -->
				<RegExpr attribute="Attachment" String="::&regexpr_identifier;"/> <!-- This rule must be _before_ the “Operator” rule to make sure it is working. -->
				<DetectChar attribute="Operator" char=":" context="context_expression"/>
				<RegExpr attribute="CartoCSS Variable" String="&regexpr_variable;"/>
				<RegExpr attribute="Named instances" String="&regexpr_identifier;/"/>
				<RegExpr attribute="Layer ID" String="#&regexpr_identifier;"/>
				<RegExpr attribute="Class" String="\.&regexpr_identifier;"/>
			</context>

			<context attribute="Keyword" lineEndContext="#stay" name="context_expression">
				<DetectSpaces/>
				<RangeDetect char="[" char1="]" attribute="Data Field"/> <!-- This rule must be _before_ the “Operator” rule to make sure it is working. -->
				<RegExpr attribute="Number" String="&regexpr_number;"/> <!-- This rule must be _before_ the “Operator” rule to make sure it is working. -->
				<AnyChar attribute="Operator" String="&anychar_operator;[]"/>
				<RegExpr attribute="CartoCSS Variable" String="&regexpr_variable;"/>
				<RegExpr attribute="Function" String="&regexpr_identifier;(?=\()"/>
				<RegExpr attribute="Color" String="&regexpr_color;"/>
				<keyword attribute="Color" context="#stay" String="list_colornames"/>
				<!-- The strings that might appear hear (both single-quoted and double-quoted strings)
				 are either normal strings or expression strings: If they are the only content
				 (like in “test: "mystring";”) than they are expression strings. If there is other
				 content (like in “test: "mystring" + [myfield];” or “test: [myfield] + "mystring";”),
				 than they are normal strings. This is however difficult to detect, therefore we default
				 simply to expression strings.-->
				<DetectChar attribute="Expression String" char="&quot;" context="context_expressionstring_doublequote"/>
				<DetectChar attribute="Expression String" char="'" context="context_expressionstring_singlequote"/>
				<!-- An expression ends with a semicolon “;”. However, the
				CartoCSS parser allows to omit the semicolon at the end
				of a block of curly braces “{}”. Therefore, we also
				have to detect the closing curly braces “}” here: -->
				<DetectChar attribute="Operator" char=";" context="#pop"/>
				<DetectChar attribute="Operator" char="}" endRegion="region_braces" context="#pop"/>
			</context>

			<context attribute="Data Field" lineEndContext="#stay" name="context_filter_attribute">
				<DetectSpaces/>
				<RegExpr attribute="CartoCSS Variable" String="&regexpr_variable;"/>
				<AnyChar attribute="Operator" String="&anychar_operator;" context="context_filter_rule"/>
				<WordDetect String="zoom" insensitive="true" attribute="Keyword"/>
				<DetectChar attribute="Data Field" char="&quot;" context="context_filter_attribute_doublequote"/>
				<DetectChar attribute="Data Field" char="'" context="context_filter_attribute_singlequote"/>
				<DetectChar attribute="Operator" char="]" context="#pop"/>
			</context>

			<context attribute="Data Field" lineEndContext="#pop" name="context_filter_attribute_doublequote">
				<DetectChar char="&quot;" context="#pop"/>
			</context>

			<context attribute="Data Field" lineEndContext="#pop" name="context_filter_attribute_singlequote">
				<DetectChar char="'" context="#pop"/>
			</context>

			<context attribute="Keyword" lineEndContext="#stay" name="context_filter_rule">
				<DetectSpaces/>
				<RegExpr attribute="Number" String="&regexpr_number;"/> <!-- This rule must be _before_ the “Operator” rule to make sure it is working. -->
				<AnyChar attribute="Operator" String="&anychar_operator;"/>
				<RegExpr attribute="CartoCSS Variable" String="&regexpr_variable;"/>
				<WordDetect String="zoom" insensitive="true" attribute="Keyword"/>
				<RegExpr attribute="Function" String="&regexpr_identifier;(?=\()"/>
				<RegExpr attribute="Color" String="&regexpr_color;"/>
				<keyword attribute="Color" context="#stay" String="list_colornames"/>
				<DetectChar attribute="Normal String" char="&quot;" context="context_normalstring_doublequote"/>
				<DetectChar attribute="Normal String" char="'" context="context_normalstring_singlequote"/>
				<DetectChar attribute="Operator" char="]" context="#pop#pop"/>
			</context>

			<context attribute="Comment" lineEndContext="#stay" name="context_comment_multiline">
				<Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" endRegion="region_comment"/>
				<IncludeRules context="##Comments"/>
			</context>

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

			<context attribute="Expression String" lineEndContext="#pop" name="context_expressionstring_doublequote">
				<DetectChar attribute="Expression String" char="&quot;" context="#pop"/>
				<RangeDetect char="[" char1="]" attribute="Data Field"/>
				<RegExpr attribute="Mapnik Render-Time Variable" String="&regexpr_variable;"/>
				<DetectChar attribute="Normal String" char="'" context="context_normalstring_singlequote"/>
			</context>

			<context attribute="Expression String" lineEndContext="#pop" name="context_expressionstring_singlequote">
				<DetectChar attribute="Expression String" char="'" context="#pop"/>
				<RangeDetect char="[" char1="]" attribute="Data Field"/>
				<RegExpr attribute="Mapnik Render-Time Variable" String="&regexpr_variable;"/>
				<DetectChar attribute="Normal String" char="&quot;" context="context_normalstring_doublequote"/>
			</context>

			<context attribute="Normal String" lineEndContext="#pop" name="context_include_escape_characters">
				<!-- Helper context. Can be included in other contexts to detect escape characters. -->
				<RegExpr attribute="Escape Sequenze" String="(\\[abfnrtv&quot;'\\])|(\\u[0-9a-fA-F]{4})|(\\U[0-9a-fA-F]{8})"/>
				<RegExpr attribute="Error" String="\\[uU]"/>
			</context>

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

			<context attribute="Normal String" lineEndContext="#pop" name="context_normalstring_singlequote">
				<DetectChar attribute="Normal String" char="'" context="#pop"/>
				<IncludeRules context="context_include_escape_characters"/>
			</context>

		</contexts>

		<itemDatas>
			<itemData name="Class"                       defStyleNum="dsNormal"        spellChecking="false"/>
			<itemData name="Layer ID"                    defStyleNum="dsNormal"        spellChecking="false"/>
			<itemData name="Attachment"                  defStyleNum="dsControlFlow"   spellChecking="false"/>
			<itemData name="Named instances"             defStyleNum="dsDataType"      spellChecking="false"/>
			<itemData name="Mapnik Symbolizer Parameter" defStyleNum="dsNormal"        spellChecking="false"/>
			<itemData name="Operator"                    defStyleNum="dsOperator"      spellChecking="false"/>
			<itemData name="Keyword"                     defStyleNum="dsKeyword"       spellChecking="false"/>
			<itemData name="Function"                    defStyleNum="dsFunction"      spellChecking="false"/>
			<itemData name="Number"                      defStyleNum="dsFloat"         spellChecking="false"/>
			<itemData name="Color"                       defStyleNum="dsConstant"      spellChecking="false"/>
			<itemData name="Expression String"           defStyleNum="dsSpecialString" spellChecking="false"/>
			<!-- “Mapnik Render-Time Variable” work completly different from “CartoCSS Variable” and
			     has therefore a completly different color. -->
			<itemData name="Mapnik Render-Time Variable" defStyleNum="dsSpecialChar"   spellChecking="false"/>
			<itemData name="Normal String"               defStyleNum="dsString"        spellChecking="false"/>
			<itemData name="Escape Sequenze"             defStyleNum="dsSpecialChar"   spellChecking="false"/>
			<itemData name="Data Field"                  defStyleNum="dsVariable"      spellChecking="false"/>
			<!-- “CartoCSS Variable”, inspite of its name, uses “dsPreprocessor” as default color.
			     This is appropriate because it actually behaves rather like a preprocessor: It is even
			     possible to define strings, and if escape sequences like “\n” are treated as such
			     is decided later, depending on the position of the actual usage of the variable. -->
			<itemData name="CartoCSS Variable"           defStyleNum="dsPreprocessor"  spellChecking="false"/>
			<itemData name="Comment"                     defStyleNum="dsComment"       spellChecking="true" />
			<itemData name="Error"                       defStyleNum="dsError"         spellChecking="false"/>
		</itemDatas>

	</highlighting>

	<general>
		<comments>
			<comment name="singleLine" start="//" position="afterwhitespace"/>
			<comment name="multiLine" start="/*" end="*/" region="region_comment"/>
		</comments>
		<keywords casesensitive="true" weakDeliminator="-"/>
	</general>
</language>
<!-- kate: replace-tabs off; -->
