Neil Hodgson wrote:
Darren Schroeder:


Ya, I changed the lexer and "fixed" it.  I also noticed that in the CPP
lexer there is are several checks for sc.atLineEnd.  That check will never
return true because the sc.More() function that the state machine is driven
off always returns (currentPos < endPos) so it will never be equal or true.
I "fixed" that too. :)


   Be careful here: its easy to "fix" problems with the termination
logic and cause other problems.

   Neil

Another reason to be careful is that there are two kinds of languages:
those that can end with a keyword, no following newline necessary,
and those that rely on punctuation for syntax as opposed to keywords.
The first group is small, including at least Python, Ruby, and members
of the Basic family.  I suspect any others will be relatively obscure;
most languages these days require that a module end with something like
";", "}", or for the closest-to-prose award, Pascal's "end."[1].

So if you can end a program with a keyword, that term needs to be colorized
as a keyword.  The editor *could* do some syntactic analysis to determine if
the instance of 'end' that has just been typed in a Ruby program is actually
a potential end of a top-level construct, but I don't think anyone wants to
add that kind of code to a lexer.

This means that lexers for python/ruby/basic always should colorize a word
as a keyword as soon as the final letter of the word has been typed, and
recolorize it as an identifier if a further change to the word makes it a
non-keyword.  Now if scintilla lexers for the other languages choose to wait 
for a delimiter
after the word has been typed before checking to see if it's a keyword, we've
introduced a cross-language inconsistency into scintilla (which we probably
have anyway, but I haven't checked every lexer).

Now onto UI philosophy ... the main reason why we colorize the parts of the
code is to give feedback to the user.  Say we've got a novice-level user who
is writing code for a web site using JavaScript and Perl.  He[2] loads up a
Perl file, needs to enter a function, types "s-u-b" and immediately gets the
positive feedback that he's typed a keyword.  He can then press a
space and move on.

Now this user switches to a JS file.  With his brain addled by too much Perl, he
starts a new function by typing "d-e-f", but doesn't see the change in color.
This negative feedback helps him switch gears into the other language.

So whatever the language, its lexer should always color a keyword at the end
of the file as a keyword, not as an identifier that might be a keyword.

Thank you for your time.
- Eric

[1] I remember feeling a certain sense of completion whenever I got to type that
"." after the "end" at the end of a Pascal program.

[2] s/he/she/ if you feel so inclined.
_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Reply via email to