comp.lang.ada
 help / color / mirror / Atom feed
* How is an ADA compiler done?
@ 1996-10-26  0:00 schizophonic
  1996-10-27  0:00 ` Robert Dewar
  0 siblings, 1 reply; 32+ messages in thread
From: schizophonic @ 1996-10-26  0:00 UTC (permalink / raw)



I am following a course about languages and compilers; I would like to
have an idea about how a real-life language and compiler is done. I
will post you some questions, and I hope that someone who works in the
project of a commercial ADA compiler will answer me.

1- is ADA an LR(1), an LALR(1) language, or neither?
2- how is a commercial ADA compiler structured?
3- what kind of tools are used to support the developing of the
compiler?
4- are there some features in the language that deserve particular
attention, or create particular trouble?
5- are attribute grammars the formalism used for the semantical
analisis? if not, what kind of formalism is used, and why?

Thank you!

z





^ permalink raw reply	[flat|nested] 32+ messages in thread
* Calling Ada from C
@ 2007-02-22 15:46 hannibal.holm
  2007-02-22 16:17 ` Ludovic Brenta
                   ` (3 more replies)
  0 siblings, 4 replies; 32+ messages in thread
From: hannibal.holm @ 2007-02-22 15:46 UTC (permalink / raw)


I have a slight problem trying to call an Ada function from a C
function. I need to pass in an unconstrained array to the Ada
function. The problem is how I specify the size.

This is probably very simple, but I am more or less just getting
started with Ada, comming from a C-background.

My code yealds warnings like this (when compiled with GNAT):

foo.ads:50:23: warning: type of argument "Insert_C.Packet" is
unconstrained array
foo.ads:50:23: warning: foreign caller must pass bounds explicitly

I have been searching a lot in order to figure out what to do about
this, but all the FFI documentation is for calling C-functions from
Ada, and some very simple examples of how to call ada functions that
take primitive arguments (ints, and similar items).

Anyone who know how to pass in the bounds explicitly?




^ permalink raw reply	[flat|nested] 32+ messages in thread
* Calling Ada from C
@ 2000-08-25  0:00 Maxwelton
  0 siblings, 0 replies; 32+ messages in thread
From: Maxwelton @ 2000-08-25  0:00 UTC (permalink / raw)


I am missing something in a program I am working on. I am using a C
function to call a function in Ada.  I have the function defined in
a ".h" file as an "extern". It takes a string as a parameter. In Ada I
have a function with the same name defined along with the export pragma
in the .ads file. The C function name is the 3rd parameter. If I were
calling "C" from Ada I would use the import pragma. The .adb file has
the function containing
       procedure To_Ada (Item     : in char_array;
                         Target   : out String;
                         Count    : out Natural;
                         Trim_Nul : in Boolean := True);

I am using the Interfaces.C package in my ada files. My files compile
but the C compilation generates an error that states "undefined
function". What am I not doing?

--
Maxwelton


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 32+ messages in thread
* Calling Ada from C
@ 1995-03-22 13:26 Roger L Costello
  1995-03-22 13:58 ` David Paton
  1995-03-23 17:22 ` Theodore Dennison
  0 siblings, 2 replies; 32+ messages in thread
From: Roger L Costello @ 1995-03-22 13:26 UTC (permalink / raw)


Hi Folks,
    I am trying (unsuccessfully) to call an Ada program from a C program.
I am using the SUN (VADS) Ada, and SUN C.  I am running on a SUN SPARC 10.

Here's my simple C program:

extern hello()'

main ()
{
   hello();
}

My intent is for this C program to call the following hello world Ada
program:

with text_io;

package hello_pkg is

   procedure hello;

pragma EXTERNAL (C, hello);
pragma EXTERNAL_NAME (hello, "hello");

end hello_pkg;

package body hello_pkg is


procedure hello is
i : integer := 0;
begin

    text_io.put_line ("Hello World");

end hello;

end hello_pkg;

I compiled the Ada program.  It generated hello02 and hello03 in the
.objects directory.

When I tried compiling/linking the C program:

cc test.c .objects/hello03

I got the following errors:

Undefined                       first referenced
 symbol                             in file
STACK_LIMIT                         ./.objects/hello03
_A_put_line.123S12.text_io          ./.objects/hello03
ld: fatal: Symbol referencing errors. No output written to a.out

I really haven't a clue what to do.  The SUN documenation hasn't
been of much help.  Can you assist?  Thanks in advance.  /Roger ~

Please respond to: costello@mitre.org




^ permalink raw reply	[flat|nested] 32+ messages in thread
* calling Ada from C
@ 1991-02-23 16:01 David B Lightstone
  0 siblings, 0 replies; 32+ messages in thread
From: David B Lightstone @ 1991-02-23 16:01 UTC (permalink / raw)


There is a possible backdoor strategy which may be used. I previously 
discussed this with Telesoft tech support cerca their version 1.3 and
version 1.5 (Motorola 68000 target, Vax host). 

The problem arose when I needed an interrupt handler, but needed
a response time on the order of 10 - 20 micro seconds. 

The strategy was never implemented, so I can not say if it will be 
successful. It was straight forward. When the assembler interrupt was
ready to complete  spin off another interrupt handler by changing
machine priority, restoring the registers, enabling interrupts and 
branching to a standard Ada Interrupt.

What prevents the C program from calling a software interrupt which
will be fielded by Ada? There will be logistical problem relatable to
exchanging data, so conventions will have to be established.

I don't consider this a clean solution.

When I discussed this approach with Telesoft is was not rejected out
of hand. Their implementation has changed substancially since then, so
there should be a much better solution somewhere.

^ permalink raw reply	[flat|nested] 32+ messages in thread
* calling ada from c
@ 1988-10-16  0:23 Maureen Cragg
  1988-10-17 17:21 ` Maureen Cragg
  0 siblings, 1 reply; 32+ messages in thread
