prism-powerquery.js 2.2 KB

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