PageRenderTime 43ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-0-pre3/doc/users-guide/writing-modes.xml

#
XML | 515 lines | 507 code | 6 blank | 2 comment | 0 complexity | 1386484f546c7d11e0ad5d68fdd0325a MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. <!-- jEdit buffer-local properties: -->
  2. <!-- :indentSize=1:noTabs=true:folding=indent:collapseFolds=1: -->
  3. <chapter id="writing-modes"><title>Writing Edit Modes</title>
  4. <para>
  5. Edit modes are defined using XML, the <firstterm>extensible markup
  6. language</firstterm>; mode files have the extension
  7. <filename>.xml</filename>. XML is a very simple language, and as a result
  8. edit modes are easy to create and modify. This section will
  9. start with a short XML primer, followed by detailed information about
  10. each supported tag and highlighting rule.
  11. </para>
  12. <sidebar><title>Changes to modes take effect immediately</title>
  13. <para>
  14. Editing a mode file, or a mode catalog file within jEdit will cause the
  15. edit modes to be reloaded automatically as soon as the file is saved.
  16. </para>
  17. <para>
  18. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Reload Edit Modes</guimenuitem>
  19. can be used to reload edit modes after changes to mode files are made
  20. outside jEdit.
  21. </para>
  22. </sidebar>
  23. <sect1 id="xml-primer"><title>An XML Primer</title>
  24. <para>
  25. A very simple edit mode looks like so:
  26. </para>
  27. <programlisting><![CDATA[<?xml version="1.0"?>
  28. <!DOCTYPE MODE SYSTEM "xmode.dtd">
  29. <MODE>
  30. <PROPS>
  31. <PROPERTY NAME="commentStart" VALUE="/*" />
  32. <PROPERTY NAME="commentEnd" VALUE="*/" />
  33. </PROPS>
  34. <RULES>
  35. <SPAN TYPE="COMMENT1">
  36. <BEGIN>/*</BEGIN>
  37. <END>*/</END>
  38. </SPAN>
  39. </RULES>
  40. </MODE>]]></programlisting>
  41. <para>
  42. Note that each opening tag must have a corresponding closing tag.
  43. If there is nothing between the opening and closing tags, for example
  44. <literal>&lt;TAG&gt;&lt;/TAG&gt;</literal>, the shorthand notation
  45. <literal>&lt;TAG /&gt;</literal> may be used. An example of this shorthand
  46. can be seen
  47. in the <literal>&lt;PROPERTY&gt;</literal> tags above.
  48. </para>
  49. <para>
  50. XML is case sensitive. <literal>Span</literal> or <literal>span</literal>
  51. is not the same as <literal>SPAN</literal>.
  52. </para>
  53. <para>
  54. To insert a special character such as &lt; or &gt; literally in XML
  55. (for example, inside an attribute value), you must write it as
  56. an <firstterm>entity</firstterm>. An
  57. entity consists of the character's symbolic name enclosed with
  58. <quote>&amp;</quote> and <quote>;</quote>. A full list of entities is out of
  59. the scope of this section, but the most important are:
  60. </para>
  61. <itemizedlist>
  62. <listitem><para><literal>&amp;lt;</literal> - The less-than (&lt;)
  63. character</para></listitem>
  64. <listitem><para><literal>&amp;gt;</literal> - The greater-than (&gt;)
  65. character</para></listitem>
  66. <listitem><para><literal>&amp;amp;</literal> - The ampersand (&amp;)
  67. character</para></listitem>
  68. </itemizedlist>
  69. <para>
  70. For example, the following will cause a syntax error:
  71. </para>
  72. <programlisting>&lt;SEQ TYPE="OPERATOR"&gt;&amp;&lt;/SEQ&gt;</programlisting>
  73. <para>
  74. Instead, you must write:
  75. </para>
  76. <programlisting>&lt;SEQ TYPE="OPERATOR"&gt;&amp;amp;&lt;/SEQ&gt;</programlisting>
  77. <para>
  78. Now that the basics of XML have been covered, the rest of this
  79. section will cover each construct in detail.
  80. </para>
  81. </sect1>
  82. <sect1 id="mode-preamble"><title>The Preamble and MODE tag</title>
  83. <para>
  84. Each mode definition must begin with the following:
  85. </para>
  86. <programlisting>&lt;?xml version="1.0"?&gt;
  87. &lt;!DOCTYPE MODE SYSTEM "xmode.dtd"&gt;</programlisting>
  88. <para>
  89. Each mode definition must also contain exactly one <literal>MODE</literal>
  90. tag. All other tags (<literal>PROPS</literal>, <literal>RULES</literal>)
  91. must be placed inside the <literal>MODE</literal> tag.
  92. </para>
  93. </sect1>
  94. <sect1 id="mode-tag-props"><title>The PROPS Tag</title>
  95. <para>
  96. The <literal>PROPS</literal> tag and the <literal>PROPERTY</literal> tags
  97. inside it are used to define mode-specific
  98. properties. Each <literal>PROPERTY</literal> tag must have a
  99. <literal>NAME</literal> attribute set to the property's name, and a
  100. <literal>VALUE</literal> attribute with the property's value.
  101. </para>
  102. <para>
  103. All buffer-local properties listed in <xref linkend="buffer-local" />
  104. may be given values in edit modes. In addition, the following mode
  105. properties have no buffer-local equivalent:
  106. </para>
  107. <itemizedlist>
  108. <listitem><para><literal>indentCloseBrackets</literal> -
  109. A list of characters (usually brackets) that subtract indent from
  110. the <emphasis>current</emphasis> line. For example, in Java mode this
  111. property is set to <quote>}</quote>.</para></listitem>
  112. <listitem><para><literal>indentOpenBrackets</literal> -
  113. A list of characters (usually brackets) that add indent to
  114. the <emphasis>next</emphasis> line. For example, in Java mode this
  115. property is set to <quote>{</quote>.</para></listitem>
  116. <listitem><para><literal>indentPrevLine</literal> -
  117. When indenting a line, jEdit checks if the previous line matches
  118. the regular expression stored in this property. If it does, a level
  119. of indent is added. For example, in Java mode this regular expression
  120. matches language constructs such as
  121. <quote>if</quote>, <quote>else</quote>, <quote>while</quote>, etc.</para>
  122. </listitem>
  123. <listitem><para><literal>doubleBracketIndent</literal> -
  124. If a line matches the <literal>indentPrevLine</literal> regular
  125. expression and the next line contains an opening bracket,
  126. a level of indent will not be added to the next line, unless
  127. this property is set to <quote>true</quote>. For example, with this
  128. property set to <quote>false</quote>, Java code will be indented like so:
  129. </para>
  130. <programlisting>while(objects.hasMoreElements())
  131. {
  132. ((Drawable)objects.nextElement()).draw();
  133. }</programlisting>
  134. <para>
  135. On the other hand, settings this property to <quote>true</quote> will
  136. give the following result:
  137. </para>
  138. <programlisting>while(objects.hasMoreElements())
  139. {
  140. ((Drawable)objects.nextElement()).draw();
  141. }</programlisting></listitem>
  142. </itemizedlist>
  143. <para>
  144. Here is the complete <literal>&lt;PROPS&gt;</literal> tag for Java mode:
  145. </para>
  146. <programlisting>&lt;PROPS&gt;
  147. &lt;PROPERTY NAME="indentOpenBrackets" VALUE="{" /&gt;
  148. &lt;PROPERTY NAME="indentCloseBrackets" VALUE="}" /&gt;
  149. &lt;PROPERTY NAME="indentPrevLine" VALUE="\s*(((if|while)
  150. \s*\(|else|case|default)[^;]*|for\s*\(.*)" /&gt;
  151. &lt;PROPERTY NAME="doubleBracketIndent" VALUE="false" /&gt;
  152. &lt;PROPERTY NAME="commentStart" VALUE="/*" /&gt;
  153. &lt;PROPERTY NAME="commentEnd" VALUE="*/" /&gt;
  154. &lt;PROPERTY NAME="blockComment" VALUE="//" /&gt;
  155. &lt;PROPERTY NAME="wordBreakChars" VALUE=",+-=&lt;&gt;/?^&amp;*" /&gt;
  156. &lt;/PROPS&gt;</programlisting>
  157. </sect1>
  158. <sect1 id="mode-tag-rules"><title>The RULES Tag</title>
  159. <para>
  160. <literal>RULES</literal> tags must be placed inside the
  161. <literal>MODE</literal> tag. Each <literal>RULES</literal> tag defines a
  162. <firstterm>ruleset</firstterm>. A ruleset consists of a number of
  163. <firstterm>parser rules</firstterm>, with each parser
  164. rule specifying how to highlight a specific syntax token. There must
  165. be at least one ruleset in each edit mode. There can also be more
  166. than one, with different rulesets being used to highlight different
  167. parts of a buffer (for example, in HTML mode, one rule set
  168. highlights HTML tags, and another highlights inline JavaScript).
  169. For information about using more
  170. than one ruleset, see <xref linkend="mode-rule-span" />.
  171. </para>
  172. <para>
  173. The <literal>RULES</literal> tag supports the following attributes, all of
  174. which are optional:
  175. </para>
  176. <itemizedlist>
  177. <listitem><para><literal>SET</literal> - the name of this ruleset.
  178. All rulesets other than the first must have a name.
  179. </para></listitem>
  180. <listitem><para><literal>HIGHLIGHT_DIGITS</literal> - if set to
  181. <literal>TRUE</literal>, digits (0-9, as well as hexadecimal literals
  182. prefixed with <quote>0x</quote>) will be highlighted with the
  183. <classname>DIGIT</classname> token type. Default is <literal>FALSE</literal>.
  184. </para></listitem>
  185. <listitem><para><literal>IGNORE_CASE</literal> - if set to
  186. <literal>FALSE</literal>, matches will be case sensitive. Otherwise, case
  187. will not matter. Default is <literal>TRUE</literal>.
  188. </para></listitem>
  189. <listitem><para><literal>DEFAULT</literal> - the token type for
  190. text which doesn't match
  191. any specific rule. Default is <literal>NULL</literal>. See
  192. <xref linkend="mode-syntax-tokens" /> for a list of token types.
  193. </para></listitem>
  194. </itemizedlist>
  195. <para>
  196. Here is an example <literal>RULES</literal> tag:
  197. </para>
  198. <programlisting>&lt;RULES IGNORE_CASE="FALSE" HIGHLIGHT_DIGITS="TRUE"&gt;
  199. <replaceable>... parser rules go here ...</replaceable>
  200. &lt;/RULES&gt;</programlisting>
  201. <sidebar><title>Rule Ordering Requirements</title>
  202. <para>
  203. You might encounter this very common pitfall when writing your own modes.
  204. </para>
  205. <para>
  206. Since jEdit checks buffer text against parser rules in the order they appear
  207. in the ruleset, more specific rules must be placed before generalized ones,
  208. otherwise the generalized rules will catch everything.
  209. </para>
  210. <para>
  211. This is best demonstrated with an example. The following is incorrect rule
  212. ordering:
  213. </para>
  214. <programlisting><![CDATA[<SPAN TYPE="MARKUP">
  215. <BEGIN>[</BEGIN>
  216. <END>]</END>
  217. </SPAN>
  218. <SPAN TYPE="KEYWORD1">
  219. <BEGIN>[!</BEGIN>
  220. <END>]</END>
  221. </SPAN>]]></programlisting>
  222. <para>
  223. If you write the above in a rule set, any occurrence of <quote>[</quote>
  224. (even things like <quote>[!DEFINE</quote>, etc)
  225. will be highlighted using the first rule, because it will be the
  226. first to match. This is most likely not the intended behavior.
  227. </para>
  228. <para>
  229. The problem can be solved by placing the more specific rule before the
  230. general one:
  231. </para>
  232. <programlisting><![CDATA[<SPAN TYPE="KEYWORD1">
  233. <BEGIN>[!</BEGIN>
  234. <END>]</END>
  235. </SPAN>
  236. <SPAN TYPE="MARKUP">
  237. <BEGIN>[</BEGIN>
  238. <END>]</END>
  239. </SPAN>]]></programlisting>
  240. <para>
  241. Now, if the buffer contains the text <quote>[!SPECIAL]</quote>, the
  242. rules will be checked in order, and the first rule will be the first
  243. to match. However, if you write <quote>[FOO]</quote>, it will be highlighted
  244. using the second rule, which is exactly what you would expect.
  245. </para>
  246. </sidebar>
  247. <sect2 id="mode-rule-terminate"><title>The TERMINATE Rule</title>
  248. <para>
  249. The <literal>TERMINATE</literal> rule specifies that parsing should stop
  250. after the specified number of characters have been read from a line. The
  251. number of characters to terminate after should be specified with the
  252. <literal>AT_CHAR</literal> attribute. Here is an example:
  253. </para>
  254. <programlisting>&lt;TERMINATE AT_CHAR="1" /&gt;</programlisting>
  255. <para>
  256. This rule is used in Patch mode, for example, because only the first
  257. character of each line affects highlighting.
  258. </para>
  259. </sect2>
  260. <sect2 id="mode-rule-whitespace"><title>The WHITESPACE Rule</title>
  261. <para>
  262. The <literal>WHITESPACE</literal> rule specifies characters which are to
  263. be treated as keyword delimiters.
  264. Most rulesets will have <literal>WHITESPACE</literal> tags for spaces and
  265. tabs. Here is an example:
  266. </para>
  267. <programlisting>&lt;WHITESPACE&gt; &lt;/WHITESPACE&gt;
  268. &lt;WHITESPACE&gt; &lt;/WHITESPACE&gt;</programlisting>
  269. </sect2>
  270. <sect2 id="mode-rule-span"><title>The SPAN Rule</title>
  271. <para>
  272. The <literal>SPAN</literal> rule highlights text between a start
  273. and end string. The start and end strings are specified inside
  274. child elements of the <literal>SPAN</literal> tag.
  275. The following attributes are supported:
  276. </para>
  277. <itemizedlist>
  278. <listitem><para><literal>TYPE</literal> - The token type to highlight the
  279. span with. See <xref linkend="mode-syntax-tokens" /> for a list of token
  280. types</para></listitem>
  281. <listitem><para><literal>AT_LINE_START</literal> - If set to
  282. <literal>TRUE</literal>, the span will only be highlighted if the start
  283. sequence occurs at the beginning of a line</para></listitem>
  284. <listitem><para><literal>EXCLUDE_MATCH</literal> - If set to
  285. <literal>TRUE</literal>, the start and end sequences will not be highlighted,
  286. only the text between them will</para></listitem>
  287. <listitem><para><literal>NO_LINE_BREAK</literal> - If set to
  288. <literal>TRUE</literal>, the span will be highlighted with the
  289. <classname>INVALID</classname> token type if it spans more than one
  290. line</para></listitem>
  291. <listitem><para><literal>NO_WORD_BREAK</literal> - If set to
  292. <literal>TRUE</literal>, the span will be highlighted with the
  293. <classname>INVALID</classname> token type if it includes
  294. whitespace</para></listitem>
  295. <listitem><para><literal>DELEGATE</literal> - text inside the span will be
  296. highlighted with the specified ruleset. To delegate to a ruleset defined
  297. in the current mode, just specify its name. To delegate to a ruleset
  298. defined in another mode, specify a name of the form
  299. <literal><replaceable>mode</replaceable>::<replaceable>ruleset</replaceable></literal>.
  300. Note that the first (unnamed) ruleset in a mode is called
  301. <quote>MAIN</quote>.</para></listitem>
  302. </itemizedlist>
  303. <note>
  304. <para>
  305. Do not delegate to rulesets that define a <literal>TERMINATE</literal> rule
  306. (examples of such rulesets include <literal>text::MAIN</literal> and
  307. <literal>patch::MAIN</literal>). It won't work.
  308. </para>
  309. </note>
  310. <para>
  311. Here is a <literal>SPAN</literal> that highlights Java string literals,
  312. which cannot include line breaks:
  313. </para>
  314. <programlisting>&lt;SPAN TYPE="LITERAL1" NO_LINE_BREAK="TRUE"&gt;
  315. &lt;BEGIN&gt;"&lt;/BEGIN&gt;
  316. &lt;END&gt;"&lt;/END&gt;
  317. &lt;/SPAN&gt;</programlisting>
  318. <para>
  319. Here is a <literal>SPAN</literal> that highlights Java documentation
  320. comments by delegating to the <quote>JAVADOC</quote> ruleset defined
  321. elsewhere in the current mode:
  322. </para>
  323. <programlisting>&lt;SPAN TYPE="COMMENT2" DELEGATE="JAVADOC"&gt;
  324. &lt;BEGIN&gt;/**&lt;/BEGIN&gt;
  325. &lt;END&gt;*/&lt;/END&gt;
  326. &lt;/SPAN&gt;</programlisting>
  327. <para>
  328. Here is a <literal>SPAN</literal> that highlights HTML cascading stylesheets
  329. inside <literal>&lt;STYLE&gt;</literal> tags by delegating to the main
  330. ruleset in the CSS edit mode:
  331. </para>
  332. <programlisting>&lt;SPAN TYPE="MARKUP" DELEGATE="css::MAIN"&gt;
  333. &lt;BEGIN&gt;&amp;lt;style&amp;gt;&lt;/BEGIN&gt;
  334. &lt;END&gt;&amp;lt;/style&amp;gt;&lt;/END&gt;
  335. &lt;/SPAN&gt;</programlisting>
  336. <tip>
  337. <para>
  338. The <literal>&lt;END&gt;</literal> tag is optional. If it is not specified,
  339. any occurrence of the start string will cause the remainder of the buffer
  340. to be highlighted with this rule.
  341. </para>
  342. <para>
  343. This can be very useful when combined with delegation.
  344. </para>
  345. </tip>
  346. </sect2>
  347. <sect2 id="mode-rule-eol-span"><title>The EOL_SPAN Rule</title>
  348. <para>
  349. An <literal>EOL_SPAN</literal> is similar to a <literal>SPAN</literal>
  350. except that highlighting stops at the end of the line, not after the end
  351. sequence is found. The text to match is specified between the opening and
  352. closing <literal>EOL_SPAN</literal> tags.
  353. The following attributes are supported:
  354. </para>
  355. <itemizedlist>
  356. <listitem><para><literal>TYPE</literal> - The token type to highlight the span
  357. with. See <xref linkend="mode-syntax-tokens" /> for a list of token
  358. types</para></listitem>
  359. <listitem><para><literal>AT_LINE_START</literal> - If set to
  360. <literal>TRUE</literal>, the span will only be highlighted if the start
  361. sequence occurs at the beginning of a line</para></listitem>
  362. <listitem><para><literal>EXCLUDE_MATCH</literal> - If set to
  363. <literal>TRUE</literal>, the start sequence will not be highlighted,
  364. only the text after it will</para></listitem>
  365. </itemizedlist>
  366. <para>
  367. Here is an <literal>EOL_SPAN</literal> that highlights C++ comments:
  368. </para>
  369. <programlisting>&lt;EOL_SPAN TYPE="COMMENT1"&gt;//&lt;/EOL_SPAN&gt;</programlisting>
  370. </sect2>
  371. <sect2 id="mode-rule-mark-prev"><title>The MARK_PREVIOUS Rule</title>
  372. <para>
  373. The <literal>MARK_PREVIOUS</literal> rule highlights from the end of the
  374. previous syntax token to the matched text. The text to match
  375. is specified between opening and closing <literal>MARK_PREVIOUS</literal>
  376. tags. The following attributes are supported:
  377. </para>
  378. <itemizedlist>
  379. <listitem><para><literal>TYPE</literal> - The token type to highlight the
  380. text with. See <xref linkend="mode-syntax-tokens" /> for a list of token
  381. types</para></listitem>
  382. <listitem><para><literal>AT_LINE_START</literal> - If set to
  383. <literal>TRUE</literal>,
  384. the text will only be highlighted if it occurs at the beginning of
  385. the line</para></listitem>
  386. <listitem><para><literal>EXCLUDE_MATCH</literal> - If set to
  387. <literal>TRUE</literal>, the match will not be highlighted,
  388. only the text before it will</para></listitem>
  389. </itemizedlist>
  390. <para>
  391. Here is a rule that highlights labels in Java mode (for example,
  392. <quote>XXX:</quote>):
  393. </para>
  394. <programlisting>&lt;MARK_PREVIOUS AT_LINE_START="TRUE"
  395. EXCLUDE_MATCH="TRUE"&gt;:&lt;/MARK_PREVIOUS&gt;</programlisting>
  396. </sect2>
  397. <sect2 id="mode-rule-mark-following"><title>The MARK_FOLLOWING Rule</title>
  398. <para>
  399. The <literal>MARK_FOLLOWING</literal> rule highlights from the start of the
  400. match to the next syntax token. The text to match
  401. is specified between opening and closing <literal>MARK_FOLLOWING</literal>
  402. tags. The following attributes are supported:
  403. </para>
  404. <itemizedlist>
  405. <listitem><para><literal>TYPE</literal> - The token type to highlight the
  406. text with. See <xref linkend="mode-syntax-tokens" /> for a list of token
  407. types</para></listitem>
  408. <listitem><para><literal>AT_LINE_START</literal> - If set to
  409. <literal>TRUE</literal>, the text will only be highlighted if the start
  410. sequence occurs at the beginning of a line</para></listitem>
  411. <listitem><para><literal>EXCLUDE_MATCH</literal> - If set to
  412. <literal>TRUE</literal>, the match will not be highlighted,
  413. only the text after it will</para></listitem>
  414. </itemizedlist>
  415. <para>
  416. Here is a rule that highlights variables in Unix shell scripts
  417. (<quote>$CLASSPATH</quote>, <quote>$IFS</quote>, etc):
  418. </para>
  419. <programlisting>&lt;MARK_FOLLOWING TYPE="KEYWORD2"&gt;$&lt;/MARK_FOLLOWING&gt;</programlisting>
  420. </sect2>
  421. <sect2 id="mode-rule-seq"><title>The SEQ Rule</title>
  422. <para>
  423. The <literal>SEQ</literal> rule highlights fixed sequences of text. The text
  424. to highlight is specified between opening and closing <literal>SEQ</literal>
  425. tags. The following attributes are supported:
  426. </para>
  427. <itemizedlist>
  428. <listitem><para><literal>TYPE</literal> - the token type to highlight the
  429. sequence with. See <xref linkend="mode-syntax-tokens" /> for a list of token
  430. types</para></listitem>
  431. <listitem><para><literal>AT_LINE_START</literal> - If set to
  432. <literal>TRUE</literal>, the sequence will only be highlighted if it occurs
  433. at the beginning of a line</para></listitem>
  434. </itemizedlist>
  435. <para>
  436. The following rules highlight a few Java operators:
  437. </para>
  438. <programlisting>&lt;SEQ TYPE="OPERATOR"&gt;+&lt;/SEQ&gt;
  439. &lt;SEQ TYPE="OPERATOR"&gt;-&lt;/SEQ&gt;
  440. &lt;SEQ TYPE="OPERATOR"&gt;*&lt;/SEQ&gt;
  441. &lt;SEQ TYPE="OPERATOR"&gt;/&lt;/SEQ&gt;</programlisting>
  442. </sect2>
  443. <sect2 id="mode-rule-keywords"><title>The KEYWORDS Rule</title>
  444. <para>
  445. There can only be one <literal>KEYWORDS</literal> tag per ruleset.
  446. The <literal>KEYWORDS</literal> rule defines keywords to highlight.
  447. Keywords are similar to <literal>SEQ</literal>s, except that
  448. <literal>SEQ</literal>s match anywhere in the text, whereas keywords only
  449. match whole words.
  450. </para>
  451. <para>
  452. The <literal>KEYWORDS</literal> tag supports only one attribute,
  453. <literal>IGNORE_CASE</literal>. If set to <literal>FALSE</literal>, keywords
  454. will be case sensitive. Otherwise, case will not matter. Default is
  455. <literal>TRUE</literal>.
  456. </para>
  457. <para>
  458. Each child element of the <literal>KEYWORDS</literal> tag should be named
  459. after the desired token type, with the keyword text between the start and
  460. end tags. For example, the following rule highlights the most common Java
  461. keywords:
  462. </para>
  463. <programlisting>&lt;KEYWORDS IGNORE_CASE="FALSE"&gt;
  464. &lt;KEYWORD1&gt;if&lt;/KEYWORD1&gt;
  465. &lt;KEYWORD1&gt;else&lt;/KEYWORD1&gt;
  466. &lt;KEYWORD3&gt;int&lt;/KEYWORD3&gt;
  467. &lt;KEYWORD3&gt;void&lt;/KEYWORD3&gt;
  468. &lt;/KEYWORDS&gt;</programlisting>
  469. </sect2>
  470. <sect2 id="mode-syntax-tokens"><title>Token Types</title>
  471. <para>
  472. Parser rules can highlight tokens using any of the following token
  473. types:
  474. </para>
  475. <itemizedlist>
  476. <listitem><para><literal>NULL</literal> - no special
  477. highlighting is performed on tokens of type <literal>NULL</literal>
  478. </para></listitem>
  479. <listitem><para><literal>COMMENT1</literal>
  480. </para></listitem>
  481. <listitem><para><literal>COMMENT2</literal>
  482. </para></listitem>
  483. <listitem><para><literal>FUNCTION</literal>
  484. </para></listitem>
  485. <listitem><para><literal>INVALID</literal> - tokens of this type are
  486. automatically added if a <literal>NO_WORD_BREAK</literal> or
  487. <literal>NO_LINE_BREAK</literal> <literal>SPAN</literal> spans more than
  488. one word or line, respectively.
  489. </para></listitem>
  490. <listitem><para><literal>KEYWORD1</literal>
  491. </para></listitem>
  492. <listitem><para><literal>KEYWORD2</literal>
  493. </para></listitem>
  494. <listitem><para><literal>KEYWORD3</literal>
  495. </para></listitem>
  496. <listitem><para><literal>LABEL</literal>
  497. </para></listitem>
  498. <listitem><para><literal>LITERAL1</literal>
  499. </para></listitem>
  500. <listitem><para><literal>LITERAL2</literal>
  501. </para></listitem>
  502. <listitem><para><literal>MARKUP</literal>
  503. </para></listitem>
  504. <listitem><para><literal>OPERATOR</literal>
  505. </para></listitem>
  506. </itemizedlist>
  507. </sect2>
  508. </sect1>
  509. </chapter>