1DEX-SYNTAX(7)          Miscellaneous Information Manual          DEX-SYNTAX(7)
2
3
4

NAME

6       Syntax of syntax highlighting files used by dex.
7

DESCRIPTION

9       Syntax file consists of states. A state consists of optional
10       conditionals and one default action. The best way understand the syntax
11       is to read /usr/share/dex/syntax/dex (a simple example) or
12       /usr/share/dex/syntax/c (a more complete example using sub-syntaxes).
13
14       Basic syntax of the syntax files is the same used in the rc files, but
15       the available commands are different.
16
17       Conditionals and default actions have destination state. The special
18       destination state "this" can be used to jump to current state.
19

COMMANDS

21   Main commands
22       syntax <name>
23              Begin a new syntax. One syntax file can contain multiple syntax
24              definitions, but you should only define one real syntax in one
25              syntax file.
26
27              See also SUB-SYNTAXES.
28
29       state <name> [emit-color]
30              Add new state. Conditionals (if any) and one default action must
31              follow. First state is the start state.
32
33       default <color> <name>...
34              Set default color for emitted name.
35
36              Example:
37                     default numeric oct dec hex
38
39              If there is no color defined for oct, dec or hex then color
40              numeric is used instead.
41
42       list [-i] <name> <string>...
43              Define a list of strings.
44
45              Example:
46                     list keyword if else for while do continue switch case
47
48              Use conditional inlist to test if a buffered string is in a
49              list.
50
51               -i Make list case-insensitive.
52
53   Conditionals
54       bufis [-i] <string> <destination> [emit-name]
55              Test if buffered bytes are same as string. If they are emit
56              emit-name and jump to destination state.
57
58       char [-bn] <characters> <destination> [emit-name]
59              Test if current byte is in the character list. If it is then
60              emit emit-color and jump to destination state. If emit-name is
61              not given then destination states emit name is used.
62
63              Characters is a list of strings. Ranges are supported (a-d is
64              same as abcd).
65
66              -b Add byte to buffer.
67
68              -n Invert character bitmap.
69
70       heredocend <destination>
71              Compare following characters to heredoc end delimiter and go to
72              destination state if comparison is true.
73
74       inlist <list> <destination> [emit-name]
75              Test if buffered bytes are found in list. If found emit
76              emit-name and jump to destination state.
77
78       str [-i] <string> <destination> [emit-name]
79              See if following bytes are same as string. If they are emit
80              emit-name and jump to destination state.
81
82              -i case-insensitive.
83
84              NOTE: This conditional can be slow, especially if string is
85              longer than two bytes.
86
87   Default actions
88       Last command of every state must be default action. It is an
89       unconditional jump.
90
91       eat <destination> [emit-name]
92              Consume byte, emit emit-name color and continue to destination
93              state.
94
95       heredocbegin <subsyntax> <return-state>
96              Store buffered bytes as heredoc end delimiter and go to
97              subsyntax. Subsyntax is like any other subsyntax but it must
98              contain heredocend conditional.
99
100       noeat [-b] <destination>
101              Continue to destination state without emitting color or
102              consuming byte.
103
104              -b Don't stop buffering.
105
106   Other commands
107       recolor <color> [count]
108              If count is given, recolor count previous bytes, otherwise
109              recolor buffered bytes.
110

SUB-SYNTAXES

112       Sub-syntaxes are useful when same states are needed in many contexts.
113
114       Sub-syntax name must be prefixed with ".". It is recommended to also
115       use main syntax's name in the prefix. For example ".c-comment" if "c"
116       is the main syntax.
117
118       Sub-syntax is a syntax of which some destination state's name is END.
119       END is a special state name which is replaced by state given at another
120       syntax.
121
122       Example:
123
124              # sub-syntax
125              syntax .c-comment
126
127              state comment
128                     char "*" star
129                     eat comment
130
131              state star comment
132                     # END is a special state name
133                     char / END comment
134                     noeat comment
135
136              # main syntax
137              syntax c
138
139              state c code
140                     char " \t\n" c
141                     char -b a-zA-Z_ ident
142                     char "\"" string
143                     char "'" char
144                     # call sub-syntax
145                     str "/*" .c-comment:c
146                     eat c
147
148              # other states removed
149
150       In this example the destination state .c-comment:c is special syntax
151       for calling a sub-syntax. ".c-comment" is name of the sub-syntax and
152       "c" is the return state defined in the main syntax. Whole sub-syntax
153       tree is copied into the main syntax and all destination states in the
154       sub-syntax whose name is END are replaced with "c".
155

AUTHORS

157       Timo Hirvonen <tihirvon@gmail.com>
158

SEE ALSO

160       dex(1)
161
162
163
164                                     2012                        DEX-SYNTAX(7)
Impressum