[antlr-interest] Re: ASTFactory initialization inconsistencies in Parser & TreeParser
micheal_jor
open.zone at virgin.net
Thu Nov 14 11:55:43 PST 2002
Hi Ric,
> > Why do ANTLR Parsers initialize their ASTFactory appropriately
whilst
> > TreeParsers have to operate with an uninitialized factory?.
>
> Which kind of initialization do you mean? You mean the setting of
an AST
> factory in the treewalker or the initialization of that factory?
Both have
> to be done manually.
The initialization of the default factory -- pre-loading it with the
Token-ID-to-ASTNodeType mappings for all the known tokens.
> With the use of a AST superfactory a chain of parser/treeparsers
must have
> one superfactory (or exact copies). Which will be initialized in
several
> steps, in each generated (tree)parser an initializeASTFactory()
method is
> added which adds the AST type data for that parser to the factory.
It is up
> to the user to ensure things happen in the right order.
OK. This sounds more flexible. initiializeASTFactory() can be called
after setASTFactory() is called.
> Since antlr does not impose an order in import/exportvocabs in a
parser
> hierarchy it makes no sense to have a default. Since there is no
sane
> default.
The sensible default might be to register the closure of all
importVocab/exportVocab/in-grammar Token IDs in each generated
lexer/parser/treeparser.
> > The factory fails on create()-ing/dup()-ping valid token ID
(obtained from
> > the Parser by reflection) when treeparser rules are invoked by
reflection.
>
> I guess it is bombing out on a lack of factory? If you're adopting
the same
> super factory strategy used in C++, then I'd check out the C++
examples as
> well.
It's bombing out on account of no Token IDs being registered in the
default factory.
Cheers,
Micheal
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list