1 # $MirOS: contrib/code/jupp/syntax/c.jsf.in,v 1.8 2017/12/02 05:38:05 tg Exp $
3 # JOE syntax highlight file for C and C++
5 # A (deterministic) state machine which performs lexical analysis of C.
6 # (This is the "assembly language" of syntax highlighting. A separate
7 # program could be used to convert a regular expression NFA syntax into this
10 # Each state begins with ':<name> <color-name>'
11 # <color-name> is the color used for characters eaten by the state
12 # (really a symbol for a user definable color).
14 # The first state defined is the initial state.
16 # Within a state, define transitions (jumps) to other states. Each
17 # jump has the form: <character-list> <target-state> [<option>s]
19 # There are two ways to specify <character-list>s, either * for any
20 # character not otherwise specified, or a literal list of characters within
21 # quotes (ranges and escape sequences allows). When the next character
22 # matches any in the list, a jump to the target-state is taken and the
23 # character is eaten (we advance to the next character of the file to be
26 # The * transition should be the first transition specified in the state.
28 # There are several options:
29 # noeat do not eat the character, instead feed it to the next state
30 # (this tends to make the states smaller, but be careful: you
31 # can make infinite loops). 'noeat' implies 'recolor=-1'.
33 # recolor=-N Recolor the past N characters with the color of the
34 # target-state. For example once /* is recognized as the
35 # start of C comment, you want to color the /* with the C
38 # buffer start copying characters to a buffer, beginning with this
39 # one (it's ok to not terminate buffering with a matching
40 # 'strings' option- the buffer is limited to leading 19
43 # strings A list of strings follows. If the buffer matches any of the
44 # given strings, a jump to the target-state in the string list
45 # is taken instead of the normal jump.
47 # istrings Same as strings, but case is ignored.
49 # hold Stop buffering string- a future 'strings' or 'istrings' will
50 # look at contents of buffer at this point. Useful for distinguishing
51 # commands and function calls in some languages 'write 7' is a command
52 # 'write (' is a function call- hold lets us stop at the space and delay
53 # the string lookup until the ( or 7.
55 # The format of the string list is:
57 # "string" <target-state> [<options>s]
58 # "string" <target-state> [<options>s]
61 # (all of the options above are allowed except "strings", "istrings" and "noeat". noeat is
62 # always implied after a matched string).
64 # Weirdness: only states have colors, not transitions. This means that you
65 # sometimes have to make dummy states with '* next-state noeat' just to get
66 # a color specification.
68 # Encoding: everything is handled as UTF-8 by octets, that is, you can have
69 # individual octets change states (the colour of the last octet applies).
70 # The JSF files themselves must accordingly be encoded in UTF-8. When a raw
71 # octet or an invalid UTF-8 sequence is read, a number of \xFF octets are
75 # Define no. sync lines
77 # -200 means 200 lines
78 # - means always start parsing from beginning of file when we lose sync
79 # if nothing is specified, the default is -120
81 # Always reparse from beginning
87 # bold inverse blink dim underline
88 # white cyan magenta blue yellow green red black
89 # bg_white bg_cyan bg_magenta bg_blue bg_yellow bg_green bg_red bg_black
117 "a-z" preident recolor=-1 buffer
120 * preproc noeat strings
134 "\"" preinc_local recolor=-1
135 "<" preinc_system recolor=-1
137 :preinc_local IncLocal
141 :preinc_system IncSystem
158 "a-zA-Z0-9_" predef_ident recolor=-1
162 "a-zA-Z0-9_" predef_ident
171 :preproc_slash Preproc
173 "*" comment recolor=-2
174 "/" line_comment recolor=-2
176 :preproc_cont Preproc
180 # All following states are for when we're not in a preprocessor line
186 "0" first_digit recolor=-1
187 "1-9" decimal recolor=-1
189 "\"" string recolor=-1
191 "a-zA-Z_" ident buffer
192 "{}" brace recolor=-1
193 ",:;=()><[]*&|!~+\-%^" control recolor=-1
202 * idle noeat recolor=-2 # Not sure about this
203 "*" comment recolor=-2
204 "/" line_comment recolor=-2
208 "*" maybe_end_comment
210 :maybe_end_comment Comment
213 "*" maybe_end_comment
215 :line_comment Comment
219 :first_digit Constant
225 "89" bad_number recolor=-1
234 "89" bad_number recolor=-1
246 :maybe_float Constant
247 * idle recolor=-2 noeat
248 "0-9" float recolor=-2
266 "\\" string_escape recolor=-1
267 "%" string_control recolor=-1
269 :string_escape Escape
273 "\n" string recolor=-2
277 "0-9a-fA-F" string_hex2
283 :string_octal2 Escape
287 :string_octal3 Escape
291 :string_control Escape
294 "diouxXeEfFgGaAcspn%SC\n" string
295 "\\" string_escape recolor=-1
301 "\\" char_escape recolor=-1
311 "0-9a-fA-F" char_hex2