ruby.jsf (11473B)
1 # JOE syntax highlight file for Ruby 2 3 # Glitches: 4 # <<EOF1, <<EOF2 is not working. Only EOF1 is seen. It should wait for the 5 # EOF2. 6 7 =Idle 8 =Comment 9 =Constant 10 =Number +Constant 11 =String +Constant 12 =StringEscape +Escape 13 =StringVariable +StringEscape 14 =Regex +String 15 =RegexEscape +StringEscape 16 =Boolean +Constant 17 =Escape 18 =Type 19 =Keyword 20 =Statement +Keyword 21 =Operator +Keyword 22 =Conditional +Statement 23 =Loop +Statement 24 =Label +DefinedIdent 25 =StorageClass +Type +Keyword 26 =Structure +Statement 27 28 =Bad 29 =Brace 30 31 =Symbol +Constant +DefinedIdent 32 =SymbolEscape +Escape 33 =ProcArg +DefinedIdent 34 =GlobalVar +Builtin # TODO: No good class for this. 35 36 =DefinedType +DefinedIdent +Ident 37 =DefinedFunction +DefinedIdent +Ident 38 =ClassMember +Variable +DefinedIdent 39 40 =POD +Preproc 41 42 # Detect pod 43 44 :pre_idle Idle 45 * NULL noeat call=.ruby() 46 47 .subr ruby 48 49 :idle Idle 50 * rest noeat 51 "=" pod_start 52 53 # Rest of line 54 55 :rest Idle 56 * rest 57 "(" after_term call=.ruby(paren) 58 "[" after_term call=.ruby(brack) 59 "{" do_brace recolor=-1 noeat 60 .ifdef paren 61 ")" rest return 62 .else 63 ")" stray recolor=-1 64 .endif 65 .ifdef brack 66 "]" rest return 67 .else 68 "]" stray recolor=-1 69 .endif 70 .ifdef squiggly 71 "}" brace recolor=-1 return 72 .else 73 "}" stray recolor=-1 74 .endif 75 "#" line_comment recolor=-1 76 .ifdef haml 77 "\n" NULL return 78 .else 79 "\n" idle 80 .endif 81 "0" first_digit recolor=-1 82 "1-9" decimal recolor=-1 83 "." ident_no_kw 84 "\"" string recolor=-1 85 "'" char recolor=-1 86 "`" backtick recolor=-1 87 "/" regex recolor=-1 88 "<" maybe_inc 89 "$" not_string buffer 90 "%" pstring 91 "\i" ident buffer 92 "?" opr 93 94 # higher level, ruby specific 95 ":" maybe_symbol 96 # "|" proc_arg 97 "@" class_member1 98 99 :opr Idle 100 * rest noeat 101 "/" rest 102 "%" rest 103 104 :do_brace Brace 105 * rest noeat 106 "{" brace call=.ruby(squiggly) 107 108 :brace Brace 109 * after_term noeat 110 111 :stray Bad 112 * rest 113 114 115 # / / regex not allowed after terms 116 117 :after_term Idle 118 * rest noeat 119 " \t" after_term 120 .ifdef erb 121 "/" rest 122 "%" after_term_erb_end 123 .else 124 "/%" rest 125 .endif 126 127 :after_term_erb_end Idle 128 * rest noeat 129 ">" NULL recolor=-2 return 130 131 :pod_start Idle 132 * pod_start 133 "\n" pod_block 134 135 :pod_block POD 136 * pod_block 137 "=" pod_ident buffer 138 139 :pod_ident POD 140 * pod_block noeat strings 141 "=end" rest 142 done 143 "\c" pod_ident 144 145 :maybe_inc Idle 146 * after_term noeat 147 "<" maybe_inc1 148 149 :maybe_inc1 Idle 150 * after_term noeat 151 "-" allow_space 152 "'\"" quoted_inc_start save_c recolor=-1 153 "\i" inc buffer noeat 154 155 :allow_space Idle 156 * after_term noeat 157 "'\"" quoted_inc_start_allow save_c recolor=-1 158 "\i" inc_allow buffer noeat 159 160 :quoted_inc_start StringVariable string 161 * quoted_inc buffer 162 163 :quoted_inc_start_allow StringVariable string 164 * quoted_inc_allow buffer 165 166 :quoted_inc StringVariable string 167 * quoted_inc 168 & skipline save_s 169 170 :quoted_inc_allow StringVariable string 171 * quoted_inc_allow 172 & skipline_allow save_s 173 174 :inc StringVariable string 175 * skipline save_s noeat 176 "\c" inc 177 178 :inc_allow StringVariable string 179 * skipline_allow save_s noeat 180 "\c" inc_allow 181 182 # Should be treated as a normal line here... 183 184 :skipline Idle 185 * skipline 186 "\n" next_line 187 188 :skipline_allow Idle 189 * skipline_allow 190 "\n" next_line_allow 191 192 :todelim String string 193 * todelim 194 "\n" next_line strings 195 "&" founddelim 196 done 197 198 :todelim_allow String string 199 * todelim_allow 200 "\n" next_line_allow strings 201 "&" founddelim 202 done 203 204 # eat \n so it's not in string. 205 :next_line String string 206 * todelim buffer 207 "\n" next_line 208 209 :next_line_allow String string 210 * todelim_allow buffer 211 " \t\n" next_line_allow 212 213 :founddelim StringEscape string 214 * idle noeat 215 216 :regex Regex string 217 * regex 218 "\\" regex_quote recolor=-1 219 "/" after_term 220 221 :regex_quote RegexEscape string 222 * regex 223 224 :not_string Idle 225 * rest noeat 226 "\c" global_var recolor=-2 227 "\"'`#/" rest 228 229 :brace Brace 230 * rest noeat 231 232 :line_comment Comment comment 233 * line_comment 234 .ifdef erb 235 "%" line_comment_maybe_erb_end 236 .endif 237 "BFHNTX" line_comment noeat call=comment_todo.comment_todo() 238 .ifdef haml 239 "\n" NULL return 240 .else 241 "\n" idle 242 .endif 243 244 :line_comment_maybe_erb_end Comment comment 245 ">" NULL recolor=-2 return 246 247 :end_of_file_comment Comment comment 248 * end_of_file_comment 249 250 :first_digit Number 251 * after_term noeat 252 "x" hex 253 "b" binary 254 "." maybe_float 255 "eE" epart 256 "0-7" octal 257 "89" bad_number recolor=-1 258 259 :bad_number Bad 260 * after_term noeat 261 "0-9" bad_number 262 263 :octal Number 264 * after_term noeat 265 "0-7_" octal 266 "89" bad_number recolor=-1 267 268 :binary Number 269 * after_term noeat 270 "01_" binary 271 "2-9" bad_number recolor=-1 272 273 :hex Number 274 * after_term noeat 275 "0-9A-Fa-f_" hex 276 277 :decimal Number 278 * after_term noeat 279 "0-9_" decimal 280 "eE" epart 281 "." maybe_float 282 283 :maybe_float Idle 284 * after_term noeat recolor=-2 285 "0-9" float noeat 286 287 :float Number 288 * after_term noeat 289 "eE" epart 290 "0-9_" float 291 292 :epart Number 293 * after_term noeat 294 "0-9+\-" enum 295 296 :enum Number 297 * after_term noeat 298 "0-9_" enum 299 300 :string String string 301 * string 302 "\"" after_term 303 "\\" string_escape recolor=-1 304 "#" maybe_string_subst recolor=-1 305 306 :maybe_string_subst String string 307 * string noeat 308 "{" string_subst_begin recolor=-2 309 310 :string_subst_begin StringEscape string 311 * string_subst noeat call=.ruby(squiggly) 312 313 :string_subst StringEscape string 314 * string noeat 315 316 :string_escape Escape 317 * string 318 "x" string_hex1 319 "c" string_ctrl 320 "N" string_named 321 "0-7" string_octal2 322 "\n" string recolor=-2 323 324 :string_named Escape 325 * string 326 "{" string_named_rest 327 328 :string_named_rest Escape 329 * string_named_rest 330 "}" string 331 332 :string_ctrl Escape 333 * string 334 335 :string_hex1 Escape 336 * string noeat 337 "{" string_unicode 338 "0-9a-fA-F" string_hex2 339 340 :string_unicode Escape 341 * string_unicode 342 "}" string 343 344 :string_hex2 Escape 345 * string noeat 346 "0-9a-fA-F" string 347 348 :string_octal2 Escape 349 * string noeat 350 "0-7" string_octal3 351 352 :string_octal3 Escape 353 * string noeat 354 "0-7" string 355 356 # Only \\ and \' allowed in single quoted strings 357 358 :char String string 359 * char 360 "\n" reset 361 "'" after_term 362 "\\" char_escape recolor=-1 363 364 :char_escape Escape 365 * char recolor=-2 366 "\\'" char 367 368 :backtick String string 369 * backtick 370 "`" after_term 371 "\\" backtick_escape recolor=-1 372 "$@" backtick_subst recolor=-1 373 374 :backtick_subst Escape 375 * backtick noeat recolor=-1 376 "\c" backtick_subst 377 378 :backtick_escape Escape 379 * backtick 380 "x" backtick_hex1 381 "c" backtick_ctrl 382 "N" backtick_named 383 "0-7" backtick_octal2 384 "\n" backtick recolor=-2 385 386 :backtick_named Escape 387 * backtick 388 "{" backtick_named_rest 389 390 :backtick_named_rest Escape 391 * backtick_named_rest 392 "}" backtick 393 394 :backtick_ctrl Escape 395 * backtick 396 397 :backtick_hex1 Escape 398 * backtick noeat 399 "{" backtick_unicode 400 "0-9a-fA-F" backtick_hex2 401 402 :backtick_unicode Escape 403 * backtick_unicode 404 "}" backtick 405 406 :backtick_hex2 Escape 407 * backtick noeat 408 "0-9a-fA-F" backtick 409 410 :backtick_octal2 Escape 411 * backtick noeat 412 "0-7" backtick_octal3 413 414 :backtick_octal3 Escape 415 * backtick noeat 416 "0-7" backtick 417 418 :ident_no_kw Idle 419 * after_term noeat 420 "0" first_digit recolor=-2 421 "1-9" decimal recolor=-2 422 "\i" ident_no_kw1 423 424 :ident_no_kw1 Idle 425 * after_term noeat 426 "\c?!" ident_no_kw1 427 428 :ident Idle 429 * after_term noeat strings 430 "BEGIN" kw 431 "END" kw 432 "alias" kw_after 433 "and" oper 434 "begin" kw 435 "break" loop 436 "case" label 437 "catch" stmt 438 "class" kw_class 439 "def" kw_def 440 "defined" kw 441 "do" loop 442 "else" cond 443 "elsif" cond 444 "end" kw 445 "ensure" kw 446 "fail" kw 447 "false" bool 448 "for" loop 449 "if" cond 450 "in" oper 451 "lambda" kw 452 "module" kw_class 453 "next" kw 454 "nil" const 455 "not" oper 456 "or" oper 457 "private" storage 458 "proc" kw 459 "protected" storage 460 "public" storage 461 "raise" stmt 462 "redo" kw 463 "rescue" kw 464 "retry" stmt 465 "return" stmt 466 "self" kw_after 467 "super" kw 468 "then" cond 469 "throw" stmt 470 "true" bool 471 "undef" stmt 472 "unless" cond 473 "until" loop 474 "when" loop 475 "while" loop 476 "yield" stmt 477 # quasi-keywords (Module or Kernel methods) 478 "require" kw 479 "autoload" kw 480 "extend" kw 481 "include" kw 482 "puts" kw 483 "exit" kw 484 "attr_accessor" kw 485 "attr_reader" kw 486 "attr_writer" kw 487 "module_function" kw 488 done 489 # allowing ?! is not nearly correct but fixes more than 490 # it destructs 491 "\c?!" ident 492 493 :bool Boolean 494 * rest noeat 495 496 :loop Loop 497 * rest noeat 498 499 :cond Conditional 500 * rest noeat 501 502 :oper Operator 503 * rest noeat 504 505 :kw Keyword 506 * rest noeat 507 508 :label Label 509 * rest noeat 510 511 :const Constant 512 * rest noeat 513 514 :storage StorageClass 515 * rest noeat 516 517 :struct Structure 518 * rest noeat 519 520 :const Constant 521 * rest noeat 522 523 :stmt Statement 524 * rest noeat 525 526 # Handle case of def / 527 :kw_after Keyword 528 * after_term noeat 529 530 :kw_def Structure 531 * after_term noeat 532 " \t\n" kw_def_space 533 534 :kw_def_space Idle 535 * rest noeat 536 "\i" kw_func_decl noeat 537 " \t\n" kw_def_space 538 539 :kw_func_decl DefinedFunction 540 * rest noeat 541 "\c!?" kw_func_decl 542 543 :kw_class Structure 544 * rest noeat 545 " \t\n" kw_class_space 546 547 :kw_class_space Idle 548 * rest noeat 549 # first char should be uppercase letter 550 "\i" kw_class_decl noeat 551 " \t\n" kw_class_space 552 553 :kw_class_decl DefinedType 554 * rest noeat 555 "\c!?" kw_class_decl 556 557 :pstring Idle 558 * match noeat 559 " \t" after_term noeat 560 "xrsqQwW" match 561 .ifdef erb 562 ">" NULL recolor=-2 return 563 .endif 564 565 :match Idle 566 * inmatch save_c recolor=-1 567 " \t" match 568 569 :inmatch Regex string 570 * inmatch 571 & after_term 572 % inmatch call=.inmatch_recur() 573 "#" inmatch_maybe_subst 574 "\\" inmatch_quote recolor=-1 575 576 :inmatch_maybe_subst Regex string 577 * inmatch noeat 578 "{" inmatch_subst recolor=-2 call=.ruby(squiggly) 579 580 :inmatch_subst Idle 581 * inmatch noeat 582 583 :inmatch_quote RegexEscape string 584 * inmatch 585 586 :subst Idle 587 * insubst save_c recolor=-1 588 "<([{`" delim_insubst save_c recolor=-1 589 " \t" subst 590 591 :insubst Regex string 592 * insubst 593 & inrepl 594 "\\" insubst_quote recolor=-1 595 596 :insubst_quote RegexEscape string 597 * insubst 598 599 :inrepl Regex string 600 * inrepl 601 & after_term 602 "\\" inrepl_quote 603 604 :inrepl_quote RegexEscape string 605 * inrepl 606 607 :delim_insubst Regex string 608 * delim_insubst 609 & delim_repl 610 "\\" delim_quote 611 612 :delim_quote RegexEscape string 613 * delim_insubst 614 615 :delim_repl Regex string 616 * repl save_c recolor=-1 617 " \t" delim_repl 618 619 :repl Regex string 620 * repl 621 & after_term 622 "\\" repl_quote 623 624 :repl_quote RegexEscape string 625 * repl 626 627 :maybe_symbol Idle 628 * rest noeat 629 # prevent wrong Module::Member detection 630 ":" rest 631 # first char mustn't be 0-9 632 "\i" symbol recolor=-2 633 "\"" symbol_str recolor=-2 634 "'" symbol_str_sq recolor=-2 635 "/" rest 636 637 :symbol Symbol 638 * rest noeat 639 "\c?!" symbol 640 641 :symbol_str Symbol 642 * symbol_str 643 "\"" after_term 644 "#" symbol_maybe_str_subst recolor=-1 645 646 :symbol_maybe_str_subst Symbol 647 * symbol_str 648 "{" symbol_str_subst recolor=-2 call=.ruby(squiggly) 649 650 :symbol_str_subst Idle 651 * symbol_str noeat 652 653 :symbol_str_sq Symbol 654 * symbol_str_sq 655 "'" after_term 656 657 :proc_arg ProcArg 658 * rest noeat 659 "," proc_arg_sep noeat 660 "\i" proc_arg 661 662 :proc_arg_sep Idle 663 * proc_arg 664 665 :class_member1 Idle 666 * rest noeat 667 "\i" class_member recolor=-2 668 "@" class_member2 669 670 :class_member2 ClassMember 671 * rest noeat 672 "\i" class_member recolor=-3 673 674 :class_member ClassMember 675 * after_term noeat 676 "\c" class_member 677 678 :global_var GlobalVar 679 * after_term noeat 680 "\c" global_var 681 682 .end 683 684 .subr inmatch_recur 685 686 :inmatch Constant 687 * inmatch 688 & after_term return 689 % inmatch call=.inmatch_recur() 690 "#" inmatch_maybe_subst 691 "\\" inmatch_quote recolor=-1 692 693 :inmatch_maybe_subst Constant 694 * inmatch noeat 695 "{" inmatch_subst recolor=-2 call=.ruby(squiggly) 696 697 :inmatch_subst Idle 698 * inmatch noeat 699 700 :inmatch_quote Escape 701 * inmatch 702 703 .end