tartrazine/lexers/standard_ml.xml

548 lines
16 KiB
XML

<lexer>
<config>
<name>Standard ML</name>
<alias>sml</alias>
<filename>*.sml</filename>
<filename>*.sig</filename>
<filename>*.fun</filename>
<mime_type>text/x-standardml</mime_type>
<mime_type>application/x-standardml</mime_type>
</config>
<rules>
<state name="delimiters">
<rule pattern="\(|\[|\{">
<token type="Punctuation"/>
<push state="main"/>
</rule>
<rule pattern="\)|\]|\}">
<token type="Punctuation"/>
<pop depth="1"/>
</rule>
<rule pattern="\b(let|if|local)\b(?!\&#39;)">
<token type="KeywordReserved"/>
<push state="main" state="main"/>
</rule>
<rule pattern="\b(struct|sig|while)\b(?!\&#39;)">
<token type="KeywordReserved"/>
<push state="main"/>
</rule>
<rule pattern="\b(do|else|end|in|then)\b(?!\&#39;)">
<token type="KeywordReserved"/>
<pop depth="1"/>
</rule>
</state>
<state name="root">
<rule>
<push state="main"/>
</rule>
</state>
<state name="breakout">
<rule pattern="(?=\b(where|do|handle|if|sig|op|while|case|as|else|signature|andalso|struct|infixr|functor|in|structure|then|local|rec|end|fun|of|orelse|val|include|fn|with|exception|let|and|infix|sharing|datatype|type|abstype|withtype|eqtype|nonfix|raise|open)\b(?!\&#39;))">
<token type="Text"/>
<pop depth="1"/>
</rule>
</state>
<state name="tyvarseq">
<rule pattern="\s">
<token type="Text"/>
</rule>
<rule pattern="\(\*">
<token type="CommentMultiline"/>
<push state="comment"/>
</rule>
<rule pattern="\&#39;[\w\&#39;]*">
<token type="NameDecorator"/>
</rule>
<rule pattern="[a-zA-Z][\w&#39;]*">
<token type="Name"/>
</rule>
<rule pattern=",">
<token type="Punctuation"/>
</rule>
<rule pattern="\)">
<token type="Punctuation"/>
<pop depth="1"/>
</rule>
<rule pattern="[!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+">
<token type="Name"/>
</rule>
</state>
<state name="char">
<rule pattern="[^&#34;\\]">
<token type="LiteralStringChar"/>
</rule>
<rule pattern="\\[\\&#34;abtnvfr]">
<token type="LiteralStringEscape"/>
</rule>
<rule pattern="\\\^[\x40-\x5e]">
<token type="LiteralStringEscape"/>
</rule>
<rule pattern="\\[0-9]{3}">
<token type="LiteralStringEscape"/>
</rule>
<rule pattern="\\u[0-9a-fA-F]{4}">
<token type="LiteralStringEscape"/>
</rule>
<rule pattern="\\\s+\\">
<token type="LiteralStringInterpol"/>
</rule>
<rule pattern="&#34;">
<token type="LiteralStringChar"/>
<pop depth="1"/>
</rule>
</state>
<state name="datbind">
<rule>
<include state="whitespace"/>
</rule>
<rule pattern="\b(and)\b(?!\&#39;)">
<token type="KeywordReserved"/>
<push state="#pop" state="dname"/>
</rule>
<rule pattern="\b(withtype)\b(?!\&#39;)">
<token type="KeywordReserved"/>
<push state="#pop" state="tname"/>
</rule>
<rule pattern="\b(of)\b(?!\&#39;)">
<token type="KeywordReserved"/>
</rule>
<rule pattern="(\|)(\s*)([a-zA-Z][\w&#39;]*)">
<bygroups>
<token type="Punctuation"/>
<token type="Text"/>
<token type="NameClass"/>
</bygroups>
</rule>
<rule pattern="(\|)(\s+)([!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+)">
<bygroups>
<token type="Punctuation"/>
<token type="Text"/>
<token type="NameClass"/>
</bygroups>
</rule>
<rule>
<include state="breakout"/>
</rule>
<rule>
<include state="core"/>
</rule>
<rule pattern="\S+">
<token type="Error"/>
</rule>
</state>
<state name="string">
<rule pattern="[^&#34;\\]">
<token type="LiteralStringDouble"/>
</rule>
<rule pattern="\\[\\&#34;abtnvfr]">
<token type="LiteralStringEscape"/>
</rule>
<rule pattern="\\\^[\x40-\x5e]">
<token type="LiteralStringEscape"/>
</rule>
<rule pattern="\\[0-9]{3}">
<token type="LiteralStringEscape"/>
</rule>
<rule pattern="\\u[0-9a-fA-F]{4}">
<token type="LiteralStringEscape"/>
</rule>
<rule pattern="\\\s+\\">
<token type="LiteralStringInterpol"/>
</rule>
<rule pattern="&#34;">
<token type="LiteralStringDouble"/>
<pop depth="1"/>
</rule>
</state>
<state name="tname">
<rule>
<include state="whitespace"/>
</rule>
<rule>
<include state="breakout"/>
</rule>
<rule pattern="\&#39;[\w\&#39;]*">
<token type="NameDecorator"/>
</rule>
<rule pattern="\(">
<token type="Punctuation"/>
<push state="tyvarseq"/>
</rule>
<rule pattern="=(?![!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+)">
<token type="Punctuation"/>
<push state="#pop" state="typbind"/>
</rule>
<rule pattern="([a-zA-Z][\w&#39;]*)">
<token type="KeywordType"/>
</rule>
<rule pattern="([!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+)">
<token type="KeywordType"/>
</rule>
<rule pattern="\S+">
<token type="Error"/>
<pop depth="1"/>
</rule>
</state>
<state name="dname">
<rule>
<include state="whitespace"/>
</rule>
<rule>
<include state="breakout"/>
</rule>
<rule pattern="\&#39;[\w\&#39;]*">
<token type="NameDecorator"/>
</rule>
<rule pattern="\(">
<token type="Punctuation"/>
<push state="tyvarseq"/>
</rule>
<rule pattern="(=)(\s*)(datatype)">
<bygroups>
<token type="Punctuation"/>
<token type="Text"/>
<token type="KeywordReserved"/>
</bygroups>
<pop depth="1"/>
</rule>
<rule pattern="=(?![!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+)">
<token type="Punctuation"/>
<push state="#pop" state="datbind" state="datcon"/>
</rule>
<rule pattern="([a-zA-Z][\w&#39;]*)">
<token type="KeywordType"/>
</rule>
<rule pattern="([!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+)">
<token type="KeywordType"/>
</rule>
<rule pattern="\S+">
<token type="Error"/>
<pop depth="1"/>
</rule>
</state>
<state name="typbind">
<rule>
<include state="whitespace"/>
</rule>
<rule pattern="\b(and)\b(?!\&#39;)">
<token type="KeywordReserved"/>
<push state="#pop" state="tname"/>
</rule>
<rule>
<include state="breakout"/>
</rule>
<rule>
<include state="core"/>
</rule>
<rule pattern="\S+">
<token type="Error"/>
<pop depth="1"/>
</rule>
</state>
<state name="ename">
<rule>
<include state="whitespace"/>
</rule>
<rule pattern="(exception|and)\b(\s+)([a-zA-Z][\w&#39;]*)">
<bygroups>
<token type="KeywordReserved"/>
<token type="Text"/>
<token type="NameClass"/>
</bygroups>
</rule>
<rule pattern="(exception|and)\b(\s*)([!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+)">
<bygroups>
<token type="KeywordReserved"/>
<token type="Text"/>
<token type="NameClass"/>
</bygroups>
</rule>
<rule pattern="\b(of)\b(?!\&#39;)">
<token type="KeywordReserved"/>
</rule>
<rule>
<include state="breakout"/>
</rule>
<rule>
<include state="core"/>
</rule>
<rule pattern="\S+">
<token type="Error"/>
</rule>
</state>
<state name="vname">
<rule>
<include state="whitespace"/>
</rule>
<rule pattern="\&#39;[\w\&#39;]*">
<token type="NameDecorator"/>
</rule>
<rule pattern="\(">
<token type="Punctuation"/>
<push state="tyvarseq"/>
</rule>
<rule pattern="([a-zA-Z][\w&#39;]*)(\s*)(=(?![!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+))">
<bygroups>
<token type="NameVariable"/>
<token type="Text"/>
<token type="Punctuation"/>
</bygroups>
<pop depth="1"/>
</rule>
<rule pattern="([!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+)(\s*)(=(?![!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+))">
<bygroups>
<token type="NameVariable"/>
<token type="Text"/>
<token type="Punctuation"/>
</bygroups>
<pop depth="1"/>
</rule>
<rule pattern="([a-zA-Z][\w&#39;]*)">
<token type="NameVariable"/>
<pop depth="1"/>
</rule>
<rule pattern="([!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+)">
<token type="NameVariable"/>
<pop depth="1"/>
</rule>
<rule>
<pop depth="1"/>
</rule>
</state>
<state name="sname">
<rule>
<include state="whitespace"/>
</rule>
<rule>
<include state="breakout"/>
</rule>
<rule pattern="([a-zA-Z][\w&#39;]*)">
<token type="NameNamespace"/>
</rule>
<rule>
<pop depth="1"/>
</rule>
</state>
<state name="main-fun">
<rule>
<include state="whitespace"/>
</rule>
<rule pattern="\s">
<token type="Text"/>
</rule>
<rule pattern="\(\*">
<token type="CommentMultiline"/>
<push state="comment"/>
</rule>
<rule pattern="\b(fun|and)\b(?!\&#39;)">
<token type="KeywordReserved"/>
<push state="fname"/>
</rule>
<rule pattern="\b(val)\b(?!\&#39;)">
<token type="KeywordReserved"/>
<push state="#pop" state="main" state="vname"/>
</rule>
<rule pattern="\|">
<token type="Punctuation"/>
<push state="fname"/>
</rule>
<rule pattern="\b(case|handle)\b(?!\&#39;)">
<token type="KeywordReserved"/>
<push state="#pop" state="main"/>
</rule>
<rule>
<include state="delimiters"/>
</rule>
<rule>
<include state="core"/>
</rule>
<rule pattern="\S+">
<token type="Error"/>
</rule>
</state>
<state name="datcon">
<rule>
<include state="whitespace"/>
</rule>
<rule pattern="([a-zA-Z][\w&#39;]*)">
<token type="NameClass"/>
<pop depth="1"/>
</rule>
<rule pattern="([!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+)">
<token type="NameClass"/>
<pop depth="1"/>
</rule>
<rule pattern="\S+">
<token type="Error"/>
<pop depth="1"/>
</rule>
</state>
<state name="dotted">
<rule pattern="([a-zA-Z][\w&#39;]*)(\.)">
<token type="NameNamespace"/>
</rule>
<rule pattern="([a-zA-Z][\w&#39;]*)">
<token type="Name"/>
<pop depth="1"/>
</rule>
<rule pattern="([!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+)">
<token type="Name"/>
<pop depth="1"/>
</rule>
<rule pattern="\s+">
<token type="Error"/>
</rule>
<rule pattern="\S+">
<token type="Error"/>
</rule>
</state>
<state name="main">
<rule>
<include state="whitespace"/>
</rule>
<rule pattern="\b(val|and)\b(?!\&#39;)">
<token type="KeywordReserved"/>
<push state="vname"/>
</rule>
<rule pattern="\b(fun)\b(?!\&#39;)">
<token type="KeywordReserved"/>
<push state="#pop" state="main-fun" state="fname"/>
</rule>
<rule>
<include state="delimiters"/>
</rule>
<rule>
<include state="core"/>
</rule>
<rule pattern="\S+">
<token type="Error"/>
</rule>
</state>
<state name="comment">
<rule pattern="[^(*)]">
<token type="CommentMultiline"/>
</rule>
<rule pattern="\(\*">
<token type="CommentMultiline"/>
<push/>
</rule>
<rule pattern="\*\)">
<token type="CommentMultiline"/>
<pop depth="1"/>
</rule>
<rule pattern="[(*)]">
<token type="CommentMultiline"/>
</rule>
</state>
<state name="whitespace">
<rule pattern="\s+">
<token type="Text"/>
</rule>
<rule pattern="\(\*">
<token type="CommentMultiline"/>
<push state="comment"/>
</rule>
</state>
<state name="core">
<rule pattern="(_|\}|\{|\)|;|,|\[|\(|\]|\.\.\.)">
<token type="Punctuation"/>
</rule>
<rule pattern="#&#34;">
<token type="LiteralStringChar"/>
<push state="char"/>
</rule>
<rule pattern="&#34;">
<token type="LiteralStringDouble"/>
<push state="string"/>
</rule>
<rule pattern="~?0x[0-9a-fA-F]+">
<token type="LiteralNumberHex"/>
</rule>
<rule pattern="0wx[0-9a-fA-F]+">
<token type="LiteralNumberHex"/>
</rule>
<rule pattern="0w\d+">
<token type="LiteralNumberInteger"/>
</rule>
<rule pattern="~?\d+\.\d+[eE]~?\d+">
<token type="LiteralNumberFloat"/>
</rule>
<rule pattern="~?\d+\.\d+">
<token type="LiteralNumberFloat"/>
</rule>
<rule pattern="~?\d+[eE]~?\d+">
<token type="LiteralNumberFloat"/>
</rule>
<rule pattern="~?\d+">
<token type="LiteralNumberInteger"/>
</rule>
<rule pattern="#\s*[1-9][0-9]*">
<token type="NameLabel"/>
</rule>
<rule pattern="#\s*([a-zA-Z][\w&#39;]*)">
<token type="NameLabel"/>
</rule>
<rule pattern="#\s+([!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+)">
<token type="NameLabel"/>
</rule>
<rule pattern="\b(datatype|abstype)\b(?!\&#39;)">
<token type="KeywordReserved"/>
<push state="dname"/>
</rule>
<rule pattern="(?=\b(exception)\b(?!\&#39;))">
<token type="Text"/>
<push state="ename"/>
</rule>
<rule pattern="\b(functor|include|open|signature|structure)\b(?!\&#39;)">
<token type="KeywordReserved"/>
<push state="sname"/>
</rule>
<rule pattern="\b(type|eqtype)\b(?!\&#39;)">
<token type="KeywordReserved"/>
<push state="tname"/>
</rule>
<rule pattern="\&#39;[\w\&#39;]*">
<token type="NameDecorator"/>
</rule>
<rule pattern="([a-zA-Z][\w&#39;]*)(\.)">
<token type="NameNamespace"/>
<push state="dotted"/>
</rule>
<rule pattern="\b(abstype|and|andalso|as|case|datatype|do|else|end|exception|fn|fun|handle|if|in|infix|infixr|let|local|nonfix|of|op|open|orelse|raise|rec|then|type|val|with|withtype|while|eqtype|functor|include|sharing|sig|signature|struct|structure|where)\b">
<token type="KeywordReserved"/>
</rule>
<rule pattern="([a-zA-Z][\w&#39;]*)">
<token type="Name"/>
</rule>
<rule pattern="\b(:|\|,=|=&gt;|-&gt;|#|:&gt;)\b">
<token type="KeywordReserved"/>
</rule>
<rule pattern="([!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+)">
<token type="Name"/>
</rule>
</state>
<state name="fname">
<rule>
<include state="whitespace"/>
</rule>
<rule pattern="\&#39;[\w\&#39;]*">
<token type="NameDecorator"/>
</rule>
<rule pattern="\(">
<token type="Punctuation"/>
<push state="tyvarseq"/>
</rule>
<rule pattern="([a-zA-Z][\w&#39;]*)">
<token type="NameFunction"/>
<pop depth="1"/>
</rule>
<rule pattern="([!%&amp;$#+\-/:&lt;=&gt;?@\\~`^|*]+)">
<token type="NameFunction"/>
<pop depth="1"/>
</rule>
<rule>
<pop depth="1"/>
</rule>
</state>
</rules>
</lexer>