On 11/17/07, David Gerard <dgerard@gmail.com> wrote:
On 17/11/2007, Steve Bennett <stevagewp@gmail.com> wrote:

> Here's a bit of ANTLR grammar I wrote to handle basic article structure:


I see from [[:en:ANTLR]] that ANTLR compiles to C++, Java, Python and
C# - not PHP. How feasible will it be to get PHP from this?

Yeah, I addressed that in my second email. There are four roads I can think of:

1) Help implement the PHP target.
2) Compile to one of the other targets, then translate (possibly using an automated tool)
3) Translate the original grammar to Lex or whatever.
4) Compile to one of the other targets (eg, C) then link to that from the PHP code. Apparently that makes it harder for 3rd parties to run, but I can't really speak to why.

Option 3 is not so bad. We need a formal grammar. A formal grammar written in ANTLR is an incredibly useful thing, and if it's slightly inconvenient for our immediate parser-writing purposes, so be it. ANTLR is so expressive that whatever *other* mechanism we could be writing it in (eg, EBNF with English descriptions for semantically disambiguating ambiguous syntax), ANTLR syntax would *still* be a better way of expressing it, even if we don't use a parser directly generated by ANTLR.

Steve