syntax_test_ruby.rb (53572B)
1 # SYNTAX TEST "Packages/Ruby/Ruby.sublime-syntax" 2 3 ################## 4 # block comments 5 ################## 6 7 =begin 8 #<- comment.block.documentation.ruby punctuation.definition.comment.begin.ruby 9 #^^^^^ comment.block.documentation.ruby punctuation.definition.comment.begin.ruby 10 =end 11 # ^^^^^ comment.block.documentation.ruby - punctuation 12 =end 13 #<- comment.block.documentation.ruby punctuation.definition.comment.end.ruby 14 #^^^ comment.block.documentation.ruby punctuation.definition.comment.end.ruby 15 16 ################## 17 # line comments 18 ################## 19 20 ## comment 21 #<- comment.line.number-sign.ruby punctuation.definition.comment.ruby 22 #^ comment.line.number-sign.ruby punctuation.definition.comment.ruby 23 # ^^^^^^^^ comment.line.number-sign.ruby - punctuation 24 25 ## comment 26 #^ - comment - punctuation 27 # ^^ comment.line.number-sign.ruby punctuation.definition.comment.ruby 28 # ^^^^^^^^^ comment.line.number-sign.ruby - punctuation 29 30 ################## 31 # Heredocs 32 ################## 33 34 # HEREDOC with indented end tag containing an interpolated string 35 puts <<~EOF; # comment 36 #^^^^ - meta.string - string.unquoted 37 # ^^^ meta.string.heredoc.ruby - meta.tag 38 # ^^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby 39 # ^^^ punctuation.definition.heredoc.ruby 40 # ^^^ entity.name.tag.ruby 41 # ^ punctuation.terminator.statement.ruby - meta.string - string 42 # ^ comment.line.number-sign.ruby punctuation.definition.comment.ruby - meta.string - string 43 Indented string! 44 # ^^^^^^^^^^^^^^^^^ meta.string.heredoc.ruby string.unquoted.heredoc.ruby 45 #{ sym } #@var 46 # ^ meta.string.heredoc.ruby string.unquoted.heredoc.ruby - meta.interpolation 47 # ^^^^^^^^ meta.string.heredoc.ruby meta.interpolation.ruby 48 # ^ meta.string.heredoc.ruby string.unquoted.heredoc.ruby - meta.interpolation 49 # ^^^^^ meta.string.heredoc.ruby meta.interpolation.ruby variable.other.readwrite.instance.ruby 50 # ^ meta.string.heredoc.ruby string.unquoted.heredoc.ruby - meta.interpolation 51 # ^^ punctuation.section.interpolation.begin.ruby 52 # ^^^^^ source.ruby.embedded.ruby 53 # ^ punctuation.section.interpolation.end.ruby 54 # ^^ punctuation.definition.variable.ruby 55 # ^^^^^ variable.other.readwrite.instance.ruby 56 EOF 57 # ^^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby entity.name.tag.ruby 58 # ^ - meta.string - string.unquoted 59 60 # HEREDOC with indented end tag containing a plain string 61 puts <<~'EOF'; # comment 62 #^^^^ - meta.string - string.unquoted 63 # ^^^ meta.string.heredoc.ruby - meta.tag 64 # ^^^^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby 65 # ^^^ punctuation.definition.heredoc.ruby 66 # ^ punctuation.definition.tag.begin.ruby 67 # ^^^ entity.name.tag.ruby 68 # ^ punctuation.definition.tag.end.ruby 69 # ^ punctuation.terminator.statement.ruby - meta.string - string 70 # ^ comment.line.number-sign.ruby punctuation.definition.comment.ruby - meta.string - string 71 Indented string! 72 # ^^^^^^^^^^^^^^^^^ meta.string.heredoc.ruby string.unquoted.heredoc.ruby 73 #{ sym } #@var 74 # ^^^^^^^^^^^^^^^^^ meta.string.heredoc.ruby string.unquoted.heredoc.ruby - meta.interpolation 75 EOF 76 # ^^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby entity.name.tag.ruby 77 # ^ - meta.string - string.unquoted 78 79 # HEREDOC with unindented end tag containing an interpolated string 80 puts <<EOF; # comment 81 #^^^^ - meta.string - string.unquoted 82 # ^^ meta.string.heredoc.ruby - meta.tag 83 # ^^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby 84 # ^^ punctuation.definition.heredoc.ruby 85 # ^^^ entity.name.tag.ruby 86 # ^ punctuation.terminator.statement.ruby - meta.string - string 87 # ^ comment.line.number-sign.ruby punctuation.definition.comment.ruby - meta.string - string 88 Indented string! 89 # ^^^^^^^^^^^^^^^^^ meta.string.heredoc.ruby string.unquoted.heredoc.ruby 90 #{ sym } #@var 91 # ^ meta.string.heredoc.ruby string.unquoted.heredoc.ruby - meta.interpolation 92 # ^^^^^^^^ meta.string.heredoc.ruby meta.interpolation.ruby 93 # ^ meta.string.heredoc.ruby string.unquoted.heredoc.ruby - meta.interpolation 94 # ^^^^^ meta.string.heredoc.ruby meta.interpolation.ruby variable.other.readwrite.instance.ruby 95 # ^ meta.string.heredoc.ruby string.unquoted.heredoc.ruby - meta.interpolation 96 # ^^ punctuation.section.interpolation.begin.ruby 97 # ^^^^^ source.ruby.embedded.ruby 98 # ^ punctuation.section.interpolation.end.ruby 99 # ^^ punctuation.definition.variable.ruby 100 # ^^^^^ variable.other.readwrite.instance.ruby 101 EOF 102 #^^^^^ meta.string.heredoc.ruby string.unquoted.heredoc.ruby 103 EOF 104 #^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby entity.name.tag.ruby 105 # ^ - meta.string - string.unquoted 106 107 # HEREDOC with unindented end tag containing a plain string 108 puts <<'EOF'; # comment 109 #^^^^ - meta.string - string.unquoted 110 # ^^ meta.string.heredoc.ruby - meta.tag 111 # ^^^^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby 112 # ^^ punctuation.definition.heredoc.ruby 113 # ^ punctuation.definition.tag.begin.ruby 114 # ^^^ entity.name.tag.ruby 115 # ^ punctuation.definition.tag.end.ruby 116 # ^ punctuation.terminator.statement.ruby - meta.string - string 117 # ^ comment.line.number-sign.ruby punctuation.definition.comment.ruby - meta.string - string 118 Indented string! 119 # ^^^^^^^^^^^^^^^^^ meta.string.heredoc.ruby string.unquoted.heredoc.ruby 120 #{ sym } #@var 121 # ^^^^^^^^^^^^^^^^^ meta.string.heredoc.ruby string.unquoted.heredoc.ruby - meta.interpolation 122 EOF 123 #^^^^^ meta.string.heredoc.ruby string.unquoted.heredoc.ruby 124 EOF 125 #^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby entity.name.tag.ruby 126 # ^ - meta.string - string.unquoted 127 128 puts <<-HTML; # comment 129 #^^^^ - meta.string - string.unquoted 130 # ^^^ meta.string.heredoc.ruby - meta.tag 131 # ^^^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby 132 # ^^^ punctuation.definition.heredoc.ruby 133 # ^^^^ entity.name.tag.ruby 134 # ^ punctuation.terminator.statement.ruby - meta.string 135 # ^ comment.line.number-sign.ruby punctuation.definition.comment.ruby - meta.string - string 136 <body> 137 # ^^^^^^ meta.string.heredoc.ruby text.html.embedded.ruby meta.tag.structure 138 #{ sym } #@var 139 # ^ meta.string.heredoc.ruby text.html.embedded.ruby - meta.interpolation 140 # ^^^^^^^^ meta.string.heredoc.ruby meta.interpolation.ruby 141 # ^ meta.string.heredoc.ruby text.html.embedded.ruby - meta.interpolation 142 # ^^^^^ meta.string.heredoc.ruby meta.interpolation.ruby variable.other.readwrite.instance.ruby 143 # ^ meta.string.heredoc.ruby text.html.embedded.ruby - meta.interpolation 144 # ^^ punctuation.section.interpolation.begin.ruby 145 # ^^^^^ source.ruby.embedded.ruby 146 # ^ punctuation.section.interpolation.end.ruby 147 # ^^ punctuation.definition.variable.ruby 148 # ^^^^^ variable.other.readwrite.instance.ruby 149 </body> 150 # ^^^^^^^ meta.string.heredoc.ruby text.html.embedded.ruby meta.tag.structure.any.html 151 HTML 152 # ^^^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby entity.name.tag.ruby 153 # ^ - meta.string - string.unquoted 154 155 class_eval <<-RUBY, __FILE__, __LINE__ + 1 156 def #{sym}(*args, &block) 157 # ^^^^ meta.string.heredoc.ruby - meta.interpolation 158 # ^^^^^^ meta.string.heredoc.ruby source.ruby.embedded.ruby meta.interpolation.ruby 159 # ^^^^^^^^^^^^^^^ meta.string.heredoc.ruby source.ruby.embedded.ruby - meta.interpolation 160 # ^^ punctuation.section.interpolation.begin.ruby 161 # ^ punctuation.section.interpolation.end.ruby 162 custom(Mime[:#{sym}], *args, &block) 163 end 164 RUBY 165 #^^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby entity.name.tag.ruby 166 # ^ - meta.string - string.unquoted 167 168 puts <<-SH; # comment 169 # ^^^^^ meta.string.heredoc.ruby 170 # ^^^ punctuation.definition.heredoc.ruby 171 # ^^ entity.name.tag.ruby 172 # ^ punctuation.terminator.statement.ruby - meta.string - string 173 # ^ comment.line.number-sign.ruby punctuation.definition.comment.ruby - meta.string - string 174 git log 175 # ^^^^^^^ meta.string.heredoc.ruby source.shell.embedded.ruby 176 SH 177 # ^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby entity.name.tag.ruby 178 # ^ - meta.string - string.unquoted 179 180 puts <<-SHELL; # comment 181 # ^^^ meta.string.heredoc.ruby punctuation.definition.heredoc.ruby 182 # ^^^^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby entity.name.tag.ruby 183 # ^ punctuation.terminator.statement.ruby - meta.string - string 184 # ^ comment.line.number-sign.ruby punctuation.definition.comment.ruby - meta.string - string 185 git log 186 # ^^^^^^^ meta.string.heredoc.ruby source.shell.embedded.ruby 187 SHELL 188 # ^^^^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby entity.name.tag.ruby 189 # ^ - meta.string - string.unquoted 190 191 DB.fetch(<<-SQL, conn).name 192 #^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ruby 193 # ^^^^^^ meta.string.heredoc.ruby 194 # ^^^ punctuation.definition.heredoc.ruby 195 # ^^^ entity.name.tag.ruby 196 # ^^^^^^^^^^^^ - meta.string - string 197 # ^ punctuation.separator 198 # ^ punctuation.definition.group.end 199 SELECT * FROM #$users; 200 #^^^^^^^^^^^^^ meta.string.heredoc.ruby source.sql.embedded.ruby - meta.interpolation 201 # ^^^^^^^ meta.string.heredoc.ruby source.sql.embedded.ruby meta.interpolation.ruby variable.other.readwrite.global 202 # ^ meta.string.heredoc.ruby source.sql.embedded.ruby - meta.interpolation 203 SQL 204 #^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby entity.name.tag.ruby 205 # ^ - meta.string - string.unquoted 206 207 foo, bar = <<BAR, 2 208 #^^^^^^^^^^^^^^^^^^ source.ruby 209 # ^^ meta.string.heredoc.ruby - meta.tag 210 # ^^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby 211 # ^^^ - meta.string.heredoc 212 # ^^ punctuation.definition.heredoc.ruby 213 # ^^^ entity.name.tag.ruby 214 # ^ punctuation.separator 215 # ^ constant.numeric 216 BAR 217 #^^ meta.string.heredoc.ruby meta.tag.heredoc.ruby entity.name.tag.ruby 218 # ^ - meta.string - string.unquoted 219 220 ################## 221 # Numbers 222 ################## 223 224 1234 225 #^^^^ meta.number.integer.decimal.ruby constant.numeric.value.ruby 226 1_234 227 #^^^^^ meta.number.integer.decimal.ruby constant.numeric.value.ruby 228 0d170 229 #^^ meta.number.integer.decimal.ruby constant.numeric.base.ruby 230 # ^^^ meta.number.integer.decimal.ruby constant.numeric.value.ruby 231 0D170 232 #^^ meta.number.integer.decimal.ruby constant.numeric.base.ruby 233 # ^^^ meta.number.integer.decimal.ruby constant.numeric.value.ruby 234 0xAa 235 #^^ meta.number.integer.hexadecimal.ruby constant.numeric.base.ruby 236 # ^^ meta.number.integer.hexadecimal.ruby constant.numeric.value.ruby 237 0XAa 238 #^^ meta.number.integer.hexadecimal.ruby constant.numeric.base.ruby 239 # ^^ meta.number.integer.hexadecimal.ruby constant.numeric.value.ruby 240 0252 241 #^ meta.number.integer.octal.ruby constant.numeric.base.ruby 242 # ^^^ meta.number.integer.octal.ruby constant.numeric.value.ruby 243 0o252 244 #^^ meta.number.integer.octal.ruby constant.numeric.base.ruby 245 # ^^^ meta.number.integer.octal.ruby constant.numeric.value.ruby 246 0O252 247 #^^ meta.number.integer.octal.ruby constant.numeric.base.ruby 248 # ^^^ meta.number.integer.octal.ruby constant.numeric.value.ruby 249 0b10101010 250 #^^ meta.number.integer.binary.ruby constant.numeric.base.ruby 251 # ^^^^^^^^ meta.number.integer.binary.ruby constant.numeric.value.ruby 252 0B10101010 253 #^^ meta.number.integer.binary.ruby constant.numeric.base.ruby 254 # ^^^^^^^^ meta.number.integer.binary.ruby constant.numeric.value.ruby 255 12. 256 #^^ meta.number.integer.decimal.ruby constant.numeric.value.ruby 257 # ^ punctuation.accessor - constant.numeric - invalid.illegal 258 12.ir 259 #^^ meta.number.integer.decimal.ruby constant.numeric.value.ruby 260 # ^ punctuation.accessor - constant.numeric - invalid.illegal 261 # ^^ - constant.numeric - invalid.illegal - storage.type.numeric 262 263 12.34 264 #^^^^^ meta.number.float.decimal.ruby constant.numeric.value.ruby 265 # ^ punctuation.separator.decimal 266 1234e-2 267 #^^^^^^^ meta.number.float.decimal.ruby constant.numeric.value.ruby 268 1.234E1 269 #^^^^^^^ meta.number.float.decimal.ruby constant.numeric.value.ruby 270 # ^ punctuation.separator.decimal 271 12e3r 272 #^^^^ meta.number.float.decimal.ruby constant.numeric.value.ruby 273 # ^ meta.number.float.decimal.ruby constant.numeric.suffix.ruby invalid.illegal.numeric.rational.ruby 274 1.2e3r 275 #^^^^^ meta.number.float.decimal.ruby constant.numeric.value.ruby 276 # ^ punctuation.separator.decimal 277 # ^ meta.number.float.decimal.ruby constant.numeric.suffix.ruby invalid.illegal.numeric.rational.ruby 278 279 12r 280 #^^ meta.number.rational.decimal.ruby constant.numeric.value.ruby 281 # ^ meta.number.rational.decimal.ruby constant.numeric.suffix.ruby 282 12.3r 283 #^^^^ meta.number.rational.decimal.ruby constant.numeric.value.ruby 284 # ^ punctuation.separator.decimal 285 # ^ meta.number.rational.decimal.ruby constant.numeric.suffix.ruby 286 0d170r 287 #^^ meta.number.rational.decimal.ruby constant.numeric.base.ruby 288 # ^^^ meta.number.rational.decimal.ruby constant.numeric.value.ruby 289 # ^ meta.number.rational.decimal.ruby constant.numeric.suffix.ruby 290 0xAar 291 #^^ meta.number.rational.hexadecimal.ruby constant.numeric.base.ruby 292 # ^^ meta.number.rational.hexadecimal.ruby constant.numeric.value.ruby 293 # ^ meta.number.rational.hexadecimal.ruby constant.numeric.suffix.ruby 294 0o252r 295 #^^ meta.number.rational.octal.ruby constant.numeric.base.ruby 296 # ^^^ meta.number.rational.octal.ruby constant.numeric.value.ruby 297 # ^ meta.number.rational.octal.ruby constant.numeric.suffix.ruby 298 0b10101010r 299 #^^ meta.number.rational.binary.ruby constant.numeric.base.ruby 300 # ^^^^^^^^ meta.number.rational.binary.ruby constant.numeric.value.ruby 301 # ^ meta.number.rational.binary.ruby constant.numeric.suffix.ruby 302 303 12i 304 #^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 305 # ^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 306 12.3i 307 #^^^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 308 # ^ punctuation.separator.decimal 309 # ^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 310 12e3i 311 #^^^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 312 # ^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 313 12e-3i 314 #^^^^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 315 # ^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 316 1.2e3i 317 #^^^^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 318 # ^ punctuation.separator.decimal 319 # ^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 320 1.2e-3i 321 #^^^^^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 322 # ^ punctuation.separator.decimal 323 # ^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 324 12ri 325 #^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 326 # ^^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 327 12.3ri 328 #^^^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 329 # ^ punctuation.separator.decimal 330 # ^^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 331 0d170i 332 #^^ meta.number.imaginary.decimal.ruby constant.numeric.base.ruby 333 # ^^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 334 # ^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 335 0d170ri 336 #^^ meta.number.imaginary.decimal.ruby constant.numeric.base.ruby 337 # ^^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 338 # ^^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 339 0xAai 340 #^^ meta.number.imaginary.hexadecimal.ruby constant.numeric.base.ruby 341 # ^^ meta.number.imaginary.hexadecimal.ruby constant.numeric.value.ruby 342 # ^ meta.number.imaginary.hexadecimal.ruby constant.numeric.suffix.ruby 343 0xAari 344 #^^ meta.number.imaginary.hexadecimal.ruby constant.numeric.base.ruby 345 # ^^ meta.number.imaginary.hexadecimal.ruby constant.numeric.value.ruby 346 # ^^ meta.number.imaginary.hexadecimal.ruby constant.numeric.suffix.ruby 347 0o252i 348 #^^ meta.number.imaginary.octal.ruby constant.numeric.base.ruby 349 # ^^^ meta.number.imaginary.octal.ruby constant.numeric.value.ruby 350 # ^ meta.number.imaginary.octal.ruby constant.numeric.suffix.ruby 351 0o252ri 352 #^^ meta.number.imaginary.octal.ruby constant.numeric.base.ruby 353 # ^^^ meta.number.imaginary.octal.ruby constant.numeric.value.ruby 354 # ^^ meta.number.imaginary.octal.ruby constant.numeric.suffix.ruby 355 0b10101010i 356 #^^ meta.number.imaginary.binary.ruby constant.numeric.base.ruby 357 # ^^^^^^^^ meta.number.imaginary.binary.ruby constant.numeric.value.ruby 358 # ^ meta.number.imaginary.binary.ruby constant.numeric.suffix.ruby 359 0b10101010ri 360 #^^ meta.number.imaginary.binary.ruby constant.numeric.base.ruby 361 # ^^^^^^^^ meta.number.imaginary.binary.ruby constant.numeric.value.ruby 362 # ^^ meta.number.imaginary.binary.ruby constant.numeric.suffix.ruby 363 12e3ri 364 #^^^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 365 # ^^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 366 # ^ invalid.illegal.numeric 367 1.2e3ri 368 #^^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 369 # ^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 370 # ^ invalid.illegal.numeric.ruby 371 # ^^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 372 12ir 373 #^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 374 # ^^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 375 # ^ invalid.illegal.numeric 376 12.3ir 377 #^^^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 378 # ^ punctuation.separator.decimal 379 # ^^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 380 # ^ invalid.illegal.numeric 381 12e3ir 382 #^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 383 # ^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 384 # ^^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 385 # ^ invalid.illegal.numeric 386 1.2e3ir 387 #^^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 388 # ^ punctuation.separator.decimal 389 # ^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 390 # ^^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 391 # ^ invalid.illegal.numeric 392 0d170ir 393 #^^ meta.number.imaginary.decimal.ruby constant.numeric.base.ruby 394 # ^^^ meta.number.imaginary.decimal.ruby constant.numeric.value.ruby 395 # ^^ meta.number.imaginary.decimal.ruby constant.numeric.suffix.ruby 396 # ^ invalid.illegal.numeric 397 0xAair 398 #^^ meta.number.imaginary.hexadecimal.ruby constant.numeric.base.ruby 399 # ^^ meta.number.imaginary.hexadecimal.ruby constant.numeric.value.ruby 400 # ^^ meta.number.imaginary.hexadecimal.ruby constant.numeric.suffix.ruby 401 # ^ invalid.illegal.numeric 402 0o252ir 403 #^^ meta.number.imaginary.octal.ruby constant.numeric.base.ruby 404 # ^^^ meta.number.imaginary.octal.ruby constant.numeric.value.ruby 405 # ^^ meta.number.imaginary.octal.ruby constant.numeric.suffix.ruby 406 # ^ invalid.illegal.numeric 407 0b10101010ir 408 #^^ meta.number.imaginary.binary.ruby constant.numeric.base.ruby 409 # ^^^^^^^^ meta.number.imaginary.binary.ruby constant.numeric.value.ruby 410 # ^^ meta.number.imaginary.binary.ruby constant.numeric.suffix.ruby 411 # ^ invalid.illegal.numeric 412 413 ################## 414 # Strings 415 ################## 416 417 puts 'test' 418 419 str = "number %d" % 11 420 # ^^ string.quoted.double.ruby constant.other.placeholder.ruby 421 str = 'number %d' % 11 422 # ^^ string.quoted.single.ruby constant.other.placeholder.ruby 423 str = 'number %08d' % 11 424 # ^^^^ string.quoted.single.ruby constant.other.placeholder.ruby 425 str = 'number %.2f' % 11 426 # ^^^^ string.quoted.single.ruby constant.other.placeholder.ruby 427 str = 'number %-8.2d' % 11 428 # ^^^^^^ string.quoted.single.ruby constant.other.placeholder.ruby 429 str = '%2$02d' % [212.00, 3] 430 # ^^^^^^ string.quoted.single.ruby constant.other.placeholder.ruby 431 str = sprintf("%1$*2$s %2$d", "hello", -8) 432 # ^^^^^^^ string.quoted.double.ruby constant.other.placeholder.ruby 433 # ^^^^ string.quoted.double.ruby constant.other.placeholder.ruby 434 435 ################## 436 # Escape sequences 437 ################## 438 439 "This string has a quote: \". As you can see, it is escaped" 440 # ^^ constant.character.escape.ruby 441 "\a bell, ASCII 07h (BEL)" 442 # ^^ constant.character.escape.ruby 443 "\b backspace, ASCII 08h (BS)" 444 # ^^ constant.character.escape.ruby 445 "\t horizontal tab, ASCII 09h (TAB)" 446 # ^^ constant.character.escape.ruby 447 "\n newline (line feed), ASCII 0Ah (LF)" 448 # ^^ constant.character.escape.ruby 449 "\v vertical tab, ASCII 0Bh (VT)" 450 # ^^ constant.character.escape.ruby 451 "\f form feed, ASCII 0Ch (FF)" 452 # ^^ constant.character.escape.ruby 453 "\r carriage return, ASCII 0Dh (CR)" 454 # ^^ constant.character.escape.ruby 455 "\e escape, ASCII 1Bh (ESC)" 456 # ^^ constant.character.escape.ruby 457 "\s space, ASCII 20h (SPC)" 458 # ^^ constant.character.escape.ruby 459 "\\ backslash" 460 # ^^ constant.character.escape.ruby 461 "\0 \7 \07 \007 \0170 octal bit pattern, where nnn is 1-3 octal digits ([0-7])" 462 # ^^ constant.character.escape.ruby 463 # ^ - constant 464 # ^^ constant.character.escape.ruby 465 # ^ - constant 466 # ^^^ constant.character.escape.ruby 467 # ^ - constant 468 # ^^^^ constant.character.escape.ruby 469 # ^ - constant 470 # ^^^^ constant.character.escape.ruby 471 # ^ - constant 472 "\x0 \xF \x0F \x0FF hexadecimal bit pattern, where nn is 1-2 hexadecimal digits ([0-9a-fA-F])" 473 # ^^^ constant.character.escape.ruby 474 # ^ - constant 475 # ^^^ constant.character.escape.ruby 476 # ^ - constant 477 # ^^^^ constant.character.escape.ruby 478 # ^ - constant 479 # ^^^^ constant.character.escape.ruby 480 # ^ - constant 481 "\u0B \u0AF4 Unicode character, where nnnn is exactly 4 hexadecimal digits ([0-9a-fA-F])" 482 # ^^ constant.character.escape.ruby 483 # ^^ - constant 484 # ^^^^^^ constant.character.escape.ruby 485 "\u{nnnn Ab0 09AFaf ...} Unicode character(s), where each nnnn is 1-6 hexadecimal digits ([0-9a-fA-F])" 486 # ^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.ruby 487 # ^^^^ invalid.illegal.escape.ruby 488 # ^^^ invalid.illegal.escape.ruby 489 # ^ - constant 490 "\cx or \C-x control character, where x is an ASCII printable character" 491 # ^^^ constant.character.escape.ruby 492 # ^^^^ - constant 493 # ^^^^ constant.character.escape.ruby 494 # ^ - constant 495 "\M-x meta character, where x is an ASCII printable character" 496 # ^^^^ constant.character.escape.ruby 497 # ^ - constant 498 "\M-\C-x meta control character, where x is an ASCII printable character" 499 # ^^^^^^^ constant.character.escape.ruby 500 # ^ - constant 501 "\M-\cx same as above" 502 # ^^^^^^ constant.character.escape.ruby 503 # ^ - constant 504 "\c\M-x same as above" 505 # ^^^^^^ constant.character.escape.ruby 506 # ^ - constant 507 "\c? or \C-? delete, ASCII 7Fh (DEL)" 508 # ^^^ constant.character.escape.ruby 509 # ^^^^ - constant 510 # ^^^^ constant.character.escape.ruby 511 # ^ - constant 512 513 ################## 514 # Interpolation 515 ################## 516 517 "#{MyParams.new.require(:filename)}" 518 # ^ meta.string.ruby string.quoted.double.ruby - meta.interpolation 519 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.ruby meta.interpolation.ruby - string 520 # ^ meta.string.ruby string.quoted.double.ruby - meta.interpolation 521 # ^ punctuation.definition.string.begin.ruby 522 # ^^ punctuation.section.interpolation.begin.ruby 523 # ^ punctuation.section.interpolation.end.ruby 524 # ^ punctuation.definition.string.end.ruby 525 %I[#{ENV['APP_NAME']} apple #@orange#@@juice banana] 526 # ^^^ meta.string.ruby - meta.interpolation 527 # ^^^^^^ meta.string.ruby meta.interpolation.ruby - string 528 # ^^^^^^^^^^^^^^^ meta.environment-variable.ruby 529 # ^^^^^^^^^^ meta.string.ruby meta.interpolation.ruby meta.string.ruby 530 # ^^ meta.string.ruby meta.interpolation.ruby - string 531 # ^^^^^ constant.other.symbol.ruby 532 # ^^^^^^^^^^^^^^^^ meta.string.ruby meta.interpolation.ruby - string 533 # ^^^^^^ constant.other.symbol.ruby 534 # ^^^ punctuation.definition.string.begin.ruby 535 # ^^^ string.quoted.other.literal.upper.ruby 536 # ^^ punctuation.section.interpolation.begin.ruby 537 # ^^^ variable.other.constant.ruby 538 # ^^^^^^^^^^ string.quoted.single.ruby 539 # ^^^^^^^ string.quoted.other.literal.upper.ruby 540 # ^^ punctuation.definition.variable.ruby 541 # ^^^^^^^^ variable.other.readwrite.instance.ruby 542 # ^^^ punctuation.definition.variable.ruby 543 # ^^^^^^^^ variable.other.readwrite.class.ruby 544 # ^ punctuation.definition.string.end.ruby 545 # ^ string.quoted.other.literal.upper.ruby 546 %x[ foo #@bar [ foo #@bar [ foo #@bar ] baz ] baz ] 547 # ^^^^^^^^ meta.string.ruby string.interpolated.ruby - meta.interpolation 548 # ^^^^^ meta.string.ruby meta.interpolation.ruby - string 549 # ^^^^^^^ meta.string.ruby string.interpolated.ruby - meta.interpolation 550 # ^^^^^ meta.string.ruby meta.interpolation.ruby - string 551 # ^^^^^^^ meta.string.ruby string.interpolated.ruby - meta.interpolation 552 # ^^^^^ meta.string.ruby meta.interpolation.ruby - string 553 # ^^^^^^^^^^^^^^ meta.string.ruby string.interpolated.ruby - meta.interpolation 554 # ^^^ punctuation.definition.string.begin.ruby 555 # ^^^^^ variable.other.readwrite.instance.ruby 556 # ^ punctuation.section.scope.ruby 557 # ^^^^^ variable.other.readwrite.instance.ruby 558 # ^ punctuation.section.scope.ruby 559 # ^^^^^ variable.other.readwrite.instance.ruby 560 # ^ punctuation.section.scope.ruby 561 # ^ punctuation.section.scope.ruby 562 # ^ punctuation.definition.string.end.ruby 563 564 ################## 565 # Constants 566 ################## 567 568 lower_snake_case = 1 569 # ^^^^^^^^^^^^^^ -meta.constant.ruby -entity.name.constant.ruby 570 lowerCamelCase = 2 571 # ^^^^^^^^^^^^ -meta.constant.ruby -entity.name.constant.ruby 572 UpperCamelCase = 3 573 # ^^^^^^^^^^^^ meta.constant.ruby entity.name.constant.ruby 574 UPPER_SNAKE_CASE = 4 575 # ^^^^^^^^^^^^^^ meta.constant.ruby entity.name.constant.ruby 576 A, B, C = 0 577 # <- entity.name.constant 578 # ^ entity.name.constant 579 # ^ entity.name.constant 580 581 Symbol === :foo 582 # ^^^^ variable.other.constant.ruby -meta.constant.ruby 583 # ^^^^ 584 585 :'foo #{ } #@bar baz' 586 # ^^^^^^^^^^^^^^^^^^^^^ meta.constant.ruby - meta.interpolation 587 # ^^ punctuation.definition.constant.ruby 588 # ^^^^^^^^^^^^^^^^^^^^^ constant.other.symbol.single-quoted.ruby 589 # ^ punctuation.definition.constant.ruby 590 :"foo #{ } #@bar baz" 591 # ^^^^^^ meta.constant.ruby - meta.interpolation 592 # ^^^^ meta.constant.ruby meta.interpolation.ruby - constant 593 # ^ meta.constant.ruby - meta.interpolation 594 # ^^^^^ meta.constant.ruby meta.interpolation.ruby - constant 595 # ^^^^^ meta.constant.ruby - meta.interpolation 596 # ^^ punctuation.definition.constant.ruby 597 # ^^^^^^ constant.other.symbol.double-quoted.ruby 598 # ^^ punctuation.section.interpolation.begin.ruby 599 # ^ punctuation.section.interpolation.end.ruby 600 # ^^ punctuation.definition.variable.ruby 601 # ^^^^^ variable.other.readwrite.instance.ruby 602 # ^^^^ constant.other.symbol.double-quoted.ruby 603 # ^ punctuation.definition.constant.ruby 604 605 ################## 606 # Character literals 607 ################## 608 609 ## meta control sequences 610 611 ?\C-a ?\ca ?\c-a #=> "\x01" 612 #^ - constant 613 # ^ punctuation.definition.constant.ruby 614 # ^^^^^ constant.character.ruby 615 # ^ - constant 616 # ^ punctuation.definition.constant.ruby 617 # ^^^^ constant.character.ruby 618 # ^ - constant 619 # ^ punctuation.definition.constant.ruby 620 # ^^^ constant.character.ruby 621 # ^ - constant 622 ?\M-a ?\m-a ?\ma #=> "\xE1" 623 #^ - constant 624 # ^ punctuation.definition.constant.ruby 625 # ^^^^^ constant.character.ruby 626 # ^ - constant 627 # ^ punctuation.definition.constant.ruby 628 # ^^ constant.character.ruby 629 # ^^^ - constant 630 # ^ punctuation.definition.constant.ruby 631 # ^^^^ constant.character.ruby 632 # ^^^ invalid.illegal.character.ruby 633 # ^ - constant 634 ?\M-\C-a ?\M-\ca #=> "\x81" 635 #^ - constant 636 # ^ punctuation.definition.constant.ruby 637 # ^^^^^^^^ constant.character.ruby 638 # ^ - constant 639 # ^ punctuation.definition.constant.ruby 640 # ^^^^^^^ constant.character.ruby 641 # ^ - constant 642 ?\C-\M-a ?\c\M-a #=> "\x81", same as above 643 #^ - constant 644 # ^ punctuation.definition.constant.ruby 645 # ^^^^^^^^ constant.character.ruby 646 # ^ - constant 647 # ^ punctuation.definition.constant.ruby 648 # ^^^^^^^ constant.character.ruby 649 # ^ - constant 650 651 ## hexadecimal 652 653 ?\x10 ?\xAF ?\xAG ?\x0AF 654 #^ - constant 655 # ^ punctuation.definition.constant.ruby 656 # ^^^^^ constant.character.ruby 657 # ^ - constant 658 # ^ punctuation.definition.constant.ruby 659 # ^^^^^ constant.character.ruby 660 # ^ - constant 661 # ^ punctuation.definition.constant.ruby 662 # ^^^^^ constant.character.ruby 663 # ^^^^ invalid.illegal.character.ruby 664 # ^ - constant 665 # ^ punctuation.definition.constant.ruby 666 # ^^^^^^ constant.character.ruby 667 # ^^^^^ invalid.illegal.character.ruby 668 # ^ - constant 669 670 ## octal 671 672 ?\00 ?\07 ?\000 ?\077 ?\080 ?\0777 673 #^ - constant 674 # ^ punctuation.definition.constant.ruby 675 # ^^^^ constant.character.ruby 676 # ^ - constant 677 # ^ punctuation.definition.constant.ruby 678 # ^^^^ constant.character.ruby 679 # ^ - constant 680 # ^ punctuation.definition.constant.ruby 681 # ^^^^^ constant.character.ruby 682 # ^ - constant 683 # ^ punctuation.definition.constant.ruby 684 # ^^^^^ constant.character.ruby 685 # ^ - constant 686 # ^ punctuation.definition.constant.ruby 687 # ^^^^^ constant.character.ruby 688 # ^^^^ invalid.illegal.character.ruby 689 # ^ - constant 690 # ^ punctuation.definition.constant.ruby 691 # ^^^^^^ constant.character.ruby 692 # ^^^^^ invalid.illegal.character.ruby 693 # ^ - constant 694 695 ## escape sequences 696 697 ?\b ?\n ?\s ?\\ ?\\n ?\bn 698 #^ - constant 699 # ^ punctuation.definition.constant.ruby 700 # ^^^ constant.character.ruby 701 # ^ - constant 702 # ^ punctuation.definition.constant.ruby 703 # ^^^ constant.character.ruby 704 # ^ - constant 705 # ^ punctuation.definition.constant.ruby 706 # ^^^ constant.character.ruby 707 # ^ - constant 708 # ^ punctuation.definition.constant.ruby 709 # ^^^ constant.character.ruby 710 # ^ - constant 711 # ^ constant.character.ruby punctuation.definition.constant.ruby 712 # ^^^ constant.character.ruby invalid.illegal.character.ruby 713 # ^ - constant 714 # ^ constant.character.ruby punctuation.definition.constant.ruby 715 # ^^^ constant.character.ruby invalid.illegal.character.ruby 716 # ^ - constant 717 718 ## unicode 719 720 ?\u{41} #=> "A" 721 # ^^^ meta.constant.ruby - meta.braces.ruby constant.character.ruby 722 # ^^^^ meta.constant.ruby meta.braces.ruby - constant.character.ruby 723 # ^ punctuation.definition.constant.ruby 724 # ^ punctuation.section.braces.begin.ruby 725 # ^^ meta.number.integer.hexadecimal.ruby constant.numeric.value.ruby 726 # ^ punctuation.section.braces.end.ruby 727 ?\u{012ACF 0gxs} 728 # ^^^ meta.constant.ruby - meta.braces.ruby constant.character.ruby 729 # ^^^^^^^^^^^^^ meta.constant.ruby meta.braces.ruby - constant.character.ruby 730 # ^ punctuation.definition.constant.ruby 731 # ^ punctuation.section.braces.begin.ruby 732 # ^^^^^^ meta.number.integer.hexadecimal.ruby constant.numeric.value.ruby 733 # ^ meta.number.integer.hexadecimal.ruby constant.numeric.value.ruby 734 # ^^^ invalid.illegal.escape.ruby 735 # ^ punctuation.section.braces.end.ruby 736 737 ## normal character literals 738 739 ?0 ?1 ?9 ?20 740 #^ - constant 741 # ^ punctuation.definition.constant.ruby 742 # ^^ constant.character.ruby 743 # ^ - constant 744 # ^ punctuation.definition.constant.ruby 745 # ^^ constant.character.ruby 746 # ^ - constant 747 # ^ punctuation.definition.constant.ruby 748 # ^^ constant.character.ruby 749 # ^ - constant 750 # ^ keyword.operator.conditional.ruby 751 # ^^ meta.number.integer.decimal.ruby constant.numeric.value.ruby 752 ?a ?A ?あ ?abc ?a0 753 #^ - constant 754 # ^ punctuation.definition.constant.ruby 755 # ^^ constant.character.ruby 756 # ^ - constant 757 # ^ punctuation.definition.constant.ruby 758 # ^^ constant.character.ruby 759 # ^ - constant 760 # ^ punctuation.definition.constant.ruby 761 # ^^ constant.character.ruby 762 # ^ - constant 763 # ^ punctuation.definition.constant.ruby 764 # ^^^^ constant.character.ruby 765 # ^^^ invalid.illegal.character.ruby 766 # ^ - constant 767 # ^ punctuation.definition.constant.ruby 768 # ^^^ constant.character.ruby 769 # ^^ invalid.illegal.character.ruby 770 # ^ - constant 771 ?* ?" ?( ?[ ?{ ?. ?# ?_ ?\ 772 #^ - constant 773 # ^ punctuation.definition.constant.ruby 774 # ^^ constant.character.ruby 775 # ^ - constant 776 # ^ punctuation.definition.constant.ruby 777 # ^^ constant.character.ruby 778 # ^ - constant 779 # ^ punctuation.definition.constant.ruby 780 # ^^ constant.character.ruby 781 # ^ - constant 782 # ^ punctuation.definition.constant.ruby 783 # ^^ constant.character.ruby 784 # ^ - constant 785 # ^ punctuation.definition.constant.ruby 786 # ^^ constant.character.ruby 787 # ^ - constant 788 # ^ punctuation.definition.constant.ruby 789 # ^^ constant.character.ruby 790 # ^ - constant 791 # ^ punctuation.definition.constant.ruby 792 # ^^ constant.character.ruby 793 # ^ - constant 794 # ^ punctuation.definition.constant.ruby 795 # ^^ constant.character.ruby 796 # ^ - constant 797 # ^ punctuation.definition.constant.ruby 798 # ^^ constant.character.ruby 799 # ^ - constant 800 801 ################## 802 # Constant reserved keyword symbols 803 ################## 804 805 begin: 'begin' 806 # ^^^^ constant.other.symbol 807 end: 'end' 808 # ^^ constant.other.symbol 809 require: 'require' 810 # ^^^^^^ constant.other.symbol 811 class: 'class' 812 # ^^^^ constant.other.symbol 813 module: 'module' 814 # ^^^^^ constant.other.symbol 815 816 ################## 817 # Operators 818 ################## 819 820 , 821 # ^ punctuation.separator.sequence.ruby 822 ; 823 # ^ punctuation.terminator.statement.ruby 824 . 825 # ^ punctuation.accessor.dot.ruby 826 :: 827 # ^^ punctuation.accessor.double-colon.ruby 828 <<= 829 # ^^^ keyword.operator.assignment.augmented.ruby 830 &&= 831 # ^^^ keyword.operator.assignment.augmented.ruby 832 ||= 833 # ^^^ keyword.operator.assignment.augmented.ruby 834 **= 835 # ^^^ keyword.operator.assignment.augmented.ruby 836 += 837 # ^^ keyword.operator.assignment.augmented.ruby 838 -= 839 # ^^ keyword.operator.assignment.augmented.ruby 840 *= 841 # ^^ keyword.operator.assignment.augmented.ruby 842 /= 843 # ^^ keyword.operator.assignment.augmented.ruby 844 &= 845 # ^^ keyword.operator.assignment.augmented.ruby 846 |= 847 # ^^ keyword.operator.assignment.augmented.ruby 848 ^= 849 # ^^ keyword.operator.assignment.augmented.ruby 850 << 851 # ^^ keyword.operator.assignment.augmented.ruby 852 >> 853 # ^^ keyword.operator.other.ruby 854 + 855 # ^ keyword.operator.arithmetic.ruby 856 - 857 # ^ keyword.operator.arithmetic.ruby 858 * 859 # ^ keyword.operator.arithmetic.ruby 860 ** 861 # ^^ keyword.operator.arithmetic.ruby 862 / 863 # ^ keyword.operator.arithmetic.ruby 864 % 865 # ^ keyword.operator.arithmetic.ruby 866 !~ 867 # ^^ keyword.operator.comparison.ruby 868 =~ 869 # ^^ keyword.operator.comparison.ruby 870 <=> 871 # ^^^ keyword.operator.comparison.ruby 872 == 873 # ^^ keyword.operator.comparison.ruby 874 != 875 # ^^ keyword.operator.comparison.ruby 876 >= 877 # ^^ keyword.operator.comparison.ruby 878 <= 879 # ^^ keyword.operator.comparison.ruby 880 > 881 # ^ keyword.operator.comparison.ruby 882 < 883 # ^ keyword.operator.comparison.ruby 884 && 885 # ^^ keyword.operator.logical.ruby 886 || 887 # ^^ keyword.operator.logical.ruby 888 ! 889 # ^ keyword.operator.logical.ruby 890 ? 891 # ^ keyword.operator.conditional.ruby 892 : 893 # ^ keyword.operator.conditional.ruby 894 ~ 895 # ^ keyword.operator.bitwise.ruby 896 & 897 # ^ keyword.operator.bitwise.ruby 898 | 899 # ^ keyword.operator.bitwise.ruby 900 ^ 901 # ^ keyword.operator.bitwise.ruby 902 .. 903 # ^^ keyword.operator.range.ruby 904 ... 905 # ^^^ keyword.operator.range.ruby 906 907 ################## 908 # Blocks 909 ################## 910 911 [self.class.name, @name].map do |*args| 912 # ^ variable.language.ruby 913 # ^ variable.other.readwrite.instance.ruby punctuation.definition.variable.ruby 914 # ^^^^ variable.other.readwrite.instance.ruby 915 # ^ keyword.operator.splat.ruby 916 # ^ variable.parameter.ruby 917 end 918 919 { |a, b=2, *c| a + b} 920 # <- punctuation.section.scope 921 # ^^^^^^^^^^^^ meta.block.parameters 922 # ^ punctuation.definition.parameters.begin 923 # ^ variable.parameter 924 # ^ punctuation.separator 925 # ^ variable.parameter 926 # ^^ meta.block.parameters.default-value 927 # ^ keyword.operator.assignment 928 # ^ constant.numeric 929 # ^ punctuation.separator 930 # ^ keyword.operator.splat 931 # ^ variable.parameter 932 # ^ punctuation.definition.parameters.end 933 # ^ punctuation.section.scope 934 935 do |&bl| end 936 # <- keyword.control.block.do.ruby 937 # ^^^^^ meta.block.parameters 938 # ^ punctuation.definition.parameters 939 # ^ keyword.operator 940 # ^^ variable.parameter 941 # ^ punctuation.definition.parameters 942 943 { |a={|b={a: 1, b: 2}|}| a * 2 } 944 # ^^^^^^^^^^^^^^^^^^^^^^ meta.block.parameters 945 # ^ punctuation.definition.parameters.begin 946 # ^ variable.parameter 947 # ^^^^^^^^^^^^^^^^^^^ meta.block.parameters.default-value 948 # ^^^^^^^^^^^^^^^^ meta.block.parameters meta.block.parameters 949 # ^ variable.parameter 950 # ^^^^^^^^^^^^^ meta.block.parameters.default-value meta.block.parameters.default-value 951 # ^ keyword.operator.assignment 952 # ^^ constant.other.symbol 953 # ^ constant.numeric 954 # ^ punctuation.separator 955 # ^^ constant.other.symbol 956 # ^ constant.numeric 957 # ^ punctuation.definition.parameters.end 958 # ^ punctuation.definition.parameters.end 959 # ^ keyword.operator.arithmetic 960 961 962 ################## 963 # Modules, classes and methods 964 ################## 965 966 module MyModule 967 #^^^^^^^^^^^^^^ meta.namespace 968 # <- meta.namespace keyword.declaration.namespace 969 #^^^^^ keyword.declaration.namespace 970 # ^ - entity - keyword - storage 971 # ^^^^^^^^ entity.name.namespace 972 end 973 974 module MyModule::OtherModule 975 #^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace 976 # <- meta.namespace keyword.declaration.namespace 977 # ^^^^^^^^^^^^^^^^^^^^^ entity.name.namespace 978 #^^^^^ keyword.declaration.namespace 979 # ^ - entity - keyword - storage 980 # ^^^^^^^^ support.other.namespace 981 # ^^ punctuation.accessor.double-colon 982 # ^^^^^^^^^^^ entity.name.namespace 983 end 984 985 class ::MyModule::MyClass < MyModule::InheritedClass 986 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class 987 # <- meta.class keyword.declaration.class 988 #^^^^ keyword.declaration.class 989 # ^ - entity - keyword - storage - punctuation 990 # ^^ punctuation.accessor.double-colon 991 # ^^^^^^^^ support.other.namespace 992 # ^^ punctuation.accessor.double-colon 993 # ^^^^^^^ entity.name.class 994 # ^ punctuation.separator.inheritance 995 # ^^^^^^^^^^^^^^^^^^^^^^^^ entity.other.inherited-class 996 # ^^ punctuation.accessor.double-colon 997 998 def my_method(param1, param2) 999 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function 1000 # ^^^ keyword.declaration.function 1001 # ^^^^^^^^^ entity.name.function 1002 # ^^^^^^^^^^^^^^^^ meta.function.parameters 1003 # ^ punctuation.definition.group.begin 1004 # ^ punctuation.separator - variable.parameter 1005 # ^ punctuation.definition.group.end 1006 end 1007 1008 def self.my_second_method *arg_without_parens # comment 1009 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function 1010 # ^^^ keyword.declaration.function 1011 # ^^^^ variable.language 1012 # ^ punctuation.accessor.dot 1013 # ^^^^^^^^^^^^^^^^ entity.name.function 1014 # ^^^^^^^^^^^^^^^^^^^ meta.function.parameters 1015 # ^ keyword.operator.splat 1016 # ^^^^^^^^^^^^^^^^^^ variable.parameter 1017 # ^^^^^^^^^ comment.line.number-sign 1018 end 1019 1020 def self.my_third_method(a, b="foo", c=[], d=foo(), *args) 1021 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function 1022 # ^^^ keyword.declaration.function 1023 # ^^^^ variable.language 1024 # ^ punctuation.accessor.dot 1025 # ^^^^^^^^^^^^^^^ entity.name.function 1026 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters 1027 # ^ punctuation.definition.group.begin 1028 # ^ variable.parameter 1029 # ^ punctuation.separator - variable.parameter 1030 # ^ variable.parameter 1031 # ^^^^^^ meta.function.parameters.default-value 1032 # ^ keyword.operator - variable.parameter 1033 # ^^^^^ string.quoted - variable.parameter 1034 # ^ punctuation.separator 1035 # ^ variable.parameter 1036 # ^ keyword.operator.assignment 1037 # ^^ punctuation.section.array 1038 # ^ punctuation.separator 1039 # ^ variable.parameter 1040 # ^ keyword.operator.assignment 1041 # ^^ punctuation.definition.group 1042 # ^ punctuation.separator 1043 # ^ keyword.operator 1044 # ^^^^ variable.parameter 1045 # ^ punctuation.definition.group.end 1046 end 1047 1048 def nested((a, b), c, (d, *e)) 1049 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function 1050 # ^^^ keyword.declaration.function 1051 # ^^^^^^ entity.name.function 1052 # ^^^^^^^^^^^^^^^^^^^^ meta.function.parameters 1053 # ^ punctuation.definition.group.begin 1054 # ^ punctuation.definition.group.begin 1055 # ^ variable.parameter 1056 # ^ punctuation.separator 1057 # ^ variable.parameter 1058 # ^ punctuation.definition.group.end 1059 # ^ punctuation.separator 1060 # ^ variable.parameter 1061 # ^ punctuation.separator 1062 # ^ punctuation.definition.group.begin 1063 # ^ variable.parameter 1064 # ^ punctuation.separator 1065 # ^ keyword.operator.splat 1066 # ^ variable.parameter 1067 # ^^ punctuation.definition.group.end 1068 end 1069 1070 def block_param(&block) 1071 # ^^^ keyword.declaration.function 1072 # ^^^^^^^^ meta.function.parameters 1073 # ^ keyword.operator 1074 # ^^^^^ variable.parameter 1075 end 1076 1077 def keyword_args a: nil, b: true 1078 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function 1079 # ^^^^^^^^^^^^^^^ meta.function.parameters 1080 # ^^^^^ meta.function.parameters.default-value 1081 # ^ punctuation.separator 1082 # ^^^ constant.language 1083 # ^ punctuation.separator 1084 # ^ punctuation.separator 1085 # ^^^^ constant.language 1086 end 1087 1088 def multiline_args(a, # a comment 1089 # ^^^^^^^^^^^^^^^^^^^^^ meta.function 1090 # ^^ meta.function.parameters 1091 # ^ punctuation.separator 1092 # ^^^^^^^^^^^ comment.line.number-sign 1093 b) 1094 # ^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters 1095 # ^ punctuation.definition.group.end 1096 end 1097 end 1098 1099 def MyModule::module_method 1100 #^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function 1101 # ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.function 1102 # ^^^^^^^^ support.other.namespace 1103 # ^^ punctuation.accessor.double-colon 1104 super /pattern/ 1105 # ^^^^^ support.function.builtin.ruby 1106 # ^^^^^^^^^ meta.string.regexp.ruby 1107 end 1108 1109 def my_function 1110 #^^^^^^^^^^^^^^ meta.function 1111 # ^^^^^^^^^^^ entity.name.function 1112 end 1113 1114 f = MyModule::MyClass.new 1115 # ^^ punctuation.accessor.double-colon 1116 1117 def f.my_instance_method 1118 #^^^^^^^^^^^^^^^^^^^^^^^ meta.function 1119 # ^^^^^^^^^^^^^^^^^^^^ entity.name.function 1120 # ^ punctuation.accessor.dot 1121 end 1122 1123 class MyClass 1124 # ^ meta.class.ruby keyword.declaration.class.ruby 1125 # ^ meta.class.ruby entity.name.class.ruby 1126 1127 prepend Module.new 1128 # ^ keyword.other.special-method.ruby 1129 # ^ support.class.ruby 1130 # ^ keyword.other.special-method.ruby 1131 1132 1133 A, B, C = :a, :b, :c 1134 # ^ meta.constant.ruby entity.name.constant.ruby 1135 # ^ punctuation.separator.sequence.ruby 1136 # ^ meta.constant.ruby entity.name.constant.ruby 1137 # ^ punctuation.separator.sequence.ruby 1138 # ^ meta.constant.ruby entity.name.constant.ruby 1139 end 1140 1141 1142 ################## 1143 # Well-known methods 1144 ################## 1145 1146 puts "Output" 1147 # <- support.function.builtin 1148 1149 abort "Ending" 1150 # <- support.function.builtin 1151 1152 exit! 2 1153 #^^^^ support.function.builtin 1154 1155 get :name, -> { "John" } 1156 # ^^ meta.function.ruby keyword.declaration.function.anonymous.ruby 1157 1158 ################## 1159 # Symbol literals 1160 ################## 1161 1162 FIELDS = %i[a b c] 1163 # ^^^^^^ meta.constant.ruby entity.name.constant.ruby 1164 # ^ keyword.operator.assignment.ruby 1165 # ^^^ punctuation.definition.string.begin.ruby 1166 # ^ constant.other.symbol.ruby 1167 # ^ constant.other.symbol.ruby 1168 # ^ constant.other.symbol.ruby 1169 # ^ punctuation.definition.string.end.ruby 1170 1171 %i(a b c) 1172 # ^^^ punctuation.definition.string.begin.ruby 1173 # ^ constant.other.symbol.ruby 1174 # ^ constant.other.symbol.ruby 1175 # ^ constant.other.symbol.ruby 1176 # ^ punctuation.definition.string.end.ruby 1177 1178 %I[#{'a'} b #@c#@@d e] 1179 # ^^^ meta.string.ruby - meta.interpolation 1180 # ^^ source.ruby meta.string.ruby meta.interpolation.ruby punctuation.section.interpolation.begin.ruby 1181 # ^^^ meta.string.ruby meta.interpolation.ruby meta.string.ruby 1182 # ^ source.ruby meta.string.ruby meta.interpolation.ruby punctuation.section.interpolation.end.ruby 1183 # ^ constant.other.symbol.ruby 1184 # ^^^^^^^ meta.string.ruby meta.interpolation.ruby - string 1185 # ^ constant.other.symbol.ruby 1186 # ^ punctuation.definition.string.end.ruby 1187 1188 ################## 1189 # String literals 1190 ################## 1191 1192 %w[a b c] 1193 # ^^^ punctuation.definition.string.begin.ruby 1194 # ^^^^^ string.quoted.other.literal.lower.ruby 1195 # ^ punctuation.definition.string.end.ruby 1196 1197 %w(a b c) 1198 # ^^^ punctuation.definition.string.begin.ruby 1199 # ^^^^^ string.quoted.other.literal.lower.ruby 1200 # ^ punctuation.definition.string.end.ruby 1201 1202 ################## 1203 # Tokens with Multiple Meanings 1204 ################## 1205 1206 method? 1 1207 # ^ - keyword.operator 1208 1209 (methodname)?foobar : baz 1210 # ^ keyword.operator.conditional 1211 # ^ keyword.operator.conditional 1212 1213 methodname ?foo : baz 1214 # ^ keyword.operator.conditional 1215 # ^ keyword.operator.conditional 1216 1217 puts 1 ?1 : 2 1218 # ^ keyword.operator.conditional 1219 # ^ constant.numeric 1220 # ^ keyword.operator.conditional 1221 1222 puts 1 ?12 : 2 1223 # ^ keyword.operator.conditional 1224 # ^^ constant.numeric 1225 # ^ keyword.operator.conditional 1226 1227 puts ?1 1228 # ^^ constant.character.ruby 1229 1230 puts 1 ? foo:bar 1231 # ^ keyword.operator.conditional 1232 # ^ keyword.operator.conditional 1233 # ^^^ - constant.other.symbol 1234 1235 puts 1 ? foo::baz:bar 1236 # ^ keyword.operator.conditional 1237 # ^^ punctuation.accessor.double-colon 1238 # ^^^ - constant.other.symbol 1239 # ^ keyword.operator.conditional 1240 1241 puts foo: bar 1242 # ^^^^ constant.other.symbol 1243 1244 1245 ################## 1246 # Regular expressions vs division operator 1247 ################## 1248 1249 "foo".sub /t{1,}/i 1250 # ^^^^^^^^ string.regexp 1251 # ^ keyword.other 1252 "foo".sub! /t{1,}/i 1253 # ^^^^^^^^ string.regexp 1254 # ^ keyword.other 1255 "foo".sub!(/t{1,}/i) 1256 # ^^^^^^^^ string.regexp 1257 # ^ keyword.other 1258 "foo".gsub /t{1,}/i 1259 # ^^^^^^^^ string.regexp 1260 # ^ keyword.other 1261 "foo".gsub! /t{1,}/i 1262 # ^^^^^^^^ string.regexp 1263 # ^ keyword.other 1264 "foo".gsub!(/t{1,}/i) 1265 # ^^^^^^^^ string.regexp 1266 # ^ keyword.other 1267 "foo".eql? /t{1,}/i 1268 # ^^^^^^^^ string.regexp 1269 # ^ keyword.other 1270 "foo".eql?(/t{1,}/i) 1271 # ^^^^^^^^ string.regexp 1272 # ^ keyword.other 1273 'foo'.match? /t{1,}/i 1274 # ^^^^^^^^ string.regexp 1275 # ^ keyword.other 1276 'foo'.match?(/t{1,}/i) 1277 # ^^^^^^^^ string.regexp 1278 # ^ keyword.other 1279 'foo'.matches?(/t{1,}/i) 1280 # ^^^^^^^^ string.regexp 1281 # ^ keyword.other 1282 1283 a = /(foo)*baz/m 1284 # ^^^^^^^^^^^^ string.regexp 1285 1286 a = /{foo}*baz/m 1287 # ^^^^^^^^^^^^ string.regexp 1288 1289 a = /?foo*baz/m 1290 # ^^^^^^^^^^^ string.regexp 1291 1292 a = /=foo/m 1293 # ^^ keyword.operator.assignment.augmented.ruby 1294 # ^^^^^^^ - string.regexp 1295 1296 begin 1297 # <- keyword.control.block.begin 1298 end while /foo/ =~ bar 1299 # ^^^^^ string.regexp 1300 1301 if /foo/i =~ baz 1302 # <- keyword.control.conditional.if 1303 # ^^^^^^ string.regexp 1304 # ^^ keyword.operator 1305 end 1306 # <- keyword.control.block.end.ruby 1307 1308 if baz =~ /foo/i 1309 # ^^ keyword.operator 1310 # ^^^^^^ string.regexp 1311 end 1312 # <- keyword.control.block.end.ruby 1313 1314 ['a()', 'b()'].select { |var| /^a\(/ =~ var } 1315 # ^^^^^^ string.regexp 1316 1317 {foo: /bar/} 1318 # ^^^^^ string.regexp 1319 1320 str = "#{('A'.ord + index / (26*26) - 1).chr}" 1321 # ^ keyword.operator 1322 # ^^ constant.numeric 1323 # ^ keyword.operator 1324 1325 if 1 / 2 == 3 1326 # ^ keyword.operator 1327 # ^^ keyword.operator 1328 end 1329 1330 a = 1 / 2 1331 # ^ keyword.operator.arithmetic 1332 1333 b = testing! / foo 1334 # ^ keyword.operator.arithmetic 1335 1336 rule /`/ do 1337 # ^^^ string.regexp 1338 # ^ - string.regexp string.regexp 1339 # ^^ keyword.control.block.do 1340 end 1341 1342 ################## 1343 # Crazy Stuff Found Online™ 1344 ################## 1345 1346 ( 1347 def huh?(a, b=def huh?(a); "h?"; end) 1348 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function 1349 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters 1350 # ^^^^^^^^^^^ meta.function meta.function 1351 # ^^^ meta.function.parameters meta.function.parameters 1352 #^^ keyword.declaration.function 1353 # ^ variable.parameter 1354 a 1355 end 1356 1357 p huh?("H", 1) + huh?("u") + huh?("gs") 1358 ) 1359 1360 1361 # issue #923 1362 foo = 2 / @d 1363 # ^^ - string.regexp.classic 1364 # ^ variable.other.readwrite.instance punctuation.definition.variable 1365 # ^ keyword.operator.arithmetic.ruby 1366 1367 # issue #933 1368 a = b / "c" 1369 # ^^^ string.quoted.double.ruby - string.regexp.classic.ruby 1370 # ^ keyword.operator.arithmetic.ruby 1371 1372 foo / "bar/bla" 1373 # ^ keyword.operator.arithmetic.ruby 1374 # ^^^^^^^^^ string.quoted.double.ruby 1375 1376 { 1377 /foo/ => :foo 1378 # ^^^^^ string.regexp.classic.ruby 1379 } 1380 1381 assert_no_match /1/, "2" 1382 # ^^^^^^^^^^^^^^^ support.function.builtin.ruby 1383 # ^ punctuation.definition.string.begin.ruby 1384 # ^^^ meta.string.regexp.ruby string.regexp.classic.ruby 1385 # ^ punctuation.definition.string.end.ruby 1386 # ^ punctuation.separator.sequence.ruby 1387 # ^^^ string.quoted.double.ruby 1388 1389 # issue #2181 1390 foo << bar if baz.include?(x) 1391 # ^^ keyword.control.conditional.if.ruby 1392 foo << bar.baz if baz.include?(x) 1393 # ^^ keyword.control.conditional.if.ruby 1394 foo << bar.assert_match if baz.include?(x) 1395 # ^^ keyword.control.conditional.if.ruby 1396 foo << bar.to_s if baz.include?(x) 1397 # ^^ keyword.control.conditional.if.ruby