[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-core-dev] Prototype AST2 available in cdt_ast2
|
On Tue, 28 Sep 2004 08:44:32 -0400, Douglas Schaefer <dschaefe@xxxxxxxxxx>
wrote:
cdt-core-dev-admin@xxxxxxxxxxx wrote on 09/28/2004 04:55:02 AM:
[snip]
I read through you paper and the basic design seems quite good, but I?m
not clear on some distinctions between difference kind of nodes, e.g.:
What is the difference between a variable and an identifier? And what is
the difference between a reference and an identifier?
An identifier is simply a name in the program text. A declaration
introduces a name into scope and associates it with a variable, function,
or type. I am starting to refer to variables, functions, and types as
'definitions'. A reference is the use by name of a definition somewhere
in the program, e.g., the use of a variable in an expression, the use of
a
type in a declaration.
Ok, I see. IMO, "definition" is a better name for those three. It is also
a concept that can be for other things that are not functions, variables,
or types (such as Bison rules or Ada tasks).
[snip]
I've considered this. My objective with the AST is to be able to
implement core features in as language independent of a manner as
possible. For
example for some new language that we handle, once you build a parser to
create the AST, you would get some minimal functionality such as content
assist for free. To do that practically, I am limiting the support for
C-like languages (not having studied Algol myself I suppose we are
Algol-like as well).
With Algol-like I mean essentially all structured languages. I belive that
is a sound limitation, since most languages in practical use today are
structured (with the exception of macro languages, which are actually
quite common).
The plan is to extends the AST for new concepts but relate them back to
the language independent concepts. For example, Ada tasks could be
represented as special functions.
Yes, my thoughts were along the same lines. After all, we are only
concerned with syntax since we are not going to generate code for the
constructions, only keep them under control.
Since we're not perfectionists, we will make exceptions for things we
needto represent in the AST to fully capture the contents of the source
code.C macros would fall into this category since we'll need that info
to properly
implement refactoring.
As soon as the usage of macros in the AST is clear, I belive that it
simple to construct a language independent abstraction of macro-like
constructions.
Can we do bison and flex? That sounds pretty difficult but theorectically
possible. The most difficult part will be constructing a useful AST out
of it. Feel free to experiment and let us know how if this is actually
possible.
I can't see any big problems with supporting Bison and Flex, esp. if we
already have C/C++ (this is needed since the actions are usually written
in C or C++). There are a few parsing issues, such as the fact that Flex
is sensitive to line breaks and columns (pieces of text can mean different
things depending on what column they are in) and that the C/C++ parser
need to have hooks to handle special cases ($n references in semantic
actions). Apart from that, I belive that both are much easier to parse
than C and esp. C++.
I'll take a stab at it and see what it gives... (As soon as I get the code
out of the repository.)
Best wishes,
Mats Kindahl
--
IAR Systems AB
Box 23051 / Islandsgatan 2 / SE-750 23 Uppsala
Sweden
Tel: +46 18 16 78 79
Fax: +46 18 16 78 38