[comp.lang.pascal] include files in U. of Virginia's 3b2 pascal compiler

duvalj@bionette.cgrb.orst.edu (Joe Duval - Entomology) (11/18/89)

Hi,
  I recently downloaded and got running a copy of the U. of Virginia's Pascal
Compiler for 3b2s (AT&T has been *promising* us a copy of their compiler for 
months now).  Well, I have a snag.

I have a few include files that declare constants on their own.  The UofV system
will not let me do this.  It burps up the error

	Fatal: file "devdecl.p" : line 3
	       syntax error: reserved word "const" not expected
	       const
	       ^

I need to have those include files declare the constants or it will mean a lot 
of code changes.  Any ideas on fixes, or is the UofV system not even going allow
this?

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
duvalj@bionette.cgrb.orst.edu.UUCP      | Life is a tragedy for those that feel
jozo@aes.orst.edu.UUCP                  | and a comedy for those that think!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

scl@sasha.acc.Virginia.EDU (Steve Losen) (11/21/89)

In article <13867@orstcs.CS.ORST.EDU>, duvalj@bionette.cgrb.orst.edu
(Joe Duval - Entomology) writes:
> Hi,
>   I recently downloaded and got running a copy of the U. of Virginia's Pascal
> Compiler for 3b2s (AT&T has been *promising* us a copy of their compiler for 
> months now).  Well, I have a snag.
> 
> I have a few include files that declare constants on their own.  The
UofV system
> will not let me do this.  It burps up the error
> 
> 	Fatal: file "devdecl.p" : line 3
> 	       syntax error: reserved word "const" not expected
> 	       const
> 	       ^
> 
> I need to have those include files declare the constants or it will
mean a lot 
> of code changes.  Any ideas on fixes, or is the UofV system not even
going allow
> this?
> 
>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> duvalj@bionette.cgrb.orst.edu.UUCP      | Life is a tragedy for those
that feel
> jozo@aes.orst.edu.UUCP                  | and a comedy for those that think!
>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

The uvapc compiler is ISO standard (for good or for bad).  There can be
only one constant-declaration-part in each block.  Thus, this is not
legal ISO Pascal:

program junk(output);

const
	x=10;
type
	foo = array [1 .. x] of integer;

const  {sorry, this is illegal.}
	y = 100;

I know it's a pain, but I doubt seriously that we will ever relax this
restriction because of ISO Pascal's scope rules.  Note that this is legal
ISO pascal:

program test(output);
type
	ptr = ^integer;
	integer = record a : char; b : ptr end;

var
	p : ptr;

procedure fillit(p : ptr);
begin
	p^.a := 'x';
	p^.b := p;
end;

begin
	new(p);
	fillit(p);
end.
	
This is pretty easy to compile correctly.  But If we relax the rules, then
I presume that the following rearrangements should have no effect on this
program's semantics.  I can assure you that this would be much harder to
compile correctly.

program test(output);
type
	ptr = ^integer;

procedure fillit(p : ptr);
begin
	p^.a := 'x';
	p^.b := p;
end;

var
	p : ptr;

type
	integer = record a : char; b : ptr end;

begin
	new(p);
	fillit(p);
end.

If you think that this relaxation of the rules allows too much freedom
then where do you draw the line?  Someone will always want more flexibility.

Steve Losen     scl@virginia.edu
University of Virginia Academic Computing Center