dotfiles

My dotfiles.
Log | Files | Refs | LICENSE

sml.jsf (8585B)


      1 # JOE syntax highlight file for SML
      2 
      3 # A (deterministic) state machine which performs lexical analysis of SML.
      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>'
      9 # <color-name> is the color used for characters eaten by the state
     10 # (really a symbol for a user definable color).
     11 
     12 # The first state defined is the initial state.
     13 
     14 # Within a state, define transitions (jumps) to other states.  Each
     15 # jump has the form: <character-list> <target-state> [<option>s]
     16 
     17 # There are two ways to specify <character-list>s, either * for any
     18 # character not otherwise specified, or a literal list of characters within
     19 # quotes (ranges and escape sequences allows).  When the next character
     20 # matches any in the list, a jump to the target-state is taken and the
     21 # character is eaten (we advance to the next character of the file to be
     22 # colored).
     23 #
     24 # The * transition should be the first transition specified in the state.
     25 #
     26 # There are several options:
     27 #   noeat     	do not eat the character, instead feed it to the next state
     28 #             	(this tends to make the states smaller, but be careful: you
     29 #		can make infinite loops).  'noeat' implies 'recolor=-1'.
     30 #
     31 #   recolor=-N	Recolor the past N characters with the color of the
     32 #		target-state.  For example once /* is recognized as the
     33 #		start of C comment, you want to color the /* with the C
     34 #		comment color.
     35 #
     36 #   buffer    	start copying characters to a buffer, beginning with this
     37 #		one (it's ok to not terminate buffering with a matching
     38 #		'strings' option- the buffer is limited to leading 19
     39 #		characters).
     40 #
     41 #   strings	A list of strings follows.  If the buffer matches any of the
     42 #		given strings, a jump to the target-state in the string list
     43 #		is taken instead of the normal jump.
     44 #
     45 #   istrings	Same as strings, but case is ignored.
     46 #
     47 #   hold        Stop buffering string- a future 'strings' or 'istrings' will
     48 #               look at contents of buffer at this point.  Useful for distinguishing
     49 #               commands and function calls in some languages 'write 7' is a command
     50 #               'write (' is a function call- hold lets us stop at the space and delay
     51 #               the string lookup until the ( or 7.
     52 #
     53 #   The format of the string list is:
     54 #
     55 #      "string"   <target-state> [<options>s]
     56 #      "string"   <target-state> [<options>s]
     57 #      done
     58 #
     59 #   (all of the options above are allowed except "strings", "istrings" and "noeat".  noeat is
     60 #    always implied after a matched string).
     61 #
     62 # Weirdness: only states have colors, not transitions.  This means that you
     63 # sometimes have to make dummy states with '* next-state noeat' just to get
     64 # a color specification.
     65 
     66 =Idle
     67 =Ident
     68 =Bad
     69 =Comment
     70 =Constant
     71 =String		+Constant
     72 =Number		+Constant
     73 =Boolean	+Constant
     74 =StringEscape	+Escape +String
     75 =Type
     76 =Keyword
     77 =Operator	+Keyword
     78 =Control
     79 =Conditional	+Statement +Keyword
     80 =Loop		+Statement +Keyword
     81 =StorageClass	+Keyword
     82 =DefinedIdent	+Ident
     83 =DefinedFunction +DefinedIdent
     84 =DefinedType	+Type +DefinedIdent
     85 
     86 :expr Idle
     87 	*		expr
     88 	".,[{})];"	control		recolor=-1 # . or ... both control
     89 	"("		bracket		recolor=-1
     90 	"_"		underline	recolor=-1
     91 	"!%&$+/:<=>?@`^|*\-" operator	buffer recolor=-1
     92 	"#"		hash		recolor=-1
     93 	"~"		tilde		recolor=-1
     94 	"0"		zero		recolor=-1
     95 	"1-9"		decimal		recolor=-1
     96 	"\""		string		recolor=-1
     97 	"a-zA-Z"	id		buffer recolor=-1
     98 
     99 :bad Bad
    100 	*		expr
    101 
    102 :control Control
    103 	*		expr		noeat
    104 
    105 :bracket Control
    106 	*		expr		noeat
    107 	"*"		comment1	recolor=-2
    108 
    109 :underline Keyword
    110 	*		expr		noeat
    111 	"a-zA-Z"	kw
    112 
    113 :operator Operator
    114 	*		expr 		noeat strings
    115 	":>"		colon
    116 	":"		colon
    117 	"::"		control # can be overloaded, but you would burn in hell
    118 	":="		control # ditto
    119 	"="		control # only in some contexts is it _really_ control
    120 	"->"		control
    121 	"=>"		control
    122 	"|"		control
    123 done
    124 	"!%&$+/:<=>?@~`^|#*\-" operator
    125 
    126 :colon Control
    127 	*		type1		noeat
    128 
    129 :hash Control
    130 	*		expr		noeat
    131 	"!%&$+/:<=>?@~`^|#*\-" operator	recolor=-2
    132 	"\""		string		recolor=-2
    133 	
    134 :tilde Operator
    135 	*		expr		noeat
    136 	"!%&$+/:<=>?@~`^|#*\-" operator
    137 	"0"		zero		recolor=-2
    138 	"1-9"		decimal		recolor=-2
    139 
    140 :zero Number
    141 	*		expr		noeat
    142 	"0-9"		decimal
    143 	"w"		word		buffer
    144 	"x"		hex1		buffer
    145 	"e"		epart		buffer
    146 	"E"		epart		buffer
    147 	"."		float1
    148 
    149 :word Number
    150 	*		id		noeat recolor=-2
    151 	"0-9"		decimal
    152 	"x"		hexword
    153 
    154 :hexword Number
    155 	*		id		noeat recolor=-3
    156 	"0-9a-fA-F"	hex
    157 
    158 :hex1 Number
    159 	*		id		noeat recolor=-2
    160 	"0-9a-fA-F"	hex
    161 
    162 :hex Number
    163 	*		expr		noeat
    164 	"0-9a-fA-F"	hex
    165 
    166 :decimal Number
    167 	*		expr		noeat
    168 	"0-9"		decimal
    169 	"."		float1
    170 	"e"		epart		buffer
    171 	"E"		epart		buffer
    172 
    173 # trailing digits required in SML (unlike OCaml)
    174 :float1 Number
    175 	*		bad		noeat
    176 	"0-9"		float
    177 
    178 :float Number
    179 	*		expr		noeat
    180 	"0-9"		float
    181 	"e"		epart		buffer
    182 	"E"		epart		buffer
    183 
    184 :epart Number
    185 	*		id		noeat recolor=-2
    186 	"0-9"		enum
    187 	"~"		epart		# bug: 3e~~3
    188 
    189 :enum Number
    190 	*		expr		noeat
    191 	"0-9"		enum
    192 
    193 :string	String string
    194 	*		string
    195 	"\""		expr
    196 	"\n"		bad
    197 	"\\"		string_escape	recolor=-1
    198 
    199 :string_escape StringEscape string
    200 	*		bad		noeat
    201 	"abfnrtv\"\\"	string
    202 	"^"		string_carret
    203 	"u"		string_hex1
    204 	"0-9"		string_decimal2
    205 	"\n\r\f\t "	string_eatws
    206 
    207 :string_carret StringEscape string
    208 	*		bad		noeat
    209 	"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^_" string
    210 
    211 :string_eatws StringEscape string
    212 	*		bad 		noeat
    213 	"\n\r\f\t "	string_eatws
    214 	"\\"		string
    215 
    216 :string_hex1 StringEscape string
    217 	*		bad		noeat
    218 	"0-9a-fA-F"	string_hex2
    219 
    220 :string_hex2 StringEscape string
    221 	*		bad		noeat
    222 	"0-9a-fA-F"	string_hex3
    223 
    224 :string_hex3 StringEscape string
    225 	*		bad		noeat
    226 	"0-9a-fA-F"	string_hex4
    227 
    228 :string_hex4 StringEscape string
    229 	*		bad		noeat
    230 	"0-9a-fA-F"	string
    231 
    232 :string_decimal2 StringEscape string
    233 	*		bad		noeat
    234 	"0-9"		string_decimal3
    235 
    236 :string_decimal3 StringEscape string
    237 	*		bad		noeat
    238 	"0-9"		string
    239 
    240 :id Ident
    241 	*		expr		noeat strings
    242 	"_"		kw
    243 	"ann"		kw
    244 	"and"		kw
    245 	"as"		kw
    246 	"case"		cond
    247 	"do"		loop
    248 	"else"		cond
    249 	"end"		cond
    250 	"exception"	kw
    251 	"false"		bool
    252 	"fn"		kw
    253 	"fun"		kw
    254 	"functor"	kw
    255 	"handle"	kw
    256 	"if"		cond
    257 	"in"		kw
    258 	"include"	kw
    259 	"infix"		kw
    260 	"infixr"	kw
    261 	"let"		kw
    262 	"local"		kw
    263 	"nil"		const
    264 	"nonfix"	kw
    265 	"of"		kw
    266 	"op"		kw
    267 	"open"		kw
    268 	"raise"		kw
    269 	"rec"		kw
    270 	"sharing"	kw
    271 	"sig"		kw
    272 	"signature"	kw
    273 	"struct"	kw
    274 	"structure"	kw
    275 	"then"		kw
    276 	"true"		bool
    277 	"val"		val
    278 	"where"		kw
    279 	"while"		loop
    280 	"with"		kw
    281 	"abstype"	kwtype
    282 	"datatype"	kwtype
    283 	"eqtype"	kwtype
    284 	"type"		kwtype
    285 	"withtype"	kwtype
    286 	"before"	operatorkw
    287 	"o"		operatorkw
    288 	"orelse"	operatorkw
    289 	"andalso"	operatorkw
    290 	"div"		operatorkw
    291 	"mod"		operatorkw
    292 done
    293 	"a-zA-Z0-9_'"	id
    294 
    295 :kw Keyword
    296 	*		expr		noeat
    297 
    298 :operatorkw Operator
    299 	*		expr		noeat
    300 
    301 :kwtype StorageClass
    302 	*		kwtype1		noeat
    303 
    304 :const Constant
    305 	*		expr		noeat
    306 
    307 :cond Conditional
    308 	*		expr		noeat
    309 
    310 :loop Loop
    311 	*		expr		noeat
    312 
    313 :bool Boolean
    314 	*		expr		noeat
    315 
    316 :val Keyword
    317 	*		val_preident	noeat
    318 
    319 :val_preident Idle
    320 	*		val_ident	noeat
    321 	" \t"		val_preident
    322 
    323 :val_ident DefinedIdent
    324 	*		expr		noeat
    325 	"a-zA-Z0-9_'" val_ident
    326 
    327 :kwtype1 DefinedType
    328 	*		expr		noeat
    329 	"="		typeval		recolor=-1
    330 	"a-zA-Z0-9_'., :|*>\t\-" kwtype1
    331 	"({"		kwtype2
    332 
    333 :kwtype2 Type
    334 	*		expr		noeat
    335 	")}"		kwtype1
    336 	"a-zA-Z0-9_'., :|*>\t\n\-" kwtype2
    337 	"({"		kwtype3
    338 
    339 :kwtype3 Type
    340 	*		expr		noeat
    341 	")}"		kwtype2
    342 	"a-zA-Z0-9_'., :|*>\t\n\-" kwtype3
    343 	"({"		expr				# too deep nesting
    344 
    345 :typeval Control
    346 	*		type1		noeat
    347 	" \t\n"		typeval
    348 
    349 :type1 Type
    350 	*		expr		noeat
    351 	"a-zA-Z0-9_'., :|*>\t\-" type1
    352 	"({"		type2
    353 
    354 :type2 Type
    355 	*		expr		noeat
    356 	")}"		type1
    357 	"a-zA-Z0-9_'., :|*>\t\n\-" type2
    358 	"({"		type3
    359 
    360 :type3 Type
    361 	*		expr		noeat
    362 	")}"		type2
    363 	"a-zA-Z0-9_'., :|*>\t\n\-" type3
    364 	"({"		type4
    365 
    366 :type4 Type
    367 	*		expr		noeat
    368 	")}"		type3
    369 	"a-zA-Z0-9_'., :|*>\t\n\-" type4
    370 	"({"		expr 				# too deep nesting
    371 
    372 :comment1 Comment comment
    373 	*		comment1
    374 	"("		nestcomment1
    375 	"*"		endcomment1
    376 	"BFHNTX"	comment1	noeat call=comment_todo.comment_todo()
    377 
    378 :nestcomment1 Comment comment
    379 	*		comment1	noeat
    380 	"*"		comment2
    381 
    382 :endcomment1 Comment comment
    383 	*		comment1	noeat
    384 	")"		expr
    385 	"*"		endcomment1
    386 
    387 :comment2 Comment comment
    388 	*		comment2
    389 	"("		nestcomment2
    390 	"*"		endcomment2
    391 	"BFHNTX"	comment2	noeat call=comment_todo.comment_todo()
    392 
    393 :nestcomment2 Comment comment
    394 	*		comment2	noeat
    395 	"*"		comment3
    396 
    397 :endcomment2 Comment comment
    398 	*		comment2	noeat
    399 	")"		comment1
    400 	"*"		endcomment2
    401 
    402 :comment3 Comment comment
    403 	*		comment3
    404 	"("		nestcomment3
    405 	"*"		endcomment3
    406 	"BFHNTX"	comment3	noeat call=comment_todo.comment_todo()
    407 
    408 :nestcomment3 Comment comment
    409 	*		comment3	noeat
    410 	"*"		expr				# too deep nesting
    411 
    412 :endcomment3 Comment comment
    413 	*		comment3	noeat
    414 	")"		comment2
    415 	"*"		endcomment3