# zend_highlight routine

- Thread: https://externals.io/message/13819
- Original archive: https://news-web.php.net/php.internals/13819
- Started by Aidan Lister on 2004-11-11T03:36:48+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #13819 — Aidan Lister — 2004-11-11T03:36:48+00:00

URL: https://externals.io/message/13819#13819

I'm rewriting the highlight_file/string methods in userland code (using the 
tokenizer) because I've found the native functions painful.

It is difficult to insert line numbering properly, and have accurate 
function referencing - most pastebins now use PEAR's Text_Highlight to 
highlight the code with a bunch of intensive preg_matches. Hopefully this 
can be updated one day (though according to the bug reports it caused 
segfaults with the current implementation), but until then I thought this 
may be useful.

I'm almost finished:

http://aidan.dotgeek.org/lib/?file=PHP_Highlight.php

My problem is the token2color method, I'm not sure which tokens are classed 
as keywords. At the moment I've just guessed as many as I could think of, 
it's a bit ugly - presuming there is an easier way to do it.

I've had a look through zend_highlight.c and found that anything with 
token.type = 0 is highlighted as a keyword, however I'm unable to track down 
where token.type is set.

Is anyone able to provide some insight?

King Regards,
Aidan Lister

---

## #13822 — Robert Janeczek — 2004-11-11T11:47:36+00:00

URL: https://externals.io/message/13819#13822 · In reply to: #13819

> My problem is the token2color method, I'm not sure which tokens are
> classed as keywords. At the moment I've just guessed as many as I
> could think of, it's a bit ugly - presuming there is an easier way to
> do it.

Appendix N. List of Parser Tokens in php manual

rash

---

## #13827 — Aidan Lister — 2004-11-12T04:31:50+00:00

URL: https://externals.io/message/13819#13827 · In reply to: #13822

Hi Robert,

I think you'll find it's Appendix P. I recently documented all the PHP 5 
additions to that page, my problem is not getting a list of tokens,

http://lxr.php.net/source/php-src/ext/tokenizer/tokenizer.c#167

It's getting a list of tokens for which token.type IS_NULL.

Thanks, though...
Aidan


"Robert Janeczek" <rashid@ds.pg.gda.pl> wrote in message 
news:20041111113902.46337.qmail@pb1.pair.com...
> > […]
>
> Appendix N. List of Parser Tokens in php manual
>
> rash
