dotfiles

My dotfiles.
Log | Files | Refs | LICENSE

xml.jsf (5524B)


      1 # Improved XML highlighter by: Brian Candler <B.Candler@pobox.com>
      2 # Incorporated some Ant logic from Christian Nicolai (http://mycrobase.de)
      3 
      4 =Idle
      5 =Bad
      6 =Tag		+DefinedFunction +DefinedIdent
      7 =TagName	+Tag
      8 =TagEnd		+Tag
      9 =Attr		+Type
     10 =Constant
     11 =String		+Constant
     12 =Entity		+Escape
     13 =StringEntity	+StringEscape +Entity
     14 =Namespace	+Comment
     15 =Decl		+Preproc +Tag
     16 =Comment
     17 =CommentEdge	+Comment
     18 =PIStart	+Preproc +Tag
     19 =PIBody		+Comment
     20 =PIEnd		+Preproc +Tag
     21 =CdataEdge	+Statement
     22 =CdataBody	+String
     23 =Keyword
     24 
     25 # http://www.w3.org/TR/2004/REC-xml-20040204/
     26 #
     27 # NOTE: For UNICODE compatibility, the ranges
     28 #	"A-Za-z_:"		-- first character of Name
     29 #	"A-Za-z0-9._:-"		-- subsequent characters of Name
     30 # ought to be replaced with some appropriate Unicode character classes
     31 #
     32 # Actually the standard tells you which characters to use, see:
     33 #  http://www.w3.org/TR/xml11/#NT-NameStartChar
     34 
     35 :init Idle
     36 	*		idle noeat call=.xml()
     37 
     38 .subr xml
     39 
     40 :content Idle
     41 	*		content
     42 	"<"		tag		recolor=-1
     43 	"&"		entityref	recolor=-1
     44 
     45 # > is allowed
     46 #	">"		error		noeat recolor=-1
     47 
     48 
     49 # In several contexts a space is an error, and since a coloured space is
     50 # not visible, we colour the next non-space character as well.
     51 
     52 :error Bad
     53 	*		error_visible	noeat recolor=-1
     54 	" \t\r\n"	error
     55 
     56 :error_visible Bad
     57 	*		content
     58 
     59 # Matched: &
     60 
     61 :entityref Entity
     62 	*		error		noeat recolor=-1
     63 	"-.:\c"		entityref
     64 	"#"		entityref
     65 	";"		content
     66 
     67 # Matched: <
     68 
     69 :tag Tag
     70 	*		error		noeat recolor=-1
     71 	"/"		end_tag		recolor=-2 mark
     72 	":\i"		start_or_empty_tag recolor=-1 mark buffer
     73 	"?"		pi_start	recolor=-2
     74 	"!"		decl		recolor=-2 buffer
     75 
     76 # Matched: </
     77 
     78 :end_tag TagEnd
     79 	*		error		noeat recolor=-1
     80 	":\i"		end_tag2	recolor=-1
     81 
     82 :end_tag2 TagEnd
     83 	*		error		noeat recolor=-1
     84 	"-.:\c"		end_tag2
     85 	" \t\r\n"	end_tag2_sp	recolor=-1
     86 	">"		close_tag_end	noeat
     87 
     88 :end_tag2_sp TagEnd
     89 	*		end_tag3	noeat
     90 
     91 :end_tag3 TagEnd
     92 	*		error		noeat recolor=-1
     93 	" \t\r\n"	end_tag3_sp	recolor=-1
     94 	">"		close_tag_end	noeat
     95 
     96 :end_tag3_sp TagEnd
     97 	*		end_tag_3	noeat
     98 
     99 # Matched: <tag
    100 
    101 :start_or_empty_tag TagName
    102 .ifdef ant
    103 	*		decide_tag_type noeat strings
    104 	"target"	kw
    105 done
    106 .else
    107 	*		decide_tag_type noeat
    108 .endif
    109 	":"		tag_namespace	markend recolormark recolor=-1
    110 	"-.\c"		start_or_empty_tag
    111 
    112 :kw Keyword
    113 	*		decide_tag_type noeat
    114 
    115 :decide_tag_type TagName
    116 	*		error		noeat recolor=-1
    117 	"/"		empty_tag	mark
    118 	" \t\r\n"	start_or_empty_tag_sp	markend buffer recolor=-1
    119 	">"		close_tag	noeat
    120 
    121 :tag_namespace Namespace
    122 	*		start_or_empty_tag noeat buffer
    123 
    124 :start_or_empty_tag_sp Idle
    125 	*		tag_space	noeat
    126 
    127 # Matched: <tag/
    128 
    129 :empty_tag Tag
    130 	*		error		noeat recolor=-1
    131 	">"		close_tag	noeat
    132 
    133 # Matched: <tag SPACE
    134 
    135 :tag_space Attr
    136 	*		error		noeat recolor=-1
    137 	" \t\r\n"	tag_space_sp	recolor=-1
    138 	":\i"		attr		mark
    139 	"/"		empty_tag	recolor=-1
    140 	">"		close_tag	noeat
    141 
    142 :tag_space_sp Idle
    143 	*		tag_space	mark noeat
    144 
    145 # Matched: <tag attr
    146 
    147 :attr Attr
    148 	*		error		noeat recolor=-1
    149 	":"		attr_namespace	markend recolormark recolor=-1
    150 	"-.\c" 		attr
    151 	" \t\r\n"	attr_sp		recolor=-1
    152 	"="		string
    153 
    154 :attr_namespace Namespace
    155 	*		attr		noeat
    156 
    157 :attr_sp Idle
    158 	*		attr_before	noeat
    159 
    160 :attr_before Attr
    161 	*		error		noeat recolor=-1
    162 	" \t\r\n"	attr_sp		recolor=-1
    163 	"="		string
    164 
    165 # Matched: <tag attr=
    166 
    167 :string Attr
    168 	*		error		noeat recolor=-1
    169 	" \t\r\n"	string_sp	recolor=-1
    170 	"\""		astring		recolor=-1
    171 	"'"		bstring		recolor=-1
    172 
    173 :string_sp Idle
    174 	*		string		noeat
    175 
    176 # Matched: <tag attr="
    177 
    178 :astring String string
    179 	*		astring
    180 	"<"		error		noeat recolor=-1
    181 	"&"		achar		recolor=-1
    182 	"\""		endstring
    183 .ifdef ant
    184 	"$"		astring		call=ant.antvar() recolor=-1
    185 .endif
    186 
    187 #	">"		error		noeat recolor=-1
    188 
    189 
    190 :bstring String string
    191 	*		bstring
    192 	"<"		error		noeat recolor=-1
    193 	"&"		bchar		recolor=-1
    194 	"'"		endstring
    195 .ifdef ant
    196 	"$"		bstring		call=ant.maybe_antvar()
    197 .endif
    198 
    199 #	">"		error		noeat recolor=-1
    200 
    201 
    202 :achar StringEntity string
    203 	*		error		noeat recolor=-1
    204 	"-.:\c"		achar
    205 	"#"		achar
    206 	";"		astring
    207 
    208 :bchar Entity
    209 	*		error		noeat recolor=-1
    210 	"-.:\c"		bchar
    211 	"#"		bchar
    212 	";"		bstring
    213 
    214 # Matched: <tag attr="foo"
    215 
    216 :endstring Attr
    217 	*		error		noeat recolor=-1
    218 	" \t\r\n"	tag_space_sp
    219 	"/"		empty_tag	recolor=-1
    220 	">"		close_tag	noeat
    221 
    222 # This state is just to recolor the final ">" at the end of <tag attr="val">
    223 
    224 :close_tag Tag
    225 	*		content
    226 
    227 :close_tag_end TagEnd
    228 	*		content
    229 
    230 # Matched: <?
    231 
    232 :pi_start PIStart
    233 	*		pi		noeat recolor=-1
    234 
    235 :pi PIBody
    236 	*		pi
    237 	"?"		pi2
    238 
    239 :pi2 PIBody
    240 	*		pi
    241 	">"		pi_end		recolor=-2
    242 
    243 :pi_end PIEnd
    244 	*		content		noeat recolor=-1
    245 
    246 # Matched: <!
    247 
    248 :decl Decl
    249 	*		decl		strings
    250 	"!--"		comment_start	recolor=-5
    251 	"![CDATA["	cdata_start	recolor=-10
    252 done
    253 #	"<"		decl_nest
    254 	">"		content
    255 
    256 # We allow one level of <...> nesting within declarations
    257 
    258 :decl_nest Decl
    259 	*		decl_nest
    260 	">"		decl
    261 
    262 # Matched: <!--
    263 
    264 :comment_start CommentEdge
    265 	*		comment		noeat
    266 
    267 :comment Comment comment
    268 	*		comment
    269 	"BFHNTX"	comment		noeat call=comment_todo.comment_todo()
    270 	"-"		comment2
    271 
    272 :comment2 Comment comment
    273 	*		comment
    274 	"-"		comment3
    275 
    276 :comment3 Comment comment
    277 	*		comment_error	noeat recolor=-3
    278 	">"		comment_end	recolor=-3
    279 
    280 :comment_end CommentEdge
    281 	*		content		noeat recolor=-1
    282 
    283 # For compatibility, the string "--" (double-hyphen) MUST NOT occur within
    284 # comments. [http://www.w3.org/TR/REC-xml/ section 2.5]
    285 
    286 :comment_error Bad
    287 	*		comment
    288 	"-"		comment_error
    289 	">"		comment_end	recolor=-3
    290 
    291 # Matched: <![CDATA[
    292 
    293 :cdata_start CdataEdge
    294 	*		cdata		noeat
    295 
    296 :cdata CdataBody
    297 	*		cdata
    298 	"]"		cdata2
    299 
    300 :cdata2 CdataBody
    301 	*		cdata
    302 	"]"		cdata3
    303 
    304 :cdata3 CdataBody
    305 	*		cdata
    306 	"]"		cdata3
    307 	">"		cdata_end	recolor=-3
    308 
    309 :cdata_end CdataEdge
    310 	*		content		noeat recolor=-1
    311 
    312 .end