mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-10 05:22:23 +00:00
83 lines
2.7 KiB
XML
83 lines
2.7 KiB
XML
<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"/>
|
|
</rule>
|
|
<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="[<>!]=?"> // 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="[%@#&?]|\+(?!\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"/>
|
|
</rule>
|
|
<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=""(\\.|[^\\"\r\n])*"(?=\s*:)">
|
|
<token type="NameTag"/>
|
|
</rule>
|
|
<rule pattern=""(\\\\|\\"|[^"])*"">
|
|
<token type="LiteralStringDouble"/>
|
|
</rule>
|
|
<rule pattern="'(\\|\\'|[^'])*'">
|
|
<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 -->
|
|
<rule pattern="[a-zA-Z0-9_]*">
|
|
<token type="Name"/>
|
|
</rule>
|
|
</state>
|
|
</rules>
|
|
</lexer> |