<?xml version="1.0"?>
<syntax name="language-root.regex">
	<!--
	This Sugar provides a handle you can tie into to include regex syntax zones within your own Sugars.
	
	For instance:
		<include syntax="language-root.regex" />
	-->
	<zones>
		<include collection="constants" />
		<include collection="operators" />
		<zone name="character-class">
			<starts-with>
				<expression>(\[)(\^?)</expression>
				<capture number="1" name="punctuation.definition.begin"/>
				<capture number="2" name="operator"/>
			</starts-with>
			<ends-with>
				<expression>\]</expression>
				<capture number="0" name="punctuation.definition.end"/>
			</ends-with>
			<subzones>
				<include collection="constants" />
				<zone name="operator">
					<expression>(?&lt;!\[)-(?!\])</expression>
				</zone>
			</subzones>
		</zone>
		<zone name="group.noncapturing.lookaround">
			<starts-with>
				<expression>\(\?(?:!|=|&lt;=|&lt;!)</expression>
				<capture number="0" name="punctuation.definition.begin"/>
			</starts-with>
			<ends-with>
				<expression>\)</expression>
				<capture number="0" name="punctuation.definition.end"/>
			</ends-with>
			<subzones>
				<include syntax="self" />
			</subzones>
		</zone>
		<zone name="group.noncapturing">
			<starts-with>
				<expression>\(\?(?:>|:|([ismx-]+):)</expression>
				<capture number="0" name="punctuation.definition.begin"/>
				<capture number="1" name="options"/>
			</starts-with>
			<ends-with>
				<expression>\)</expression>
				<capture number="0" name="punctuation.definition.end"/>
			</ends-with>
			<subzones>
				<include syntax="self" />
			</subzones>
		</zone>
		<zone name="group.noncapturing.option-toggle">
			<expression>(\(\?)([ismx-]+)(\))</expression>
			<capture number="1" name="punctuation.definition.begin"/>
			<capture number="2" name="options"/>
			<capture number="3" name="punctuation.definition.end"/>
		</zone>
		<zone name="comment">
			<starts-with>
				<expression>\(\?#</expression>
				<capture number="0" name="punctuation.definition.begin"/>
			</starts-with>
			<ends-with>
				<expression>\)</expression>
				<capture number="0" name="punctuation.definition.end"/>
			</ends-with>
		</zone>
		<zone name="group">
			<starts-with>
				<expression>\(</expression>
				<capture number="0" name="punctuation.definition.begin"/>
			</starts-with>
			<ends-with>
				<expression>\)</expression>
				<capture number="0" name="punctuation.definition.end"/>
			</ends-with>
			<subzones>
				<include syntax="self" />
			</subzones>
		</zone>
	</zones>
	
	<library>
		<collection name="constants">
			<zone>
				<expression>(\\[AzZbBGdDwWsSnrtfvae])|(\\(?:x\h{2}|x\{\h{1,4}\}|u\h{2,4}|c[a-zA-Z]))|(\\[1-9]\d*)|((\\Q).+?(\\E))|(\\.)</expression>
				<capture number="1" name="constant.shorthand"/>
				<capture number="2" name="constant.character.code"/>
				<capture number="3" name="constant.back-reference"/>
				<capture number="4" name="literals.sequence"/>
				<capture number="5" name="constant.definition.begin"/>
				<capture number="6" name="constant.definition.end"/>
				<capture number="7" name="constant.character.escape"/>
			</zone>
		</collection>
		
		<collection name="operators">
			<zone name="operator">
				<expression>[.^$|?*+]|\{(?:\d*?,?\d+|\d+,)\}</expression>
			</zone>
		</collection>
	</library>
</syntax>