dotfiles

My dotfiles.
git clone git://git.ryanmj.xyz/dotfiles.git
Log | Files | Refs | LICENSE

ruby.jsf.in (10152B)


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