[antlr-interest] Extensions which I have found useful

Terence Parr parrt at cs.usfca.edu
Fri Feb 1 16:35:16 PST 2008


On Feb 1, 2008, at 10:02 AM, Fred wrote:

> A couple of items which I have found useful in the development of an
> IDL parser (with constraints).
>
> ----------
> For StringTemplates, provide a toSubList(List list, String formatName)
> method in AttributeRenderer similar to its toString(Object obj, String
> formatName) method.
> The toSubList() method would provide formatting of attribute lists.
> (I can explain the scenario where this was needed if you care.)
> The method is useful when the order, position, presence of elements in
> a list attribute need to be changed prior to formatting its elements.

can you just have model order before it's sent in?

> This could be generalized to include the 'separator' argument.
> At present the toSubList() method is called from the model prior to
> invoking the template.
> I believe that it would be more appropriate to perform this formatting
> in the view (i.e. template).
>
> -------------
> Modify the *Walker.input to be a stack rather than a single variable.
> Then similar to what is done with scope, allow the position in the AST
> to be changed (input = new CommonTreeNodeStream(subtree))  as the rule
> is entered.
> (In my current implementation the subtree is obtained from a symbol  
> table.)
> Normally, a preparatory pass through the AST to augment the symbol
> table with the relevant information would be performed but that makes
> the association less clear.
> Conceptually, the input stack provides a way to "lazily" augment the
> symbol table.

interesting. i'll think about this when doing an interpreter.

Ter


More information about the antlr-interest mailing list