Homematic Lexer Plugin is an external lexer for Homematic scripts for Notepad++. It uses the same lexing formats as the SDV 5.0 Script-Developer-CCU. This includes detection of unsued variables.
While it is possible to use a User Defined Language (UDL), the unusual comment character ! and the contexts in which it is used as a negator make reliable lexing difficult.
When I first started writing CCU scripts, I used .c file extensions and a form of “double comments”: an exclamation mark combined with C-style comments, such as !//. However, this caused inconsistent keyword parsing.
As a result, I decided to implement a fully custom lexer. The color and style definitions are closely aligned with SDV 5.0.
- It uses a similar color schema like SDV 5.0. It also parses variable definitions and tries to format them accordingly.
- Included all constant and fucntion names I can retrieve from the Homematich forum and documentation.
- Correct parsing of comments (
!character) and cares about operators starting with!to, like!=. Comments are allowed after a statement (ending;), or directly after a closing or open brace ({,}) - The folding feature is taken from the
LexCPPfrom the NotePad++ project. - If a variable has the same name like a reserved name, it is formated as a variable, not as a define or constant.
- **A real sepcial feature is the detection of undefined variables, similar as in SDV. They are shown in red backround letters.
This project is based on the Notepad++ plugin template.
Special thanks to Notepad++ plugin with crude external lexer, which provided a helpful starting point for external lexer development.
Documentation for lexer development is limited. Neither Scintilla nor Notepad++ provides comprehensive guidance for creating custom or external lexers.
The following files were copied from the Notepad++ source tree:
For implementation details, it is recommended to study the built-in lexer sources, for example the C++ lexer. The code for folding blocks is taken from this file.
The plugin was developed using Visual Studio 2022.
The HomematicNPPLexerPlugin.vcxproj file specifies:
<PlatformToolset>v145</PlatformToolset>
Copy the plugin DLL to:
plugins\HomematicNPPLexer\HomematicNPPLexer.dll
Copy the XML configuration file to:
plugins\Config\HomematicNPPLexer.xml
64-bit installation
%PROGRAMFILES%\Notepad++\plugins\HomematicNPPLexer\%PROGRAMFILES%\Notepad++\plugins\config\
32-bit installation
%PROGRAMFILES(x86)%\Notepad++\plugins\HomematicNPPLexer\%PROGRAMFILES(x86)%\Notepad++\plugins\config\
Portable installation
<portable Notepad++ directory>\plugins\HomematicNPPLexer\<portable Notepad++ directory>\plugins\config
After installation, HomematicNPPLexer should appear:
- In the Language menu
- At the bottom of Settings → Style Configuration
