I'm a keen admirer of BBEdit, and code on nothing else.
Just want to say that first, in case I come over as in any
way negative.
If there's one feature I'd request, though, it's a more
powerful syntax for syntax colouring. Codeless Language
Modules just don't quite do enough, I think, and the
frustrating thing about them is that they so nearly do.
Googling around, I have the impression that I'm not
the only BBEdit user who feels this way. 8.5 makes
one minor improvement here, but I'd hoped for more,
to be candid.
(a) Quite small generalisations would make a big
difference: for instance, we are allowed to have
two ways to open and close strings, Open Strings 1
and 2, and similarly Close Strings 1 and 2. But we
only have one Open Block Comments and Close
Block Comments. Could these not be generalised to
allow an arbitrary number of things in each category?
Or at least to have up to, say, 3?
The following example may be illustrative. I work
on a program written in about 60,000 lines of
CWEB, a "|iterate programming" language devised
by Knuth in the early 1980s. It's essentially C with
more elaborate commentary, signalled by escape
characters. Ideally I'd like to specify the language
by saying "there are two modes, C and TeX, and
this is the marker to switch from one to the other",
but that's a lot to ask. At least, though, I'd like to
able to say "don't colour paragraphs of text
between these markers, since they're comment",
but there seems no way to do this. (Remember,
one gets only one block comment syntax.)
To be more specific, CWEB's syntax looks like
this: a section marker starts with an @ sign at
the start of a line. Once we hit one of these, we're
in plain text commentary until we hit a line
reading "@c" (if we do) and then we're into C
until the next time. For instance:
@* Rebuild Database.
The following routines regenerate the data
after ... (etc., etc.).
@c
int regenerate_data(void) {
...
}
Clearly we want to treat the explanatory text
as comment. This looks like a candidate for Open
Block Comments and Close Block Comments,
but we can't have that without throwing out C's
/* and */ comments. And even so, it doesn't
quite work, because it doesn't have a way to
recognise that @@ is an escape meaning
"literal @" and should not end C code... and
there is also the issue that @< can also start
C code, whereas right now the Close Block
Comments value must be fixed and cannot be
a regular expression.
(b) The regular expression matching for functions
in 8.5 is intriguing, but I'm unable to get it to work.
I don't want to use it for C functions within CWEB -
this cannot function correctly since it picks up
spurious hits in the commentary (for the same reason,
I've deleted syntax colouring of all C keywords).
So instead, I thought it would be good to try to
pick up CWEB's section headings, such as:
@* Rebuild Database.
In principle, this is trivial to parse with a regular
expression, and indeed I've been trying with
this one:
<key>Function Pattern</key>
<string>@\*+[0-9]* \s*(?P<function_name>.*?)(?P<function>
\.)</string>
the idea being that the function name is the
text "Rebuild Database", and that its body is the
text "." Unfortunately, BBEdit recognises only the
first such instance as a function, ignoring all
subsequent matches in the file, even though the
pattern seems quite explicitly to say that the
function consists only of the text ".". Why, I don't
know, but can I suggest that it would be very
helpful if the BBEdit team could post an
example of a working Function Pattern for
some language? I may just have the wrong
idea altogether.
(c) Ultimately, one might like to be able to have
a syntax-colouring algorithm which is a finite
state machine: each state corresponding to one
of the available colours (of course, several states
might have the same colour and thus look the
same), and each state having regular expressions
to define transitions into other states. Start at the
top of the file in state 1, and work down, changing
state each time you hit one of the regular
expressions - into comment, out of comment, etc.
I'd be willing, in principle, to write a coded
language module to do this sort of thing by hand
for the fairly simply finite state machine needed
to syntax-colour CWEB. But even after looking
at the developer kit (which dates from last year),
I can't quite get a sense of whether BBEdit
plugins have sufficient power available to them
to do this sort of thing. Does anyone have any
advice on this?
With apologies for writing at such length. And it's
a terrific editor, of course.
--
Graham Nelson
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <[EMAIL PROTECTED]>