Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-12 - 43,50552/fortra.lss
There are no other files named fortra.lss in the archive.
SYN version 1.8D			FORTRAN   		19-Oct-84

    1	%|
    2	 | FORTRAN.BNF
    3	 |
    4	 | Parser for FORVER version 2.6
    5	 |%
    6	
    7	addop	= "+" |	"-"				% adding operators %.
    8	mulop	= "*" |	"/"				% multiplying operators	%.
    9	relop	= "<" |	"<=" | "==" | "=/=" | ">=" | ">" % relational operators	%.
   10	
   11	sign	= "+" |	"-"				% signs	%.
   12	
   13	simple_type	= integer | real | complex | logical.
   14	
   15	constant	= integer_constant
   16			| real_constant
   17			| boolean_constant
   18			| double_constant
   19			| string_constant
   20			| hollerith_constant
   21			| label_constant.
   22	char_string	= string_constant | hollerith_constant.
   23	integer_item	= identifier  |	integer_constant.
   24	id		= identifier  |	array_identifier.
   25	idx		= identifier
   26			| array_identifier
   27			| function_identifier
   28			| intrinsic_identifier.
   29	except		= identifier  |	array_identifier | end.
   30	
   31		% now the productions for the FORTRAN grammar %
   32		%    start symbol:     f10_program	      %
   33	
   34	f10_program	-> [ line ] end_file <verify>.
   35	
   36	line		->			      end_line <xon> @ % null statement	%
   37			 | integer_constant statement end_line <xon> @ % labeled statement %
   38			 |		    statement end_line <xon> @ % unlabeled statement %.
   39	
   40	statement	-> assignment_statement
   41			 | control_statement
   42			 | io_statement
   43			 | file_control_statement
   44			 | format_statement
   45	
   46			 | definition_statement
   47			 | data_statement
   48	
   49			 | namelist_statement
   50			 | device_control_statement.
   51	
   52	definition_statement ->
   53			   PROGRAM' <xoff> identifier'	<xmodule> <xreset>
   54			 | INCLUDE <xx>	char_string	<xinclude>
   55	
   56			 | END <xend>
   57	
   58			 | DIMENSION <xx>     idx' <- identifier <xlocal> index_spec
   59					[ "," idx' <- identifier <xlocal> index_spec ]
   60			 | IMPLICIT   type_id <xx> "(" letter_list ")" <xon> <ximplicit>
   61				[ "," type_id <xx> "(" letter_list ")" <xon> <ximplicit> ]
   62			 | COMMON <xx>	( "/" idx "/" common_spec [ "/"	idx "/"	common_spec ]
   63					|     nil     common_spec )
   64			 | EQUIVALENCE <xx> "("	index_use ")" [	"," "("	index_use ")" ]
   65	
   66			 | EXTERNAL <xx> identifier' <xexternal> [ "," identifier' <xexternal> ]
   67			 | PARAMETER <xx> identifier' "=" (sign|nil) constant' <xparameter>
   68				    [ "," identifier' "=" (sign|nil) constant' <xparameter> ]
   69			 | type_id ( FUNCTION' <xoff> identifier' <xmodule> <xentry>
   70						  ( "("	dummies	")" | nil ) <xedum>
   71				   | nil <xx> <xtyp> idx' <xstyp> index_spec [ "," idx'	<xstyp>	index_spec ]
   72				   )
   73			 | FUNCTION' nil' <xswap> <xoff> identifier' <xmodule> <xentry>
   74					   ( "(" dummies ")" | nil ) <xedum>
   75			 | SUBROUTINE'		  <xoff> identifier' <xmodule> <xentry>
   76					   ( "(" dummies ")" | nil ) <xedum>
   77			 | ENTRY'		  <xoff> identifier'	       <xentry>
   78					   ( "(" dummies ")" | nil ) <xedum>
   79			 | BLOCK' DATA		<xoff> ( identifier' | nil' ) <xmodule>	<xreset>.
   80	
   81	
   82	
   83	data_statement	-> DATA	<xx>   data_list "/" data_constant_list	"/"
   84				 [ "," data_list "/" data_constant_list	"/" ].
   85	
   86	assignment_statement ->
   87			   local_indexed_identifier "="	expression <xassign>
   88			 | ASSIGN <xx> <xon> integer_constant' TO <xoff> id' <xswap> <xassign>.
   89	
   90	control_statement ->
   91			   (GO TO | GOTO) <xx>
   92				( integer_constant
   93				| "(" integer_list ")" ("," | nil) expression <xreset>
   94				| identifier "," "(" integer_list ")" )
   95			 | IF <xx> "(" expression ")" <xon> <xreset>
   96				( integer_constant "," integer_constant
   97						 ( "," integer_constant
   98						 |	nil )
   99				| statement )
  100			 | DO	<xx> integer_constant
  101							  identifier
  102						 "=" expression
  103						 "," expression
  104					       ( "," expression	| nil )	<xreset>
  105			 | CONTINUE <xx>
  106			 | STOP	<xx>	( integer_constant
  107					| char_string
  108					| nil )
  109			 | PAUSE <xx>	( integer_constant
  110					| char_string
  111					| nil )
  112			 | RETURN <xx>	( integer_constant
  113					| nil )
  114			 | CALL	<xx> identifier' [ identifier ]
  115				( "(" #	( argument_list	| nil )	")"
  116				| nil #	) <xsref>.
  117	
  118	io_statement	-> READ	  <xx>	 "(" io_unit conditions	")" io_list
  119			 | WRITE  <xx>	 "(" io_unit conditions	")" io_list
  120			 | PRINT  <xx>	     format_spec	    io_list
  121			 | PUNCH  <xx>	     format_spec	    io_list
  122			 | TYPE	  <xx>	     format_spec	    io_list
  123			 | ACCEPT <xx>	     format_spec	    io_list
  124			 | REREAD <xx>	     format_spec	    io_list
  125			 | ENCODE <xx>	 "(" encode_decode_spec	")" io_list
  126			 | DECODE <xx>	 "(" encode_decode_spec	")" io_list
  127			 | FIND	  <xx>	 "(" io_unit ")".
  128	
  129	namelist_statement -> NAMELIST <xx>   "/" identifier "/" index_use
  130					    [ "/" identifier "/" index_use ].
  131	
  132	file_control_statement ->
  133			   OPEN	  <xx>	 "(" [ -end_line ]
  134			 | CLOSE  <xx>	 "(" [ -end_line ].
  135	
  136	format_statement -> FORMAT <xx>	  "(" [	-end_line ].
  137	
  138	device_control_statement ->
  139			   REWIND <xx>		integer_item
  140			 | UNLOAD <xx>		integer_item
  141			 | BACKSPACE <xx>	integer_item
  142			 | ENDf	FILE <xx>	integer_item % endf <> end! beware %
  143			 | SKIP	( RECORD <xx>	integer_item
  144				| FILE <xx>	integer_item )
  145			 | BACKFILE <xx>	integer_item.
  146	
  147	%	productions used by statements eg. expression	    %
  148	
  149	index_spec	-> "(" <- array_identifier one_index [ "," one_index ] ")" <xdrop>
  150			 | nil <xdrop>.
  151	one_index	-> integer_item	((":" |	"/") integer_item | nil).
  152	
  153	common_spec	->    idx' <xlocal> index_spec
  154			[ "," idx' <xlocal> index_spec ].
  155	
  156	index_use	->    idx' <xlocal> <xdrop> ( "(" integer_list ")" | nil )
  157			[ "," idx' <xlocal> <xdrop> ( "(" integer_list ")" | nil ) ].
  158	
  159		%:begin	2.3 -	"local_indexed_identifier": behaves like	%
  160		%	2.3	"indexed_identifier", but account for statement-%
  161		%:end	2.3	-function definition syntax...			%
  162	
  163	local_indexed_identifier ->
  164			   identifier' <xx> <xlocal>
  165				      (	"(" <- function_identifier #
  166					   ( argument_list | nil) ")" <xldef>
  167				      |	nil )
  168			 | array_identifier'
  169				      (	"(" expression <xdrop> [ "," expression	<xdrop>	] ")"
  170				      |	nil	% for param. passing % )
  171			 | function_identifier'
  172				      (	"(" # argument_list ")"
  173				      |	nil # )	<xfref>.
  174	
  175	indexed_identifier ->
  176			   identifier' <xx> <xlocal>
  177				      (	"(" <- function_identifier #
  178					   ( argument_list | nil ) ")" <xfref>
  179				      |	nil )
  180			 | array_identifier'
  181				      (	"(" expression <xdrop> [ "," expression	<xdrop>	] ")"
  182				      |	nil	% for param. passing % )
  183			 | function_identifier'
  184				      (	"(" # argument_list ")"
  185				      |	nil # )	<xfref>.
  186	
  187	letter_list	-> idx'	("-" idx' | nil') [ ","	idx' ("-" idx' | nil') ].
  188	
  189	integer_list	-> integer_item	[ "," integer_item ].
  190	
  191	dummies		-> dummy   [ "," dummy ].
  192	dummy		-> (idx' <xlocal> | "*"') <xdummy>.
  193	
  194	io_list		-> ( "," | nil ) (data_list | nil).
  195	
  196	argument_list	-> argument [ "," argument ].
  197	argument	-> expression.
  198	
  199	io_unit		-> integer_item	( "#" expression <xreset> | nil	).
  200	format_spec	-> integer_item
  201			 | "*".
  202	conditions	-> [ "," ( except ( "="	integer_constant	% ERR=... and END=... %
  203					  | nil		% variable format %)
  204				 | integer_constant		% format label %
  205				 | "*"			% free-format %)
  206			   ].
  207	encode_decode_spec -> integer_item "," (integer_item | array_identifier) "," indexed_identifier	<xdrop>.
  208	
  209	expression	-> expression_8	[ f10_logical_ops' expression_8	<xxtyp>	].
  210	expression_8	-> expression_7	[ or'  expression_7 <xxtyp> ].
  211	expression_7	-> expression_6	[ and' expression_6 <xxtyp> ].
  212	expression_6	-> not expression_5
  213			 |     expression_5.
  214	expression_5	-> expression_4	[ relop	 expression_4 <xxlog> ].
  215	expression_4	-> expression_3	[ addop' expression_3 <xxtyp> ].
  216	expression_3	-> expression_2	[ mulop' expression_2 <xxtyp> ].
  217	expression_2	-> sign	expression_1
  218			 |	expression_1.
  219	expression_1	-> item	 ( "**"' item <xxtyp> |	nil ).
  220	
  221	item		-> constant' <xxstyp>		% constant %
  222			 | indexed_identifier <xxstyp> <xref>	% variable/array ref. %
  223			 | intrinsic_identifier'
  224				"(" # argument_list ")"	<xxsityp>	% intrinsic function call %
  225			 | "(" expression ( ")"		% back again %
  226					  | ","	expression ")" <xcmplx>
  227							% complex constants go here %
  228					  ).
  229	
  230	type_id		-> simple_type'	( "*" integer_constant'	<xretyp>
  231					| nil )
  232			 | double' precision.
  233	
  234		%	stuff for DATA statement	%
  235	
  236	data_list	-> data_item [ "," data_item ].
  237	data_item	-> indexed_identifier <xdrop>
  238			 | implicit_do_loop.
  239	
  240	implicit_do_loop ->
  241			   "(" data_item [ "," data_item ]
  242				   (   "=" expression <xdrop>
  243				       "," expression <xdrop>
  244				     ( "," expression <xdrop>
  245				     | nil )
  246				   | nil )
  247			   ")".
  248	
  249	data_constant_list ->
  250			      x_constant ( "*" x_constant | nil	)
  251			[ "," x_constant ( "*" x_constant | nil	) ].
  252	
  253	signed_constant	-> sign	constant
  254			 |	constant.
  255	
  256	x_constant	-> "(" signed_constant "," signed_constant ")" % complex constant %
  257			 | signed_constant.
  258	

Syntax analyzer:  FORTRAN
Tokens loaded:    94
Productions:      46
Sets defined:     11
Nodes generated:  479 (gained 161 nodes in reduction)
CPU time:         7.77 seconds.