<?xml version="1.0" encoding="UTF-8"?>
<language id="inform7" name="Inform 7" version="2.0" _section="Others">
	<metadata>
		<!-- this could be text/plain but unfortunately GTE likes to autodetect normal text
		     documents as Inform 7 and that's annoying. -->
		<property name="mimetypes">text/inform7</property>
		<property name="globs">*.i7</property>
	</metadata>

	<styles>
		<style id="comment" 					name="Comment" 					map-to="def:comment"/>
		<style id="string" 					name="String" 						map-to="def:string"/>
		<style id="string2"					name="String2" 					map-to="def:string"/>
		<style id="literal" 					name="Literal" 					map-to="def:integer"/>
		<style id="text-substitution" name="Text Substitution" map-to="def:inline-code"/>
		<style id="section" 					name="Section" 					map-to="def:heading"/>
		<style id="table" 						name="Table" 						map-to="def:emphasis"/>
		<style id="logic-keyword" 		name="Logic Keyword" 		map-to="def:keyword"/>
		<style id="rules-keyword" 		name="Rules Keyword" 		map-to="def:special-char"/>
		<style id="other-keyword" 		name="Other Keyword" 		map-to="def:function"/>
	</styles>

	<definitions>

	<context id="inform7">
	<include>

		<context id="literal" style-ref="literal">
			<match>[0-9]</match>
		</context>

		<context id="string" style-ref="string">
			<start>"</start>
			<end>"</end>
			<include>
				<context id="text-substitution" style-ref="text-substitution">
					<start>\[</start>
					<end>\]</end>
				</context>
			</include>
		</context>

		<context id="comment" style-ref="comment">
			<start>\[</start>
			<end>\]</end>
			<include>
				<!-- Inform 7 lets you nest comments [like [so]] -->
				<context ref="comment"/>
			</include>
		</context>

		<context id="section" style-ref="section" end-at-line-end="true">
			<start>Section</start>
		</context>

		<context id="table" style-ref="table" end-at-line-end="true">
			<start>Table</start>
		</context>

		<context id="logic-keyword" style-ref="logic-keyword">
			<keyword>if</keyword>
			<keyword>else</keyword>
			<keyword>otherwise</keyword>
			<keyword>(U|u)nless</keyword>
		</context>
		
		<context id="rules-keyword" style-ref="rules-keyword">
			<!--TODO figure out how to make these case insensitive-->
			<keyword>Instead of</keyword>
			<keyword>Before</keyword>
			<keyword>Check</keyword>
			<keyword>Carry out</keyword>
			<keyword>After</keyword>
			<keyword>Report</keyword>
			<keyword>Definition</keyword>
			<!-- these ones are broken? -->
			<keyword>To (.*)(:|,)</keyword>
			<keyword>Rule (.*):</keyword>
			<keyword>Every turn (.*)(:|,)</keyword>
		</context>
		
		<context id="other-keyword" style-ref="other-keyword">
			<keyword>now</keyword>
			<keyword>let</keyword>
			<keyword>repeat</keyword>
			<keyword>try</keyword>
			<keyword>instead</keyword>
			<keyword>increment</keyword>
			<keyword>decrement</keyword>
			<keyword>increase</keyword>
			<keyword>decrease</keyword>
			<keyword>decide</keyword>
			<keyword>continue the action</keyword>
			<keyword>stop the action</keyword>
		</context>
		
		</include>
		</context>
	</definitions>
</language>
