On Mon, Aug 08, 2005 at 10:25:26AM +0100, Tim Bunce wrote:
> Anyone done any work on parsing Java interface definitions?
> And, ideally, translating them into roughly equivalent Perl 6?
I wrote something that did this with Parse::RecDescent. Unfortunately,
I don't own the code.
For my purposes I needed to parse several hundred interface files and
build Perl 5 classes (with hierarchy) on the fly from them. The files
in practice only used a subset of the possible Java syntax available in
an interface, but more than a trivial subset. The grammar (together with
interspersed to buildcode) came out at about 120 lines. It was fast
enough for me after the initial Parse::RecDescent startup hit.
The Java language spec contains a few grammars that helped me.
I found I couldn't use autotree because I can't control the base for
the resulting namespace: I have a patch to Parase::RecDescent somewhere
that fixes that, or you could use Class::Rebless which I wrote initially
because of this problem -- though I ended up doing the blesswork inside
the code sections manually as it made much more algorithmic sense.
Hope this helps.
Gaal Yahas <[EMAIL PROTECTED]>