Skip to content

Highlighter Demo ​

Folder: Demos\HighlighterDemo. Project: HighlighterDemo.dproj.

Shows how to create your own highlighter using a grammar file and the SynGen utility: see Create your Highlighter.

FileContent
SynHighlighterSample.msgThe grammar file: the class TSynSampleSyn, its token types with the default attributes, and the keywords.
SynHighlighterSample.pasThe unit generated by SynGen from the grammar.
uMain.pasThe main form: an editor that uses the sample highlighter.

The grammar ​

text
TSynSampleSyn
tk
IdentStart '_', 'a'..'z', 'A'..'Z':: '_', '0'..'9', 'a'..'z', 'A'..'Z'::

TOKENTYPES
Identifier
Comment Style=[fsItalic]|Foreground=clNavy
Space
String Foreground=clRed
Key Style=[fsBold]
Test Background=clSilver|Foreground=clBlue|Style=[fsUnderline, fsItalic]
|><|

KEYS
Hello
World
|><|

KEYS Test
SynEdit
|><|

The words Hello and World are keywords, shown in bold, and SynEdit is of the type Test, shown in blue on a silver background.

Released under the MPL 1.1 / GPL 2 dual license.