[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnubol: GNU Ada



FYI

I had a look at GNU Ada (GNATS) today. Some interesting things...

1. The parser and lexer are hand coded. The stated reason is that
it generates faster code and better error messages, which is
probably true. So, Bob is not alone in his thinking. Also FORTRAN
and I think PASCAL do manual parsing. C and C++ and most of the
others use flex/bison with hacks.

2. They support decimal arithmetic. This is all done in the front
end eg convert decimal to binary looks a bit like this:

COMPUTE BINVAL = 0
PERFORM VARYING I from 1 by 1 until i > size
   COMPUTE BINVAL = BINVAL * 10 + CHAR (i)
END-PERFORM

The arithmetic is all done in binary, with conversions to and
from decimal. People have suggested defining decimal types in the
GCC back end and putting the coding there, which would make
faster code, but increase the porting effort. Phase II issue.

3. The compiler is very sophisticated. For example it supports
inlining of subroutines. This would be very nice to have.

One neat thing it does is it is able to use indenting (if the
programmer allows this) to do error recovery. It can also warn
about bad indenting. It also has full wide character support,
even for compiler source - so identifiers can even be in chinese
characters!

4. Over 90% of the code is in Ada. This means among other things
that other projects that don't use Ada can't reuse their code eg
their decimal arithmetic code. It also means you need an Ada
compiler to compile it. There is no bootstrapping. They did get a
lot of help from the Ada community contributing code as a result
of writing in Ada though.

5. The compiler is absolutely huge - four times as large
(counting tokens) or seven times as large (counting lines) as the
other GCC compilers. 500,000 lines of code. I am not sure why
this is, whether Ada is verbose or because it seems to lack
macros, or whether the manual parse/lex are to blame. The
parser/lexer are huge compared to C/C++. The language is large
but not proportionately so. The language does not seem verbose to
me, other than not seeing any macros anywhere, but it is
basically just another 3GL to me (the Ada people definitely do
not share that view). 

6. They employ a minimalist approach to using GCC back end ie
they have a single module that interfaces to GCC, and ethey have
their own symbol table and parse tree. This creates some extra
code, but makes life a lot simpler. They did add things to the
back end like exceptions, abnd they have patches to the GDB
debugger to support decimal, it would appear.

Fortran also has a minimalist approach to the GCC integration,
for reasons they explain at length in their documentation.
Basically two reasons - lack of support for Fortran constructs
and lack fo support for 'forward references' other than those
required for C. 

C++ on the other hand has a maximalist approach, so they enhanced
the GCC tree structure for C++.

---

Generally someone has used every approach you may want to
describe.

Tim Josling



--
This message was sent through the gnu-cobol mailing list.  To remove yourself
from this mailing list, send a message to majordomo@lusars.net with the
words "unsubscribe gnu-cobol" in the message body.  For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@lusars.net.