Pascal (most modern languages too) can be easily broken into different language elements "ranges"
Basicaly all foldable language elements can be considered as ranges.
AHHH Yes..
That explains the word range.
Within a range (e.g. the body of a procedure versus the declaration of a class or interface vs implementation) there are different set of rules that apply.
So Storing the range, at the end of the line, allows to parse the next line in the context of that range.
--------------------
Once implemented multiple highlighters are very useful
Well there is an implementation of a multi hl. But it has quite some overhead.
1) It must decide where to break before handing down to the other hl, since the embedded HL do not know that they work on part of the text only.
E.g if pascal code is embedded into xml, the pascal HL would not know to stop at </code>
2) for the same reason it must present the other HL an extract of the complete text only
This could be optimized for a situation like asm in pascal. Both HL could know about the switching keywords. Therefore the overhead of the controller could be smaller.
Also the asm, can act on each asm block, without knowing the previous block.
In the pascal in xml, the source may be spread over several blocks, but must appear as continuous for the pas highlighter.
So the generic approach is very complex, but it does ekist: based on feeding the embedded HL with virtual documents.
to handle other editing tasks,
such as?
Something like viewing an include file embedded in the file that uses it? But that dose not need to combine the highlighters. So it is different.
especialy if the editor control canvas, the painter and the data buffer are seperated too.
that is work in progress.
I also added a distinction between highlight (based on the language) and Markup (based on language independent criteria e.g. block selection)