dotfiles

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

c.jsf.back (12691B)


      1 # JOE syntax highlight file for C and C++
      2 
      3 # A (deterministic) state machine which performs lexical analysis of C.
      4 # (This is the "assembly language" of syntax highlighting.  A separate
      5 # program could be used to convert a regular expression NFA syntax into this
      6 # format).
      7 
      8 # Each state begins with ':<name> <color-name> <context>'
      9 #
     10 # <color-name> is the color used for characters eaten by the state
     11 # (really a symbol for a user definable color).
     12 #
     13 # <context> tells JOE if the current character is part of a comment or a string.
     14 # This allows JOE to skip over comments and strings when matching characters
     15 # such as parentheses.  To use this feature, the -highlighter_context option
     16 # must be applied to the files highlighted by the corresponding syntax.  To
     17 # apply the option, add it to ftyperc for those file entries.
     18 #
     19 # The valid contexts are:
     20 #   comment  This character is part of a comment.  Example:  /* comment */
     21 #
     22 #   string   This character is part of a string.  Examples: "string" 'c' 'string'
     23 #
     24 # The comment and string delimiters themselves should be marked with the
     25 # appropriate context.  The context is considered to be part of the color, so
     26 # the recolor=-N and recolormark options apply the context to previous
     27 # characters.
     28 
     29 # The first state defined is the initial state.
     30 
     31 # Within a state, define transitions (jumps) to other states.  Each
     32 # jump has the form: <character-list> <target-state> [<option>s]
     33 
     34 # There are three ways to specify <character-list>s, either * for any
     35 # character not otherwise specified, % or & to match the character in the
     36 # delimiter match buffer or a literal list of characters within quotes
     37 # (ranges and escape sequences allowed).  When the next character matches
     38 # any in the list, a jump to the target-state is taken and the character is
     39 # eaten (we advance to the next character of the file to be colored).
     40 #
     41 # The * transition should be the first transition specified in the state.
     42 #
     43 # There are several options:
     44 #   noeat     	do not eat the character, instead feed it to the next state
     45 #             	(this tends to make the states smaller, but be careful: you
     46 #		can make infinite loops).  'noeat' implies 'recolor=-1'.
     47 #
     48 #   recolor=-N	Recolor the past N characters with the color of the
     49 #		target-state.  For example once /* is recognized as the
     50 #		start of C comment, you want to color the /* with the C
     51 #		comment color with recolor=-2.
     52 #
     53 #   mark	Mark beginning of a region with current position.
     54 #
     55 #   markend	Mark end of region.
     56 #
     57 #   recolormark Recolor all of the characters in the marked region with
     58 #               the color of the target-state.  If markend is not given,
     59 #		all of the characters up to the current position are recolored.
     60 #		Note that the marked region can not cross line boundaries and
     61 #               must be on the same line as recolormark.
     62 #
     63 #   buffer    	start copying characters to a string buffer, beginning with this
     64 #		one (it's ok to not terminate buffering with a matching
     65 #		'strings' option- the buffer is limited to leading 23
     66 #		characters).
     67 #
     68 #   save_c      Save character in delimiter match buffer.
     69 #
     70 #   save_s      Copy string buffer to delimiter match buffer.
     71 #
     72 #   strings	A list of strings follows.  If the buffer matches any of the
     73 #		given strings, a jump to the target-state in the string list
     74 #		is taken instead of the normal jump.
     75 #
     76 #   istrings	Same as strings, but case is ignored.
     77 #
     78 #               Note: strings and istrings should be the last option on the
     79 #		line.  They cause any options which follow them to be ignored.
     80 #
     81 #   hold        Stop buffering string- a future 'strings' or 'istrings' will
     82 #               look at contents of buffer at this point.  Useful for distinguishing
     83 #               commands and function calls in some languages 'write 7' is a command
     84 #               'write (' is a function call- hold lets us stop at the space and delay
     85 #               the string lookup until the ( or 7.
     86 #
     87 #   The format of the string list is:
     88 #
     89 #      "string"   <target-state> [<options>s]
     90 #      "string"   <target-state> [<options>s]
     91 #      "&"        <target-state> [<options>s]   # matches contents of delimiter match buffer
     92 #      done
     93 #
     94 #   (all of the options above are allowed except "strings", "istrings" and "noeat".  noeat is
     95 #    always implied after a matched string).
     96 #
     97 # Weirdness: only states have colors, not transitions.  This means that you
     98 # sometimes have to make dummy states with '* next-state noeat' just to get
     99 # a color specification.
    100 #
    101 # Delimiter match buffer is for perl and shell: a regex in perl can be s<..>(...)
    102 # and in shell you can say: <<EOS ....... EOS
    103 
    104 # New feature: subroutines
    105 #
    106 # Highlighter state machines can now make subroutine calls.  The highlighter has
    107 # a run-time stack that allows unlimited recursion.
    108 #
    109 # To call a subroutine, use the 'call' option:
    110 #
    111 #	"\""	fred	call=string(dquote)
    112 #
    113 # The subroutine called 'string' is called and the jump to 'fred' is
    114 # ignored.  The 'dquote' option is passed to the subroutine.
    115 #
    116 # The subroutine itself returns to the caller like this:
    117 #       "\""	whatever  return
    118 #
    119 # If we're in a subroutine, the return is made.  Otherwise the jump
    120 # to 'whatever' is made.
    121 #
    122 # There are several ways of delimiting subroutines which show up in how it
    123 # is called.  Here are the options:
    124 #
    125 # call=string()		  A file called string.jsf is the subroutine.
    126 #                         The entire file is the subroutine.  The starting
    127 #                         point is the first state in the file.
    128 #
    129 # call=library.string()	  A file called library.jsf has the subroutine.
    130 #                         The subroutine within the file is called string.
    131 #
    132 # call=.string()          There is a subroutine called string in the current file.
    133 #
    134 # When a subroutine is within a file, but is not the whole file, it is delimited
    135 # as follows:
    136 #
    137 #  .subr string
    138 #
    139 #  . . . states for string subroutine . . .
    140 #
    141 #  .end
    142 #
    143 # Option flags can be passed to subroutines which control preprocessor-like
    144 # directives.  For example:
    145 #
    146 # .ifdef dquote
    147 #    "\""	idle	return
    148 # .endif
    149 # .ifdef squote
    150 #    "'"	idle 	return
    151 # .endif
    152 #
    153 # .else if also available.  .ifdefs can be nested.
    154 
    155 
    156 # Obsolete feature: the sync lines specification no longer matter.  We now always parse
    157 # from the beginning of the file.  Here is the old description:
    158 #
    159 # Define no. sync lines
    160 # You can say:
    161 # -200     means 200 lines
    162 # -        means always start parsing from beginning of file when we lose sync
    163 #          if nothing is specified, the default is -50
    164 -
    165 
    166 # Define colors and attributes.  Give a list of attributes, one
    167 # background color and one foreground color (default is used if
    168 # color is left out).
    169 #
    170 # Attributes:
    171 #   bold inverse blink dim underline italic
    172 #
    173 # Standard colors:
    174 #
    175 # Foreground:
    176 #   white cyan magenta blue yellow green red black
    177 #
    178 # Background:
    179 #   bg_white bg_cyan bg_magenta bg_blue bg_yellow bg_green bg_red bg_black
    180 #
    181 # For 16 color and 256 color xterms: "export TERM=xterm-16color", these
    182 # brighter than normal colors are available:
    183 #
    184 # Note that you need an xterm which was compiled to support 16 or 256 colors
    185 # and a matching termcap/terminfo entry for it.
    186 #
    187 # Foreground:
    188 #   WHITE CYAN MAGENTA BLUE YELLOW GREEN RED BLACK
    189 #
    190 # Background:
    191 #   bg_WHITE bg_CYAN bg_MAGENTA bg_BLUE bg_YELLOW bg_GREEN bg_RED bg_BLACK
    192 #
    193 # For 256 color xterm: "export TERM=xterm-256color", these become available:
    194 #
    195 # Note that you need an xterm which was compiled to support 256 colors and a
    196 # matching termcap/terminfo entry for it.
    197 #
    198 # fg_RGB and bg_RGB, where R, G, and B range from 0 - 5.  So: fg_500 is bright red.
    199 #
    200 # fg_NN and bg_NN give shades of grey, where the intensity, NN, ranges from 0 - 23.
    201 
    202 =Idle
    203 =Bad		bold red
    204 =Preproc 	blue
    205 =Define		bold blue
    206 =Comment 	red
    207 =IncLocal	cyan
    208 =IncSystem	bold cyan
    209 =Constant 	magenta
    210 =Escape 	bold cyan
    211 =Type 		bold
    212 =Keyword 	bold
    213 =CppKeyword	bold
    214 =Brace		green
    215 =Control	cyan
    216 
    217 :reset Idle
    218 	*		first		noeat
    219 	" \t"		reset
    220 
    221 :first Idle
    222 	*		idle		noeat
    223 	"#"		pre		recolor=-1
    224 
    225 :pre Preproc
    226 	*		preproc		noeat
    227 	" \t"		pre
    228 	"a-z"		preident	recolor=-1 buffer
    229 
    230 :preident Preproc
    231 	*		preproc		noeat strings
    232 	"define"	predef
    233 	"include"	preinc
    234 done
    235 	"a-z"		preident
    236 
    237 :preinc Preproc
    238 	*		preinc
    239 	" \t"		preinc_ws
    240 	"\n"		reset
    241 	
    242 :preinc_ws Preproc
    243 	*		prebad		recolor=-1
    244 	" \t"		preinc_ws
    245 	"\""		preinc_local	recolor=-1
    246 	"<"		preinc_system	recolor=-1
    247 
    248 :preinc_local IncLocal string
    249 	*		preinc_local
    250 	"\"\n"		reset
    251 	
    252 :preinc_system IncSystem string
    253 	*		preinc_system
    254 	">\n"		reset
    255 
    256 :prebad	Bad	
    257 	*		prebad
    258 	"\n"		reset
    259 
    260 
    261 :predef Preproc
    262 	*		predef
    263 	" \t"		predef_ws
    264 	"\n"		reset
    265 	
    266 :predef_ws Preproc
    267 	*		prebad		recolor=-1
    268 	" \t"		predef_ws
    269 	"\c"		predef_ident	recolor=-1
    270 
    271 :predef_ident Define
    272 	*		idle		noeat
    273 	"\c"		predef_ident
    274 
    275 
    276 :preproc Preproc
    277 	*		preproc
    278 	"\n"		reset
    279 	"\\"		preproc_cont
    280 	"/"		preproc_slash
    281 	
    282 :preproc_slash Preproc
    283 	*		preproc		noeat
    284 	"*"		comment		recolor=-2
    285 	"/"		line_comment	recolor=-2
    286 	
    287 :preproc_cont Preproc
    288 	*		preproc_cont
    289 	"\n"		preproc
    290 
    291 # All following states are for when we're not in a preprocessor line
    292 
    293 :idle Idle
    294 	*		idle
    295 	"\n"		reset
    296 	"0"		first_digit	recolor=-1
    297 	"1-9"		decimal	recolor=-1
    298 	"."		maybe_float
    299 	"\""		string		recolor=-1
    300 	"'"		char		recolor=-1
    301 	"\i"		ident		buffer
    302 	"\\"		outside_escape	recolor=-1
    303 	"{}:,;"		brace		recolor=-1
    304 	",=()><[]*&|!~+\-%^\/"	control		recolor=-1
    305 	"/"		slash
    306 
    307 
    308 :outside_escape	Escape
    309 	*	idle
    310 
    311 :brace Brace
    312 	*	idle	noeat
    313 
    314 :control Control
    315 	*	idle	noeat
    316 
    317 :slash Idle
    318 	*		idle		noeat recolor=-2	# Not sure about this
    319 	"*"		comment		recolor=-2
    320 	"/"		line_comment	recolor=-2
    321 
    322 :comment Comment comment
    323 	*		comment
    324 	"*"		maybe_end_comment
    325 
    326 :maybe_end_comment Comment comment
    327 	*		comment
    328 	"/"		idle
    329 	"*"		maybe_end_comment
    330 
    331 :line_comment Comment comment
    332 	*		line_comment
    333 	"\n"		reset
    334 
    335 :first_digit Constant
    336 	*		idle	noeat
    337 	"xX"		hex
    338 	"."		float
    339 	"eE"		epart
    340 	"0-7"		octal
    341 	"89"		bad_number	recolor=-1
    342 
    343 :bad_number Bad
    344 	*		idle	noeat
    345 	"0-9"		bad_number
    346 
    347 :octal Constant
    348 	*		idle	noeat
    349 	"0-7"		octal
    350 	"89"		bad_number	recolor=-1
    351 
    352 :hex Constant
    353 	*		idle	noeat
    354 	"0-9A-Fa-f"	hex
    355 
    356 :decimal Constant
    357 	*		idle	noeat
    358 	"0-9"		decimal
    359 	"eE"		epart
    360 	"."		float
    361 
    362 :maybe_float Constant
    363 	*		idle	recolor=-2	noeat
    364 	"0-9"		float		recolor=-2
    365 
    366 :float Constant
    367 	*		idle	noeat
    368 	"eE"		epart
    369 	"0-9"		float
    370 
    371 :epart Constant
    372 	*		idle	noeat
    373 	"0-9+\-"	enum
    374 
    375 :enum Constant
    376 	*		idle	noeat
    377 	"0-9"		enum
    378 
    379 :string	Constant string
    380 	*		string
    381 	"\""		idle
    382 	"\\"		string_escape	recolor=-1
    383 	"%"		string_control	recolor=-1
    384 
    385 :string_escape Escape string
    386 	*		string
    387 	"x"		string_hex
    388 	"0-7"		string_octal2
    389 	"\n"		string		recolor=-2
    390 
    391 # \x will consume all successive hex digits (ANSI C).
    392 :string_hex Escape string
    393 	*		string		noeat
    394 	"0-9a-fA-F"	string_hex
    395 
    396 :string_octal2 Escape string
    397 	*		string		noeat
    398 	"0-7"		string_octal3
    399 
    400 :string_octal3 Escape string
    401 	*		string		noeat
    402 	"0-7"		string
    403 
    404 :string_control Escape string
    405 	*		string
    406 	"\""		string noeat
    407 	"\n"		reset
    408 	"\\"		string_escape	recolor=-1
    409 	"0-9.\-+ #hjILtz$"	string_control
    410 
    411 :char Constant string
    412 	*		char
    413 	"\n"		reset
    414 	"'"		idle
    415 	"\\"		char_escape	recolor=-1
    416 
    417 :char_escape	Escape string
    418 	*		char
    419 	"x"		char_hex
    420 	"0-7"		char_octal2
    421 	"\n"		char		recolor=-2
    422 
    423 # \x will consume all successive hex digits (ANSI C).
    424 :char_hex Escape string
    425 	*		char		noeat
    426 	"0-9a-fA-F"	char_hex
    427 
    428 :char_octal2 Escape string
    429 	*		char		noeat
    430 	"0-7"		char_octal3
    431 
    432 :char_octal3 Escape string
    433 	*		char		noeat
    434 	"0-7"		char
    435 
    436 :ident Idle
    437 	*		idle		noeat strings
    438 	"int"		type
    439 	"float"		type
    440 	"long"		type
    441 	"short"		type
    442 	"char"		type
    443 	"double"	type
    444 	"signed"	type
    445 	"unsigned"	type
    446 	"void"		type
    447 	"static"	type
    448 	"register"	type
    449 	"extern"	type
    450 	"inline"	type
    451 	"auto"		type
    452 	"const"		type
    453 	"volatile"	type
    454 	"if"		kw
    455 	"else"		kw
    456 	"while"		kw
    457 	"for"		kw
    458 	"break"		kw
    459 	"continue"	kw
    460 	"do"		kw
    461 	"case"		kw
    462 	"default"	kw
    463 	"switch"	kw
    464 	"goto"		kw
    465 	"struct"	kw
    466 	"enum"		kw
    467 	"return"	kw
    468 	"sizeof"	kw
    469 	"typedef"	kw
    470 	"union"		kw
    471 	"asm"		kw
    472 	"case"      kw
    473 # C++ keywords
    474 	#"asm"			cppkw (listed above as a C keyword)
    475 	"bool"			cppkw
    476 	"catch"			cppkw
    477 	"class"			cppkw
    478 	"const_cast"		cppkw
    479 	"delete"		cppkw
    480 	"dynamic_cast"		cppkw
    481 	"nullptr"       cppkw
    482 	"explicit"		cppkw
    483 	"false"			cppkw
    484 	"friend"		cppkw
    485 	#"inline"		cppkw (listed above as a C keyword)
    486 	"mutable"		cppkw
    487 	"namespace"		cppkw
    488 	"new"			cppkw
    489 	"operator"		cppkw
    490 	"private"		cppkw
    491 	"protected"		cppkw
    492 	"public"		cppkw
    493 	"reinterpret_cast"	cppkw
    494 	"static_cast"		cppkw
    495 	"template"		cppkw
    496 	"this"			cppkw
    497 	"throw"			cppkw
    498 	"true"			cppkw
    499 	"try"			cppkw
    500 	"typeid"		cppkw
    501 	"typename"		cppkw
    502 	"using"			cppkw
    503 	"virtual"		cppkw
    504 	"wchar_t"		type
    505 # Non-Standard
    506 	"typeof"		cppkw
    507 done
    508 	"\c"		ident
    509 
    510 :type Type
    511 	*	idle	noeat
    512 
    513 :kw Keyword
    514 	*	idle	noeat
    515 
    516 :cppkw CppKeyword
    517 	*	idle	noeat