DTE-SYNTAX(5)
π¦ DTE-SYNTAX(5) β the file format manual, but make it cute π¦
okay bestie, so this is dte-syntax, the whole entire vibe of the syntax highlighting files that dte(1) uses. yes THE editor. she reads these files, she highlights ur code, she slays. let's get into it π
β¨ SYNOPSIS β¨
Commands, in all their glory:
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]
πΈ DESCRIPTION πΈ
So a dte syntax file is literally just a bunch of states. Each state has some optional conditionals and then exactly one default action. that's the whole structure, no cap.
The best way to actually get it is to go read some of the built-in syntax files, which you can print out with dte -b, like:
dte -b syntax/dte
The base syntax is the same as in dterc(5) files, but the commands available are different. same grammar, different menu, iykyk.
Conditionals and default actions both have a destination state. And there's one special destination state β this β which jumps you to the current state. she's a lil shortcut, she's iconic.
π COMMANDS π
π Main commands
syntax nameβ Start a whole new syntax. One syntax file can hold multiple syntax definitions, but bestie, you should only define one real syntax in one syntax file. fr.
See also: sub-syntaxes. (they're down below, don't worry π«Ά)
state name [emit-color]β Add a new state. Conditionals (if there are any) and one default action must follow it. The first state is the start state. she goes first, main character energy.default color name...β Set the default color for an emitted name.
Example:
default numeric oct dec hex
So if there's no color defined for oct, dec or hex, then the color numeric gets used instead. fallback queen π
list [-i] name string...β Define a list of strings.
Example:
list keyword if else for while do continue switch case
Then use the inlist command to check whether a buffered string is in the list.
-iβ Make the list case-insensitive.
π Conditionals
bufis [-i] string destination [emit-name]β Test whether the buffered bytes are the same asstring. If they are: emitemit-nameand jump to thedestinationstate.-iβ Case-insensitive.
char [-bn] characters destination [emit-name]β Test whether the current byte is in thecharacterslist. If it is, then emitemit-colorand jump to thedestinationstate. Ifemit-nameisn't given, then the destination state's emit name gets used instead.
characters is a list of strings. Ranges are supported β a-d is the same as abcd. cute right?
-bβ Add byte to buffer.-nβ Invert character bitmap.
heredocend destinationβ Compare the following characters to the heredoc end delimiter, and go to thedestinationstate if the comparison is true.inlist list destination [emit-name]β Test whether the buffered bytes are found inlist. If found: emitemit-nameand jump to thedestinationstate.str [-i] string destination [emit-name]β See if the following bytes are the same asstring. If they are: emitemit-nameand jump to thedestinationstate.-iβ Case-insensitive.
β οΈ NOTE: This conditional can be slow, especially if string is longer than two bytes. she's pretty but she's not fast, ok π
π Default actions
The last command of every state must be a default action. It's an unconditional jump. no conditions, she just goes.
eat destination [emit-name]β Consume a byte, emit theemit-namecolor, and continue to thedestinationstate.heredocbegin subsyntax return-stateβ Store the buffered bytes as the heredoc end delimiter and go tosubsyntax. A sub-syntax is like any other sub-syntax, except it must contain aheredocendconditional. mandatory. non-negotiable.noeat [-b] destinationβ Continue to thedestinationstate without emitting color and without consuming a byte.-bβ Don't stop buffering.
π Other commands
recolor color [count]β Ifcountis given, recolorcountprevious bytes. Otherwise, recolor the buffered bytes.
π§ SUB-SYNTAXES π§
Sub-syntaxes are lowkey the best thing ever when you need the same states in a bunch of different contexts. reusable. sustainable. iconic.
Sub-syntax names must be prefixed with .. And it's recommended that you 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 gets replaced by the state specified in another syntax. she's a placeholder, she's a chameleon π
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
So 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 gets copied into the main syntax, and every destination state in the sub-syntax whose name is END gets replaced with c. it's a copy-paste but make it elegant β¨
π₯ SEE ALSO π₯
π AUTHORS π
Craig Barnes Timo Hirvonen
okay and that's the whole page bestie β this was the <b>File Formats Manual</b> entry DTE-SYNTAX(5), dated May 2020, and yes that date is giving vintage but she still eats. go forth and highlight ur little heart out π«Άβ¨
π¦ where this page comes from
- debian bookworm: dte 1.10-1 Β· GPL-2.0-only
- debian trixie: dte 1.10-1 Β· GPL-2.0-only
- ubuntu jammy: dte 1.10-1 Β· GPL-2.0-only
- ubuntu noble: dte 1.10-1 Β· GPL-2.0-only
- ubuntu resolute: dte 1.10-1build1 Β· GPL-2.0-only
- ubuntu stonking: dte 1.10-1build1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms