DTE-SYNTAX(5) | File Formats Manual | DTE-SYNTAX(5) |
dte-syntax - Format of syntax highlighting files used by dte(1)
Commands:
Main commands:
syntax name
state name [emit-color]
default color name...
list [-i] name string...
Conditionals:
bufis [-i] string destination [emit-name]
char [-bn] characters destination
[emit-name]
heredocend destination
inlist list destination [emit-name]
str [-i] string destination [emit-name]
Default actions:
eat destination [emit-name]
heredocbegin subsyntax return-state
noeat [-b] destination
Other commands:
recolor color [count]
A dte syntax file consists of multiple states. A state consists of optional conditionals and one default action. The best way understand the syntax is to read through some of the built-in syntax files, which can be printed with dte -b, for example:
dte -b syntax/dte
The basic syntax used is the same as in dterc(5) files, but the available commands are different.
Conditionals and default actions have a destination state. The special destination state this can be used to jump to the current state.
syntax name
See also: sub-syntaxes.
state name [emit-color]
default color name...
Example:
default numeric oct dec hex
If there is no color defined for oct, dec or hex then color numeric is used instead.
list [-i] name string...
Example:
list keyword if else for while do continue switch case
Use the inlist command to test if a buffered string is in a list.
bufis [-i] string destination [emit-name]
char [-bn] characters destination [emit-name]
characters is a list of strings. Ranges are supported (a-d is the same as abcd).
heredocend destination
inlist list destination [emit-name]
str [-i] string destination [emit-name]
NOTE: This conditional can be slow, especially if string is longer than two bytes.
The last command of every state must be a default action. It is an unconditional jump.
eat destination [emit-name]
heredocbegin subsyntax return-state
noeat [-b] destination
recolor color [count]
Sub-syntaxes are useful when the same states are needed in many contexts.
Sub-syntax names must be prefixed with .. It's recommended to also use the main syntax name in the prefix. For example .c-comment if c is the main syntax.
A sub-syntax is a syntax in which some destination state's name is END. END is a special state name that is replaced by the state specified in another syntax.
Example:
# Sub-syntax syntax .c-comment state comment char "*" star eat comment state star comment # END is a special state name char / END comment noeat comment # Main syntax syntax c state c code char " \t\n" c char -b a-zA-Z_ ident char "\"" string char "'" char # Call sub-syntax str "/*" .c-comment:c eat c # Other states removed
In this example the destination state .c-comment:c is a special syntax for calling a sub-syntax. .c-comment is the name of the sub-syntax and c is the return state defined in the main syntax. The whole sub-syntax tree is copied into the main syntax and all destination states in the sub-syntax whose name is END are replaced with c.
Craig Barnes
Timo Hirvonen
May 2020 |