1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
|
.TH DTE\-SYNTAX 5 "May 2020"
.nh
.ad l
.
.SH NAME
dte\-syntax \- Format of syntax highlighting files used by \fBdte\fR(1)
.SH SYNOPSIS
.P
Commands:
.br
.P
Main commands:
.br
\fBsyntax\fR \fIname\fR
.br
\fBstate\fR \fIname\fR [\fIemit\-color\fR]
.br
\fBdefault\fR \fIcolor\fR \fIname\fR...
.br
\fBlist\fR [\fB\-i\fR] \fIname\fR \fIstring\fR...
.br
.P
Conditionals:
.br
\fBbufis\fR [\fB\-i\fR] \fIstring\fR \fIdestination\fR [\fIemit\-name\fR]
.br
\fBchar\fR [\fB\-bn\fR] \fIcharacters\fR \fIdestination\fR [\fIemit\-name\fR]
.br
\fBheredocend\fR \fIdestination\fR
.br
\fBinlist\fR \fIlist\fR \fIdestination\fR [\fIemit\-name\fR]
.br
\fBstr\fR [\fB\-i\fR] \fIstring\fR \fIdestination\fR [\fIemit\-name\fR]
.br
.P
Default actions:
.br
\fBeat\fR \fIdestination\fR [\fIemit\-name\fR]
.br
\fBheredocbegin\fR \fIsubsyntax\fR \fIreturn\-state\fR
.br
\fBnoeat\fR [\fB\-b\fR] \fIdestination\fR
.br
.P
Other commands:
.br
\fBrecolor\fR \fIcolor\fR [\fIcount\fR]
.br
.SH DESCRIPTION
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 \fBdte \-b\fR, for example:
.P
.IP
.nf
\f[C]
dte\ \-b\ syntax/dte
\f[]
.fi
.PP
The basic syntax used is the same as in \fBdterc\fR(5) files, but the
available commands are different.
.P
Conditionals and default actions have a destination state. The special
destination state \fBthis\fR can be used to jump to the current state.
.P
.SH COMMANDS
.SS Main commands
\fBsyntax\fR \fIname\fR
.RS
Begin a new syntax. One syntax file can contain multiple syntax
definitions, but you should only define one real syntax in one
syntax file.
.P
See also: sub\-syntaxes.
.P
.RE
\fBstate\fR \fIname\fR [\fIemit\-color\fR]
.RS
Add new state. Conditionals (if any) and one default action must
follow. The first state is the \fBstart\fR state.
.P
.RE
\fBdefault\fR \fIcolor\fR \fIname\fR...
.RS
Set default \fIcolor\fR for emitted \fIname\fR.
.P
Example:
.P
.IP
.nf
\f[C]
default\ numeric\ oct\ dec\ hex
\f[]
.fi
.PP
If there is no color defined for \fIoct\fR, \fIdec\fR or \fIhex\fR then color
\fInumeric\fR is used instead.
.P
.RE
\fBlist\fR [\fB\-i\fR] \fIname\fR \fIstring\fR...
.RS
Define a list of strings.
.P
Example:
.P
.IP
.nf
\f[C]
list\ keyword\ if\ else\ for\ while\ do\ continue\ switch\ case
\f[]
.fi
.PP
Use the \fBinlist\fR command to test if a buffered string is in a list.
.P
.TP
\fB\-i\fR
Make list case\-insensitive.
.PP
.RE
.SS Conditionals
\fBbufis\fR [\fB\-i\fR] \fIstring\fR \fIdestination\fR [\fIemit\-name\fR]
.RS
Test if buffered bytes are same as \fIstring\fR. If they are, emit
\fIemit\-name\fR and jump to \fIdestination\fR state.
.P
.TP
\fB\-i\fR
Case\-insensitive.
.PP
.RE
\fBchar\fR [\fB\-bn\fR] \fIcharacters\fR \fIdestination\fR [\fIemit\-name\fR]
.RS
Test if current byte is in the \fIcharacters\fR list. If it is then emit
\fIemit\-color\fR and jump to \fIdestination\fR state. If \fIemit\-name\fR is not
given then the \fIdestination\fR state's emit name is used.
.P
\fIcharacters\fR is a list of strings. Ranges are supported (\fBa\-d\fR is the
same as \fBabcd\fR).
.P
.TP
\fB\-b\fR
Add byte to buffer.
.PP
.TP
\fB\-n\fR
Invert character bitmap.
.PP
.RE
\fBheredocend\fR \fIdestination\fR
.RS
Compare following characters to heredoc end delimiter and go to
destination state if comparison is true.
.P
.RE
\fBinlist\fR \fIlist\fR \fIdestination\fR [\fIemit\-name\fR]
.RS
Test if buffered bytes are found in \fIlist\fR. If found, emit
\fIemit\-name\fR and jump to \fIdestination\fR state.
.P
.RE
\fBstr\fR [\fB\-i\fR] \fIstring\fR \fIdestination\fR [\fIemit\-name\fR]
.RS
See if following bytes are same as \fIstring\fR. If they are, emit
\fIemit\-name\fR and jump to \fIdestination\fR state.
.P
.TP
\fB\-i\fR
Case\-insensitive.
.PP
NOTE: This conditional can be slow, especially if \fIstring\fR is
longer than two bytes.
.P
.RE
.SS Default actions
The last command of every state must be a default action. It is an
unconditional jump.
.P
\fBeat\fR \fIdestination\fR [\fIemit\-name\fR]
.RS
Consume byte, emit \fIemit\-name\fR color and continue to \fIdestination\fR
state.
.P
.RE
\fBheredocbegin\fR \fIsubsyntax\fR \fIreturn\-state\fR
.RS
Store buffered bytes as heredoc end delimiter and go to
\fIsubsyntax\fR. Sub\-syntax is like any other sub\-syntax but it must
contain a \fIheredocend\fR conditional.
.P
.RE
\fBnoeat\fR [\fB\-b\fR] \fIdestination\fR
.RS
Continue to \fIdestination\fR state without emitting color or
consuming byte.
.P
.TP
\fB\-b\fR
Don't stop buffering.
.PP
.RE
.SS Other commands
\fBrecolor\fR \fIcolor\fR [\fIcount\fR]
.RS
If \fIcount\fR is given, recolor \fIcount\fR previous bytes, otherwise
recolor buffered bytes.
.P
.RE
.SH SUB\-SYNTAXES
Sub\-syntaxes are useful when the same states are needed in many contexts.
.P
Sub\-syntax names must be prefixed with \fB.\fR. It's recommended to also use
the main syntax name in the prefix. For example \fB.c\-comment\fR if \fBc\fR is
the main syntax.
.P
A sub\-syntax is a syntax in which some destination state's name is
\fBEND\fR. \fBEND\fR is a special state name that is replaced by the state
specified in another syntax.
.P
Example:
.P
.IP
.nf
\f[C]
#\ 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
\f[]
.fi
.PP
In this example the destination state \fB.c\-comment:c\fR is a special syntax
for calling a sub\-syntax. \fB.c\-comment\fR is the name of the sub\-syntax and
\fBc\fR 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 \fBEND\fR are replaced with \fBc\fR.
.P
.
.SH SEE ALSO
\fBdte\fR(1),
\fBdterc\fR(5)
.SH AUTHORS
Craig Barnes
.br
Timo Hirvonen
|