[comp.lang.fortran] f77 yacc grammar

hirchert@uxe.cso.uiuc.edu (07/18/88)

Alan Klietz(alan@mn-at1.k.mn.org) writes:
>In article <3662@omepd> pcm@iwarpj.UUCP (Phil C. Miller) writes:
><>In article <769@naucse.UUCP>, jdc@naucse.UUCP writes:
><>
><>I don't know that a full f77 grammar is possible.
><
><   Actually, this is incorrect. 

>How about 8X?  Parse the statement

>        USE PACKAGE
>	INTEGERRECURSIVESUBROUTINERECURSIVESUBROUTINE(RECURSIVESUBROUTINE)

>where "RECURSIVESUBROUTINE" may or may not be a constant defined in PACKAGE.

As best I can determine, the second statement is not a valid statement in
Fortran 8x.  The closest you could come would be to interpret it as
	INTEGER RECURSIVESUBROUTINERECURSIVESUBROUTINE(RECURSIVESUBROUTINE)
i.e., the declaration of RECURSIVESUBROUTINERECURSIVESUBROUTINE as an integer
array of size determined by symbolic constant RECURSIVESUBROUTINE, but this
isn't legal because RECURSIVESUBROUTINERECURSIVESUBROUTINE is longer than 31
characters.  I can't come up with any other interpretation.  Note that
1. The only statement that includes both INTEGER and RECURSIVE as keywords is
   the FUNCTION statement, not the SUBROUTINE statement.
2. Both the FUNCTION statement and the SUBROUTINE statement must be the first
   statement of the scoping unit in which they appear (i.e. they appear at the
   beginning of a file, after an "END" statement, or after a CONTAINS
   statement.)
3. All the contexts in which a symbolic constant (such as RECURSIVESUBROUTINE
   may or may not be) have that constant surrounded by delimiters, so the only
   place that qualifies in this statement is between the parentheses.

>Have fun.

>--
>Alan Klietz
>Minnesota Supercomputer Center (*)

Kurt W. Hirchert     hirchert@ncsa.uiuc.edu
National Center for Supercomputing Applications