mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-10 05:22:23 +00:00
318 lines
9.1 KiB
XML
318 lines
9.1 KiB
XML
<lexer>
|
|
<config>
|
|
<name>ANTLR</name>
|
|
<alias>antlr</alias>
|
|
</config>
|
|
<rules>
|
|
<state name="nested-arg-action">
|
|
<rule pattern="([^$\[\]\'"/]+|"(\\\\|\\"|[^"])*"|'(\\\\|\\'|[^'])*'|//.*$\n?|/\*(.|\n)*?\*/|/(?!\*)(\\\\|\\/|[^/])*/|/)+">
|
|
<token type="Other"/>
|
|
</rule>
|
|
<rule pattern="\[">
|
|
<token type="Punctuation"/>
|
|
<push/>
|
|
</rule>
|
|
<rule pattern="\]">
|
|
<token type="Punctuation"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule pattern="(\$[a-zA-Z]+)(\.?)(text|value)?">
|
|
<bygroups>
|
|
<token type="NameVariable"/>
|
|
<token type="Punctuation"/>
|
|
<token type="NameProperty"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="(\\\\|\\\]|\\\[|[^\[\]])+">
|
|
<token type="Other"/>
|
|
</rule>
|
|
</state>
|
|
<state name="exception">
|
|
<rule pattern="\n">
|
|
<token type="TextWhitespace"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
<rule pattern="\s">
|
|
<token type="TextWhitespace"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="comments"/>
|
|
</rule>
|
|
<rule pattern="\[">
|
|
<token type="Punctuation"/>
|
|
<push state="nested-arg-action"/>
|
|
</rule>
|
|
<rule pattern="\{">
|
|
<token type="Punctuation"/>
|
|
<push state="action"/>
|
|
</rule>
|
|
</state>
|
|
<state name="whitespace">
|
|
<rule pattern="\s+">
|
|
<token type="TextWhitespace"/>
|
|
</rule>
|
|
</state>
|
|
<state name="root">
|
|
<rule>
|
|
<include state="whitespace"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="comments"/>
|
|
</rule>
|
|
<rule pattern="(lexer|parser|tree)?(\s*)(grammar\b)(\s*)([A-Za-z]\w*)(;)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="Keyword"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="NameClass"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="options\b">
|
|
<token type="Keyword"/>
|
|
<push state="options"/>
|
|
</rule>
|
|
<rule pattern="tokens\b">
|
|
<token type="Keyword"/>
|
|
<push state="tokens"/>
|
|
</rule>
|
|
<rule pattern="(scope)(\s*)([A-Za-z]\w*)(\s*)(\{)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="NameVariable"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
<push state="action"/>
|
|
</rule>
|
|
<rule pattern="(catch|finally)\b">
|
|
<token type="Keyword"/>
|
|
<push state="exception"/>
|
|
</rule>
|
|
<rule pattern="(@[A-Za-z]\w*)(\s*)(::)?(\s*)([A-Za-z]\w*)(\s*)(\{)">
|
|
<bygroups>
|
|
<token type="NameLabel"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="Punctuation"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="NameLabel"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
<push state="action"/>
|
|
</rule>
|
|
<rule pattern="((?:protected|private|public|fragment)\b)?(\s*)([A-Za-z]\w*)(!)?">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="NameLabel"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
<push state="rule-alts" state="rule-prelims"/>
|
|
</rule>
|
|
</state>
|
|
<state name="tokens">
|
|
<rule>
|
|
<include state="whitespace"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="comments"/>
|
|
</rule>
|
|
<rule pattern="\{">
|
|
<token type="Punctuation"/>
|
|
</rule>
|
|
<rule pattern="([A-Z]\w*)(\s*)(=)?(\s*)(\'(?:\\\\|\\\'|[^\']*)\')?(\s*)(;)">
|
|
<bygroups>
|
|
<token type="NameLabel"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="Punctuation"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="LiteralString"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="\}">
|
|
<token type="Punctuation"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
</state>
|
|
<state name="options">
|
|
<rule>
|
|
<include state="whitespace"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="comments"/>
|
|
</rule>
|
|
<rule pattern="\{">
|
|
<token type="Punctuation"/>
|
|
</rule>
|
|
<rule pattern="([A-Za-z]\w*)(\s*)(=)(\s*)([A-Za-z]\w*|\'(?:\\\\|\\\'|[^\']*)\'|[0-9]+|\*)(\s*)(;)">
|
|
<bygroups>
|
|
<token type="NameVariable"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="Punctuation"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="Text"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="\}">
|
|
<token type="Punctuation"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
</state>
|
|
<state name="rule-alts">
|
|
<rule>
|
|
<include state="whitespace"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="comments"/>
|
|
</rule>
|
|
<rule pattern="options\b">
|
|
<token type="Keyword"/>
|
|
<push state="options"/>
|
|
</rule>
|
|
<rule pattern=":">
|
|
<token type="Punctuation"/>
|
|
</rule>
|
|
<rule pattern="'(\\\\|\\'|[^'])*'">
|
|
<token type="LiteralString"/>
|
|
</rule>
|
|
<rule pattern=""(\\\\|\\"|[^"])*"">
|
|
<token type="LiteralString"/>
|
|
</rule>
|
|
<rule pattern="<<([^>]|>[^>])>>">
|
|
<token type="LiteralString"/>
|
|
</rule>
|
|
<rule pattern="\$?[A-Z_]\w*">
|
|
<token type="NameConstant"/>
|
|
</rule>
|
|
<rule pattern="\$?[a-z_]\w*">
|
|
<token type="NameVariable"/>
|
|
</rule>
|
|
<rule pattern="(\+|\||->|=>|=|\(|\)|\.\.|\.|\?|\*|\^|!|\#|~)">
|
|
<token type="Operator"/>
|
|
</rule>
|
|
<rule pattern=",">
|
|
<token type="Punctuation"/>
|
|
</rule>
|
|
<rule pattern="\[">
|
|
<token type="Punctuation"/>
|
|
<push state="nested-arg-action"/>
|
|
</rule>
|
|
<rule pattern="\{">
|
|
<token type="Punctuation"/>
|
|
<push state="action"/>
|
|
</rule>
|
|
<rule pattern=";">
|
|
<token type="Punctuation"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
</state>
|
|
<state name="rule-prelims">
|
|
<rule>
|
|
<include state="whitespace"/>
|
|
</rule>
|
|
<rule>
|
|
<include state="comments"/>
|
|
</rule>
|
|
<rule pattern="returns\b">
|
|
<token type="Keyword"/>
|
|
</rule>
|
|
<rule pattern="\[">
|
|
<token type="Punctuation"/>
|
|
<push state="nested-arg-action"/>
|
|
</rule>
|
|
<rule pattern="\{">
|
|
<token type="Punctuation"/>
|
|
<push state="action"/>
|
|
</rule>
|
|
<rule pattern="(throws)(\s+)([A-Za-z]\w*)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="NameLabel"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="(,)(\s*)([A-Za-z]\w*)">
|
|
<bygroups>
|
|
<token type="Punctuation"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="NameLabel"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="options\b">
|
|
<token type="Keyword"/>
|
|
<push state="options"/>
|
|
</rule>
|
|
<rule pattern="(scope)(\s+)(\{)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
<push state="action"/>
|
|
</rule>
|
|
<rule pattern="(scope)(\s+)([A-Za-z]\w*)(\s*)(;)">
|
|
<bygroups>
|
|
<token type="Keyword"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="NameLabel"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="(@[A-Za-z]\w*)(\s*)(\{)">
|
|
<bygroups>
|
|
<token type="NameLabel"/>
|
|
<token type="TextWhitespace"/>
|
|
<token type="Punctuation"/>
|
|
</bygroups>
|
|
<push state="action"/>
|
|
</rule>
|
|
<rule pattern=":">
|
|
<token type="Punctuation"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
</state>
|
|
<state name="action">
|
|
<rule pattern="([^${}\'"/\\]+|"(\\\\|\\"|[^"])*"|'(\\\\|\\'|[^'])*'|//.*$\n?|/\*(.|\n)*?\*/|/(?!\*)(\\\\|\\/|[^/])*/|\\(?!%)|/)+">
|
|
<token type="Other"/>
|
|
</rule>
|
|
<rule pattern="(\\)(%)">
|
|
<bygroups>
|
|
<token type="Punctuation"/>
|
|
<token type="Other"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="(\$[a-zA-Z]+)(\.?)(text|value)?">
|
|
<bygroups>
|
|
<token type="NameVariable"/>
|
|
<token type="Punctuation"/>
|
|
<token type="NameProperty"/>
|
|
</bygroups>
|
|
</rule>
|
|
<rule pattern="\{">
|
|
<token type="Punctuation"/>
|
|
<push/>
|
|
</rule>
|
|
<rule pattern="\}">
|
|
<token type="Punctuation"/>
|
|
<pop depth="1"/>
|
|
</rule>
|
|
</state>
|
|
<state name="comments">
|
|
<rule pattern="//.*$">
|
|
<token type="Comment"/>
|
|
</rule>
|
|
<rule pattern="/\*(.|\n)*?\*/">
|
|
<token type="Comment"/>
|
|
</rule>
|
|
</state>
|
|
</rules>
|
|
</lexer>
|