[antlr-interest] Extensions which I have found useful

Fred phreed at gmail.com
Mon Feb 4 08:25:14 PST 2008


On Feb 1, 2008 6:35 PM, Terence Parr <parrt at cs.usfca.edu> wrote:
>
> 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?

Not really, the order of the list is dependent on the output language.
The compiler needs to generate methods
that conform to data structures that are *structurally different*.
Without getting into the details, the language specific data structure
are produced by two different compilers (produced by different people).
So, the approach you suggest would require that the model be aware of
the view details.
What I do now is have the model invoke the toSubList() method of the
language specific renderer.
I actually works pretty well.
What I am suggesting is that the 'format' idea be extended to work
with attributes that are lists.

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

> Ter
>

peace
Fred


More information about the antlr-interest mailing list