On Sun, Jun 02, 2002 at 02:40:48PM -0500, David Beers wrote:
> Let me be a bit more specific about the information I'm seeking. I'm
> guessing that syntax highlighting is usually accomplished in text editors by
> comparing the string delimited by the insertion point and  the last
> separating character (space, comma, paren, brace, etc.), then bracketing the
> string with some kind of non-printing escape code or tag that the editor
> reads but the compiler ignores. The editor then renders the text like a
> browser renders HTML presentation tags.

?
AFAIK editors supporting syntax highlighting perform a textual analysis on
the text (usually source code, but not necessarily), following a set of rules
that permit to augment the internal representation of the text with
attributes (syntactic class and consequently color, font, ...). But these
attributes are usually kept internally and never saved along with the
original text or source code, so the hypothetical compiler translating
the same source file will never see anything but the original source code,
without any attributes or tags.
Perhaps the easiest way to specify syntax rules suitable for syntax highlight
is through the use of regular expressions or similar pattern language, but
there are issues to keep into consideration like literal text contained
in strings or comments and so on. In the most general situation the only
reliable solution is to use a full blown parser for the language (but
there are other issues for some languages like C, related to the
preprocessor: macro expansion, include files, ...).

> 4. Does anyone know of any code samples that could give me a leg up on this
> feature?

You can look at the source code of freely available editors implementing
syntax highlighting (like jed, vim, emacs, ...)

Marco

-- 
========================================================================
Marco Pantaleoni                                  [EMAIL PROTECTED]
Padova, Italy                                              [EMAIL PROTECTED]
elastiC language developer                   http://www.elasticworld.org

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to