1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-17 20:58:08 +02:00

Add lexer for ArangoDB Query Language (AQL) (#794)

* Add ArangoDB Query Language (AQL) lexer
This commit is contained in:
Simran 2023-06-30 01:43:39 +03:00 committed by GitHub
parent e422a6286f
commit e8acfc274c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 705 additions and 2 deletions

View File

@ -37,7 +37,7 @@ translators for Pygments lexers and styles.
Prefix | Language
:----: | --------
A | ABAP, ABNF, ActionScript, ActionScript 3, Ada, Angular2, ANTLR, ApacheConf, APL, AppleScript, Arduino, Awk
A | ABAP, ABNF, ActionScript, ActionScript 3, Ada, Angular2, ANTLR, ApacheConf, APL, AppleScript, ArangoDB AQL, Arduino, Awk
B | Ballerina, Bash, Batchfile, BibTeX, Bicep, BlitzBasic, BNF, Brainfuck, BQN
C | C, C#, C++, Caddyfile, Caddyfile Directives, Cap'n Proto, Cassandra CQL, Ceylon, CFEngine3, cfstatement, ChaiScript, Chapel, Cheetah, Clojure, CMake, COBOL, CoffeeScript, Common Lisp, Coq, Crystal, CSS, Cython
D | D, Dart, Diff, Django/Jinja, Docker, DTD, Dylan

View File

@ -5,7 +5,7 @@ All lexers in Chroma should now be defined in XML unless they require custom cod
## Lexer tests
The tests in this directory feed a known input `testdata/<name>.actual` into the parser for `<name>` and check
that its output matches `<name>.exported`.
that its output matches `<name>.expected`.
It is also possible to perform several tests on a same parser `<name>`, by placing know inputs `*.actual` into a
directory `testdata/<name>/`.

175
lexers/embedded/aql.xml Normal file
View File

@ -0,0 +1,175 @@
<lexer>
<config>
<name>ArangoDB AQL</name>
<alias>aql</alias>
<filename>*.aql</filename>
<mime_type>text/x-aql</mime_type>
<dot_all>true</dot_all>
<ensure_nl>true</ensure_nl>
<case_insensitive>true</case_insensitive>
</config>
<rules>
<state name="comments-and-whitespace">
<rule pattern="\s+">
<token type="Text"/>
</rule>
<rule pattern="//.*?\n">
<token type="CommentSingle"/>
</rule>
<rule pattern="/\*">
<token type="CommentMultiline"/>
<push state="multiline-comment"/>
</rule>
</state>
<state name="multiline-comment">
<rule pattern="[^*]+">
<token type="CommentMultiline"/>
</rule>
<rule pattern="\*/">
<token type="CommentMultiline"/>
<pop depth="1"/>
</rule>
<rule pattern="\*">
<token type="CommentMultiline"/>
</rule>
</state>
<state name="double-quote">
<rule pattern="\\.">
<token type="LiteralStringDouble"/>
</rule>
<rule pattern="[^&quot;\\]+">
<token type="LiteralStringDouble"/>
</rule>
<rule pattern="&quot;">
<token type="LiteralStringDouble"/>
<pop depth="1"/>
</rule>
</state>
<state name="single-quote">
<rule pattern="\\.">
<token type="LiteralStringSingle"/>
</rule>
<rule pattern="[^'\\]+">
<token type="LiteralStringSingle"/>
</rule>
<rule pattern="'">
<token type="LiteralStringSingle"/>
<pop depth="1"/>
</rule>
</state>
<state name="backtick">
<rule pattern="\\.">
<token type="Name"/>
</rule>
<rule pattern="[^`\\]+">
<token type="Name"/>
</rule>
<rule pattern="`">
<token type="Name"/>
<pop depth="1"/>
</rule>
</state>
<state name="forwardtick">
<rule pattern="\\.">
<token type="Name"/>
</rule>
<rule pattern="[^´\\]+">
<token type="Name"/>
</rule>
<rule pattern="´">
<token type="Name"/>
<pop depth="1"/>
</rule>
</state>
<state name="identifier">
<rule pattern="(?:\$?|_+)[a-z]+[_a-z0-9]*">
<token type="Name"/>
</rule>
<rule pattern="`">
<token type="Name"/>
<push state="backtick"/>
</rule>
<rule pattern="´">
<token type="Name"/>
<push state="forwardtick"/>
</rule>
</state>
<state name="root">
<rule>
<include state="comments-and-whitespace"/>
</rule>
<rule pattern="0b[01]+">
<token type="LiteralNumberBin"/>
</rule>
<rule pattern="0x[0-9a-f]+">
<token type="LiteralNumberHex"/>
</rule>
<rule pattern="(?:0|[1-9][0-9]*)(?![\.e])">
<token type="LiteralNumberInteger"/>
</rule>
<rule pattern="(?:(?:0|[1-9][0-9]*)(?:\.[0-9]+)?|\.[0-9]+)(?:e[\-\+]?[0-9]+)?">
<token type="LiteralNumberFloat"/>
</rule>
<rule pattern="@@(?:_+[a-z0-9]+[a-z0-9_]*|[a-z0-9][a-z0-9_]*)">
<token type="NameVariableGlobal"/>
</rule>
<rule pattern="@(?:_+[a-z0-9]+[a-z0-9_]*|[a-z0-9][a-z0-9_]*)">
<token type="NameVariable"/>
</rule>
<rule pattern="=~|!~|[=!&lt;&gt;]=?|[%?:/*+-]|\.\.|&amp;&amp;|\|\|">
<token type="Operator"/>
</rule>
<rule pattern="[.,(){}\[\]]">
<token type="Punctuation"/>
</rule>
<rule pattern="[a-zA-Z0-9][a-zA-Z0-9_]*(?:::[a-zA-Z0-9_]+)+(?=\s*\()">
<token type="NameFunction"/>
</rule>
<rule pattern="(WITH)(\s+)(COUNT)(\s+)(INTO)\b">
<bygroups>
<token type="KeywordReserved"/>
<token type="Text"/>
<token type="KeywordPseudo"/>
<token type="Text"/>
<token type="KeywordReserved"/>
</bygroups>
</rule>
<rule pattern="(?:KEEP|PRUNE|SEARCH|TO)\b">
<token type="KeywordPseudo"/>
</rule>
<rule pattern="OPTIONS(?=\s*\{)">
<token type="KeywordPseudo"/>
</rule>
<rule pattern="(?:AGGREGATE|ALL|ALL_SHORTEST_PATHS|AND|ANY|ASC|AT LEAST|COLLECT|DESC|DISTINCT|FILTER|FOR|GRAPH|IN|INBOUND|INSERT|INTO|K_PATHS|K_SHORTEST_PATHS|LIKE|LIMIT|NONE|NOT|OR|OUTBOUND|REMOVE|REPLACE|RETURN|SHORTEST_PATH|SORT|UPDATE|UPSERT|WITH|WINDOW)\b">
<token type="KeywordReserved"/>
</rule>
<rule pattern="LET\b">
<token type="KeywordDeclaration"/>
</rule>
<rule pattern="(?:true|false|null)\b">
<token type="KeywordConstant"/>
</rule>
<rule pattern="(?-i)(?:CURRENT|NEW|OLD)\b">
<token type="NameBuiltinPseudo"/>
</rule>
<rule pattern="(?:to_bool|to_number|to_string|to_array|to_list|is_null|is_bool|is_number|is_string|is_array|is_list|is_object|is_document|is_datestring|typename|json_stringify|json_parse|concat|concat_separator|char_length|lower|upper|substring|substring_bytes|left|right|trim|reverse|contains|log|log2|log10|exp|exp2|sin|cos|tan|asin|acos|atan|atan2|radians|degrees|pi|regex_test|regex_replace|like|floor|ceil|round|abs|rand|sqrt|pow|length|count|min|max|average|avg|sum|product|median|variance_population|variance_sample|variance|percentile|bit_and|bit_or|bit_xor|bit_negate|bit_test|bit_popcount|bit_shift_left|bit_shift_right|bit_construct|bit_deconstruct|bit_to_string|bit_from_string|first|last|unique|outersection|interleave|in_range|jaccard|matches|merge|merge_recursive|has|attributes|keys|values|unset|unset_recursive|keep|keep_recursive|near|within|within_rectangle|is_in_polygon|distance|fulltext|stddev_sample|stddev_population|stddev|slice|nth|position|contains_array|translate|zip|call|apply|push|append|pop|shift|unshift|remove_value|remove_values|remove_nth|replace_nth|date_now|date_timestamp|date_iso8601|date_dayofweek|date_year|date_month|date_day|date_hour|date_minute|date_second|date_millisecond|date_dayofyear|date_isoweek|date_isoweekyear|date_leapyear|date_quarter|date_days_in_month|date_trunc|date_round|date_add|date_subtract|date_diff|date_compare|date_format|date_utctolocal|date_localtoutc|date_timezone|date_timezones|fail|passthru|v8|sleep|schema_get|schema_validate|shard_id|version|noopt|noeval|not_null|first_list|first_document|parse_identifier|current_user|current_database|collection_count|pregel_result|collections|document|decode_rev|range|union|union_distinct|minus|intersection|flatten|is_same_collection|check_document|ltrim|rtrim|find_first|find_last|split|substitute|ipv4_to_number|ipv4_from_number|is_ipv4|md5|sha1|sha256|sha512|crc32|fnv64|hash|random_token|to_base64|to_hex|encode_uri_component|soundex|assert|warn|is_key|sorted|sorted_unique|count_distinct|count_unique|levenshtein_distance|levenshtein_match|regex_matches|regex_split|ngram_match|ngram_similarity|ngram_positional_similarity|uuid|tokens|exists|starts_with|phrase|min_match|bm25|tfidf|boost|analyzer|offset_info|value|cosine_similarity|decay_exp|decay_gauss|decay_linear|l1_distance|l2_distance|minhash|minhash_count|minhash_error|minhash_match|geo_point|geo_multipoint|geo_polygon|geo_multipolygon|geo_linestring|geo_multilinestring|geo_contains|geo_intersects|geo_equals|geo_distance|geo_area|geo_in_range)(?=\s*\()">
<token type="NameFunction"/>
</rule>
<rule pattern="&quot;">
<token type="LiteralStringDouble"/>
<push state="double-quote"/>
</rule>
<rule pattern="'">
<token type="LiteralStringSingle"/>
<push state="single-quote"/>
</rule>
<!-- not part of the language but useful for highlighting query explain outputs -->
<rule pattern="#\d+\b">
<token type="NameLabel"/>
</rule>
<rule>
<include state="identifier"/>
</rule>
</state>
</rules>
</lexer>

5
lexers/testdata/aql/comments.actual vendored Normal file
View File

@ -0,0 +1,5 @@
code//comment
code/*comment*/
/* comment RETURN 42 "'` *
multiline */code
white space

13
lexers/testdata/aql/comments.expected vendored Normal file
View File

@ -0,0 +1,13 @@
[
{"type":"Name","value":"code"},
{"type":"CommentSingle","value":"//comment\n"},
{"type":"Name","value":"code"},
{"type":"CommentMultiline","value":"/*comment*/"},
{"type":"Text","value":"\n"},
{"type":"CommentMultiline","value":"/* comment RETURN 42 \"'` *\nmultiline */"},
{"type":"Name","value":"code"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"white"},
{"type":"Text","value":" \t"},
{"type":"Name","value":"space"}
]

14
lexers/testdata/aql/functions.actual vendored Normal file
View File

@ -0,0 +1,14 @@
RAND()
rand ()
Collections()
COUNT_DISTINCT()
COUNT()
not_null()
REMOVE_VALUE()
group::func()
GROUP_57::F9_()
0::0()
1SUM()
_G::A()
_aql::avg()

48
lexers/testdata/aql/functions.expected vendored Normal file
View File

@ -0,0 +1,48 @@
[
{"type":"NameFunction","value":"RAND"},
{"type":"Punctuation","value":"()"},
{"type":"Text","value":"\n"},
{"type":"NameFunction","value":"rand"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"()"},
{"type":"Text","value":"\n"},
{"type":"NameFunction","value":"Collections"},
{"type":"Punctuation","value":"()"},
{"type":"Text","value":"\n"},
{"type":"NameFunction","value":"COUNT_DISTINCT"},
{"type":"Punctuation","value":"()"},
{"type":"Text","value":"\n"},
{"type":"NameFunction","value":"COUNT"},
{"type":"Punctuation","value":"()"},
{"type":"Text","value":"\n"},
{"type":"NameFunction","value":"not_null"},
{"type":"Punctuation","value":"()"},
{"type":"Text","value":"\n"},
{"type":"NameFunction","value":"REMOVE_VALUE"},
{"type":"Punctuation","value":"()"},
{"type":"Text","value":"\n"},
{"type":"NameFunction","value":"group::func"},
{"type":"Punctuation","value":"()"},
{"type":"Text","value":"\n"},
{"type":"NameFunction","value":"GROUP_57::F9_"},
{"type":"Punctuation","value":"()"},
{"type":"Text","value":"\n\n"},
{"type":"LiteralNumberInteger","value":"0"},
{"type":"Operator","value":"::"},
{"type":"LiteralNumberInteger","value":"0"},
{"type":"Punctuation","value":"()"},
{"type":"Text","value":"\n"},
{"type":"LiteralNumberInteger","value":"1"},
{"type":"NameFunction","value":"SUM"},
{"type":"Punctuation","value":"()"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"_G"},
{"type":"Operator","value":"::"},
{"type":"Name","value":"A"},
{"type":"Punctuation","value":"()"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"_aql"},
{"type":"Operator","value":"::"},
{"type":"NameFunction","value":"avg"},
{"type":"Punctuation","value":"()"}
]

19
lexers/testdata/aql/identifiers.actual vendored Normal file
View File

@ -0,0 +1,19 @@
i
doc
Vertex
n036
$X
__foo__
`FILTER`
`@12 3!`
´&tab FOR äöü´
`multi\`
\\\`
line`
´multi\´
\\\´
line´
$6
$_Y
_8

View File

@ -0,0 +1,32 @@
[
{"type":"Name","value":"i"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"doc"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"Vertex"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"n036"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"$X"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"__foo__"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"`FILTER`"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"`@12 3!`"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"´\u0026tab\tFOR äöü´"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"`multi\\`\n\\\\\\`\nline`"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"´multi\\´\n\\\\\\´\nline´"},
{"type":"Text","value":"\n\n"},
{"type":"Error","value":"$"},
{"type":"LiteralNumberInteger","value":"6"},
{"type":"Text","value":"\n"},
{"type":"Error","value":"$"},
{"type":"Name","value":"_Y"},
{"type":"Text","value":"\n"},
{"type":"Error","value":"_"},
{"type":"LiteralNumberInteger","value":"8"}
]

31
lexers/testdata/aql/keywords.actual vendored Normal file
View File

@ -0,0 +1,31 @@
LET
AT LEAST
NULL
nULL
true
false
TRUE
FALSE
True
fAlSe
WITH COUNT INTO
KEEP
prune
SEARCH
to
OPTIONS {}
options{}
CURRENT
NEW
OLD
LEAST
AT
CAT LEAST
KNULL
falsey
COUNT
OPTIONS
current
New
old

70
lexers/testdata/aql/keywords.expected vendored Normal file
View File

@ -0,0 +1,70 @@
[
{"type":"KeywordDeclaration","value":"LET"},
{"type":"Text","value":"\n"},
{"type":"KeywordReserved","value":"AT LEAST"},
{"type":"Text","value":"\n"},
{"type":"KeywordConstant","value":"NULL"},
{"type":"Text","value":"\n"},
{"type":"KeywordConstant","value":"nULL"},
{"type":"Text","value":"\n"},
{"type":"KeywordConstant","value":"true"},
{"type":"Text","value":"\n"},
{"type":"KeywordConstant","value":"false"},
{"type":"Text","value":"\n"},
{"type":"KeywordConstant","value":"TRUE"},
{"type":"Text","value":"\n"},
{"type":"KeywordConstant","value":"FALSE"},
{"type":"Text","value":"\n"},
{"type":"KeywordConstant","value":"True"},
{"type":"Text","value":"\n"},
{"type":"KeywordConstant","value":"fAlSe"},
{"type":"Text","value":"\n"},
{"type":"KeywordReserved","value":"WITH"},
{"type":"Text","value":" "},
{"type":"KeywordPseudo","value":"COUNT"},
{"type":"Text","value":" "},
{"type":"KeywordReserved","value":"INTO"},
{"type":"Text","value":"\n"},
{"type":"KeywordPseudo","value":"KEEP"},
{"type":"Text","value":"\n"},
{"type":"KeywordPseudo","value":"prune"},
{"type":"Text","value":"\n"},
{"type":"KeywordPseudo","value":"SEARCH"},
{"type":"Text","value":"\n"},
{"type":"KeywordPseudo","value":"to"},
{"type":"Text","value":"\n"},
{"type":"KeywordPseudo","value":"OPTIONS"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"{}"},
{"type":"Text","value":"\n"},
{"type":"KeywordPseudo","value":"options"},
{"type":"Punctuation","value":"{}"},
{"type":"Text","value":"\n"},
{"type":"NameBuiltinPseudo","value":"CURRENT"},
{"type":"Text","value":"\n"},
{"type":"NameBuiltinPseudo","value":"NEW"},
{"type":"Text","value":"\n"},
{"type":"NameBuiltinPseudo","value":"OLD"},
{"type":"Text","value":"\n\n"},
{"type":"Name","value":"LEAST"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"AT"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"CAT"},
{"type":"Text","value":" "},
{"type":"Name","value":"LEAST"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"KNULL"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"falsey"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"COUNT"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"OPTIONS"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"current"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"New"},
{"type":"Text","value":"\n"},
{"type":"Name","value":"old"}
]

9
lexers/testdata/aql/numbers.actual vendored Normal file
View File

@ -0,0 +1,9 @@
0b1100 0B1
0xC0DE 0Xa7
0.0 -1.23 .5 8e9 3.33E-3 456.7e+89
0 2 400
0B 0b1e
0x 0X5G
00.7 .e6 ..5
01

52
lexers/testdata/aql/numbers.expected vendored Normal file
View File

@ -0,0 +1,52 @@
[
{"type":"LiteralNumberBin","value":"0b1100"},
{"type":"Text","value":" "},
{"type":"LiteralNumberBin","value":"0B1"},
{"type":"Text","value":"\n"},
{"type":"LiteralNumberHex","value":"0xC0DE"},
{"type":"Text","value":" "},
{"type":"LiteralNumberHex","value":"0Xa7"},
{"type":"Text","value":"\n"},
{"type":"LiteralNumberFloat","value":"0.0"},
{"type":"Text","value":" "},
{"type":"Operator","value":"-"},
{"type":"LiteralNumberFloat","value":"1.23"},
{"type":"Text","value":" "},
{"type":"LiteralNumberFloat","value":".5"},
{"type":"Text","value":" "},
{"type":"LiteralNumberFloat","value":"8e9"},
{"type":"Text","value":" "},
{"type":"LiteralNumberFloat","value":"3.33E-3"},
{"type":"Text","value":" "},
{"type":"LiteralNumberInteger","value":"45"},
{"type":"LiteralNumberFloat","value":"6.7e+89"},
{"type":"Text","value":"\n"},
{"type":"LiteralNumberInteger","value":"0"},
{"type":"Text","value":" "},
{"type":"LiteralNumberInteger","value":"2"},
{"type":"Text","value":" "},
{"type":"LiteralNumberInteger","value":"400"},
{"type":"Text","value":"\n\n"},
{"type":"LiteralNumberInteger","value":"0"},
{"type":"Name","value":"B"},
{"type":"Text","value":" "},
{"type":"LiteralNumberBin","value":"0b1"},
{"type":"Name","value":"e"},
{"type":"Text","value":"\n"},
{"type":"LiteralNumberInteger","value":"0"},
{"type":"Name","value":"x"},
{"type":"Text","value":" "},
{"type":"LiteralNumberHex","value":"0X5"},
{"type":"Name","value":"G"},
{"type":"Text","value":"\n"},
{"type":"LiteralNumberInteger","value":"0"},
{"type":"LiteralNumberFloat","value":"0.7"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"."},
{"type":"Name","value":"e6"},
{"type":"Text","value":" "},
{"type":"Operator","value":".."},
{"type":"LiteralNumberInteger","value":"5"},
{"type":"Text","value":"\n"},
{"type":"LiteralNumberInteger","value":"01"}
]

12
lexers/testdata/aql/queries.actual vendored Normal file
View File

@ -0,0 +1,12 @@
FOR doc IN @@coll
FILTER doc.value >= @val && doc["value"] < COUNT ([.1, FALSE])
COLLECT ´v a l´ /* legal! */ = doc.value WITH COUNT INTO count // blarg
RETURN MERGE(doc, { [CONCAT("new", 0.125)]: true } )
LET arr = [[1,2],3,[0]]
RETURN arr[** FILTER CURRENT % 2 == 0 RETURN CURRENT||null]
FOR v,e,p IN 2..4 OUTBOUND "components/S" GRAPH "g"
PRUNE e != null AND p.edges[-1].text =~ @AND
OPTIONS { vertexCollections: ['components'] }
RETURN v.´sort´ ?: 0xBEEF

194
lexers/testdata/aql/queries.expected vendored Normal file
View File

@ -0,0 +1,194 @@
[
{"type":"KeywordReserved","value":"FOR"},
{"type":"Text","value":" "},
{"type":"Name","value":"doc"},
{"type":"Text","value":" "},
{"type":"KeywordReserved","value":"IN"},
{"type":"Text","value":" "},
{"type":"NameVariableGlobal","value":"@@coll"},
{"type":"Text","value":"\n "},
{"type":"KeywordReserved","value":"FILTER"},
{"type":"Text","value":" "},
{"type":"Name","value":"doc"},
{"type":"Punctuation","value":"."},
{"type":"Name","value":"value"},
{"type":"Text","value":" "},
{"type":"Operator","value":"\u003e="},
{"type":"Text","value":" "},
{"type":"NameVariable","value":"@val"},
{"type":"Text","value":" "},
{"type":"Operator","value":"\u0026\u0026"},
{"type":"Text","value":" "},
{"type":"Name","value":"doc"},
{"type":"Punctuation","value":"["},
{"type":"LiteralStringDouble","value":"\"value\""},
{"type":"Punctuation","value":"]"},
{"type":"Text","value":" "},
{"type":"Operator","value":"\u003c"},
{"type":"Text","value":" "},
{"type":"NameFunction","value":"COUNT"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"(["},
{"type":"LiteralNumberFloat","value":".1"},
{"type":"Punctuation","value":","},
{"type":"Text","value":" "},
{"type":"KeywordConstant","value":"FALSE"},
{"type":"Punctuation","value":"])"},
{"type":"Text","value":"\n "},
{"type":"KeywordReserved","value":"COLLECT"},
{"type":"Text","value":" "},
{"type":"Name","value":"´v a l´"},
{"type":"Text","value":" "},
{"type":"CommentMultiline","value":"/* legal! */"},
{"type":"Text","value":" "},
{"type":"Operator","value":"="},
{"type":"Text","value":" "},
{"type":"Name","value":"doc"},
{"type":"Punctuation","value":"."},
{"type":"Name","value":"value"},
{"type":"Text","value":" "},
{"type":"KeywordReserved","value":"WITH"},
{"type":"Text","value":" "},
{"type":"KeywordPseudo","value":"COUNT"},
{"type":"Text","value":" "},
{"type":"KeywordReserved","value":"INTO"},
{"type":"Text","value":" "},
{"type":"Name","value":"count"},
{"type":"Text","value":" "},
{"type":"CommentSingle","value":"// blarg\n"},
{"type":"Text","value":" "},
{"type":"KeywordReserved","value":"RETURN"},
{"type":"Text","value":" "},
{"type":"NameFunction","value":"MERGE"},
{"type":"Punctuation","value":"("},
{"type":"Name","value":"doc"},
{"type":"Punctuation","value":","},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"["},
{"type":"NameFunction","value":"CONCAT"},
{"type":"Punctuation","value":"("},
{"type":"LiteralStringDouble","value":"\"new\""},
{"type":"Punctuation","value":","},
{"type":"Text","value":" "},
{"type":"LiteralNumberFloat","value":"0.125"},
{"type":"Punctuation","value":")]"},
{"type":"Operator","value":":"},
{"type":"Text","value":" "},
{"type":"KeywordConstant","value":"true"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"}"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":")"},
{"type":"Text","value":"\n\n"},
{"type":"KeywordDeclaration","value":"LET"},
{"type":"Text","value":" "},
{"type":"Name","value":"arr"},
{"type":"Text","value":" "},
{"type":"Operator","value":"="},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"[["},
{"type":"LiteralNumberInteger","value":"1"},
{"type":"Punctuation","value":","},
{"type":"LiteralNumberInteger","value":"2"},
{"type":"Punctuation","value":"],"},
{"type":"LiteralNumberInteger","value":"3"},
{"type":"Punctuation","value":",["},
{"type":"LiteralNumberInteger","value":"0"},
{"type":"Punctuation","value":"]]"},
{"type":"Text","value":"\n"},
{"type":"KeywordReserved","value":"RETURN"},
{"type":"Text","value":" "},
{"type":"Name","value":"arr"},
{"type":"Punctuation","value":"["},
{"type":"Operator","value":"**"},
{"type":"Text","value":" "},
{"type":"KeywordReserved","value":"FILTER"},
{"type":"Text","value":" "},
{"type":"NameBuiltinPseudo","value":"CURRENT"},
{"type":"Text","value":" "},
{"type":"Operator","value":"%"},
{"type":"Text","value":" "},
{"type":"LiteralNumberInteger","value":"2"},
{"type":"Text","value":" "},
{"type":"Operator","value":"=="},
{"type":"Text","value":" "},
{"type":"LiteralNumberInteger","value":"0"},
{"type":"Text","value":" "},
{"type":"KeywordReserved","value":"RETURN"},
{"type":"Text","value":" "},
{"type":"NameBuiltinPseudo","value":"CURRENT"},
{"type":"Operator","value":"||"},
{"type":"KeywordConstant","value":"null"},
{"type":"Punctuation","value":"]"},
{"type":"Text","value":"\n\n"},
{"type":"KeywordReserved","value":"FOR"},
{"type":"Text","value":" "},
{"type":"Name","value":"v"},
{"type":"Punctuation","value":","},
{"type":"Name","value":"e"},
{"type":"Punctuation","value":","},
{"type":"Name","value":"p"},
{"type":"Text","value":" "},
{"type":"KeywordReserved","value":"IN"},
{"type":"Text","value":" "},
{"type":"LiteralNumberFloat","value":"2"},
{"type":"Operator","value":".."},
{"type":"LiteralNumberInteger","value":"4"},
{"type":"Text","value":" "},
{"type":"KeywordReserved","value":"OUTBOUND"},
{"type":"Text","value":" "},
{"type":"LiteralStringDouble","value":"\"components/S\""},
{"type":"Text","value":" "},
{"type":"KeywordReserved","value":"GRAPH"},
{"type":"Text","value":" "},
{"type":"LiteralStringDouble","value":"\"g\""},
{"type":"Text","value":"\n "},
{"type":"KeywordPseudo","value":"PRUNE"},
{"type":"Text","value":" "},
{"type":"Name","value":"e"},
{"type":"Text","value":" "},
{"type":"Operator","value":"!="},
{"type":"Text","value":" "},
{"type":"KeywordConstant","value":"null"},
{"type":"Text","value":" "},
{"type":"KeywordReserved","value":"AND"},
{"type":"Text","value":" "},
{"type":"Name","value":"p"},
{"type":"Punctuation","value":"."},
{"type":"Name","value":"edges"},
{"type":"Punctuation","value":"["},
{"type":"Operator","value":"-"},
{"type":"LiteralNumberInteger","value":"1"},
{"type":"Punctuation","value":"]."},
{"type":"Name","value":"text"},
{"type":"Text","value":" "},
{"type":"Operator","value":"=~"},
{"type":"Text","value":" "},
{"type":"NameVariable","value":"@AND"},
{"type":"Text","value":"\n "},
{"type":"KeywordPseudo","value":"OPTIONS"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"Text","value":" "},
{"type":"Name","value":"vertexCollections"},
{"type":"Operator","value":":"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"["},
{"type":"LiteralStringSingle","value":"'components'"},
{"type":"Punctuation","value":"]"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"}"},
{"type":"Text","value":"\n "},
{"type":"KeywordReserved","value":"RETURN"},
{"type":"Text","value":" "},
{"type":"Name","value":"v"},
{"type":"Punctuation","value":"."},
{"type":"Name","value":"´sort´"},
{"type":"Text","value":" "},
{"type":"Operator","value":"?:"},
{"type":"Text","value":" "},
{"type":"LiteralNumberHex","value":"0xBEEF"},
{"type":"Text","value":"\n"}
]

12
lexers/testdata/aql/strings.actual vendored Normal file
View File

@ -0,0 +1,12 @@
"double"
'single'
"multi
line"
'multi
line'
"escaped\"
quote"
'escaped\'
quote'
"backtick\\'"
'backtick\\"'

17
lexers/testdata/aql/strings.expected vendored Normal file
View File

@ -0,0 +1,17 @@
[
{"type":"LiteralStringDouble","value":"\"double\""},
{"type":"Text","value":"\n"},
{"type":"LiteralStringSingle","value":"'single'"},
{"type":"Text","value":"\n"},
{"type":"LiteralStringDouble","value":"\"multi\nline\""},
{"type":"Text","value":"\n"},
{"type":"LiteralStringSingle","value":"'multi\nline'"},
{"type":"Text","value":"\n"},
{"type":"LiteralStringDouble","value":"\"escaped\\\"\nquote\""},
{"type":"Text","value":"\n"},
{"type":"LiteralStringSingle","value":"'escaped\\'\nquote'"},
{"type":"Text","value":"\n"},
{"type":"LiteralStringDouble","value":"\"backtick\\\\'\""},
{"type":"Text","value":"\n"},
{"type":"LiteralStringSingle","value":"'backtick\\\\\"'"}
]