[antlr-interest] ANTLR backend for ruby?
Ric Klaren
klaren at cs.utwente.nl
Tue Jul 29 05:01:13 PDT 2003
Hi,
On Tue, Jul 29, 2003 at 07:48:26AM -0300, Rodrigo B. de Oliveira wrote:
> Let's say I wanted to write an ANTLR backend for ruby (parser generation
> and associate runtime support), where would I start? I mean, are there any
> docs/examples about it? Is it feasible right now or should I wait for the
> next release?
There's no docs about how to implement new backends. Although if you have a
good understanding of the code ANTLR generates then you can get quite a
long way.
Important files:
antlr/*CodeGenerator.java -> actual codegenerator
antlr/actions/*/action.g -> does the translations of the $setXXX and
#( [..], .. , .. ) in the actions to target
code.
antlr/DefineGrammarSymbols.java -> part of option handling
antlr/*BlockFinishingInfo.java -> don't recall exact function offhand
antlr/*CharFormatter.java -> does various formatting of values to
target language
About all the rest you don't have to touch except for the support library.
I don't know ruby but it's probably pretty doable to write a new backend.
To start with I'd grab the generated code for a few trivial parsers and try
to translate it manually into ruby and then try to adapt the one of the
codegenerators to it. Make sure to also include a grammar including
'guessing mode' eg. one with a syntactic predicate.
Next release might still be a ways off.
HTH,
Ric
--
-----+++++*****************************************************+++++++++-------
---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722 ----
-----+++++*****************************************************+++++++++-------
Time what is time - I wish I knew how to tell You why - It hurts to know -
Aren't we machines - Time what is time - Unlock the door
- And see the truth - Then time is time again
From: 'Time what is Time' by Blind Guardian
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list