poetix

this time for sure

Does PHP Have a Grammar?

I had a notion that I might take a closer look at the PHP code powering the excellent WordPress, on which this very site is based.

Then I thought, why not analyse the code automatically and extract a list of function names, show where each function is called, map dependencies between scripts and so on.

So then I thought, I need a parser for PHP. Right, I’ll just go and find the EBNF and then see what I can do in Haskell. I’ve never written a parser for a whole programming language before, but I’ve had a play with Haskell’s parser combinator library Parsec and I bet I can get somewhere fairly quickly with that. It will be an interesting challenge, is what I thought.

So then I went to google, and searched for PHP and EBNF.

And I’m still searching.

This, I suspect, is what they call “getting off on the wrong foot”…