[d24f17c] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | module.exports = powerquery
|
---|
| 4 | powerquery.displayName = 'powerquery'
|
---|
| 5 | powerquery.aliases = []
|
---|
| 6 | function powerquery(Prism) {
|
---|
| 7 | // https://docs.microsoft.com/en-us/powerquery-m/power-query-m-language-specification
|
---|
| 8 | Prism.languages.powerquery = {
|
---|
| 9 | comment: {
|
---|
| 10 | pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
|
---|
| 11 | lookbehind: true,
|
---|
| 12 | greedy: true
|
---|
| 13 | },
|
---|
| 14 | 'quoted-identifier': {
|
---|
| 15 | pattern: /#"(?:[^"\r\n]|"")*"(?!")/,
|
---|
| 16 | greedy: true
|
---|
| 17 | },
|
---|
| 18 | string: {
|
---|
| 19 | pattern: /(?:#!)?"(?:[^"\r\n]|"")*"(?!")/,
|
---|
| 20 | greedy: true
|
---|
| 21 | },
|
---|
| 22 | constant: [
|
---|
| 23 | /\bDay\.(?:Friday|Monday|Saturday|Sunday|Thursday|Tuesday|Wednesday)\b/,
|
---|
| 24 | /\bTraceLevel\.(?:Critical|Error|Information|Verbose|Warning)\b/,
|
---|
| 25 | /\bOccurrence\.(?:All|First|Last)\b/,
|
---|
| 26 | /\bOrder\.(?:Ascending|Descending)\b/,
|
---|
| 27 | /\bRoundingMode\.(?:AwayFromZero|Down|ToEven|TowardZero|Up)\b/,
|
---|
| 28 | /\bMissingField\.(?:Error|Ignore|UseNull)\b/,
|
---|
| 29 | /\bQuoteStyle\.(?:Csv|None)\b/,
|
---|
| 30 | /\bJoinKind\.(?:FullOuter|Inner|LeftAnti|LeftOuter|RightAnti|RightOuter)\b/,
|
---|
| 31 | /\bGroupKind\.(?:Global|Local)\b/,
|
---|
| 32 | /\bExtraValues\.(?:Error|Ignore|List)\b/,
|
---|
| 33 | /\bJoinAlgorithm\.(?:Dynamic|LeftHash|LeftIndex|PairwiseHash|RightHash|RightIndex|SortMerge)\b/,
|
---|
| 34 | /\bJoinSide\.(?:Left|Right)\b/,
|
---|
| 35 | /\bPrecision\.(?:Decimal|Double)\b/,
|
---|
| 36 | /\bRelativePosition\.From(?:End|Start)\b/,
|
---|
| 37 | /\bTextEncoding\.(?:Ascii|BigEndianUnicode|Unicode|Utf16|Utf8|Windows)\b/,
|
---|
| 38 | /\b(?:Any|Binary|Date|DateTime|DateTimeZone|Duration|Function|Int16|Int32|Int64|Int8|List|Logical|None|Number|Record|Table|Text|Time)\.Type\b/,
|
---|
| 39 | /\bnull\b/
|
---|
| 40 | ],
|
---|
| 41 | boolean: /\b(?:false|true)\b/,
|
---|
| 42 | keyword:
|
---|
| 43 | /\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/,
|
---|
| 44 | function: {
|
---|
| 45 | pattern: /(^|[^#\w.])[a-z_][\w.]*(?=\s*\()/i,
|
---|
| 46 | lookbehind: true
|
---|
| 47 | },
|
---|
| 48 | 'data-type': {
|
---|
| 49 | pattern:
|
---|
| 50 | /\b(?:any|anynonnull|binary|date|datetime|datetimezone|duration|function|list|logical|none|number|record|table|text|time)\b/,
|
---|
| 51 | alias: 'class-name'
|
---|
| 52 | },
|
---|
| 53 | number: {
|
---|
| 54 | pattern:
|
---|
| 55 | /\b0x[\da-f]+\b|(?:[+-]?(?:\b\d+\.)?\b\d+|[+-]\.\d+|(^|[^.])\B\.\d+)(?:e[+-]?\d+)?\b/i,
|
---|
| 56 | lookbehind: true
|
---|
| 57 | },
|
---|
| 58 | operator: /[-+*\/&?@^]|<(?:=>?|>)?|>=?|=>?|\.\.\.?/,
|
---|
| 59 | punctuation: /[,;\[\](){}]/
|
---|
| 60 | }
|
---|
| 61 | Prism.languages.pq = Prism.languages['powerquery']
|
---|
| 62 | Prism.languages.mscript = Prism.languages['powerquery']
|
---|
| 63 | }
|
---|