From: Maureen Cragg @ 1988-10-16  0:23 UTC (permalink / raw)


i have successfully called c functions from ada (the pragma import works fine),
but i'm having more difficulty the other way...

i'm trying to pass a string from c to ada:

extern void adaprint_s(char *str);
char str[81];
main(){
   puts("enter a string:");
   gets(str);
   adaprint_s(str);
}

package adaprint is

type string_ptr is access string(1..81);

procedure adaprint_s(
                     str : IN string_ptr );
pragma export_procedure(internal=>adaprint_s,external=>adaprint_s,
                        parameter_types=>(string_ptr));
end;

with text_io;
use text_io;
package body adaprint is

procedure adaprint_s(
                     str : IN string_ptr )
is
begin
   put("the string is:");
   put_line(str.all);
end;
end;

now it looks like i'm passing the address of a string to ada, which is expect-
ing a string pointer, but somehow my adaprint.str is set to the first 4 char-
acters of the string, in reverse order! (i've inspected the values with debug).

if i pass the address of the string pointer ( adaprint_s(&str); ) everything
works fine, but i'm at a loss to understand this behavior...

if anyone out there can explain this to me, i'll sleep better tonight;-)

and can anyone tell me how to pass a simple integer? i'm having less luck with
that...

adTHANXvance,
the air drummer

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2007-02-28  2:54 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-26  0:00 How is an ADA compiler done? schizophonic
1996-10-27  0:00 ` Robert Dewar
1996-10-29  0:00   ` schizophonic
1996-10-29  0:00     ` Robert Dewar
1996-11-08  0:00       ` calling ADA from C EDSTAM Mikael
1996-11-14  0:00         ` Robert Dewar
1996-10-30  0:00     ` How is an ADA compiler done? Larry Kilgallen
  -- strict thread matches above, loose matches on Subject: below --
2007-02-22 15:46 Calling Ada from C hannibal.holm
2007-02-22 16:17 ` Ludovic Brenta
2007-02-22 17:28 ` Adam Beneschan
2007-02-22 20:40 ` Aurele
2007-02-23 13:53 ` Stephen Leake
2007-02-27 12:49   ` hannibal.holm
2007-02-27 18:03     ` Adam Beneschan
2007-02-28  2:54     ` Jeffrey R. Carter
2000-08-25  0:00 Maxwelton
1995-03-22 13:26 Roger L Costello
1995-03-22 13:58 ` David Paton
1995-03-23 17:22 ` Theodore Dennison
1995-03-24 17:14   ` Larry Kilgallen, LJK Software
1995-03-26 11:53     ` Robert Dewar
1995-03-27 14:47       ` Theodore Dennison
1995-03-28  0:00         ` Robert Dewar
1995-03-28  0:00         ` Cyrille Comar
1995-03-29  2:47         ` Larry Kilgallen, LJK Software
1995-03-29  0:00           ` Theodore Dennison
1995-04-04  0:00             ` Robert Dewar
1995-03-27 19:48     ` Robert I. Eachus
1995-03-29  0:00       ` Larry Kilgallen, LJK Software
1991-02-23 16:01 calling " David B Lightstone
1988-10-16  0:23 calling ada from c Maureen Cragg
1988-10-17 17:21 ` Maureen Cragg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox