Q: Make comments greedy. Update known failures and tests.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
diff --git a/components/prism-q.js b/components/prism-q.js
index 7815956..985b7a5 100644
--- a/components/prism-q.js
+++ b/components/prism-q.js
@@ -6,7 +6,8 @@ Prism.languages.q = {
{
pattern: /([\t )\]}])\/.*/,
- lookbehind: true
+ lookbehind: true,
+ greedy: 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.
@@ -15,13 +16,19 @@ Prism.languages.q = {
// 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
+ lookbehind: true,
+ greedy: 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
+ {
+ pattern: /^\\[\t ]*(?:\r?\n|\r)[\s\S]+/m,
+ greedy: true
+ },
+ {
+ pattern: /^#!.+/m,
+ greedy: true
+ }
],
'symbol': /`(?::\S+|[\w.]*)/,
'datetime': {
diff --git a/components/prism-q.min.js b/components/prism-q.min.js
index 2490258..308eac8 100644
--- a/components/prism-q.min.js
+++ b/components/prism-q.min.js
@@ -1 +1 @@
-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
+Prism.languages.q={string:/"(?:\\.|[^"\\\r\n])*"/,comment:[{pattern:/([\t )\]}])\/.*/,lookbehind:!0,greedy:!0},{pattern:/(^|\r?\n|\r)\/[\t ]*(?:(?:\r?\n|\r)(?:.*(?:\r?\n|\r))*?(?:\\(?=[\t ]*(?:\r?\n|\r))|$)|\S.*)/,lookbehind:!0,greedy:!0},{pattern:/^\\[\t ]*(?:\r?\n|\r)[\s\S]+/m,greedy:!0},{pattern:/^#!.+/m,greedy:!0}],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 7a0e7b3..58d674f 100644
--- a/examples/prism-q.html
+++ b/examples/prism-q.html
@@ -108,8 +108,5 @@ adjust[t;`dividend] / adjust trades for dividends only</code></pre>
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.
</p>
-<h3>Two double quotes in a comment</h3>
-<pre><code>/ This "comment" is broken</code></pre>
-
<h3>The global context is highlighted as a verb</h3>
<pre><code>\d .</code></pre>
\ No newline at end of file
diff --git a/tests/languages/q/comment_feature.test b/tests/languages/q/comment_feature.test
index 2f260e4..c78bb33 100644
--- a/tests/languages/q/comment_feature.test
+++ b/tests/languages/q/comment_feature.test
@@ -1,22 +1,22 @@
#!/usr/bin/env q
-/ Foobar
+/ Foobar "baz"
/
Foo
-bar
+bar "baz"
\
\
Foo
-Bar
+Bar "baz"
----------------------------------------------------
[
["comment", "#!/usr/bin/env q"],
- ["comment", "/ Foobar"],
- ["comment", "/\r\nFoo\r\nbar\r\n\\"],
- ["comment", "\\\r\nFoo\r\nBar"]
+ ["comment", "/ Foobar \"baz\""],
+ ["comment", "/\r\nFoo\r\nbar \"baz\"\r\n\\"],
+ ["comment", "\\\r\nFoo\r\nBar \"baz\""]
]
----------------------------------------------------