TextPad Syntax Definition Files

Syntax definition files contain the information TextPad uses to highlight keywords in different colors. A standard set is provided for common programming languages, and contributed files are available from the TextPad web site.

If you want to implement syntax highlighting for a document class that has not been catered for, you must create a file of keywords that you want to be colored, as described below, and save it as "myfile.SYN" in the Syntax folder. Note that double byte character sets cannot be used in syntax definition files.

The first line of the file must be one of the following:

We will introduce other grammars as and when necessary.

The rest looks like an .INI file, with the following sections:

The [Syntax] section must be first, followed by [Keywords 1]. The other sections are optional. The [Preprocessor keywords] section can only be used when a single character (such as "#") is used to start a statement that is handled by a pre-processor.

Keywords are entered one per line. The split between the keyword sections is arbitrary. You only need to use Keywords 2-6, if you want some keywords in different colors. They are all in the same namespace, unless "HTML=1" is used, when "Namespace1 = n" specifies how many of the keyword sections are in the first namespace, with the remainder in another. This means that the same name can appear in both namespaces when "HTML=1". The pre-processor keywords are always in their own namespace.

You can select the newly created .SYN file using the Preferences command on the Configure menu. It should be displayed in the drop-down list box for Syntax settings, for the new document class you created.

The [Syntax] section must contain the following lines: