dotfiles

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

coffee.jsf (8386B)


      1 # JOE syntax highlight file for Coffeescript
      2 
      3 # node = a.b.c /\s+/ seems to be allowed, foo
      4 # need to recognize ... and ..
      5 # include - as part of number?
      6 
      7 # after term: it's a regex if
      8 
      9 # suppress literals after .
     10 
     11 =Idle
     12 =Comment	green
     13 =Constant	cyan
     14 =Escape		bold cyan
     15 =Operator	bold
     16 =Keyword	bold
     17 =Bad		bold red
     18 
     19 :pre_idle Idle
     20 	*		NULL		noeat call=.coffee()
     21 
     22 .subr coffee
     23 
     24 :idle Idle
     25 	*		idle
     26 	"("		idle		call=.coffee(paren)
     27 	"["		idle		call=.coffee(brack)
     28 	"{"		idle		call=.coffee(squiggly)
     29 .ifdef paren
     30 	")"		idle		return
     31 .else
     32 	")"		stray		recolor=-1
     33 .endif
     34 .ifdef brack
     35 	"]"		idle		return
     36 .else
     37 	"]"		stray		recolor=-1
     38 .endif
     39 .ifdef squiggly
     40 	"}"		idle		return
     41 .else
     42 	"}"		stray		recolor=-1
     43 .endif
     44 	"#"		comment		recolor=-1
     45 	"0"		zero		recolor=-1
     46 	"1-9"		decimal		recolor=-1
     47 	"."		decimal_point	recolor=-1
     48 	"\""		maybe_string	recolor=-1
     49 	"'"		maybe_char	recolor=-1
     50 	"/"		slash		recolor=-1
     51 	"@$\i"		ident		buffer
     52 
     53 :stray Bad
     54 	*		idle
     55 
     56 :after_term Idle
     57 	*		idle		noeat
     58 	" \t"		after_term_1
     59 	"/"		slash_after_term_0
     60 
     61 # "foo/x" is division?
     62 # "foo/ x" is division.
     63 
     64 :slash_after_term_0 Idle
     65 	*		idle		noeat
     66 
     67 :after_term_1 Idle
     68 	*		idle		noeat
     69 	" \t"		after_term_1
     70 	"/"		slash_after_term_1
     71 
     72 # "foo / x"  is division
     73 # "foo /x"   is regex
     74 
     75 :slash_after_term_1 Idle
     76 	*		sregex		noeat
     77 	"/"		slashslash
     78 	" =	"	idle		noeat
     79 
     80 :comment Comment
     81 	*		line_comment	noeat
     82 	"#"		maybe_block_comment
     83 
     84 :maybe_block_comment Comment
     85 	*		line_comment	noeat
     86 	"#"		maybe_block_comment_1
     87 
     88 # This is weird... #### is a line comment, but ### is a block comment
     89 
     90 :maybe_block_comment_1 Comment
     91 	*		block_comment	noeat
     92 	"#"		line_comment
     93 
     94 :line_comment Comment
     95 	*		line_comment
     96 	"\n"		idle
     97 
     98 :block_comment Comment
     99 	*		block_comment
    100 	"#"		block_comment_1
    101 
    102 :block_comment_1 Comment
    103 	*		block_comment	noeat
    104 	"#"		block_comment_2
    105 
    106 :block_comment_2 Comment
    107 	*		block_comment	noeat
    108 	"#"		idle
    109 
    110 # Check for regex
    111 
    112 :slash Constant
    113 	*		sregex		noeat
    114 	"/"		slashslash
    115 
    116 :slashslash Constant
    117 	*		after_term		noeat
    118 	"/"		regex
    119 
    120 # Regex like this ///foo///
    121 
    122 :regex Constant
    123 	*		regex
    124 	"\\"		regex_escape	recolor=-1
    125 	"#"		regex_maybe_subst
    126 	"/"		regexslash
    127 
    128 :regex_maybe_subst Constant
    129 	*		regex	noeat
    130 	"{"		regex		recolor=-2 call=.coffee(squiggly)
    131 
    132 :regexslash Constant
    133 	*		regex		noeat
    134 	"/"		regexslashslash
    135 
    136 :regexslashslash Constant
    137 	*		regex		noeat
    138 	"/"		after_term
    139 
    140 :regex_escape Escape
    141 	*		regex
    142 	"x"		regex_hex2
    143 	"u"		regex_hex4
    144 
    145 :regex_uni Escape
    146 	*		regex_uni
    147 	"}"		regex
    148 
    149 :regex_hex4 Escape
    150 	*		regex		noeat
    151 	"{"		regex_uni
    152 	"0-9a-fA-F"	regex_hex3
    153 
    154 :regex_hex3 Escape
    155 	*		regex		noeat
    156 	"0-9a-fA-F"	regex_hex2
    157 
    158 :regex_hex2 Escape
    159 	*		regex		noeat
    160 	"0-9a-fA-F"	regex_hex1
    161 
    162 :regex_hex1 Escape
    163 	*		regex		noeat
    164 	"0-9a-fA-F"	regex
    165 
    166 # Regex like this: /foo/
    167 
    168 :sregex Constant
    169 	*		sregex
    170 	"\\"		sregex_escape	recolor=-1
    171 	"#"		sregex_maybe_subst
    172 	"/"		after_term
    173 
    174 :sregex_maybe_subst Constant
    175 	*		sregex	noeat
    176 	"{"		sregex	call=.coffee(squiggly) recolor=-2
    177 
    178 :sregex_escape Escape
    179 	*		sregex
    180 	"x"		sregex_hex2
    181 	"u"		sregex_hex4
    182 
    183 :sregex_uni Escape
    184 	*		sregex_uni
    185 	"}"		sregex
    186 
    187 :sregex_hex4 Escape
    188 	*		sregex		noeat
    189 	"{"		sregex_uni
    190 	"0-9a-fA-F"	sregex_hex3
    191 
    192 :sregex_hex3 Escape
    193 	*		sregex		noeat
    194 	"0-9a-fA-F"	sregex_hex2
    195 
    196 :sregex_hex2 Escape
    197 	*		sregex		noeat
    198 	"0-9a-fA-F"	sregex_hex1
    199 
    200 :sregex_hex1 Escape
    201 	*		sregex		noeat
    202 	"0-9a-fA-F"	sregex
    203 
    204 # Numbers
    205 
    206 :bad_number Bad
    207 	*		after_term	noeat
    208 	"0-9"		bad_number
    209 
    210 :zero Constant
    211 	*		after_term	noeat
    212 	"b"		binary
    213 	"o"		octal
    214 	"x"		hex
    215 	"."		maybe_float
    216 	"eE"		epart
    217 	"0-9"		decimal	recolor=-1
    218 
    219 :decimal_point Constant
    220 	*		after_term	noeat	recolor=-2
    221 	"."		decimal_point_1	recolor=-2
    222 	"\i"		not_ident	recolor=-2
    223 	"0-9"		float
    224 
    225 :not_ident Idle
    226 	*		after_term	noeat
    227 	"\c"		not_ident
    228 
    229 :decimal_point_1 Idle
    230 	*		idle		noeat
    231 	"."		idle
    232 
    233 :octal Constant
    234 	*		after_term	noeat
    235 	"0-7_"		octal
    236 	"89"		bad_number	recolor=-1
    237 
    238 :binary Constant
    239 	*		after_term	noeat
    240 	"01_"		binary
    241 	"2-9"		bad_number	recolor=-1
    242 
    243 :hex Constant
    244 	*		after_term	noeat
    245 	"0-9A-Fa-f_"	hex
    246 
    247 :decimal Constant
    248 	*		after_term	noeat
    249 	"0-9_"		decimal
    250 	"eE"		epart
    251 	"."		maybe_float
    252 
    253 :maybe_float Constant
    254 	*		after_term	noeat recolor=-2
    255 	"."		decimal_point_1	recolor=-2
    256 	"eE"		epart
    257 	"0-9_"		float
    258 
    259 :float Constant
    260 	*		after_term	noeat
    261 	"eE"		epart
    262 	"0-9_"		float
    263 
    264 :epart Constant
    265 	*		after_term	noeat
    266 	"0-9+\-"	enum
    267 
    268 :enum Constant
    269 	*		after_term	noeat
    270 	"0-9_"		enum
    271 
    272 # strings like "hello"
    273 
    274 :maybe_string Constant
    275 	*		string		noeat
    276 	"\""		maybe_string_1
    277 
    278 :maybe_string_1 Constant
    279 	*		after_term	noeat
    280 	"\""		stringstring
    281 
    282 :string	Constant
    283 	*		string
    284 	"\""		after_term
    285 	"#"		string_maybe_subst
    286 	"\\"		string_escape	recolor=-1
    287 
    288 :string_maybe_subst Constant
    289 	*		string	noeat
    290 	"{"		string	call=.coffee(squiggly)	recolor=-2
    291 
    292 :string_escape Escape
    293 	*		string
    294 	"x"		string_hex2
    295 	"u"		string_hex4
    296 
    297 :string_uni Escape
    298 	*		string_uni
    299 	"}"		string
    300 
    301 :string_hex4 Escape
    302 	*		string		noeat
    303 	"{"		string_uni
    304 	"0-9a-fA-F"	string_hex3
    305 
    306 :string_hex3 Escape
    307 	*		string		noeat
    308 	"0-9a-fA-F"	string_hex2
    309 
    310 :string_hex2 Escape
    311 	*		string		noeat
    312 	"0-9a-fA-F"	string_hex1
    313 
    314 :string_hex1 Escape
    315 	*		string		noeat
    316 	"0-9a-fA-F"	string
    317 
    318 # Strings like """ foo """
    319 
    320 :stringstring	Constant
    321 	*		stringstring
    322 	"\""		stringstring_1
    323 	"#"		stringstring_maybe_subst
    324 	"\\"		stringstring_escape	recolor=-1
    325 
    326 :stringstring_1	Constant
    327 	*		stringstring	noeat
    328 	"\""		stringstring_2
    329 
    330 :stringstring_2 Constant
    331 	*		stringstring	noeat
    332 	"\""		after_term
    333 
    334 :stringstring_maybe_subst Constant
    335 	*		stringstring	noeat
    336 	"{"		stringstring	call=.coffee(squiggly)	recolor=-2
    337 
    338 :stringstring_escape Escape
    339 	*		stringstring
    340 	"x"		stringstring_hex2
    341 	"u"		stringstring_hex4
    342 
    343 :stringstring_uni Escape
    344 	*		stringstring_uni
    345 	"}"		stringstring
    346 
    347 :stringstring_hex4 Escape
    348 	*		stringstring		noeat
    349 	"{"		stringstring_uni
    350 	"0-9a-fA-F"	stringstring_hex3
    351 
    352 :stringstring_hex3 Escape
    353 	*		stringstring		noeat
    354 	"0-9a-fA-F"	stringstring_hex2
    355 
    356 :stringstring_hex2 Escape
    357 	*		stringstring		noeat
    358 	"0-9a-fA-F"	stringstring_hex1
    359 
    360 :stringstring_hex1 Escape
    361 	*		stringstring		noeat
    362 	"0-9a-fA-F"	stringstring
    363 
    364 # character constants like 'h'
    365 
    366 :maybe_char	Constant
    367 	*		char	noeat
    368 	"'"	maybe_char_1
    369 
    370 :maybe_char_1	Constant
    371 	*	after_term	noeat
    372 	"'"	charchar
    373 
    374 :char	Constant
    375 	*		char
    376 	"'"		after_term
    377 	"\\"		char_escape	recolor=-1
    378 
    379 :char_escape Escape
    380 	*		char		noeat
    381 	"x"		char_hex2
    382 	"u"		char_hex4
    383 
    384 :char_uni Escape
    385 	*		char_uni
    386 	"}"		char_done
    387 
    388 :char_hex4 Escape
    389 	*		char		noeat
    390 	"{"		char_uni
    391 	"0-9a-fA-F"	char_hex3
    392 
    393 :char_hex3 Escape
    394 	*		char		noeat
    395 	"0-9a-fA-F"	char_hex2
    396 
    397 :char_hex2 Escape
    398 	*		char		noeat
    399 	"0-9a-fA-F"	char_hex1
    400 
    401 :char_hex1 Escape
    402 	*		char		noeat
    403 	"0-9a-fA-F"	char
    404 
    405 # strings like this '''foo'''
    406 
    407 :charchar Constant
    408 	*		charchar
    409 	"'"		charchar_1
    410 	"\\"		charchar_escape	recolor=-1
    411 
    412 :charchar_1 Constant
    413 	*		charchar		noeat
    414 	"'"		charchar_2
    415 
    416 :charchar_2 Constant
    417 	*		charchar		noeat
    418 	"'"		after_term
    419 
    420 :charchar_escape Escape
    421 	*		charchar		noeat
    422 	"x"		charchar_hex2
    423 	"u"		charchar_hex4
    424 
    425 :charchar_uni Escape
    426 	*		charchar_uni
    427 	"}"		charchar_done
    428 
    429 :charchar_hex4 Escape
    430 	*		charchar		noeat
    431 	"{"		charchar_uni
    432 	"0-9a-fA-F"	charchar_hex3
    433 
    434 :charchar_hex3 Escape
    435 	*		charchar		noeat
    436 	"0-9a-fA-F"	charchar_hex2
    437 
    438 :charchar_hex2 Escape
    439 	*		charchar		noeat
    440 	"0-9a-fA-F"	charchar_hex1
    441 
    442 :charchar_hex1 Escape
    443 	*		charchar		noeat
    444 	"0-9a-fA-F"	charchar
    445 
    446 
    447 # Identifiers
    448 
    449 :ident Idle
    450 	*		after_term	noeat strings
    451 	"and"		operator
    452 	"break"		kw
    453 	"by"		kw
    454 	"catch"		kw
    455 	"class"		kw
    456 	"continue"	kw
    457 	"delete"	kw
    458 	"debugger"	kw
    459 	"do"		kw
    460 	"else"		kw
    461 	"extends"	kw
    462 	"false"		lit
    463 	"finally"	kw
    464 	"for"		kw
    465 	"if"		kw
    466 	"in"		kw
    467 	"instanceof"	kw
    468 	"is"		kw
    469 	"isnt"		kw
    470 	"loop"		kw
    471 	"new"		kw
    472 	"no"		lit
    473 	"not"		operator
    474 	"null"		lit
    475 	"off"		lit
    476 	"of"		kw
    477 	"on"		lit
    478 	"or"		operator
    479 	"return"	kw
    480 	"super"		kw
    481 	"switch"	kw
    482 	"then"		kw
    483 	"this"		lit
    484 	"throw"		kw
    485 	"true"		lit
    486 	"try"		kw
    487 	"typeof"	kw
    488 	"undefined"	lit
    489 	"unless"	kw
    490 	"until"		kw
    491 	"when"		kw
    492 	"while"		kw
    493 	"yes"		lit
    494 	"yield"		kw
    495 	"case"		forbid
    496 	"default"	forbid
    497 	"function"	forbid
    498 	"var"		forbid
    499 	"void"		forbid
    500 	"with"		forbid
    501 	"const"		forbid
    502 	"let"		forbid
    503 	"enum"		forbid
    504 	"export"	forbid
    505 	"import"	forbid
    506 	"native"	forbid
    507 	"implements"	forbid
    508 	"interface"	forbid
    509 	"package"	forbid
    510 	"private"	forbid
    511 	"protected"	forbid
    512 	"public"	forbid
    513 	"static"	forbid
    514 	"arguments"	forbid
    515 	"eval"		forbid
    516 done
    517 	"$\c"	ident
    518 
    519 :kw Keyword
    520 	*		idle			noeat
    521 
    522 :forbid Keyword
    523 	*		idle			noeat
    524 
    525 :lit Constant
    526 	*		after_term		noeat
    527 
    528 :operator Operator
    529 	*		idle			noeat
    530 
    531 .end