Hi Neil,
On Mon, 15 Aug 2022 09:16:46 +1000
"'Neil Hodgson' via scite-interest" <
scite-i...@googlegroups.com> wrote:
> Hi Mitchell,
>
> > Attached is a small patch against SciTE 5.2.4 that updates property handling for Scintillua lexers.
>
> This has grown enough that it may be better as its own method where its more obvious that the code is Scintillua-specific.
That's a good idea. I've moved the code into a function in an anonymous namespace. I'm also using constexpr like you suggest. Please see the revised patch.
> The loops are a bit complex. The subtraction of numPredefined in the max expression isn't clear to me - if the lexer returns '4', say, then no lexer styles will be processed. If I've understood correctly, there is a range of named styles and a range of predefined styles that may or may not overlap so its divided into 3 ranges (named-before, predefined, named-after). I'd think this was clearer as enumerating up to max of named and predefined then ignoring when in the (potential) hole (namedStyles..StyleDefault).
To make bookkeeping inside the lexer easier, NamedStyles() includes predefined styles in the count, so there are no overlapping ranges. It will always return at least 8 (the number of predefined styles from StyleDefault to LastDefined). If there are 33 named styles, it is composed of 33-8 lexer-defined styles, and 8 predefined styles. The predefined styles always need to be set, so that's where there's a separate loop from StyleDefault to LastDefined. This was the easiest way I could wrap my head around it.
Cheers,
Mitchell
>
> for (i=0, i < max(namedStyles, LastPredefined+1); i++) {
> if (i < namedStyles || i >= StyleDefault) {
> // find the name and apply it.
> }
> }
>
> 'constexpr' should be used for compile-time constants like LastPredefined and numPredefined as they aren't just locally const and Visual C++ shows warnings.
>
> Neil
>
> --
> You received this message because you are subscribed to the Google Groups "scite-interest" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
scite-interes...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/scite-interest/633F3D80-6E3A-4ACB-8963-4EB0B494C88E%40me.com.
Cheers,
Mitchell