dotfiles

My dotfiles.
Log | Files | Refs | LICENSE

perl.jsf (7797B)


      1 # JOE syntax highlight file for Perl
      2 
      3 # Define colors
      4 
      5 =Idle
      6 =Ident
      7 =Comment
      8 =Pod		+Preproc
      9 =Variable	+DefinedIdent # TODO: Make this work.
     10 =Constant
     11 =Number		+Constant
     12 =String		+Constant
     13 =StringEscape	+Escape
     14 =StringVariable	+StringEscape
     15 =Regex		+String
     16 =RegexEscape	+StringEscape
     17 =Type
     18 =Keyword
     19 =Statement	+Keyword
     20 =Loop		+Statement
     21 =Conditional	+Statement
     22 =Structure	+Statement
     23 =Bad
     24 
     25 :begin Idle
     26 	*		begin noeat call=.perl()
     27 
     28 #
     29 # Perl as a subroutine for Mason
     30 #
     31 
     32 .subr perl
     33 
     34 # Detect pod
     35 
     36 :idle Idle
     37 	*		idle1		noeat
     38 .ifdef mason_line
     39 	"\n"		idle return
     40 .else
     41 	"\n"		idle
     42 .endif
     43 	"="		pod_start
     44 
     45 # allow keywords
     46 
     47 :idle1 Idle
     48 	*		idle1
     49 	"#"		line_comment_i	recolor=-1
     50 	"\n"		idle noeat
     51 	"0"		first_digit	recolor=-1
     52 	"1-9"		decimal	recolor=-1
     53 	"."		maybe_float
     54 	"\""		string		recolor=-1
     55 	"'"		char		recolor=-1
     56 	"`"		backtick	recolor=-1
     57 	"<"		maybe_inc
     58 	"$"		not_string	buffer recolor=-1
     59 .ifdef mason_block
     60 	"&%"		perl_maybe_done	buffer
     61 	"-@\i"		ident		buffer recolor=-1
     62 .else
     63 	"/"		regex		recolor=-1
     64 	"-\i@%&"	ident		buffer recolor=-1
     65 .endif
     66 
     67 :perl_maybe_done Idle
     68 	*		ident noeat
     69 	">"		idle1	recolor=-2 return
     70 
     71 # prevent keywords
     72 
     73 :rest Idle
     74 	*		rest
     75 	"({;~"		idle1
     76 	"#"		line_comment	recolor=-1
     77 	"\n"		idle noeat
     78 	"0"		first_digit	recolor=-1
     79 	"1-9"		decimal	recolor=-1
     80 	"."		maybe_float
     81 	"\""		string		recolor=-1
     82 	"'"		char		recolor=-1
     83 	"`"		backtick	recolor=-1
     84 	"$"		not_string	buffer recolor=-1
     85 	"<"		maybe_inc
     86 .ifdef mason_block
     87 	"&%"		perl_maybe_done buffer recolor=-1
     88 	"\i@"		maybe_string	buffer
     89 .else
     90 	"\i@%&"		maybe_string	buffer
     91 .endif
     92 
     93 :pod_start Idle
     94 	*		pod_start
     95 	"\n"		pod_block
     96 
     97 :pod_block Pod
     98 	*		pod_block
     99 	"="		pod_ident	buffer
    100 
    101 :pod_ident Pod
    102 	*		pod_block	noeat strings
    103 	"=cut"		rest
    104 done
    105 	"\c"		pod_ident
    106 
    107 :maybe_inc Idle
    108 	*		rest		noeat
    109 .ifdef mason_block
    110 	"/"		perl_maybe_done_2
    111 .endif
    112 	"<"		maybe_inc1
    113 
    114 :perl_maybe_done_2 Idle
    115 	*		perl_idle	noeat
    116 	"a-z"		perl_maybe_done_2
    117 	">"		idle
    118 
    119 
    120 :maybe_inc1 Idle
    121 	*		rest		noeat
    122 	" 	"	maybe_inc1
    123 	"'\""		quoted_inc_start	save_c recolor=-1
    124 	"\i"		inc		buffer noeat
    125 
    126 :quoted_inc_start Variable
    127 	*		quoted_inc	buffer
    128 
    129 :quoted_inc Variable
    130 	*		quoted_inc
    131 	&		skipline	save_s
    132 
    133 :inc Variable
    134 	*		skipline	save_s noeat
    135 	"\c"		inc
    136 
    137 # Should be treated as a normal line here...
    138 
    139 :skipline Idle
    140 	*		skipline
    141 	"\n"		next_line
    142 
    143 :todelim String string
    144 	*		todelim
    145 	"\n"		next_line	strings
    146 	"&"		founddelim
    147 done
    148 
    149 # eat \n so it's not in string.
    150 :next_line String string
    151 	*		todelim		buffer
    152 	"\n"		next_line
    153 
    154 :founddelim Variable
    155 	*		idle		noeat
    156 
    157 :regex Regex
    158 	*		regex
    159 	"\\"		regex_quote	recolor=-1
    160 	"/"		rest
    161 
    162 :regex_quote RegexEscape
    163 	*		regex
    164 
    165 :not_string Idle
    166 	*		rest noeat
    167 	"\i"		ident
    168 	"\"'`#"		rest
    169 
    170 :line_comment Comment comment
    171 	*		line_comment
    172 	"BFHNTX"	line_comment	noeat call=comment_todo.comment_todo()
    173 	"\n"		rest
    174 
    175 :line_comment_i Comment comment
    176 	*		line_comment_i
    177 	"BFHNTX"	line_comment_i	noeat call=comment_todo.comment_todo()
    178 	"\n"		idle noeat
    179 
    180 :end_of_file_comment Comment comment
    181 	"BFHNTX"	end_of_file_comment	noeat call=comment_todo.comment_todo()
    182 	*		end_of_file_comment
    183 
    184 :first_digit Number
    185 	*		rest	noeat
    186 	"x"		hex
    187 	"b"		binary
    188 	"."		float
    189 	"eE"		epart
    190 	"0-7"		octal
    191 	"89"		bad_number	recolor=-1
    192 
    193 :bad_number Bad
    194 	*		rest	noeat
    195 	"0-9"		bad_number
    196 
    197 :octal Number
    198 	*		rest	noeat
    199 	"0-7_"		octal
    200 	"89"		bad_number	recolor=-1
    201 
    202 :binary Number
    203 	*		rest	noeat
    204 	"01_"		binary
    205 	"2-9"		bad_number	recolor=-1
    206 
    207 :hex Number
    208 	*		rest	noeat
    209 	"0-9A-Fa-f_"	hex
    210 
    211 :decimal Number
    212 	*		rest	noeat
    213 	"0-9_"		decimal
    214 	"eE"		epart
    215 	"."		float
    216 
    217 :maybe_float Number
    218 	*		rest	recolor=-2	noeat
    219 	"0-9"		float		recolor=-2
    220 
    221 :float Number
    222 	*		rest	noeat
    223 	"eE"		epart
    224 	"0-9_"		float
    225 
    226 :epart Number
    227 	*		rest	noeat
    228 	"0-9+\-"	enum
    229 
    230 :enum Number
    231 	*		rest	noeat
    232 	"0-9_"		enum
    233 
    234 :string	String string
    235 	*		string
    236 	"\""		rest
    237 	"\\"		string_escape	recolor=-1
    238 	"$@"		string_subst	recolor=-1
    239 
    240 :string_subst StringVariable string
    241 	*		string	noeat recolor=-1
    242 	"\c"		string_subst
    243 
    244 :string_escape StringEscape string
    245 	*		string
    246 	"x"		string_hex1
    247 	"c"		string_ctrl
    248 	"N"		string_named
    249 	"0-7"		string_octal2
    250 	"\n"		string		recolor=-2
    251 
    252 :string_named StringEscape string
    253 	*		string
    254 	"{"		string_named_rest
    255 
    256 :string_named_rest StringEscape string
    257 	*		string_named_rest
    258 	"}"		string
    259 
    260 :string_ctrl StringEscape string
    261 	*		string
    262 
    263 :string_hex1 StringEscape string
    264 	*		string		noeat
    265 	"{"		string_unicode
    266 	"0-9a-fA-F"	string_hex2
    267 
    268 :string_unicode StringEscape string
    269 	*		string_unicode
    270 	"}"		string
    271 
    272 :string_hex2 StringEscape string
    273 	*		string		noeat
    274 	"0-9a-fA-F"	string
    275 
    276 :string_octal2 StringEscape string
    277 	*		string		noeat
    278 	"0-7"		string_octal3
    279 
    280 :string_octal3 StringEscape string
    281 	*		string		noeat
    282 	"0-7"		string
    283 
    284 :char String string
    285 	*		char
    286 	"\n"		idle noeat
    287 	"'"		rest
    288 	"\\"		char_escape	recolor=-1
    289 
    290 :char_escape	StringEscape string
    291 	*		char		recolor=-2
    292 	"\\'"		char
    293 
    294 :backtick	String string
    295 	*		backtick
    296 	"`"		rest
    297 	"\\"		backtick_escape	recolor=-1
    298 	"$@"		backtick_subst recolor=-1
    299 
    300 :backtick_subst StringVariable string
    301 	*		backtick	noeat recolor=-1
    302 	"\c"		backtick_subst
    303 
    304 :backtick_escape StringEscape string
    305 	*		backtick
    306 	"x"		backtick_hex1
    307 	"c"		backtick_ctrl
    308 	"N"		backtick_named
    309 	"0-7"		backtick_octal2
    310 	"\n"		backtick		recolor=-2
    311 
    312 :backtick_named StringEscape string
    313 	*		backtick
    314 	"{"		backtick_named_rest
    315 
    316 :backtick_named_rest StringEscape string
    317 	*		backtick_named_rest
    318 	"}"		backtick
    319 
    320 :backtick_ctrl StringEscape string
    321 	*		backtick
    322 
    323 :backtick_hex1 StringEscape string
    324 	*		backtick		noeat
    325 	"{"		backtick_unicode
    326 	"0-9a-fA-F"	backtick_hex2
    327 
    328 :backtick_unicode StringEscape string
    329 	*		backtick_unicode
    330 	"}"		backtick
    331 
    332 :backtick_hex2 StringEscape string
    333 	*		backtick		noeat
    334 	"0-9a-fA-F"	backtick
    335 
    336 :backtick_octal2 StringEscape string
    337 	*		backtick		noeat
    338 	"0-7"		backtick_octal3
    339 
    340 :backtick_octal3 StringEscape string
    341 	*		backtick		noeat
    342 	"0-7"		backtick
    343 
    344 # TODO: Tease out the variable logic from this so that we can highlight
    345 # variables separate from other identifiers.
    346 
    347 :ident Ident
    348 	*		rest		noeat strings
    349 	"BEGIN"		kw
    350 	"END"		kw
    351 	"if"		cond
    352 	"unless"	cond
    353 	"while"		loop
    354 	"until"		loop
    355 	"foreach"	loop
    356 	"sub"		struct
    357 	"my"		kw
    358 	"do"		loop
    359 	"if"		cond
    360 	"else"		cond
    361 	"elsif"		cond
    362 	"for"		loop
    363 	"continue"	loop
    364 	"last"		loop
    365 	"print"		stmt
    366 	"reset"		kw
    367 	"die"		stmt
    368 	"goto"		stmt
    369 	"require"	stmt
    370 	"use"		kw
    371 	"eval"		kw
    372 	"redo"		kw
    373 	"next"		loop
    374 	"warn"		stmt
    375 	"return"	stmt
    376 	"printf"	stmt
    377 	"close"		stmt
    378 	"package"	kw
    379 	"m"		match
    380 	"qr"		match
    381 	"qq"		match
    382 	"qx"		match
    383 	"qw"		match
    384 	"q"		match
    385 	"s"		subst
    386 	"tr"		subst
    387 	"y"		subst
    388 	"__END__"	end_of_file_comment
    389 	"__DATA__"	end_of_file_comment
    390 done
    391 	"\c"		ident
    392 
    393 :maybe_string Idle
    394 	*		rest		noeat strings
    395 	"qr"		match
    396 	"qq"		match
    397 	"qx"		match
    398 	"qw"		match
    399 	"q"		match
    400 done
    401 	"\c"		maybe_string
    402 
    403 :type Type
    404 	*		rest	noeat
    405 
    406 :kw Keyword
    407 	*		rest	noeat
    408 
    409 :cond Conditional
    410 	*		rest	noeat
    411 
    412 :loop Loop
    413 	*		rest	noeat
    414 
    415 :struct Structure
    416 	*		rest	noeat
    417 
    418 :stmt Statement
    419 	*		rest	noeat
    420 
    421 :match Idle
    422 	*		inmatch		save_c recolor=-1
    423 	" 	"	match
    424 
    425 :inmatch Regex
    426 	*		inmatch
    427 	%		inmatch		call=.inmatch()
    428 	&		rest
    429 	"\\"		inmatch_quote	recolor=-1
    430 
    431 :inmatch_quote RegexEscape
    432 	*		inmatch
    433 
    434 :subst Idle
    435 	*		insubst		save_c recolor=-1
    436 	"<([{`"		delim_insubst	save_c recolor=-1
    437 	" 	"	subst
    438 
    439 :insubst Regex
    440 	*		insubst
    441 	&		inrepl
    442 	"\\"		insubst_quote	recolor=-1
    443 
    444 :insubst_quote RegexEscape
    445 	*		insubst
    446 
    447 :inrepl Regex
    448 	*		inrepl
    449 	&		rest
    450 	"\\"		inrepl_quote
    451 
    452 :inrepl_quote RegexEscape
    453 	*		inrepl
    454 
    455 :delim_insubst Regex
    456 	*		delim_insubst
    457 	&		delim_repl
    458 	"\\"		delim_quote
    459 
    460 :delim_quote RegexEscape
    461 	*		delim_insubst
    462 
    463 :delim_repl Regex
    464 	*		repl		save_c recolor=-1
    465 	" 	"	delim_repl
    466 
    467 :repl Regex
    468 	*		repl
    469 	&		rest
    470 	"\\"		repl_quote
    471 
    472 :repl_quote RegexEscape
    473 	*		repl
    474 
    475 .end
    476 
    477 .subr inmatch
    478 
    479 :inmatch Regex
    480 	*		inmatch
    481 	%		inmatch		call=.inmatch()
    482 	&		inmatch		return
    483 	"\\"		inmatch_quote	recolor=-1
    484 
    485 :inmatch_quote RegexEscape
    486 	*		inmatch
    487 .end