dotfiles

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

c.jsf.in (12644B)


      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 	green
    207 =IncLocal	cyan
    208 =IncSystem	bold cyan
    209 =Constant 	cyan
    210 =Escape 	bold cyan
    211 =Type 		bold
    212 =Keyword 	bold
    213 =CppKeyword	bold
    214 =Brace		magenta
    215 =Control
    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 	"/"		slash
    297 	"0"		first_digit	recolor=-1
    298 	"1-9"		decimal	recolor=-1
    299 	"."		maybe_float
    300 	"\""		string		recolor=-1
    301 	"'"		char		recolor=-1
    302 	"\i"		ident		buffer
    303 	"\\"		outside_escape	recolor=-1
    304 	"{}"		brace		recolor=-1
    305 	",:;=()><[]*&|!~+\-%^"	control		recolor=-1
    306 
    307 :outside_escape	Escape
    308 	*	idle
    309 
    310 :brace Brace
    311 	*	idle	noeat
    312 
    313 :control Control
    314 	*	idle	noeat
    315 
    316 :slash Idle
    317 	*		idle		noeat recolor=-2	# Not sure about this
    318 	"*"		comment		recolor=-2
    319 	"/"		line_comment	recolor=-2
    320 
    321 :comment Comment comment
    322 	*		comment
    323 	"*"		maybe_end_comment
    324 
    325 :maybe_end_comment Comment comment
    326 	*		comment
    327 	"/"		idle
    328 	"*"		maybe_end_comment
    329 
    330 :line_comment Comment comment
    331 	*		line_comment
    332 	"\n"		reset
    333 
    334 :first_digit Constant
    335 	*		idle	noeat
    336 	"xX"		hex
    337 	"."		float
    338 	"eE"		epart
    339 	"0-7"		octal
    340 	"89"		bad_number	recolor=-1
    341 
    342 :bad_number Bad
    343 	*		idle	noeat
    344 	"0-9"		bad_number
    345 
    346 :octal Constant
    347 	*		idle	noeat
    348 	"0-7"		octal
    349 	"89"		bad_number	recolor=-1
    350 
    351 :hex Constant
    352 	*		idle	noeat
    353 	"0-9A-Fa-f"	hex
    354 
    355 :decimal Constant
    356 	*		idle	noeat
    357 	"0-9"		decimal
    358 	"eE"		epart
    359 	"."		float
    360 
    361 :maybe_float Constant
    362 	*		idle	recolor=-2	noeat
    363 	"0-9"		float		recolor=-2
    364 
    365 :float Constant
    366 	*		idle	noeat
    367 	"eE"		epart
    368 	"0-9"		float
    369 
    370 :epart Constant
    371 	*		idle	noeat
    372 	"0-9+\-"	enum
    373 
    374 :enum Constant
    375 	*		idle	noeat
    376 	"0-9"		enum
    377 
    378 :string	Constant string
    379 	*		string
    380 	"\""		idle
    381 	"\\"		string_escape	recolor=-1
    382 	"%"		string_control	recolor=-1
    383 
    384 :string_escape Escape string
    385 	*		string
    386 	"x"		string_hex
    387 	"0-7"		string_octal2
    388 	"\n"		string		recolor=-2
    389 
    390 # \x will consume all successive hex digits (ANSI C).
    391 :string_hex Escape string
    392 	*		string		noeat
    393 	"0-9a-fA-F"	string_hex
    394 
    395 :string_octal2 Escape string
    396 	*		string		noeat
    397 	"0-7"		string_octal3
    398 
    399 :string_octal3 Escape string
    400 	*		string		noeat
    401 	"0-7"		string
    402 
    403 :string_control Escape string
    404 	*		string
    405 	"\""		string noeat
    406 	"\n"		reset
    407 	"\\"		string_escape	recolor=-1
    408 	"0-9.\-+ #hjILtz$"	string_control
    409 
    410 :char Constant string
    411 	*		char
    412 	"\n"		reset
    413 	"'"		idle
    414 	"\\"		char_escape	recolor=-1
    415 
    416 :char_escape	Escape string
    417 	*		char
    418 	"x"		char_hex
    419 	"0-7"		char_octal2
    420 	"\n"		char		recolor=-2
    421 
    422 # \x will consume all successive hex digits (ANSI C).
    423 :char_hex Escape string
    424 	*		char		noeat
    425 	"0-9a-fA-F"	char_hex
    426 
    427 :char_octal2 Escape string
    428 	*		char		noeat
    429 	"0-7"		char_octal3
    430 
    431 :char_octal3 Escape string
    432 	*		char		noeat
    433 	"0-7"		char
    434 
    435 :ident Idle
    436 	*		idle		noeat strings
    437 	"int"		type
    438 	"float"		type
    439 	"long"		type
    440 	"short"		type
    441 	"char"		type
    442 	"double"	type
    443 	"signed"	type
    444 	"unsigned"	type
    445 	"void"		type
    446 	"static"	type
    447 	"register"	type
    448 	"extern"	type
    449 	"inline"	type
    450 	"auto"		type
    451 	"const"		type
    452 	"volatile"	type
    453 	"if"		kw
    454 	"else"		kw
    455 	"while"		kw
    456 	"for"		kw
    457 	"break"		kw
    458 	"continue"	kw
    459 	"do"		kw
    460 	"case"		kw
    461 	"default"	kw
    462 	"switch"	kw
    463 	"goto"		kw
    464 	"struct"	kw
    465 	"enum"		kw
    466 	"return"	kw
    467 	"sizeof"	kw
    468 	"typedef"	kw
    469 	"union"		kw
    470 	"asm"		kw
    471 # C++ keywords
    472 	#"asm"			cppkw (listed above as a C keyword)
    473 	"bool"			cppkw
    474 	"catch"			cppkw
    475 	"class"			cppkw
    476 	"const_cast"		cppkw
    477 	"delete"		cppkw
    478 	"dynamic_cast"		cppkw
    479 	"explicit"		cppkw
    480 	"false"			cppkw
    481 	"friend"		cppkw
    482 	#"inline"		cppkw (listed above as a C keyword)
    483 	"mutable"		cppkw
    484 	"namespace"		cppkw
    485 	"new"			cppkw
    486 	"operator"		cppkw
    487 	"private"		cppkw
    488 	"protected"		cppkw
    489 	"public"		cppkw
    490 	"reinterpret_cast"	cppkw
    491 	"static_cast"		cppkw
    492 	"template"		cppkw
    493 	"this"			cppkw
    494 	"throw"			cppkw
    495 	"true"			cppkw
    496 	"try"			cppkw
    497 	"typeid"		cppkw
    498 	"typename"		cppkw
    499 	"using"			cppkw
    500 	"virtual"		cppkw
    501 	"wchar_t"		type
    502 # Non-Standard
    503 	"typeof"		cppkw
    504 done
    505 	"\c"		ident
    506 
    507 :type Type
    508 	*	idle	noeat
    509 
    510 :kw Keyword
    511 	*	idle	noeat
    512 
    513 :cppkw CppKeyword
    514 	*	idle	noeat