Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why won't this package compile?

106 views
Skip to first unread message

Liddle Feesh

unread,
Dec 26, 2001, 8:33:44 AM12/26/01
to
Can anyone tell me why the queue package below won't compile?

I'm running ObjectADA Version 7.2 Special Edition, since GNAT won't run on
my machine.

The compiler keeps throwing up "Error: Line 9, col 39 Parse error: expected
COLON, got IN, Inserting COLON.

The line in question is: " procedure Remove(N: out Integer; Q: in out
Queue); "


Any ideas? I'm stumped if this is actually a syntactical problem.


--
Liddle Feesh
' O 0 o <"//>< ' o'^
(Remove UNDERPANTS to reply)


------

package queue_package is

TYPE queue is LIMITED PRIVATE;
empty_queue : EXCEPTION;

procedure initialise (q: in out queue);
function is_empty_queue (q: queue) return boolean;
procedure add(n: in integer; q: in out queue);
procedure remove(n: out integer; q: in out queue);
--remove raises the exception "empty-queue" if applied to an empty queue

PRIVATE
TYPE node;
TYPE link is ACCESS node; --ACCESS is a pointer type
TYPE node is RECORD
value : integer;
next : link :=NULL;
END RECORD;

TYPE queue is RECORD
head: link;
tail: link;
END RECORD;

END queue_package;

Liddle Feesh

unread,
Dec 26, 2001, 9:15:43 AM12/26/01
to
In addition, I've created a package body for the program as below...

Still getting errors apon errors - a parse error, plus errors for not
completing the specification -> which to my best knowledge and ability is
complete.

Does >anyone< have any pointers?

Kind Regards, and a Merry Christmas and a Happy New Year to all @
comp.lang.ada


--
Liddle Feesh
' O 0 o <"//>< ' o'^
(Remove UNDERPANTS to reply)

package body Queue_Package is

procedure add is
begin
-- put_Line("Queue_Package Add node procedure");
end add;

procedure remove is
begin
-- Put_Line("Queue_Package Remove node procedure");
end Remove;

procedure initalise is
begin

end initalise;

procedure is_empty_Queue
begin

end is_empty_Queue;

end Queue_Package;


Larry Hazel

unread,
Dec 26, 2001, 9:49:58 AM12/26/01
to

I compiled it with GNAT 3.13P with no errors.

Larry

Michal Nowak

unread,
Dec 26, 2001, 9:59:35 AM12/26/01
to comp.lang.ada usegroup->mailing list gateway
On 01-12-26 at 14:15 Liddle Feesh wrote:

>In addition, I've created a package body for the program as below...
>
>Still getting errors apon errors - a parse error, plus errors for not
>completing the specification -> which to my best knowledge and ability is
>complete.
>
>Does >anyone< have any pointers?

Just another one newbie will try to give you some access :-))

It may be a little hard, because you did not gave the errors,
that you got, but what I can say from code inspection:

>package body Queue_Package is
>
> procedure add is
> begin
> -- put_Line("Queue_Package Add node procedure");

If you want to use Put_Line you should with Ada.Text_IO
and use Ada.Text_IO;

> end add;
>
> procedure remove is
> begin
> -- Put_Line("Queue_Package Remove node procedure");
> end Remove;
>
> procedure initalise is
> begin

There cannot be nothing here.
If you want the precedure do nothing,
write just:
null;


> end initalise;
>
> procedure is_empty_Queue
> begin
>
> end is_empty_Queue;
>
>end Queue_Package;

And what is the specification?

BTW, in some previous mail you wrote, that you are not using
GNAT, because it is not working on your system.
What version of GNAT and from did you got it from?

Mike
-----------------------------------------
____|
\%/ |~~\
O |
o>> Mike Nowak |
T |
/ > vin...@inetia.pl |
http://www.geocities.com/vinnie14pl _|__

Jeff Creem

unread,
Dec 26, 2001, 10:08:27 AM12/26/01
to
Apart from your other parse error, the reason that you are getting errors
about not completing
specification is that the body procedures do not have the same parameters as
those in the spec.

"Liddle Feesh" <no_see_rep...@spam.com> wrote in message
news:CYkW7.31524$4f7.4...@news11-gui.server.ntli.net...

martin.m.dowie

unread,
Dec 26, 2001, 2:33:42 PM12/26/01
to
"Liddle Feesh" <no_see_rep...@spam.com> wrote in message
news:dlkW7.31460$4f7.4...@news11-gui.server.ntli.net...

