From d3155c97ab970732650faef13b9ca888b8f2f469 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sun, 5 Jul 2015 20:49:20 +0200 Subject: [PATCH 1/3] Add support for Q (kdb+ database) --- components.js | 4 ++ components/prism-q.js | 26 +++++++++ components/prism-q.min.js | 1 + examples/prism-q.html | 107 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 138 insertions(+) create mode 100644 components/prism-q.js create mode 100644 components/prism-q.min.js create mode 100644 examples/prism-q.html diff --git a/components.js b/components.js index 919b3c13ae..16e686bf4f 100644 --- a/components.js +++ b/components.js @@ -258,6 +258,10 @@ var components = { "title": "Python", "owner": "multipetros" }, + "q": { + "title": "Q", + "owner": "Golmote" + }, "r": { "title": "R", "owner": "Golmote" diff --git a/components/prism-q.js b/components/prism-q.js new file mode 100644 index 0000000000..4a33882f1d --- /dev/null +++ b/components/prism-q.js @@ -0,0 +1,26 @@ +Prism.languages.q = { + 'string': /"(?:\\.|[^"\\\r\n])*"/, + 'comment': [ + { + pattern: /(^|[\t ])\/.+/m, + lookbehind: true + }, + /#!.+/ + ], + 'symbol': /`(?::\S+|[\w.]*)/, + 'date': { + pattern: /0N[mdzuvt]|0W[dtz]|\d{4}\.\d\d(?:m|\.\d\d(?:T(?:\d\d(?::\d\d(?::\d\d(?:[.:]\d\d\d)?)?)?)?)?[dz]?)|\d\d:\d\d(?::\d\d(?:[.:]\d\d\d)?)?[uvt]?/, + alias: 'number' + }, + 'number': /\b-?(?![01]:)(?:0[wn]|0W[hj]?|0N[hje]?|0x[\da-fA-F]+|\d+\.?\d*(?:e[+-]?\d+)?[hjfeb]?)/, + 'keyword': /\\\w+\b|\b(?:abs|acos|aj0?|all|and|any|asc|asin|asof|atan|attr|avgs?|binr?|by|ceiling|cols|cor|cos|count|cov|cross|csv|cut|delete|deltas|desc|dev|differ|distinct|div|do|dsave|ej|enlist|eval|except|exec|exit|exp|fby|fills|first|fkeys|flip|floor|from|get|getenv|group|gtime|hclose|hcount|hdel|hopen|hsym|iasc|identity|idesc|if|ij|in|insert|inter|inv|keys?|last|like|list|ljf?|load|log|lower|lsq|ltime|ltrim|mavg|maxs?|mcount|md5|mdev|med|meta|mins?|mmax|mmin|mmu|mod|msum|neg|next|not|null|or|over|parse|peach|pj|plist|prds?|prev|prior|rand|rank|ratios|raze|read0|read1|reciprocal|reval|reverse|rload|rotate|rsave|rtrim|save|scan|scov|sdev|select|set|setenv|show|signum|sin|sqrt|ssr?|string|sublist|sums?|sv|svar|system|tables|tan|til|trim|txf|type|uj|ungroup|union|update|upper|upsert|value|var|views?|vs|wavg|where|while|within|wj1?|wsum|ww|xasc|xbar|xcols?|xdesc|xexp|xgroup|xkey|xlog|xprev|xrank)\b/, + 'adverb': { + pattern: /['\/\\]:?|\beach\b/, + alias: 'function' + }, + 'verb': { + pattern: /(?:\B\.\B|\b[01]:|<>|[<>]=?|:|[+\-*%,!?_~=|$&#@^']):?/, + alias: 'operator' + }, + 'punctuation': /[(){}\[\];.]/ +}; \ No newline at end of file diff --git a/components/prism-q.min.js b/components/prism-q.min.js new file mode 100644 index 0000000000..3c54495860 --- /dev/null +++ b/components/prism-q.min.js @@ -0,0 +1 @@ +Prism.languages.q={string:/"(?:\\.|[^"\\\r\n])*"/,comment:[{pattern:/(^|[\t ])\/.+/m,lookbehind:!0},/#!.+/],symbol:/`(?::\S+|[\w.]*)/,date:{pattern:/0N[mdzuvt]|0W[dtz]|\d{4}\.\d\d(?:m|\.\d\d(?:T(?:\d\d(?::\d\d(?::\d\d(?:[.:]\d\d\d)?)?)?)?)?[dz]?)|\d\d:\d\d(?::\d\d(?:[.:]\d\d\d)?)?[uvt]?/,alias:"number"},number:/\b-?(?![01]:)(?:0[wn]|0W[hj]?|0N[hje]?|0x[\da-fA-F]+|\d+\.?\d*(?:e[+-]?\d+)?[hjfeb]?)/,keyword:/\\\w+\b|\b(?:abs|acos|aj0?|all|and|any|asc|asin|asof|atan|attr|avgs?|binr?|by|ceiling|cols|cor|cos|count|cov|cross|csv|cut|delete|deltas|desc|dev|differ|distinct|div|do|dsave|ej|enlist|eval|except|exec|exit|exp|fby|fills|first|fkeys|flip|floor|from|get|getenv|group|gtime|hclose|hcount|hdel|hopen|hsym|iasc|identity|idesc|if|ij|in|insert|inter|inv|keys?|last|like|list|ljf?|load|log|lower|lsq|ltime|ltrim|mavg|maxs?|mcount|md5|mdev|med|meta|mins?|mmax|mmin|mmu|mod|msum|neg|next|not|null|or|over|parse|peach|pj|plist|prds?|prev|prior|rand|rank|ratios|raze|read0|read1|reciprocal|reval|reverse|rload|rotate|rsave|rtrim|save|scan|scov|sdev|select|set|setenv|show|signum|sin|sqrt|ssr?|string|sublist|sums?|sv|svar|system|tables|tan|til|trim|txf|type|uj|ungroup|union|update|upper|upsert|value|var|views?|vs|wavg|where|while|within|wj1?|wsum|ww|xasc|xbar|xcols?|xdesc|xexp|xgroup|xkey|xlog|xprev|xrank)\b/,adverb:{pattern:/['\/\\]:?|\beach\b/,alias:"function"},verb:{pattern:/(?:\B\.\B|\b[01]:|<>|[<>]=?|:|[+\-*%,!?_~=|$&#@^']):?/,alias:"operator"},punctuation:/[(){}\[\];.]/}; \ No newline at end of file diff --git a/examples/prism-q.html b/examples/prism-q.html new file mode 100644 index 0000000000..81046b5071 --- /dev/null +++ b/examples/prism-q.html @@ -0,0 +1,107 @@ +

Q (kdb+ database)

+

To use this language, use the class "language-q".

+ +

Comments

+
foo / This is a comment
+ +

Character data and strings

+
"q"
+"\""
+"\\"
+"\142"
+"foo bar baz"
+ +

Symbols

+
`
+`q
+`zaphod
+`:198.162.0.2:5042
+`:www.yourco.com:5042
+`.new
+ +

Numbers

+
42
+b:-123h
+c:1234567890j
+pi:3.14159265
+float1:1f
+r:1.4142e
+2.0
+4.00e
+f:1.23456789e-10
+r:1.2345678e-10e
+bit:0b
+byte:0x2a
+a:42
+bit:1b
+
+0w 0n 0W 0Wh 0Wj
+ +

Dates

+
d:2006.07.04
+t:09:04:59.000
+dt:2006.07.04T09:04:59.000
+mon:2006.07m
+mm:09:04
+sec:09:04:59
+d:2006.07.04
+
+0Nm 0Nd 0Nz 0Nu 0Nv 0Wd 0Wt 0Wz
+ +

Verbs

+
99+L
+x<42|x>98
+(x<42)|x>98
+42~(4 2;(1 0))
+(4 2)~(4; 2*1)
+ +

Adverbs

+
" ," ,/: ("Now";"is";"the";"time")
+L1,/:\:L2
+0+/10 20 30
+(1#) each 1001 1002 1004 1003
+ +

Built-in functions and q-sql

+
string 42
+L1 cross L2
+type c
+select from t where price=(max;price) fby ([]sym;ex)
+ungroup `p xgroup sp
+`instrument insert (`g; `$"Google"; `$"Internet")
+ +

Example

+
/ Example from http://code.kx.com/wiki/Cookbook/CorporateActions
+getCAs:{[caTypes]
+    / handles multiplie corporate actions on one date
+    t:0!select factor:prd factor by date-1,sym from ca where caType in caTypes;
+    t,:update date:1901.01.01,factor:1.0 from ([]sym:distinct t`sym);
+    t:`date xasc t;
+    t:update factor:reverse prds reverse 1 rotate factor by sym from t;
+    :update `g#sym from 0!t;
+  };
+
+adjust:{[t;caTypes]
+    t:0!t;
+    factors:enlist 1.0^aj[`sym`date;([] date:t`date;sym:t`sym);getCAs caTypes]`factor;
+    mc:c where (lower c:cols t) like "*price"; / find columns to multiply
+    dc:c where lower[c] like "*size"; / find columns to divide
+    :![t;();0b;(mc,dc)!((*),/:mc,\:factors),((%),/:dc,\:factors)]; / multiply or divide out the columns
+  };
+
+/ get the adjustment factors considering all corporate actions
+getCAs exec distinct caType from ca
+
+adjust[t;`dividend] / adjust trades for dividends only
+ +

Known failures

+

There are certain edge cases where Prism will fail. + There are always such cases in every regex-based syntax highlighter. + However, Prism dares to be open and honest about them. + If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug. +

+ +

Two double quotes in a comment

+
/ This "comment" is broken
+ +

The global context is highlighted as a verb

+
\d .
\ No newline at end of file From addc9710030e3b51636780e575fcd1a0a255280b Mon Sep 17 00:00:00 2001 From: Golmote Date: Tue, 8 Sep 2015 09:04:06 +0200 Subject: [PATCH 2/3] Q: Fixed comments + added explanation, renamed date to datetime, optimized operators --- components/prism-q.js | 26 ++++++++++++++++++++++---- components/prism-q.min.js | 2 +- examples/prism-q.html | 13 ++++++++++++- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/components/prism-q.js b/components/prism-q.js index 4a33882f1d..6341c0337f 100644 --- a/components/prism-q.js +++ b/components/prism-q.js @@ -1,17 +1,35 @@ Prism.languages.q = { 'string': /"(?:\\.|[^"\\\r\n])*"/, 'comment': [ + // From http://code.kx.com/wiki/Reference/Slash: + // When / is following a space (or a right parenthesis, bracket, or brace), it is ignored with the rest of the line. { - pattern: /(^|[\t ])\/.+/m, + + pattern: /([\t )\]}])\/.*/, lookbehind: true }, - /#!.+/ + // From http://code.kx.com/wiki/Reference/Slash: + // A line which has / as its first character and contains at least one other non-whitespace character is a whole-line comment and is ignored entirely. + // A / on a line by itself begins a multiline comment which is terminated by the next \ on a line by itself. + // If a / is not matched by a \, the multiline comment is unterminated and continues to end of file. + // The / and \ must be the first char on the line, but may be followed by any amount of whitespace. + { + pattern: /(^|\r?\n|\r)\/[\t ]*(?:(?:\r?\n|\r)(?:.*(?:\r?\n|\r))*?(?:\\(?=[\t ]*(?:\r?\n|\r))|$)|\S.*)/, + lookbehind: true + }, + // From http://code.kx.com/wiki/Reference/Slash: + // A \ on a line by itself with no preceding matching / will comment to end of file. + /^\\[\t ]*(?:\r?\n|\r)[\s\S]+/m, + + /^#!.+/m ], 'symbol': /`(?::\S+|[\w.]*)/, - 'date': { + 'datetime': { pattern: /0N[mdzuvt]|0W[dtz]|\d{4}\.\d\d(?:m|\.\d\d(?:T(?:\d\d(?::\d\d(?::\d\d(?:[.:]\d\d\d)?)?)?)?)?[dz]?)|\d\d:\d\d(?::\d\d(?:[.:]\d\d\d)?)?[uvt]?/, alias: 'number' }, + // The negative look-ahead prevents bad highlighting + // of verbs 0: and 1: 'number': /\b-?(?![01]:)(?:0[wn]|0W[hj]?|0N[hje]?|0x[\da-fA-F]+|\d+\.?\d*(?:e[+-]?\d+)?[hjfeb]?)/, 'keyword': /\\\w+\b|\b(?:abs|acos|aj0?|all|and|any|asc|asin|asof|atan|attr|avgs?|binr?|by|ceiling|cols|cor|cos|count|cov|cross|csv|cut|delete|deltas|desc|dev|differ|distinct|div|do|dsave|ej|enlist|eval|except|exec|exit|exp|fby|fills|first|fkeys|flip|floor|from|get|getenv|group|gtime|hclose|hcount|hdel|hopen|hsym|iasc|identity|idesc|if|ij|in|insert|inter|inv|keys?|last|like|list|ljf?|load|log|lower|lsq|ltime|ltrim|mavg|maxs?|mcount|md5|mdev|med|meta|mins?|mmax|mmin|mmu|mod|msum|neg|next|not|null|or|over|parse|peach|pj|plist|prds?|prev|prior|rand|rank|ratios|raze|read0|read1|reciprocal|reval|reverse|rload|rotate|rsave|rtrim|save|scan|scov|sdev|select|set|setenv|show|signum|sin|sqrt|ssr?|string|sublist|sums?|sv|svar|system|tables|tan|til|trim|txf|type|uj|ungroup|union|update|upper|upsert|value|var|views?|vs|wavg|where|while|within|wj1?|wsum|ww|xasc|xbar|xcols?|xdesc|xexp|xgroup|xkey|xlog|xprev|xrank)\b/, 'adverb': { @@ -19,7 +37,7 @@ Prism.languages.q = { alias: 'function' }, 'verb': { - pattern: /(?:\B\.\B|\b[01]:|<>|[<>]=?|:|[+\-*%,!?_~=|$&#@^']):?/, + pattern: /(?:\B\.\B|\b[01]:|<[=>]?|>=?|[:+\-*%,!?_~=|$&#@^]):?/, alias: 'operator' }, 'punctuation': /[(){}\[\];.]/ diff --git a/components/prism-q.min.js b/components/prism-q.min.js index 3c54495860..92df717918 100644 --- a/components/prism-q.min.js +++ b/components/prism-q.min.js @@ -1 +1 @@ -Prism.languages.q={string:/"(?:\\.|[^"\\\r\n])*"/,comment:[{pattern:/(^|[\t ])\/.+/m,lookbehind:!0},/#!.+/],symbol:/`(?::\S+|[\w.]*)/,date:{pattern:/0N[mdzuvt]|0W[dtz]|\d{4}\.\d\d(?:m|\.\d\d(?:T(?:\d\d(?::\d\d(?::\d\d(?:[.:]\d\d\d)?)?)?)?)?[dz]?)|\d\d:\d\d(?::\d\d(?:[.:]\d\d\d)?)?[uvt]?/,alias:"number"},number:/\b-?(?![01]:)(?:0[wn]|0W[hj]?|0N[hje]?|0x[\da-fA-F]+|\d+\.?\d*(?:e[+-]?\d+)?[hjfeb]?)/,keyword:/\\\w+\b|\b(?:abs|acos|aj0?|all|and|any|asc|asin|asof|atan|attr|avgs?|binr?|by|ceiling|cols|cor|cos|count|cov|cross|csv|cut|delete|deltas|desc|dev|differ|distinct|div|do|dsave|ej|enlist|eval|except|exec|exit|exp|fby|fills|first|fkeys|flip|floor|from|get|getenv|group|gtime|hclose|hcount|hdel|hopen|hsym|iasc|identity|idesc|if|ij|in|insert|inter|inv|keys?|last|like|list|ljf?|load|log|lower|lsq|ltime|ltrim|mavg|maxs?|mcount|md5|mdev|med|meta|mins?|mmax|mmin|mmu|mod|msum|neg|next|not|null|or|over|parse|peach|pj|plist|prds?|prev|prior|rand|rank|ratios|raze|read0|read1|reciprocal|reval|reverse|rload|rotate|rsave|rtrim|save|scan|scov|sdev|select|set|setenv|show|signum|sin|sqrt|ssr?|string|sublist|sums?|sv|svar|system|tables|tan|til|trim|txf|type|uj|ungroup|union|update|upper|upsert|value|var|views?|vs|wavg|where|while|within|wj1?|wsum|ww|xasc|xbar|xcols?|xdesc|xexp|xgroup|xkey|xlog|xprev|xrank)\b/,adverb:{pattern:/['\/\\]:?|\beach\b/,alias:"function"},verb:{pattern:/(?:\B\.\B|\b[01]:|<>|[<>]=?|:|[+\-*%,!?_~=|$&#@^']):?/,alias:"operator"},punctuation:/[(){}\[\];.]/}; \ No newline at end of file +Prism.languages.q={string:/"(?:\\.|[^"\\\r\n])*"/,comment:[{pattern:/([\t )\]}])\/.*/,lookbehind:!0},{pattern:/(^|\r?\n|\r)\/[\t ]*(?:(?:\r?\n|\r)(?:.*(?:\r?\n|\r))*?(?:\\(?=[\t ]*(?:\r?\n|\r))|$)|\S.*)/,lookbehind:!0},/^\\[\t ]*(?:\r?\n|\r)[\s\S]+/m,/^#!.+/m],symbol:/`(?::\S+|[\w.]*)/,datetime:{pattern:/0N[mdzuvt]|0W[dtz]|\d{4}\.\d\d(?:m|\.\d\d(?:T(?:\d\d(?::\d\d(?::\d\d(?:[.:]\d\d\d)?)?)?)?)?[dz]?)|\d\d:\d\d(?::\d\d(?:[.:]\d\d\d)?)?[uvt]?/,alias:"number"},number:/\b-?(?![01]:)(?:0[wn]|0W[hj]?|0N[hje]?|0x[\da-fA-F]+|\d+\.?\d*(?:e[+-]?\d+)?[hjfeb]?)/,keyword:/\\\w+\b|\b(?:abs|acos|aj0?|all|and|any|asc|asin|asof|atan|attr|avgs?|binr?|by|ceiling|cols|cor|cos|count|cov|cross|csv|cut|delete|deltas|desc|dev|differ|distinct|div|do|dsave|ej|enlist|eval|except|exec|exit|exp|fby|fills|first|fkeys|flip|floor|from|get|getenv|group|gtime|hclose|hcount|hdel|hopen|hsym|iasc|identity|idesc|if|ij|in|insert|inter|inv|keys?|last|like|list|ljf?|load|log|lower|lsq|ltime|ltrim|mavg|maxs?|mcount|md5|mdev|med|meta|mins?|mmax|mmin|mmu|mod|msum|neg|next|not|null|or|over|parse|peach|pj|plist|prds?|prev|prior|rand|rank|ratios|raze|read0|read1|reciprocal|reval|reverse|rload|rotate|rsave|rtrim|save|scan|scov|sdev|select|set|setenv|show|signum|sin|sqrt|ssr?|string|sublist|sums?|sv|svar|system|tables|tan|til|trim|txf|type|uj|ungroup|union|update|upper|upsert|value|var|views?|vs|wavg|where|while|within|wj1?|wsum|ww|xasc|xbar|xcols?|xdesc|xexp|xgroup|xkey|xlog|xprev|xrank)\b/,adverb:{pattern:/['\/\\]:?|\beach\b/,alias:"function"},verb:{pattern:/(?:\B\.\B|\b[01]:|<[=>]?|>=?|[:+\-*%,!?_~=|$&#@^]):?/,alias:"operator"},punctuation:/[(){}\[\];.]/}; \ No newline at end of file diff --git a/examples/prism-q.html b/examples/prism-q.html index 81046b5071..a22d557c96 100644 --- a/examples/prism-q.html +++ b/examples/prism-q.html @@ -2,7 +2,18 @@

Q (kdb+ database)

To use this language, use the class "language-q".

Comments

-
foo / This is a comment
+
foo / This is a comment
+/ This is a comment too
+
+/
+Some multi-line
+comment here
+\
+
+\
+This comment will
+continue until the
+end of code

Character data and strings

"q"

From 42f81d8593ab6372ace754d0763a8ff5d183c4b2 Mon Sep 17 00:00:00 2001
From: Golmote 
Date: Tue, 8 Sep 2015 09:04:16 +0200
Subject: [PATCH 3/3] Add tests for Q

---
 tests/languages/q/adverb_feature.test   |  17 ++
 tests/languages/q/comment_feature.test  |  24 ++
 tests/languages/q/datetime_feature.test |  39 +++
 tests/languages/q/keyword_feature.test  | 371 ++++++++++++++++++++++++
 tests/languages/q/number_feature.test   |  33 +++
 tests/languages/q/string_feature.test   |  13 +
 tests/languages/q/symbol_feature.test   |  17 ++
 tests/languages/q/verb_feature.test     |  35 +++
 8 files changed, 549 insertions(+)
 create mode 100644 tests/languages/q/adverb_feature.test
 create mode 100644 tests/languages/q/comment_feature.test
 create mode 100644 tests/languages/q/datetime_feature.test
 create mode 100644 tests/languages/q/keyword_feature.test
 create mode 100644 tests/languages/q/number_feature.test
 create mode 100644 tests/languages/q/string_feature.test
 create mode 100644 tests/languages/q/symbol_feature.test
 create mode 100644 tests/languages/q/verb_feature.test

diff --git a/tests/languages/q/adverb_feature.test b/tests/languages/q/adverb_feature.test
new file mode 100644
index 0000000000..a3fc6e318d
--- /dev/null
+++ b/tests/languages/q/adverb_feature.test
@@ -0,0 +1,17 @@
+' ':
++/ +/:
+\ \:
+each
+
+----------------------------------------------------
+
+[
+	["adverb", "'"], ["adverb", "':"],
+	["verb", "+"], ["adverb", "/"], ["verb", "+"], ["adverb", "/:"],
+	["adverb", "\\"], ["adverb", "\\:"],
+	["adverb", "each"]
+]
+
+----------------------------------------------------
+
+Checks for adverbs.
\ No newline at end of file
diff --git a/tests/languages/q/comment_feature.test b/tests/languages/q/comment_feature.test
new file mode 100644
index 0000000000..2f260e4e65
--- /dev/null
+++ b/tests/languages/q/comment_feature.test
@@ -0,0 +1,24 @@
+#!/usr/bin/env q
+/ Foobar
+
+/
+Foo
+bar
+\
+
+\
+Foo
+Bar
+
+----------------------------------------------------
+
+[
+	["comment", "#!/usr/bin/env q"],
+	["comment", "/ Foobar"],
+	["comment", "/\r\nFoo\r\nbar\r\n\\"],
+	["comment", "\\\r\nFoo\r\nBar"]
+]
+
+----------------------------------------------------
+
+Checks for comments.
\ No newline at end of file
diff --git a/tests/languages/q/datetime_feature.test b/tests/languages/q/datetime_feature.test
new file mode 100644
index 0000000000..92fe28c53f
--- /dev/null
+++ b/tests/languages/q/datetime_feature.test
@@ -0,0 +1,39 @@
+0Nm 0Nd 0Nz 0Nu 0Nv 0Nt
+0Wd 0Wt 0Wz
+
+2015.09m
+2015.09.08
+2015.09.08d
+2015.09.08z
+2015.09.08T08:25:32
+2015.09.08T08:25:32.000
+08:25
+08:25u
+08:25v
+08:25t
+08:25:32
+08:25:32:000
+
+----------------------------------------------------
+
+[
+	["datetime", "0Nm"], ["datetime", "0Nd"], ["datetime", "0Nz"], ["datetime", "0Nu"], ["datetime", "0Nv"], ["datetime", "0Nt"],
+	["datetime", "0Wd"], ["datetime", "0Wt"], ["datetime", "0Wz"],
+
+	["datetime", "2015.09m"],
+	["datetime", "2015.09.08"],
+	["datetime", "2015.09.08d"],
+	["datetime", "2015.09.08z"],
+	["datetime", "2015.09.08T08:25:32"],
+	["datetime", "2015.09.08T08:25:32.000"],
+	["datetime", "08:25"],
+	["datetime", "08:25u"],
+	["datetime", "08:25v"],
+	["datetime", "08:25t"],
+	["datetime", "08:25:32"],
+	["datetime", "08:25:32:000"]
+]
+
+----------------------------------------------------
+
+Checks for dates, times and datetimes.
\ No newline at end of file
diff --git a/tests/languages/q/keyword_feature.test b/tests/languages/q/keyword_feature.test
new file mode 100644
index 0000000000..4851408e91
--- /dev/null
+++ b/tests/languages/q/keyword_feature.test
@@ -0,0 +1,371 @@
+\foo
+\foo_bar_42
+
+abs
+acos
+aj
+aj0
+all
+and
+any
+asc
+asin
+asof
+atan
+attr
+avg
+avgs
+bin
+binr
+by
+ceiling
+cols
+cor
+cos
+count
+cov
+cross
+csv
+cut
+delete
+deltas
+desc
+dev
+differ
+distinct
+div
+do
+dsave
+ej
+enlist
+eval
+except
+exec
+exit
+exp
+fby
+fills
+first
+fkeys
+flip
+floor
+from
+get
+getenv
+group
+gtime
+hclose
+hcount
+hdel
+hopen
+hsym
+iasc
+identity
+idesc
+if
+ij
+in
+insert
+inter
+inv
+key
+keys
+last
+like
+list
+lj
+ljf
+load
+log
+lower
+lsq
+ltime
+ltrim
+mavg
+max
+maxs
+mcount
+md5
+mdev
+med
+meta
+min
+mins
+mmax
+mmin
+mmu
+mod
+msum
+neg
+next
+not
+null
+or
+over
+parse
+peach
+pj
+plist
+prd
+prds
+prev
+prior
+rand
+rank
+ratios
+raze
+read0
+read1
+reciprocal
+reval
+reverse
+rload
+rotate
+rsave
+rtrim
+save
+scan
+scov
+sdev
+select
+set
+setenv
+show
+signum
+sin
+sqrt
+ss
+ssr
+string
+sublist
+sum
+sums
+sv
+svar
+system
+tables
+tan
+til
+trim
+txf
+type
+uj
+ungroup
+union
+update
+upper
+upsert
+value
+var
+view
+views
+vs
+wavg
+where
+while
+within
+wj
+wj1
+wsum
+ww
+xasc
+xbar
+xcol
+xcols
+xdesc
+xexp
+xgroup
+xkey
+xlog
+xprev
+xrank
+
+----------------------------------------------------
+
+[
+	["keyword", "\\foo"],
+	["keyword", "\\foo_bar_42"],
+
+	["keyword", "abs"],
+	["keyword", "acos"],
+	["keyword", "aj"],
+	["keyword", "aj0"],
+	["keyword", "all"],
+	["keyword", "and"],
+	["keyword", "any"],
+	["keyword", "asc"],
+	["keyword", "asin"],
+	["keyword", "asof"],
+	["keyword", "atan"],
+	["keyword", "attr"],
+	["keyword", "avg"],
+	["keyword", "avgs"],
+	["keyword", "bin"],
+	["keyword", "binr"],
+	["keyword", "by"],
+	["keyword", "ceiling"],
+	["keyword", "cols"],
+	["keyword", "cor"],
+	["keyword", "cos"],
+	["keyword", "count"],
+	["keyword", "cov"],
+	["keyword", "cross"],
+	["keyword", "csv"],
+	["keyword", "cut"],
+	["keyword", "delete"],
+	["keyword", "deltas"],
+	["keyword", "desc"],
+	["keyword", "dev"],
+	["keyword", "differ"],
+	["keyword", "distinct"],
+	["keyword", "div"],
+	["keyword", "do"],
+	["keyword", "dsave"],
+	["keyword", "ej"],
+	["keyword", "enlist"],
+	["keyword", "eval"],
+	["keyword", "except"],
+	["keyword", "exec"],
+	["keyword", "exit"],
+	["keyword", "exp"],
+	["keyword", "fby"],
+	["keyword", "fills"],
+	["keyword", "first"],
+	["keyword", "fkeys"],
+	["keyword", "flip"],
+	["keyword", "floor"],
+	["keyword", "from"],
+	["keyword", "get"],
+	["keyword", "getenv"],
+	["keyword", "group"],
+	["keyword", "gtime"],
+	["keyword", "hclose"],
+	["keyword", "hcount"],
+	["keyword", "hdel"],
+	["keyword", "hopen"],
+	["keyword", "hsym"],
+	["keyword", "iasc"],
+	["keyword", "identity"],
+	["keyword", "idesc"],
+	["keyword", "if"],
+	["keyword", "ij"],
+	["keyword", "in"],
+	["keyword", "insert"],
+	["keyword", "inter"],
+	["keyword", "inv"],
+	["keyword", "key"],
+	["keyword", "keys"],
+	["keyword", "last"],
+	["keyword", "like"],
+	["keyword", "list"],
+	["keyword", "lj"],
+	["keyword", "ljf"],
+	["keyword", "load"],
+	["keyword", "log"],
+	["keyword", "lower"],
+	["keyword", "lsq"],
+	["keyword", "ltime"],
+	["keyword", "ltrim"],
+	["keyword", "mavg"],
+	["keyword", "max"],
+	["keyword", "maxs"],
+	["keyword", "mcount"],
+	["keyword", "md5"],
+	["keyword", "mdev"],
+	["keyword", "med"],
+	["keyword", "meta"],
+	["keyword", "min"],
+	["keyword", "mins"],
+	["keyword", "mmax"],
+	["keyword", "mmin"],
+	["keyword", "mmu"],
+	["keyword", "mod"],
+	["keyword", "msum"],
+	["keyword", "neg"],
+	["keyword", "next"],
+	["keyword", "not"],
+	["keyword", "null"],
+	["keyword", "or"],
+	["keyword", "over"],
+	["keyword", "parse"],
+	["keyword", "peach"],
+	["keyword", "pj"],
+	["keyword", "plist"],
+	["keyword", "prd"],
+	["keyword", "prds"],
+	["keyword", "prev"],
+	["keyword", "prior"],
+	["keyword", "rand"],
+	["keyword", "rank"],
+	["keyword", "ratios"],
+	["keyword", "raze"],
+	["keyword", "read0"],
+	["keyword", "read1"],
+	["keyword", "reciprocal"],
+	["keyword", "reval"],
+	["keyword", "reverse"],
+	["keyword", "rload"],
+	["keyword", "rotate"],
+	["keyword", "rsave"],
+	["keyword", "rtrim"],
+	["keyword", "save"],
+	["keyword", "scan"],
+	["keyword", "scov"],
+	["keyword", "sdev"],
+	["keyword", "select"],
+	["keyword", "set"],
+	["keyword", "setenv"],
+	["keyword", "show"],
+	["keyword", "signum"],
+	["keyword", "sin"],
+	["keyword", "sqrt"],
+	["keyword", "ss"],
+	["keyword", "ssr"],
+	["keyword", "string"],
+	["keyword", "sublist"],
+	["keyword", "sum"],
+	["keyword", "sums"],
+	["keyword", "sv"],
+	["keyword", "svar"],
+	["keyword", "system"],
+	["keyword", "tables"],
+	["keyword", "tan"],
+	["keyword", "til"],
+	["keyword", "trim"],
+	["keyword", "txf"],
+	["keyword", "type"],
+	["keyword", "uj"],
+	["keyword", "ungroup"],
+	["keyword", "union"],
+	["keyword", "update"],
+	["keyword", "upper"],
+	["keyword", "upsert"],
+	["keyword", "value"],
+	["keyword", "var"],
+	["keyword", "view"],
+	["keyword", "views"],
+	["keyword", "vs"],
+	["keyword", "wavg"],
+	["keyword", "where"],
+	["keyword", "while"],
+	["keyword", "within"],
+	["keyword", "wj"],
+	["keyword", "wj1"],
+	["keyword", "wsum"],
+	["keyword", "ww"],
+	["keyword", "xasc"],
+	["keyword", "xbar"],
+	["keyword", "xcol"],
+	["keyword", "xcols"],
+	["keyword", "xdesc"],
+	["keyword", "xexp"],
+	["keyword", "xgroup"],
+	["keyword", "xkey"],
+	["keyword", "xlog"],
+	["keyword", "xprev"],
+	["keyword", "xrank"]
+]
+
+----------------------------------------------------
+
+Checks for keywords.
\ No newline at end of file
diff --git a/tests/languages/q/number_feature.test b/tests/languages/q/number_feature.test
new file mode 100644
index 0000000000..4ddf9e5eca
--- /dev/null
+++ b/tests/languages/q/number_feature.test
@@ -0,0 +1,33 @@
+0w 0n
+0W 0Wh 0Wj
+0N 0Nh 0Nj 0Ne
+
+0xBadFace
+42
+3.14159
+3e8
+0.4e-7
+3.12e+42
+42h 42j 42f
+4.00e 1b
+
+----------------------------------------------------
+
+[
+	["number", "0w"], ["number", "0n"],
+	["number", "0W"], ["number", "0Wh"], ["number", "0Wj"],
+	["number", "0N"], ["number", "0Nh"], ["number", "0Nj"], ["number", "0Ne"],
+
+	["number", "0xBadFace"],
+	["number", "42"],
+	["number", "3.14159"],
+	["number", "3e8"],
+	["number", "0.4e-7"],
+	["number", "3.12e+42"],
+	["number", "42h"], ["number", "42j"], ["number", "42f"],
+	["number", "4.00e"], ["number", "1b"]
+]
+
+----------------------------------------------------
+
+Checks for numbers.
\ No newline at end of file
diff --git a/tests/languages/q/string_feature.test b/tests/languages/q/string_feature.test
new file mode 100644
index 0000000000..7a9309d9ef
--- /dev/null
+++ b/tests/languages/q/string_feature.test
@@ -0,0 +1,13 @@
+""
+"Fo\"obar"
+
+----------------------------------------------------
+
+[
+	["string", "\"\""],
+	["string", "\"Fo\\\"obar\""]
+]
+
+----------------------------------------------------
+
+Checks for strings.
\ No newline at end of file
diff --git a/tests/languages/q/symbol_feature.test b/tests/languages/q/symbol_feature.test
new file mode 100644
index 0000000000..0a86fb9c76
--- /dev/null
+++ b/tests/languages/q/symbol_feature.test
@@ -0,0 +1,17 @@
+`
+`foobar
+`:www.example.com:8888
+`.foo
+
+----------------------------------------------------
+
+[
+	["symbol", "`"],
+	["symbol", "`foobar"],
+	["symbol", "`:www.example.com:8888"],
+	["symbol", "`.foo"]
+]
+
+----------------------------------------------------
+
+Checks for symbols.
\ No newline at end of file
diff --git a/tests/languages/q/verb_feature.test b/tests/languages/q/verb_feature.test
new file mode 100644
index 0000000000..d8bbca6118
--- /dev/null
+++ b/tests/languages/q/verb_feature.test
@@ -0,0 +1,35 @@
+. .:
+0: 1:
+< <: <> <>: <= <=:
+> >: >= >=:
+: ::
++ +: - -:
+* *: % %:
+, ,: ! !:
+? ?: _ _:
+~ ~: = =:
+| |: $ $:
+& &: # #:
+@ @: ^ ^:
+
+----------------------------------------------------
+
+[
+	["verb", "."], ["verb", ".:"],
+	["verb", "0:"], ["verb", "1:"],
+	["verb", "<"], ["verb", "<:"], ["verb", "<>"], ["verb", "<>:"], ["verb", "<="], ["verb", "<=:"],
+	["verb", ">"], ["verb", ">:"], ["verb", ">="], ["verb", ">=:"],
+	["verb", ":"], ["verb", "::"],
+	["verb", "+"], ["verb", "+:"], ["verb", "-"], ["verb", "-:"],
+	["verb", "*"], ["verb", "*:"], ["verb", "%"], ["verb", "%:"],
+	["verb", ","], ["verb", ",:"], ["verb", "!"], ["verb", "!:"],
+	["verb", "?"], ["verb", "?:"], ["verb", "_"], ["verb", "_:"],
+	["verb", "~"], ["verb", "~:"], ["verb", "="], ["verb", "=:"],
+	["verb", "|"], ["verb", "|:"], ["verb", "$"], ["verb", "$:"],
+	["verb", "&"], ["verb", "&:"], ["verb", "#"], ["verb", "#:"],
+	["verb", "@"], ["verb", "@:"], ["verb", "^"], ["verb", "^:"]
+]
+
+----------------------------------------------------
+
+Checks for verbs.
\ No newline at end of file