"Tony" <tony@my.net> wrote in message news:08-11-004@comp.compilers...> What is the best "main" form for representation of a software program> (or lib etc)? Human-readable text? The Abstract Syntax Tree perhaps?> Something in-between?

All with all questions regarding representation, there's only a best
if you define the set of questions you want to answer easily. Since
there's lots of different questions to ask, no one representation
works best.

Having said that, the compiler community has pretty much learned that
mapping text to trees to control flow to data flow enables a lot of
standard questions to get answered in ways in which you can afford the
engineering and still get results. But I think the lesson is, be
prepared to change representations if you want to answer a question.

> The reason I asked, in the subject of this post, if ASTs could be> standardized, is because I am kinda thinking that the AST may be the> "center stage" of code representation (?). ...> Tony> [People have been looking for a common intermediate representation for> over 50 years, and it's a famous swamp from which nobody returns. Google> UNCOL for some of the older failures. The basic problem is that we have> no good way to describe the semantics of real computer languages, and the> accumulation of little differences around the edges kill you. -John]

As the moderator said...

The latest incarnation of this is the OMG's attempt to standardize
ASTs in the so called "Abstract Syntax Tree Metamodel" (ASTM). [You
may note that everything OMG does is a "metamodel"].

A flavor of what this is like (now a bit dated) can be found at:
www.omg.org/news/meetings/workshops/ADM_2005_Proceedings_FINAL/T-3_Newcomb.pdf
It has a "general abstract syntax tree model" which looks to me like
they threw everything including the kitchen sink as it is supposed to cover
a broad range of languages; this is usual place the UNCOL stuff ends up.
And of course there aren't any formal semantics [that I know of] defined
for GASTM tree nodes. [That's not their fault; we don't know how
to do this well, frankly, but it does suggest the flaw in attempting
to standardize stuff before it is really well understood]. ASTM
also suggests that there may be Specific Abstract Syntax Tree SASTM models
for specific langauges, but I can't tell if they intend to standardize
these on specific langauges (or even specific dialects, how many versions
of COBOL are there?), or simply accept whatever some vendor proposes
his parser produces.

I'm waiting to see how this turns out, but I'm not very optimistic.

Having said, this, we build a system that uses ASTs as a key
representation. Each AST is derived almost directly from the
context-free grammar defining the language the AST represents. Our
solution looks sort of like the SASTM part of tthe ASTM proposal,
except that we aren't insisting this is an exchange standard.
--
Ira Baxter, CTO
www.semanticdesigns.com