> -----Original Message-----
> From: Marco Pantaleoni [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, June 02, 2002 3:06 PM
> To: Palm Developer Forum
> Subject: Re: color syntax highlighting on a Palm
> 
> 
> 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.

I considered this, but it sounds like an awfully expensive operation for a
Palm application. Consider how often this textual analysis would need to
take place. Every time the screen is redrawn (like if you scroll or insert
some text) you would need to check each word on the screen against a huge
list of API keywords.  It seems like the key to this working on a Palm is to
break the analysis into small chunks (one word or line at a time) and to
make the result of the analysis persistent in the text.  Or am I missing
something?

> 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. 

I've heard of regular expressions but am not familiar with them. I'll
investigate this. If anyone  can point me in a specific direction with some
links, I'd appreciate it.  

> 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, ...)

Any examples of something similar to these written for the Palm? In addition
to my concerns about processor-intensive operations on the Palm, I've only
been programming C for a few months and mostly just know the Palm API. Aside
from that my programming knowledge mostly consists of scripting languages
like Javascript and VBScript. 

David Beers


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

Reply via email to