abc_highlight_rules.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* This file was partially autogenerated from https://github.com/jimhawkridge/SublimeABC
  2. Modifications
  3. - more classes to express the abc semantic
  4. - added syntax highlighting for Zupfnoter conventions (https://github.com/bwl21/zupfnoter)
  5. - separate note pitch and note duration - even if it looks the same
  6. ***********************************************************************************************/
  7. define(function (require, exports, module) {
  8. "use strict";
  9. var oop = require("../lib/oop");
  10. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  11. var ABCHighlightRules = function () {
  12. // regexp must not have capturing parentheses. Use (?:) instead.
  13. // regexps are ordered -> the first match is used
  14. this.$rules = {
  15. start: [
  16. {
  17. token: ['zupfnoter.information.comment.line.percentage', 'information.keyword', 'in formation.keyword.embedded'],
  18. regex: '(%%%%)(hn\\.[a-z]*)(.*)',
  19. comment: 'Instruction Comment'
  20. },
  21. {
  22. token: ['information.comment.line.percentage', 'information.keyword.embedded'],
  23. regex: '(%%)(.*)',
  24. comment: 'Instruction Comment'
  25. },
  26. {
  27. token: 'comment.line.percentage',
  28. regex: '%.*',
  29. comment: 'Comments'
  30. },
  31. {
  32. token: 'barline.keyword.operator',
  33. regex: '[\\[:]*[|:][|\\]:]*(?:\\[?[0-9]+)?|\\[[0-9]+',
  34. comment: 'Bar lines'
  35. },
  36. {
  37. token: ['information.keyword.embedded', 'information.argument.string.unquoted'],
  38. regex: '(\\[[A-Za-z]:)([^\\]]*\\])',
  39. comment: 'embedded Header lines'
  40. },
  41. {
  42. token: ['information.keyword', 'information.argument.string.unquoted'],
  43. regex: '^([A-Za-z]:)([^%\\\\]*)',
  44. comment: 'Header lines'
  45. },
  46. {
  47. token: ['text', 'entity.name.function', 'string.unquoted', 'text'],
  48. regex: '(\\[)([A-Z]:)(.*?)(\\])',
  49. comment: 'Inline fields'
  50. },
  51. {
  52. token: ['accent.constant.language', 'pitch.constant.numeric', 'duration.constant.numeric'],
  53. regex: '([\\^=_]*)([A-Ga-gz][,\']*)([0-9]*/*[><0-9]*)',
  54. comment: 'Notes'
  55. },
  56. {
  57. token: 'zupfnoter.jumptarget.string.quoted',
  58. regex: '[\\"!]\\^\\:.*?[\\"!]',
  59. comment: 'Zupfnoter jumptarget'
  60. }, {
  61. token: 'zupfnoter.goto.string.quoted',
  62. regex: '[\\"!]\\^\\@.*?[\\"!]',
  63. comment: 'Zupfnoter goto'
  64. },
  65. {
  66. token: 'zupfnoter.annotation.string.quoted',
  67. regex: '[\\"!]\\^\\!.*?[\\"!]',
  68. comment: 'Zupfnoter annoation'
  69. },
  70. {
  71. token: 'zupfnoter.annotationref.string.quoted',
  72. regex: '[\\"!]\\^\\#.*?[\\"!]',
  73. comment: 'Zupfnoter annotation reference'
  74. },
  75. {
  76. token: 'chordname.string.quoted',
  77. regex: '[\\"!]\\^.*?[\\"!]',
  78. comment: 'abc chord'
  79. },
  80. {
  81. token: 'string.quoted',
  82. regex: '[\\"!].*?[\\"!]',
  83. comment: 'abc annotation'
  84. }
  85. ]
  86. };
  87. // this.embedRules(JsonHighlightRules, "json-")
  88. this.normalizeRules();
  89. };
  90. ABCHighlightRules.metaData = {
  91. fileTypes: ['abc'],
  92. name: 'ABC',
  93. scopeName: 'text.abcnotation'
  94. };
  95. oop.inherits(ABCHighlightRules, TextHighlightRules);
  96. exports.ABCHighlightRules = ABCHighlightRules;
  97. });