textmate-grammar.rb 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. require "."
  2. # <- keyword.other.special-method
  3. class A::B < C
  4. # <- keyword.control.class
  5. # ^ entity.name.type.class
  6. # ^ punctuation.separator.namespace
  7. # ^ entity.name.type.class
  8. # ^ punctuation.separator.inheritance
  9. # ^ entity.other.inherited-class
  10. # ^ entity.name.type.class
  11. public
  12. # <- keyword.other.special-method
  13. protected
  14. # <- keyword.other.special-method
  15. private
  16. # <- keyword.other.special-method
  17. public def foo(a)
  18. # <- keyword.other.special-method
  19. # ^ keyword.control.def
  20. # ^ entity.name.function
  21. # ^ variable.parameter.function
  22. self
  23. # <- variable.language.self
  24. @b = a
  25. # <- variable.other.readwrite.instance
  26. # ^ keyword.operator.assignment
  27. # ^ source
  28. c = 10
  29. # <- source
  30. end
  31. end
  32. thing&.call
  33. # ^ punctuation.separator.method
  34. # ^ source
  35. VAR1 = 100
  36. # <- variable.other.constant
  37. # ^ keyword.operator.assignment
  38. # ^ constant.numeric
  39. _VAR1 = 100_000
  40. # <- variable.other.constant
  41. # ^ constant.numeric
  42. # This dot will not be tokenized as a separator
  43. 1.23
  44. #^ constant.numeric
  45. # But this will
  46. a.b
  47. #^ punctuation.separator.method
  48. # These are all also numbers:
  49. 1.23e-4
  50. # <- constant.numeric
  51. 0d100_000
  52. # <- constant.numeric
  53. 0xAFFF
  54. # <- constant.numeric
  55. 0XA_FFF
  56. # <- constant.numeric
  57. 01_777
  58. # <- constant.numeric
  59. 0o1_777
  60. # <- constant.numeric
  61. 0b100_000
  62. # <- constant.numeric
  63. 0B00100
  64. # <- constant.numeric
  65. :test
  66. # <- constant.other.symbol
  67. :$symbol
  68. # <- constant.other.symbol
  69. :<=>
  70. # <- constant.other.symbol
  71. %i(foo)
  72. # <- punctuation.section.array.begin
  73. # ^ constant.other.symbol
  74. {foo: 1}
  75. # <- punctuation.section.scope.begin
  76. # ^ constant.other.symbol.hashkey
  77. # ^ punctuation.definition.constant.hashkey
  78. {:foo => 1}
  79. # <- punctuation.section.scope.begin
  80. # ^ constant.other.symbol.hashkey
  81. # ^ punctuation.separator.key-value
  82. # ^ punctuation.section.scope.end
  83. a { |x| x }
  84. # ^ punctuation.section.scope.begin.ruby
  85. # ^ punctuation.separator.variable
  86. # ^ punctuation.separator.variable
  87. # ^ punctuation.section.scope.end
  88. class << A::B
  89. # <- keyword.control.class
  90. # ^ punctuation.definition.variable
  91. # ^ entity.name.type.class
  92. # ^ punctuation.separator.namespace
  93. end
  94. def a.b(*args)
  95. # <- meta.function.method.with-arguments
  96. # <- keyword.control.def
  97. # ^ entity.name.function
  98. # ^ entity.name.function
  99. # ^ punctuation.separator.method
  100. # ^ meta.function.method.with-arguments
  101. # ^ punctuation.definition.parameters
  102. # ^ storage.type.variable
  103. # ^ variable.parameter.function
  104. # ^ punctuation.definition.parameters
  105. end
  106. # <- keyword.control
  107. # Strings.
  108. %(te(s)t)
  109. # <- punctuation.definition.string.begin
  110. # ^ string.quoted.other.interpolated
  111. # ^ punctuation.definition.string.end
  112. %[te[s]t]
  113. # <- punctuation.definition.string.begin
  114. # ^ string.quoted.other.interpolated
  115. # ^ punctuation.definition.string.end
  116. %{te{s}t}
  117. # <- punctuation.definition.string.begin
  118. # ^ string.quoted.other.interpolated
  119. # ^ punctuation.definition.string.end
  120. %<te<s>t>
  121. # <- punctuation.definition.string.begin
  122. # ^ string.quoted.other.interpolated
  123. # ^ punctuation.definition.string.end
  124. %~te\~s~
  125. # <- punctuation.definition.string.begin
  126. # ^ string.quoted.other.interpolated
  127. # ^ constant.character.escape
  128. # ^ constant.character.escape
  129. # ^ string.quoted.other.interpolated
  130. %Q(te(s)t)
  131. # <- punctuation.definition.string.begin
  132. # ^ string.quoted.other.interpolated
  133. # ^ string.quoted.other.interpolated
  134. # ^ punctuation.definition.string.end
  135. %x!#{"l" + "s"}!
  136. # <- punctuation.definition.string.begin
  137. # ^ punctuation.definition.string.begin
  138. # ^ punctuation.section.embedded.begin
  139. # ^ punctuation.section.embedded.begin
  140. # ^ punctuation.section.embedded.end
  141. # ^ punctuation.definition.string.end
  142. /test/
  143. # <- punctuation.section.regexp
  144. # ^ string.regexp.interpolated
  145. # ^ punctuation.section.regexp