Nested lexers allows use external lexer for the defined text range. For example, in HTML we want to highlight scripts with the corresponded lexer (java script, vb script, perl script, ...).
Sub lexer rules are intended for this purpose.
Because Sub lexer rules are derived from TRuleCollectionItem they supports common properties:Parent block, Strict parent block, Not a parent, Always enabled. See "Common for Styles and Rules".
Style is applied to all text range where this nested lexer will act. If you want some rules of lexer will be enabled in the text space of nested lexer you must set "Always enabled" property of that rules to TRUE.
End at the end of text - closes sub-lexer range at the end of text.
Start at the begin of text - sub-lexer range is opened at start of text, i.e. it is opened at start of analysis.
Include bound text - specifies whether condition text will be parsed by the nested lexer, otherwise it will be parsed by current lexer.
Sub lexer combo box allows you selecting nested lexer. It contains all lexers with the same Owner, i.e. if you have two lexer on the form, for each of them they will present in sub lexer combo.
Text space of nested lexer detecting
To detect text space two regular expression are used: "Start condition" and "End condition".
Text space will be from the end of the "Start condition" to th start of the end condition.
For example, we include Assembler lexer into Pascal.
Sub lexer = "Pascal"
Start condition = "asm"
End condition = "end"
In this case text space will be from the next character after "asm" to the previous character before "end".
If text space must start from the begin of text set property "Start at the begin of text". Nested lexer starts at the begin of text.
If text space must be closed at end of text set property "End at the end of text". Nested lexer closes at the end of text.
Also if you want to extend some lexer without modifying it, you can do this:
So you create inherited lexer which have all rules of base lexer plus rules defined in the derived lexer.