> Can anyone tell me why the queue package below won't compile?
>
> I'm running ObjectADA Version 7.2 Special Edition, since GNAT won't run on
> my machine.
>
> The compiler keeps throwing up "Error: Line 9, col 39 Parse error:
expected
> COLON, got IN, Inserting COLON.

I cut and pasted your code into ObjectAda SE 7.2.1 and it compiled ok


Liddle Feesh

unread,
Dec 26, 2001, 5:20:17 PM12/26/01
to
"Michal Nowak" wrote:

> If you want to use Put_Line you should with Ada.Text_IO
> and use Ada.Text_IO;

Noted. I shall add these at the beginning of the package spec and package
body.

> > end add;
> >
> > procedure remove is
> > begin
> > -- Put_Line("Queue_Package Remove node procedure");
> > end Remove;
> >
> > procedure initalise is
> > begin
>
> There cannot be nothing here.
> If you want the precedure do nothing,
> write just:
> null;

Also noted - thanks.

> > end initalise;
> >
> > procedure is_empty_Queue
> > begin
> >
> > end is_empty_Queue;
> >
> >end Queue_Package;
>
> And what is the specification?

The specification is written in the main post.

> BTW, in some previous mail you wrote, that you are not using
> GNAT, because it is not working on your system.
> What version of GNAT and from did you got it from?

The GNAT version I downloaded was from:
ftp://cs.nyu.edu/pub/gnat/3.13p/winnt/

It appears to be version 3.31p.

I am running Windows 2000 Professional (SP2).

Liddle Feesh

unread,
Dec 26, 2001, 5:21:23 PM12/26/01
to
"Larry Hazel" wrote:

> I compiled it with GNAT 3.13P with no errors.

Really? Just as provided?

Is that with the SPEC and body, or just the SPEC?

Liddle Feesh

unread,
Dec 26, 2001, 6:10:52 PM12/26/01
to
Okay, the package SPEC compiles, and I have saved this as queue_package.ads

However - the package body doesn't... I've made the changes as you wonderful
people have suggested, but am still erroring...

One problem was that I was making package body definitions(?) for a
function. The following procedure should not have been included in the
package body. It was declared as (and should stay as - a function).

procedure is_empty_Queue (q: queue)
begin
null; -- Do nothing
end is_empty_Queue;

Removing this removed about 10 errors from the program.

The remaining two errors (as reported by ObjectADA 7.2 Compiler) are:

Error: Line 6 col 13 ... Completion required for specification 'initialise',
Continuing
Error: Line 7 col 12 ... Completion required for specification
'is_empty_queue', Continuing

is_empty_queue is a function (I hope to iterate through the list, and return
boolean true/false if empty), and 'initialise' seems to be properly complete
to me.

What on earth is the problem here? It's passed me completely. I have
attached the queue_package.ads file, which contains both Spec and Body.

TIA

--
Liddle Feesh
' O 0 o <"//>< ' o'^
(Remove UNDERPANTS to reply)

-- START OF FILE
---------------------------------------------------------------------


-- Queue_Package Spec
---------------------------------------------------------------------
package queue_package is

TYPE queue is LIMITED PRIVATE;

empty_queue : EXCEPTION; -- !! FIRST ERROR REPORTED HERE
-- !! SECOND ERROR REPORTED HERE


procedure initialise (q: in out queue);
function is_empty_queue (q: queue) return boolean;
procedure add(n: in integer; q: in out queue);
procedure remove(n: out integer; q: in out queue);
--remove raises the exception "empty-queue" if applied to an empty queue

PRIVATE
TYPE node;
TYPE link is ACCESS node; --ACCESS is a pointer type
TYPE node is RECORD
value : integer;
next : link :=NULL;
END RECORD;

TYPE queue is RECORD
head : link;
tail : link;
END RECORD;

END queue_package;

-- Queue_Package Body
---------------------------------------------------------------------
package body Queue_Package is

procedure add (n: in integer; q: in out queue) is
begin
null; -- Do nothing
end add;

procedure remove (n: out integer; q: in out queue) is
begin
null; -- Do nothing
end Remove;

procedure initalise (q: in out queue) is
begin
null; -- Do nothing
end initalise;

end Queue_Package;

-- END OF FILE
---------------------------------------------------------------------

Larry Hazel

unread,
Dec 26, 2001, 8:19:27 PM12/26/01
to

Just the spec. The body had lots of errors because it didn't match the spec and
no statement in subprograms.

Larry

Larry Hazel

unread,
Dec 26, 2001, 11:21:56 PM12/26/01
to

You still need a stub body for the function is_empty_queue in the package body.
Just return either true or false. initialise is spelled initalise in the body.
Fix these 2 things and the package body compiles.

