tartrazine/lexers/jsonata.xml

84 lines
2.7 KiB
XML
Raw Normal View History

2024-08-02 20:03:49 +00:00
<lexer>
<config>
<name>JSONata</name>
<alias>jsonata</alias>
<filename>*.jsonata</filename>
<dot_all>true</dot_all>
</config>
<rules>
<state name="root">
<rule pattern="/\*.*?\*/">
<token type="CommentMultiline"/>
</rule>
<rule pattern="[{}()\[\]:;,\.=]">
<token type="Punctuation"/>
</rule>
<rule pattern="\.\."> // Spread operator
<token type="Operator"/>
2024-08-26 23:18:28 +00:00
</rule>
2024-08-02 20:03:49 +00:00
<rule pattern="\^(?=\()"> // Sort operator
<token type="Operator"/>
</rule>
<rule pattern="\*\*|\*(?=\.)|\*"> // Descendant | Wildcard | Multiplication
<token type="Operator"/>
</rule>
<rule pattern="\/(?!\*)"> // Division
<token type="Operator"/>
</rule>
<rule pattern="[&lt;&gt;!]=?"> // Comparison operators
<token type="Operator"/>
</rule>
<rule pattern="~>">
<token type="Operator"/>
</rule>
<rule pattern="\b(and|or|in)\b">
<token type="Operator"/>
</rule>
<rule pattern="[%@#&amp;?]|\+(?!\d)|\-(?!\d)">
<token type="Operator"/>
</rule>
<rule pattern="\$[a-zA-Z0-9_]*(?![\w\(])">
<token type="NameVariable"/>
</rule>
<rule pattern="\$\w*(?=\()">
<token type="NameFunction"/>
</rule>
<rule pattern="\s+">
<token type="Text"/>
</rule>
<rule pattern="(true|false)\b">
<token type="KeywordConstant"/>
</rule>
<rule pattern="\b(function)\b">
<token type="Keyword"/>
</rule>
<rule pattern="(\+|-)?(0|[1-9]\d*)(\.\d+[eE](\+|-)?\d+|[eE](\+|-)?\d+|\.\d+)">
<token type="LiteralNumberFloat"/>
2024-08-26 23:18:28 +00:00
</rule>
2024-08-02 20:03:49 +00:00
<rule pattern="(\+|-)?(0|[1-9]\d*)">
<token type="LiteralNumberInteger"/>
</rule>
<!-- NOTE: This expression matches all object keys (NameTags), which are essentially strings with double quotes
that should only be captured on the left side of a colon (:) within a JSON-like object.
Therefore, this expression must preceed the one for all LiteralStringDouble -->
<rule pattern="&#34;(\\.|[^\\&#34;\r\n])*&#34;(?=\s*:)">
<token type="NameTag"/>
</rule>
<rule pattern="&#34;(\\\\|\\&#34;|[^&#34;])*&#34;">
<token type="LiteralStringDouble"/>
</rule>
<rule pattern="&#39;(\\|\\&#39;|[^&#39;])*&#39;">
<token type="LiteralStringSingle"/>
</rule>
<rule pattern="`.*`">
<token type="LiteralStringBacktick"/>
</rule>
<!-- NOTE: This expression matches everything remaining, which should be only JSONata names.
Therefore, it has been left as last intentionally -->
2024-08-26 23:18:28 +00:00
<rule pattern="[a-zA-Z0-9_]*">
2024-08-02 20:03:49 +00:00
<token type="Name"/>
</rule>
</state>
</rules>
2024-08-26 23:18:28 +00:00
</lexer>