[antlr-interest] ASTFactory initialization inconsistencies in Parser & TreeParser

Ric Klaren klaren at cs.utwente.nl
Thu Nov 14 07:36:22 PST 2002


Hi,

On Thu, Nov 14, 2002 at 03:15:16PM -0000, micheal_jor wrote:
> 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.

In C++ mode with the rework of the factories I opted to leave out all
initialization, this because it highly depends on the style of the
programmer what is logical.

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.

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 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.

Cheers,

Ric
-- 
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- klaren at cs.utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  Chaos is found in greatest abundance wherever order is being sought.
  --- Terry Pratchet


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list