[comp.os.vms] FORTRAN Zero Length Strings

zar@IAGO.CALTECH.EDU (Dan Zirin) (02/18/88)

Another reason you can't type
	VARIABLE = ''
is because two single quotes in VAX FORTRAN imply the string "'" (one
single quote. Even if DEC decided to allow zero length strings, the
above step would imply an unclosed string or "missing delimiter" error.
Maybe not, but I'd like to add my list to cheer on zero length strings
for the new standard.

On the side, anyone ever heard of an access vio with mask=25?

The Great Zar

d2b@rayssd.ray.com (Donald A. Borsay) (02/25/88)

In article <880217133134.2100823c@Iago.Caltech.Edu> zar@IAGO.CALTECH.EDU (Dan Zirin) writes:
>Another reason you can't type
>	VARIABLE = ''
>is because two single quotes in VAX FORTRAN imply the string "'" (one
>single quote. Even if DEC decided to allow zero length strings, the
>above step would imply an unclosed string or "missing delimiter" error.

Since you use a literal in your example, I'll limit my discussion to
parsing a <literal>.  Currently:

	<literal> = <single-quote> *and* <string> *and* <single-quote>
	<string> = *1_to_many* <character>
	<character> = <non-single-quote> *or* <single-quote> <single-quote>

When allowing zero length strings:

	<literal> = <single-quote> *and* <string> *and* <single-quote>
	<string> = *0_to_many* <character>
	<character> = <non-single-quote> *or* <single-quote> <single-quote>

The key is, the compiler looks ahead one character.  After seeing only
two single quotes in a <literal>, the next character would have to be :

	(1) another single quote (thus continuing the <literal> token),
	(2) whitespace (ending the <literal> token),
     or (3) the beginning of a valid token (ending the <literal> token).

-- 
Don    |Raytheon Company, Submarine Signal Division, Portsmouth, RI
Borsay |ARPAnet: d2b%rayssd.RAY.COM@a.cs.uiuc.edu
       |UUCPmail: {allegra, decvax!brunix, linus!raybed2}!rayssd!d2b