In this post I'm going to think out loud, as part of fixing an
interesting
puzzle involved with the new line-oriented jEdit colorizer.

Background

The aha behind the line-oriented jEdit colorizer is that we can define
one or
more *restarter* methods for each pattern matcher that could possibly
match
across line boundaries. I say "one or more" because we need a separate
restarter
method for all combinations of arguments that can be passed to the
jEdit pattern
matchers. In effect, these restarters are lambda bindings for the
generic
restarter methods.

We only create restarters as needed. In actuality, very few restarters
are
needed. For example, for Python, we need restarters for that look for
continued
strings, and both flavors of continued triple-quoted strings. For
python, these
turn out to be three separate lambda bindings for restart_match_span.

When a jEdit pattern matcher partially succeeds, it creates the lambda
binding
for its restarter and calls setRestart to set the ending state of the
present
line to an integer representing the bound restarter. setRestart calls
computeState to create a *string* representing the lambda binding of
the
restarter. setRestart then calls stateNameToStateNumber to convert
that string
to an integer state number that then gets passed to Qt's
setCurrentBlockState.
The string is useful for debugging; Qt only uses the corresponding
number.

stateNameToStateNumber creates new state numbers only if the string
representing
the state does not exist in the stateNameDict. Because the lambda
binding is
complete, you would think that there would never be any need to clear
this dict.
Alas, there are complications. You could say that the puzzle is
figuring out how
*not* to clear this dict!

For languages, like Python, that do not use jEdit "delegate"
colorizers, the new
code is a complete and total success. It is simple, clean and fast.
The
restarter methods were straightforward to create and test. They just
work.

That's enough for now. In a reply to this, I'll discuss the problems
and
possible ways of approaching solutions. I'm sure some way can be
found. In any
event, there will be no going back to the old qt colorizer.

Edward
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to