Skip to content

Commit

Permalink
Powerquery: Improved tokenization and use standard tokens correctly (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Dec 10, 2021
1 parent 59ef51d commit 5688f48
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
14 changes: 7 additions & 7 deletions components/prism-powerquery.js
Expand Up @@ -2,16 +2,16 @@

Prism.languages.powerquery = {
'comment': {
pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:\/\/).*)/,
lookbehind: true
pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
lookbehind: true,
greedy: true
},
'quoted-identifier': {
pattern: /#"(?:[^"\r\n]|"")*"(?!")/,
greedy: true,
alias: 'variable'
greedy: true
},
'string': {
pattern: /"(?:[^"\r\n]|"")*"(?!")/,
pattern: /(?:#!)?"(?:[^"\r\n]|"")*"(?!")/,
greedy: true
},
'constant': [
Expand All @@ -36,12 +36,12 @@ Prism.languages.powerquery = {
'boolean': /\b(?:false|true)\b/,
'keyword': /\b(?:and|as|each|else|error|if|in|is|let|meta|not|nullable|optional|or|otherwise|section|shared|then|try|type)\b|#(?:binary|date|datetime|datetimezone|duration|infinity|nan|sections|shared|table|time)\b/,
'function': {
pattern: /(^|[^#\w.])(?!\d)[\w.]+(?=\s*\()/,
pattern: /(^|[^#\w.])[a-z_][\w.]*(?=\s*\()/i,
lookbehind: true
},
'data-type': {
pattern: /\b(?:any|anynonnull|binary|date|datetime|datetimezone|duration|function|list|logical|none|number|record|table|text|time)\b/,
alias: 'variable'
alias: 'class-name'
},
'number': {
pattern: /\b0x[\da-f]+\b|(?:[+-]?(?:\b\d+\.)?\b\d+|[+-]\.\d+|(^|[^.])\B\.\d+)(?:e[+-]?\d+)?\b/i,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-powerquery.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions tests/languages/powerquery/string_feature.test
Expand Up @@ -2,14 +2,18 @@
"foo"
"foo""bar"

#!"Hello world#(cr,lf)"

----------------------------------------------------

[
["string", "\"\""],
["string", "\"foo\""],
["string", "\"foo\"\"bar\""]
["string", "\"foo\"\"bar\""],

["string", "#!\"Hello world#(cr,lf)\""]
]

----------------------------------------------------

Checks for strings.
Checks for strings.

0 comments on commit 5688f48

Please sign in to comment.