Larry

Michael Bode

unread,
Dec 27, 2001, 3:21:46 AM12/27/01
to
"Liddle Feesh" <no_see_rep...@spam.com> writes:

> The GNAT version I downloaded was from:
> ftp://cs.nyu.edu/pub/gnat/3.13p/winnt/
>
> It appears to be version 3.31p.
>
> I am running Windows 2000 Professional (SP2).

Not sure if I got it from that URL but at work gnat 3.13p runs quite
nicely on my W2k with SP2 machine. I got it a a selfextracting .EXE
which installed itself without problems.

Michal Nowak

unread,
Dec 27, 2001, 5:02:28 AM12/27/01
to comp.lang.ada usegroup->mailing list gateway
>> BTW, in some previous mail you wrote, that you are not using
>> GNAT, because it is not working on your system.
>> What version of GNAT and from did you got it from?
>
>The GNAT version I downloaded was from:
>ftp://cs.nyu.edu/pub/gnat/3.13p/winnt/
>
>It appears to be version 3.31p.
>
>I am running Windows 2000 Professional (SP2).

It should be named gnat-3.13p-nt.exe and have size
23_500_591 bytes.

Any messages you got? Did it installed successfully?
Maybe you forgot to put GNAT's path into PATH os variable?

Liddle Feesh

unread,
Dec 27, 2001, 11:57:13 AM12/27/01
to
"Larry Hazel" wrote:

> You still need a stub body for the function is_empty_queue in the package
body.
> Just return either true or false. initialise is spelled initalise in the
body.
> Fix these 2 things and the package body compiles.

Thankyou Larry,

I have created the function body and corrected my spelling mistake.

All compiles well.

Thx,

Liddle Feesh

unread,
Dec 27, 2001, 12:03:43 PM12/27/01
to
"Michal Nowak" wrote:

> It should be named gnat-3.13p-nt.exe and have size
> 23_500_591 bytes.

That's what I have.

> Any messages you got? Did it installed successfully?
> Maybe you forgot to put GNAT's path into PATH os variable?

Errorbox with big red cross
Title: GNAT Ada95 Compiler - Welcome: gnat-3.13p-nt.exe - Application Error
The instruction at "0xffff0871" referenced memory at "0xffff0871". The
memory could not be "read".

Click on OK to terminate...
Click on CANCEL to debug...

---
Not all that clear, really.

Michal Nowak

unread,
Dec 28, 2001, 4:15:32 AM12/28/01
to comp.lang.ada usegroup->mailing list gateway
On 01-12-27 at 17:03 Liddle Feesh wrote:

>"Michal Nowak" wrote:
>
>> It should be named gnat-3.13p-nt.exe and have size
>> 23_500_591 bytes.
>
>That's what I have.

[little snip]

>Errorbox with big red cross
>Title: GNAT Ada95 Compiler - Welcome: gnat-3.13p-nt.exe - Application Error
>The instruction at "0xffff0871" referenced memory at "0xffff0871". The
>memory could not be "read".
>
>Click on OK to terminate...
>Click on CANCEL to debug...

I'm afraid I can't help you here. I have only Win98. Maybe you have
access to Win2K or Win98 installed on another computer? If it will
run there - it means there is something with your windows. If not
- that may mean corrupted file. Maybe there is somebody here who had
similiar problems and will help you.

Good luck,
Mike

Alfred Hilscher

unread,
Dec 28, 2001, 11:25:24 AM12/28/01
to

Michal Nowak wrote:
> [little snip]
>
> >Errorbox with big red cross
> >Title: GNAT Ada95 Compiler - Welcome: gnat-3.13p-nt.exe - Application Error
> >The instruction at "0xffff0871" referenced memory at "0xffff0871". The
> >memory could not be "read".
> >
> >Click on OK to terminate...
> >Click on CANCEL to debug...
>
> I'm afraid I can't help you here. I have only Win98. Maybe you have
> access to Win2K or Win98 installed on another computer? If it will
> run there - it means there is something with your windows. If not
> - that may mean corrupted file. Maybe there is somebody here who had
> similiar problems and will help you.
>
> Good luck,
> Mike


I'm not sure. I think I had something similar when I tried to install on
a maschine where I had no admin rights.

Liddle Feesh

unread,
Dec 28, 2001, 12:08:53 PM12/28/01
to
"Alfred Hilscher" wrote:

> I'm not sure. I think I had something similar when I tried to install on
> a maschine where I had no admin rights.

Sorry, I'm a local and global admin of my machine and the domain - it's just
not gonna install. No matter though OA suits me fine.

0 new messages