pascal_highlight_rules.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Distributed under the BSD license:
  3. *
  4. * Copyright (c) 2012, Ajax.org B.V.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * * Neither the name of Ajax.org B.V. nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. * ***** END LICENSE BLOCK ***** */
  30. /* THIS FILE WAS AUTOGENERATED FROM tool\tm bundles\pascal.tmbundle\Syntaxes\Pascal.plist (UUID: F42FA544-6B1C-11D9-9517-000D93589AF6) */
  31. /****************************************************************
  32. * IT MIGHT NOT BE PERFECT, PARTICULARLY: *
  33. * IN DECIDING STATES TO TRANSITION TO, *
  34. * IGNORING WHITESPACE, *
  35. * IGNORING GROUPS WITH ?:, *
  36. * EXTENDING EXISTING MODES, *
  37. * GATHERING KEYWORDS, OR *
  38. * DECIDING WHEN TO USE PUSH. *
  39. * ...But it's a good start from an existing *.tmlanguage file. *
  40. ****************************************************************/
  41. define(function(require, exports, module) {
  42. "use strict";
  43. var oop = require("../lib/oop");
  44. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  45. var PascalHighlightRules = function() {
  46. // regexp must not have capturing parentheses. Use (?:) instead.
  47. // regexps are ordered -> the first match is used
  48. this.$rules = { start:
  49. [ { caseInsensitive: true,
  50. token: 'keyword.control.pascal',
  51. regex: '\\b(?:(absolute|abstract|all|and|and_then|array|as|asm|attribute|begin|bindable|case|class|const|constructor|destructor|div|do|do|else|end|except|export|exports|external|far|file|finalization|finally|for|forward|goto|if|implementation|import|in|inherited|initialization|interface|interrupt|is|label|library|mod|module|name|near|nil|not|object|of|only|operator|or|or_else|otherwise|packed|pow|private|program|property|protected|public|published|qualified|record|repeat|resident|restricted|segment|set|shl|shr|then|to|try|type|unit|until|uses|value|var|view|virtual|while|with|xor))\\b' },
  52. { caseInsensitive: true,
  53. token:
  54. [ 'variable.pascal', "text",
  55. 'storage.type.prototype.pascal',
  56. 'entity.name.function.prototype.pascal' ],
  57. regex: '\\b(function|procedure)(\\s+)(\\w+)(\\.\\w+)?(?=(?:\\(.*?\\))?;\\s*(?:attribute|forward|external))' },
  58. { caseInsensitive: true,
  59. token:
  60. [ 'variable.pascal', "text",
  61. 'storage.type.function.pascal',
  62. 'entity.name.function.pascal' ],
  63. regex: '\\b(function|procedure)(\\s+)(\\w+)(\\.\\w+)?' },
  64. { token: 'constant.numeric.pascal',
  65. regex: '\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b' },
  66. { token: 'punctuation.definition.comment.pascal',
  67. regex: '--.*$',
  68. push_:
  69. [ { token: 'comment.line.double-dash.pascal.one',
  70. regex: '$',
  71. next: 'pop' },
  72. { defaultToken: 'comment.line.double-dash.pascal.one' } ] },
  73. { token: 'punctuation.definition.comment.pascal',
  74. regex: '//.*$',
  75. push_:
  76. [ { token: 'comment.line.double-slash.pascal.two',
  77. regex: '$',
  78. next: 'pop' },
  79. { defaultToken: 'comment.line.double-slash.pascal.two' } ] },
  80. { token: 'punctuation.definition.comment.pascal',
  81. regex: '\\(\\*',
  82. push:
  83. [ { token: 'punctuation.definition.comment.pascal',
  84. regex: '\\*\\)',
  85. next: 'pop' },
  86. { defaultToken: 'comment.block.pascal.one' } ] },
  87. { token: 'punctuation.definition.comment.pascal',
  88. regex: '\\{',
  89. push:
  90. [ { token: 'punctuation.definition.comment.pascal',
  91. regex: '\\}',
  92. next: 'pop' },
  93. { defaultToken: 'comment.block.pascal.two' } ] },
  94. { token: 'punctuation.definition.string.begin.pascal',
  95. regex: '"',
  96. push:
  97. [ { token: 'constant.character.escape.pascal', regex: '\\\\.' },
  98. { token: 'punctuation.definition.string.end.pascal',
  99. regex: '"',
  100. next: 'pop' },
  101. { defaultToken: 'string.quoted.double.pascal' } ],
  102. //Double quoted strings are an extension and (generally) support C-style escape sequences.
  103. },
  104. { token: 'punctuation.definition.string.begin.pascal',
  105. regex: '\'',
  106. push:
  107. [ { token: 'constant.character.escape.apostrophe.pascal',
  108. regex: '\'\'' },
  109. { token: 'punctuation.definition.string.end.pascal',
  110. regex: '\'',
  111. next: 'pop' },
  112. { defaultToken: 'string.quoted.single.pascal' } ] },
  113. { token: 'keyword.operator',
  114. regex: '[+\\-;,/*%]|:=|=' } ] }
  115. this.normalizeRules();
  116. };
  117. oop.inherits(PascalHighlightRules, TextHighlightRules);
  118. exports.PascalHighlightRules = PascalHighlightRules;
  119. });