mirror of
https://github.com/cheat/cheat.git
synced 2024-12-26 06:29:45 +01:00
162 lines
11 KiB
XML
162 lines
11 KiB
XML
|
<lexer>
|
||
|
<config>
|
||
|
<name>PRQL</name>
|
||
|
<alias>prql</alias>
|
||
|
<filename>*.prql</filename>
|
||
|
<mime_type>application/prql</mime_type>
|
||
|
</config>
|
||
|
<rules>
|
||
|
<state name="root">
|
||
|
<rule pattern="#!.*"><token type="LiteralStringDoc"/></rule>
|
||
|
<rule pattern="#.*"><token type="CommentSingle"/></rule>
|
||
|
<rule pattern="\s+"><token type="TextWhitespace"/></rule>
|
||
|
<rule pattern="^(\s*)(module)(\s*)"><bygroups><token type="TextWhitespace"/><token type="KeywordNamespace"/><token type="TextWhitespace"/></bygroups><push state="imports"/></rule>
|
||
|
<rule pattern="(bool|int|int8|int16|int32|int64|int128|float|text|set)\b"><token type="KeywordType"/></rule>
|
||
|
<rule pattern="^prql "><token type="KeywordReserved"/></rule>
|
||
|
<rule pattern="let"><token type="KeywordDeclaration"/></rule>
|
||
|
<rule><include state="keywords"/></rule>
|
||
|
<rule><include state="expr"/></rule>
|
||
|
<rule pattern="^[A-Za-z_][a-zA-Z0-9_]*"><token type="Keyword"/></rule>
|
||
|
</state>
|
||
|
<state name="expr">
|
||
|
<rule pattern="(f)(""")"><bygroups><token type="LiteralStringAffix"/><token type="LiteralStringDouble"/></bygroups><combined state="fstringescape" state="tdqf"/></rule>
|
||
|
<rule pattern="(f)(''')"><bygroups><token type="LiteralStringAffix"/><token type="LiteralStringSingle"/></bygroups><combined state="fstringescape" state="tsqf"/></rule>
|
||
|
<rule pattern="(f)(")"><bygroups><token type="LiteralStringAffix"/><token type="LiteralStringDouble"/></bygroups><combined state="fstringescape" state="dqf"/></rule>
|
||
|
<rule pattern="(f)(')"><bygroups><token type="LiteralStringAffix"/><token type="LiteralStringSingle"/></bygroups><combined state="fstringescape" state="sqf"/></rule>
|
||
|
<rule pattern="(s)(""")"><bygroups><token type="LiteralStringAffix"/><token type="LiteralStringDouble"/></bygroups><combined state="stringescape" state="tdqf"/></rule>
|
||
|
<rule pattern="(s)(''')"><bygroups><token type="LiteralStringAffix"/><token type="LiteralStringSingle"/></bygroups><combined state="stringescape" state="tsqf"/></rule>
|
||
|
<rule pattern="(s)(")"><bygroups><token type="LiteralStringAffix"/><token type="LiteralStringDouble"/></bygroups><combined state="stringescape" state="dqf"/></rule>
|
||
|
<rule pattern="(s)(')"><bygroups><token type="LiteralStringAffix"/><token type="LiteralStringSingle"/></bygroups><combined state="stringescape" state="sqf"/></rule>
|
||
|
<rule pattern="(?i)(r)(""")"><bygroups><token type="LiteralStringAffix"/><token type="LiteralStringDouble"/></bygroups><push state="tdqs"/></rule>
|
||
|
<rule pattern="(?i)(r)(''')"><bygroups><token type="LiteralStringAffix"/><token type="LiteralStringSingle"/></bygroups><push state="tsqs"/></rule>
|
||
|
<rule pattern="(?i)(r)(")"><bygroups><token type="LiteralStringAffix"/><token type="LiteralStringDouble"/></bygroups><push state="dqs"/></rule>
|
||
|
<rule pattern="(?i)(r)(')"><bygroups><token type="LiteralStringAffix"/><token type="LiteralStringSingle"/></bygroups><push state="sqs"/></rule>
|
||
|
<rule pattern="""""><token type="LiteralStringDouble"/><combined state="stringescape" state="tdqs"/></rule>
|
||
|
<rule pattern="'''"><token type="LiteralStringSingle"/><combined state="stringescape" state="tsqs"/></rule>
|
||
|
<rule pattern="""><token type="LiteralStringDouble"/><combined state="stringescape" state="dqs"/></rule>
|
||
|
<rule pattern="'"><token type="LiteralStringSingle"/><combined state="stringescape" state="sqs"/></rule>
|
||
|
<rule pattern="@\d{4}-\d{2}-\d{2}T\d{2}(:\d{2})?(:\d{2})?(\.\d{1,6})?(Z|[+-]\d{1,2}(:\d{1,2})?)?"><token type="LiteralDate"/></rule>
|
||
|
<rule pattern="@\d{4}-\d{2}-\d{2}"><token type="LiteralDate"/></rule>
|
||
|
<rule pattern="@\d{2}(:\d{2})?(:\d{2})?(\.\d{1,6})?(Z|[+-]\d{1,2}(:\d{1,2})?)?"><token type="LiteralDate"/></rule>
|
||
|
<rule pattern="[^\S\n]+"><token type="Text"/></rule>
|
||
|
<rule><include state="numbers"/></rule>
|
||
|
<rule pattern="->|=>|==|!=|>=|<=|~=|&&|\|\||\?\?|\/\/"><token type="Operator"/></rule>
|
||
|
<rule pattern="[-~+/*%=<>&^|.@]"><token type="Operator"/></rule>
|
||
|
<rule pattern="[]{}:(),;[]"><token type="Punctuation"/></rule>
|
||
|
<rule><include state="functions"/></rule>
|
||
|
<rule pattern="[A-Za-z_][a-zA-Z0-9_]*"><token type="NameVariable"/></rule>
|
||
|
</state>
|
||
|
<state name="numbers">
|
||
|
<rule pattern="(\d(?:_?\d)*\.(?:\d(?:_?\d)*)?|(?:\d(?:_?\d)*)?\.\d(?:_?\d)*)([eE][+-]?\d(?:_?\d)*)?"><token type="LiteralNumberFloat"/></rule>
|
||
|
<rule pattern="\d(?:_?\d)*[eE][+-]?\d(?:_?\d)*j?"><token type="LiteralNumberFloat"/></rule>
|
||
|
<rule pattern="0[oO](?:_?[0-7])+"><token type="LiteralNumberOct"/></rule>
|
||
|
<rule pattern="0[bB](?:_?[01])+"><token type="LiteralNumberBin"/></rule>
|
||
|
<rule pattern="0[xX](?:_?[a-fA-F0-9])+"><token type="LiteralNumberHex"/></rule>
|
||
|
<rule pattern="\d(?:_?\d)*"><token type="LiteralNumberInteger"/></rule>
|
||
|
</state>
|
||
|
<state name="fstringescape">
|
||
|
<rule><include state="stringescape"/></rule>
|
||
|
</state>
|
||
|
<state name="bytesescape">
|
||
|
<rule pattern="\\([\\bfnrt"\']|\n|x[a-fA-F0-9]{2}|[0-7]{1,3})"><token type="LiteralStringEscape"/></rule>
|
||
|
</state>
|
||
|
<state name="stringescape">
|
||
|
<rule pattern="\\(N\{.*?\}|u\{[a-fA-F0-9]{1,6}\})"><token type="LiteralStringEscape"/></rule>
|
||
|
<rule><include state="bytesescape"/></rule>
|
||
|
</state>
|
||
|
<state name="fstrings-single">
|
||
|
<rule pattern="\}"><token type="LiteralStringInterpol"/></rule>
|
||
|
<rule pattern="\{"><token type="LiteralStringInterpol"/><push state="expr-inside-fstring"/></rule>
|
||
|
<rule pattern="[^\\\'"{}\n]+"><token type="LiteralStringSingle"/></rule>
|
||
|
<rule pattern="[\'"\\]"><token type="LiteralStringSingle"/></rule>
|
||
|
</state>
|
||
|
<state name="fstrings-double">
|
||
|
<rule pattern="\}"><token type="LiteralStringInterpol"/></rule>
|
||
|
<rule pattern="\{"><token type="LiteralStringInterpol"/><push state="expr-inside-fstring"/></rule>
|
||
|
<rule pattern="[^\\\'"{}\n]+"><token type="LiteralStringDouble"/></rule>
|
||
|
<rule pattern="[\'"\\]"><token type="LiteralStringDouble"/></rule>
|
||
|
</state>
|
||
|
<state name="strings-single">
|
||
|
<rule pattern="\{((\w+)((\.\w+)|(\[[^\]]+\]))*)?(\:(.?[<>=\^])?[-+ ]?#?0?(\d+)?,?(\.\d+)?[E-GXb-gnosx%]?)?\}"><token type="LiteralStringInterpol"/></rule>
|
||
|
<rule pattern="[^\\\'"%{\n]+"><token type="LiteralStringSingle"/></rule>
|
||
|
<rule pattern="[\'"\\]"><token type="LiteralStringSingle"/></rule>
|
||
|
<rule pattern="%|(\{{1,2})"><token type="LiteralStringSingle"/></rule>
|
||
|
</state>
|
||
|
<state name="strings-double">
|
||
|
<rule pattern="\{((\w+)((\.\w+)|(\[[^\]]+\]))*)?(\:(.?[<>=\^])?[-+ ]?#?0?(\d+)?,?(\.\d+)?[E-GXb-gnosx%]?)?\}"><token type="LiteralStringInterpol"/></rule>
|
||
|
<rule pattern="[^\\\'"%{\n]+"><token type="LiteralStringDouble"/></rule>
|
||
|
<rule pattern="[\'"\\]"><token type="LiteralStringDouble"/></rule>
|
||
|
<rule pattern="%|(\{{1,2})"><token type="LiteralStringDouble"/></rule>
|
||
|
</state>
|
||
|
<state name="dqf">
|
||
|
<rule pattern="""><token type="LiteralStringDouble"/><pop depth="1"/></rule>
|
||
|
<rule pattern="\\\\|\\"|\\\n"><token type="LiteralStringEscape"/></rule>
|
||
|
<rule><include state="fstrings-double"/></rule>
|
||
|
</state>
|
||
|
<state name="sqf">
|
||
|
<rule pattern="'"><token type="LiteralStringSingle"/><pop depth="1"/></rule>
|
||
|
<rule pattern="\\\\|\\'|\\\n"><token type="LiteralStringEscape"/></rule>
|
||
|
<rule><include state="fstrings-single"/></rule>
|
||
|
</state>
|
||
|
<state name="dqs">
|
||
|
<rule pattern="""><token type="LiteralStringDouble"/><pop depth="1"/></rule>
|
||
|
<rule pattern="\\\\|\\"|\\\n"><token type="LiteralStringEscape"/></rule>
|
||
|
<rule><include state="strings-double"/></rule>
|
||
|
</state>
|
||
|
<state name="sqs">
|
||
|
<rule pattern="'"><token type="LiteralStringSingle"/><pop depth="1"/></rule>
|
||
|
<rule pattern="\\\\|\\'|\\\n"><token type="LiteralStringEscape"/></rule>
|
||
|
<rule><include state="strings-single"/></rule>
|
||
|
</state>
|
||
|
<state name="tdqf">
|
||
|
<rule pattern="""""><token type="LiteralStringDouble"/><pop depth="1"/></rule>
|
||
|
<rule><include state="fstrings-double"/></rule>
|
||
|
<rule pattern="\n"><token type="LiteralStringDouble"/></rule>
|
||
|
</state>
|
||
|
<state name="tsqf">
|
||
|
<rule pattern="'''"><token type="LiteralStringSingle"/><pop depth="1"/></rule>
|
||
|
<rule><include state="fstrings-single"/></rule>
|
||
|
<rule pattern="\n"><token type="LiteralStringSingle"/></rule>
|
||
|
</state>
|
||
|
<state name="tdqs">
|
||
|
<rule pattern="""""><token type="LiteralStringDouble"/><pop depth="1"/></rule>
|
||
|
<rule><include state="strings-double"/></rule>
|
||
|
<rule pattern="\n"><token type="LiteralStringDouble"/></rule>
|
||
|
</state>
|
||
|
<state name="tsqs">
|
||
|
<rule pattern="'''"><token type="LiteralStringSingle"/><pop depth="1"/></rule>
|
||
|
<rule><include state="strings-single"/></rule>
|
||
|
<rule pattern="\n"><token type="LiteralStringSingle"/></rule>
|
||
|
</state>
|
||
|
<state name="expr-inside-fstring">
|
||
|
<rule pattern="[{([]"><token type="Punctuation"/><push state="expr-inside-fstring-inner"/></rule>
|
||
|
<rule pattern="(=\s*)?\}"><token type="LiteralStringInterpol"/><pop depth="1"/></rule>
|
||
|
<rule pattern="(=\s*)?:"><token type="LiteralStringInterpol"/><pop depth="1"/></rule>
|
||
|
<rule pattern="\s+"><token type="TextWhitespace"/></rule>
|
||
|
<rule><include state="expr"/></rule>
|
||
|
</state>
|
||
|
<state name="expr-inside-fstring-inner">
|
||
|
<rule pattern="[{([]"><token type="Punctuation"/><push state="expr-inside-fstring-inner"/></rule>
|
||
|
<rule pattern="[])}]"><token type="Punctuation"/><pop depth="1"/></rule>
|
||
|
<rule pattern="\s+"><token type="TextWhitespace"/></rule>
|
||
|
<rule><include state="expr"/></rule>
|
||
|
</state>
|
||
|
<state name="keywords">
|
||
|
<rule pattern="(into|case|type|module|internal)\b"><token type="Keyword"/></rule>
|
||
|
<rule pattern="(true|false|null)\b"><token type="KeywordConstant"/></rule>
|
||
|
</state>
|
||
|
<state name="functions">
|
||
|
<rule pattern="(min|max|sum|average|stddev|every|any|concat_array|count|lag|lead|first|last|rank|rank_dense|row_number|round|as|in|tuple_every|tuple_map|tuple_zip|_eq|_is_null|from_text|lower|upper|read_parquet|read_csv)\b"><token type="NameFunction"/></rule>
|
||
|
</state>
|
||
|
<state name="comment">
|
||
|
<rule pattern="-(?!\})"><token type="CommentMultiline"/></rule>
|
||
|
<rule pattern="\{-"><token type="CommentMultiline"/><push state="comment"/></rule>
|
||
|
<rule pattern="[^-}]"><token type="CommentMultiline"/></rule>
|
||
|
<rule pattern="-\}"><token type="CommentMultiline"/><pop depth="1"/></rule>
|
||
|
</state>
|
||
|
<state name="imports">
|
||
|
<rule pattern="\w+(\.\w+)*"><token type="NameClass"/><pop depth="1"/></rule>
|
||
|
</state>
|
||
|
</rules>
|
||
|
</lexer>
|