[PHP3] Syntax Highlight From: Vincent Driessen (vinnie.driessen <email protected>)
Date: 04/30/00

Hi there,

I'm doin' an algorithm to highlight Pascal code. When a user types is him
code in a form on my site and clicks the format button, a PHP script is
executed to start syntax highlighting.

So far, It works like this. I made a function SplitCode. It split the code
into 3 pieces:
    - First piece (no strings or comments)
    - A string or a comment
    - The rest, can be anything. This part is recursively parsed again to
       the SplitCode function

All parts work smooth by now (partly thanks to some of you guys!). I have an
array with reserved words which I want to apply to the first part. Therefor,
I thought just replacing all reserved words in the first part by the same
string, surrounded by <b></b> tags. Not...!! :-(

What happened was this (of course, you say afterwards):

    <b>uses</b>
    W<b>in</b><b>do</b>ws;

While it had to be:

    <b>uses</b>
    Windows;

You see... ("in" and "do" are reserved!)

Has anybody got a better idea to do this? Or can anybody tell me how to
parse all words in a string, then check if it is reserved and then replacing
it or something?

Thanx a lot in advance,

Vincent Driessen
Venlo, The Netherlands

-- 
PHP 3 Mailing List <http://www.php.net/>
To unsubscribe, send an empty message to php3-unsubscribe <email protected>
To subscribe to the digest, e-mail: php3-digest-subscribe <email protected>
To search the mailing list archive, go to: http://www.php.net/mailsearch.php3
To contact the list administrators, e-mail: php-list-admin <email protected>