[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.technology.imp] Re: IMP support for multplei ASTs
|
Hi,
The IDE that we are working on supports a proprietary DSL (partly influenced
by languages like Pascal and Ada).
The required semantic analysis needed is in the first stage is type checking
and scope analsysis (the language support inheritance and nested methods
etc), but in a near future we want
to add warnings for unused (unrefernced) variables etc. The analsysis is
needed to make it possible to do the correct color highlighting, symbol
linking etc in the UI, but we can antecipate
that the users wants more direct feedback by the editor to avoid round-trips
to the build system.
So as I understand from your description the scenario is: each
CompilationUnit has its corresponding AST, each AST is then condensed into a
"Symbol table" that is stored using the PDB API
[The AST is after this obsolete and can be released / deleted ? ]. The
semantic analysis is then performed [ in the background] against the PDB
API.
( It has been some years since I took a Compiler Construction Course,
noticed that the Dragon book still is used :-) , but I recall something of
a Concret Syntax Tree (CST) involved in
semantic analysis, but perhaps that is just another terminology)
I just took a quick look, but could not find much documentation or sample
code about PDB, but perhaps I can find this on the home of "Rascal"?
BR
M
"Robert M. Fuhrer" <rfuhrer@xxxxxxxxxxxxxx> skrev i meddelandet
news:h3ibt8$kie$1@xxxxxxxxxxxxxxxxxxxx
> Mattias Felt wrote:
>> Hello,
>>
>> In my IDE compilation unit has its own AST. But each project consists of
>> several
>> compilation units (e.g. files), so to be able to do some kind of semantic
>> analysis several
>> AST must be analysed. I can't see how IMP (LPG?) can help me with this.
>>
>> Any thoughts ideas would be appreciated.
>
> Hi there,
>
> The standard (scalable) way of doing this is to process each AST in turn
> to produce some sort of "digested" data structures that describe the
> salient characteristics of each compilation unit/type/function/etc. This
> representation should be space-efficient enough to be able to fit however
> many compilation units you might find in a user's workspace, or at least
> as many compilation units as you need to process for the particular
> analysis in question. You then run the core of your analysis over this
> digested representation. One needs to take care to save enough information
> in the "digested" form to correlate back to the ASTs/source.
> [Saving source extents for the relevant entities is typically enough.]
>
> The representation might be a dictionary of types, a list of defined or
> referenced variables/functions, 3-address code for function bodies, or
> whatever you need.
>
> To help with this, the IMP's "PDB" (Program DataBase) plugin
> org.eclipse.imp.pdb.values provides persistable representations and
> operators for a variety of types that are useful for program analysis,
> e.g. sets, relations, maps, and so on.
>
> The PDB is intended to be fairly CPU- and memory-efficient, and can be
> used, for example, to persist indices in support of indexed search.
>
> We're actively working on the PDB (particularly with our colleagues at
> CWI).
>
> The other area of active development in this space is the declarative
> language "Rascal", the result of some nice work at CWI, which we intend
> to make available as part of IMP in the not-too-distant future. Rascal
> combines both AST pattern matching and computations over the kinds of
> data structures that the PDB supports. As a result, it can be used for
> both "fact extraction" and analysis per se.
>
> I don't believe Rascal is ready for prime time yet, but it's getting
> there. In the meantime you can write code against the PDB API.
>
> If you tell us more about the kind of analysis you're interested in,
> I might be able to provide more specific guidance.
>
> --
> Cheers,
> -- Bob
>
> --------------------------------
> Robert M. Fuhrer
> Research Staff Member
> Programming Technologies Dept.
> IBM T.J. Watson Research Center
>
> IDE Meta-tooling Platform Project Lead (http://www.eclipse.org/imp)
> X10: Productive High-Performance Parallel Programming (http://x10.sf.net)