Subject: modification of IO

From: Yan Mi <[email-masked]>
Date: Tue, 23 Apr 1996 10:30:26 +0900 (CDT)

The following is modified by Yanmi

1: 	Expression in IO statment is SPEC_PAIR,KEYWORD_VAL is in the left pointer,
	not in the right side. 
		i.e.   unit=external_file_unit
	    		   SPEC_PAIR
				|
         	__________________________
		|			|
	KEYWORD_VAL(unit)	expr(external_file_unit)
	When the keyword_val such as unit is omitted, then the strng_val of 
	keyword_val  is "".
2:	In open_stmt, backspacre_stmt...:its component "external_file_unit" can be 	expression, i.e. open(6) should be correct.
	I have changed the rule :external_file_unit: variable 
				to
				external_file_unit:expr
3:	IN format: I think the node whose variant is KIND_VAL isnot necessary,
	so I deleted this intermid mode.

**************************
I also find some bug .

1:	"backspace(6,err=10)"
	 should be correct, but it cann't be accecpted by hpf2dep.
2:	in the statement "read(6,fmt=5) a,y", "6" should be an INT_VAL whose 
	omitted keyword_val is unit, but hpf2dep treats it as a label,
	namely when the keyword is omitted legally, hpf2dep can't distinguish 
	it between integer and label.
	I think the case of omitting keyword in "io_control_spec" hasn't been 
	dealt approriately, 
	will you please modified it ( deal it as expr of 
	SPEC_PAIR as I required the above) on my version?

###########################IO Part in f90.y###############
       
/************************ 95.8.25  ***************************************/

/********************    I/O File Operate  ********************************/
backspace_stmt           : BACKSPACE external_file_unit
			     {
				/*added by Yanmi*/
                                PTR_LLND p,q;
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"";
                                 q = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
				
                                  $$ = makeBfnd(fi,BACKSPACE_STAT);
                                 $$ = makeBackspceBfnd($$,q,LLNULL);
                                }
                         | BACKSPACE LEFTBRACKET
                               position_spec_list RIGHTBRACKET
                                {
                                 $$ = makeBfnd(fi,BACKSPACE_STAT);
                                 $$ = makeBackspceBfnd($$,LLNULL,$3);
                                }
                         ;

external_file_unit       : /* modified by Yanmi variable*/
			   expr
                         ;

position_spec_list         : position_spec
                                {
                                 $$ = makeLlnd(fi,EXPR_LIST,$1,LLNULL,SMNULL);
                                 $$ = makeLlExpLst($$,$1,LLNULL,SMNULL);
                                }
                         | position_spec_list COMMA position_spec
                                {
                                 $$ = makeLlnd(fi,EXPR_LIST,$3,LLNULL,SMNULL);
                                 $$ = makeLlExpLst($$,$3,$1,SMNULL); /* Link $3 to $1 */
                                }
                         ;

position_spec            : UNIT external_file_unit
				/* all  the position_spec is modified by Yanmi:
				modify the expr to SPEC_PAIR
				*/
                                { /*added by Yanmi*/
                                 PTR_LLND p;
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"unit";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);

				  /* deleted by Yanmi
                                 $$ = $2;
				 */
                                }
                         | external_file_unit
                                {/* added by Yanmi*/
                                 PTR_LLND p;
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$1,SMNULL);

				/* deleted by Yanmi
                                 $$ = $1;
				*/
                                }
                         | IOSTAT variable
                                { /*added by Yanmi*/
                                 PTR_LLND p;
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"iostat";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);

				  /*deleted by Yanmi
                                  $$ = makeLlnd(fi,IOSTAT_STORE,$2,LLNULL,SMNULL);
				  */
                                }
                         | ERR label   
                                {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"err";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
				 /*deleted by Yanmi
                                 $$ = makeLlnd(fi,KEYWORD_ARG,$2,p,SMNULL);
				  */
                                }
                         ;

rewind_stmt              : REWIND external_file_unit 
                                {
				/* added by Yanmi*/
                                PTR_LLND p,q;
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"";
                                 q = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);

                                 $$ = makeBfnd(fi,REWIND_STAT);
                                 $$ = makeBackspceBfnd($$,q,LLNULL);
                                 /* Using the same structure as backspace_stmt */
                                }
                         | REWIND LEFTBRACKET  position_spec_list 
                                RIGHTBRACKET 
                                {
                                 $$ = makeBfnd(fi,REWIND_STAT);
                                 $$ = makeBackspceBfnd($$,LLNULL,$3);
                                 /* Using the same structure as backspace_stmt */
                                }
                         ;

endfile_stmt             : ENDFILE external_file_unit 
                                {
                                  /*added by Yanmi*/
                                PTR_LLND p,q;
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL)
;
                                 p->entry.string_val = (char *)"";
                                 q = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);

                                 $$ = makeBfnd(fi,ENDFILE_STAT);
                                 $$ = makeBackspceBfnd($$,q,LLNULL);
                                 /* Using the same structure as backspace_stmt */
                                }
                         | ENDFILE LEFTBRACKET position_spec_list 
                             RIGHTBRACKET 
                                {
                                 $$ = makeBfnd(fi,ENDFILE_STAT);
                                 $$ = makeBackspceBfnd($$,LLNULL,$3);
                                 /* Using the same structure as backspace_stmt */
                                 }
                         ;

close_stmt               : CLOSE LEFTBRACKET close_spec_list  
                             RIGHTBRACKET 
                                {
                                 $$ = makeBfnd(fi,CLOSE_STAT);
                                 $$ = makeCloseBfnd($$,$3); 
                                }
                         ;

close_spec_list                 : close_spec
                                {
                                 $$ = makeLlnd(fi,EXPR_LIST,$1,LLNULL,SMNULL);
                                 $$ = makeLlExpLst($$,$1,LLNULL,SMNULL);
                                }
                         | close_spec_list COMMA close_spec
                                {
                                 $$ = makeLlnd(fi,EXPR_LIST,$3,LLNULL,SMNULL);
                                 $$ = makeLlExpLst($$,$3,$1,SMNULL); /* Link $3 to $1 */
                                }
                         ;
 
close_spec               : UNIT external_file_unit    
				/* modified by Yanmi*/    
                                {/* deleted by Yanmi
				  $$ = $2;
				 */
				 /*added by Yanmi*/
                                 PTR_LLND p;
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"unit";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);

				} 
                         | external_file_unit
                                { /* deleted by Yanmi
					$$ = $1;
				   */
				   /* added by Yanmi*/
                                 PTR_LLND p;
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$1,SMNULL);

				}
                         | IOSTAT variable
                                {/* deleted by Yanmi
                                 $$ = makeLlnd(fi,IOSTAT_STORE,$2,LLNULL,SMNULL);
				 */
				  /* added by Yanmi*/
                                 PTR_LLND p;
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"iostat";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);

                                }
                         | ERR label
                                {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"err";
                                 $$ = makeLlnd(fi,SPEC_PAIR,$2,p,SMNULL);
                                }
                         | STATUS default_char_expr
                                { 
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"status";
                                 $$ = makeLlnd(fi,SPEC_PAIR,$2,p,SMNULL);
                                }
                         ;

inquire_stmt             : INQUIRE LEFTBRACKET inquire_spec_list
                                 RIGHTBRACKET 
                                {
                                 $$ = makeBfnd(fi,INQUIRE_STAT);
                                 $$ = makeInquireBfnd($$,$3,LLNULL,LLNULL);
                                }
                         | INQUIRE LEFTBRACKET IOLENGTH 
                               variable RIGHTBRACKET 
                                    output_item_list 
                                {
				/* added by Yanmi*/
                               PTR_LLND p,q;
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"iolength";
                                 q = makeLlnd(fi,SPEC_PAIR,p,$4,SMNULL);

                                 $$ = makeBfnd(fi,INQUIRE_STAT);
                                 $$ = makeInquireBfnd($$,LLNULL,q,$6);
                                }
                         ;

inquire_spec_list         : inquire_spec
                                {
                                 $$ = makeLlnd(fi,EXPR_LIST,$1,LLNULL,SMNULL);
                                 $$ = makeLlExpLst($$,$1,LLNULL,SMNULL);
                                }
                         | inquire_spec_list COMMA inquire_spec
                                {
                                 $$ = makeLlnd(fi,EXPR_LIST,$3,LLNULL,SMNULL);
                                 $$ = makeLlExpLst($$,$3,$1,SMNULL); /* Link $3 to $1 */
                                }
                         ;

inquire_spec             : external_file_unit
				/* all the inquire_spec is modified by Yanmi:
				  KEYORD_VAL is put in the left pointer of 
				  SPEC_PAIR 
				*/
                                { /*added by Yanmi*/
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$1,SMNULL);

                                }
                         | UNIT external_file_unit
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"unit";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         | FILEI file_name_expr
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"file";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         | IOSTAT variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"iostat";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         | ERR label 
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"err";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                               }
                         | EXIST variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"exist";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                          | OPENED variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"opened";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | NUMBER variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"number";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | NAMED variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"name";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | NAMEI variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"namei";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | ACCESSL variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"access";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | SEQUENTIAL variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"sequential";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | DIRECT variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"direct";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | FORM variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"form";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | FORMATTED variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"formatted";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | UNFORMATTED variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"unformatted";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | RECL variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"recl";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | NEXTREC variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"nextrec";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | BLANK variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"blank";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | POSITION variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"position";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | ACTION variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"action";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | READ variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"read";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | WRITE variable
                                {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"write";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | READWRITE variable
                                {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"readwrite";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         | DELIM variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"delim";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | PAD variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"pad";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                            ;

open_stmt                : OPEN LEFTBRACKET connect_spec_list
                               RIGHTBRACKET 
                                {
                                 $$ = makeBfnd(fi,OPEN_STAT);
                                 $$ = makeOpenBfnd($$,$3);
                                }
                         ;

connect_spec_list         : connect_spec
                                    {
                                  $$ = set_ll_list($1,LLNULL,EXPR_LIST);
                                }
                         | connect_spec_list COMMA connect_spec
                                { 
                                    $$ = set_ll_list($1,$3,EXPR_LIST);
                                 }
                         ;

connect_spec             : UNIT external_file_unit
				/* all the connnect_spec: KEYWORD_ARG modified 
			       	   to  SPEC_PAIR by Yanmi, and the sequence of 
				   KEYWORD_VAL and expr modified by Yanmi*/
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"unit";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | external_file_unit
				   {/*added by Yanmi*/
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$1,SMNULL);
                                 }

                         | IOSTAT variable
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"iostat";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         | ERR label
                                {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"err";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                               }
                         | FILEI file_name_expr
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"file";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         | STATUS default_char_expr
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"status";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         | ACCESSL default_char_expr
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"access";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         | FORM default_char_expr
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"form";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         | RECL expr
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"recl";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | BLANK default_char_expr
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"blank";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | POSITION default_char_expr
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"position";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         | ACTION default_char_expr
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"action";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         | DELIM default_char_expr
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"delim";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         | PAD default_char_expr
                                     {
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"pad";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         ;

file_name_expr           : char_literal_constant
                         ;

default_char_expr         : char_literal_constant
                         ;
 
print_stmt               : PRINT format COMMA output_item_list
                                { 
                                 $$ = makeBfnd(fi,PRINT_STAT);
                                 $$ = makePrintBfnd($$,$2,$4);
                                 }
                         | PRINT format 
                                { 
                                 $$ = makeBfnd(fi,PRINT_STAT);
                                     $$ = makePrintBfnd($$,$2,LLNULL);
                                        }
                         ;

format                         : STRING
					/* all the format: delete KIND_VAL node 					by Yanmi*/
                                 { 
                                 PTR_LLND pp;
                                 pp = makeLlnd(fi,STRING_VAL, LLNULL, LLNULL, SMNULL);
                                 pp->entry.string_val = copys(yytext);
                                }
                         | label
                                {
                                 $$ = $1; 
                                }
                         | MULTIPLY 
                                { 
				$$=makeLlnd(fi,STRING_VAL, LLNULL, LLNULL, SMNULL);
				$$->entry.string_val=(char *)"*";
				/* deleted by Yanmi
                                $$ =  makeLlnd(fi,KIND_VAL,LLNULL,LLNULL,SMNULL);
                                $$->entry.var_ref_s.symbol= fi->head_symb;
				*/
                                }
                         | variable  
                                { /* added  byYanmi*/
				  $$=$1;
				/*deleted by Yanmi
                                 $$ = makeLlnd(fi,KIND_VAL,$1,LLNULL,SMNULL);
				*/
                                }                                           
                         ;

output_item_list         : output_item
                         {
                             $$ = set_ll_list($1,LLNULL,EXPR_LIST);
                            }
                         | output_item_list COMMA output_item
                         {
                             $$ = set_ll_list($1,$3,EXPR_LIST);
                         }        
                      ;

output_item             : expr1    
                            {
                              $$ = $1;
                           }
                         | io_implied_do    
                            {
                              $$ = $1;
                            }
                         ;
        
read_stmt                : READ LEFTBRACKET io_control_spec_list
                            RIGHTBRACKET input_item_list 
                                { 
                                 $$ = makeBfnd(fi,READ_STAT);
                                 $$ = makeReadBfnd($$,LLNULL,$3,$5); 
                                 } 
                         | READ LEFTBRACKET io_control_spec_list
                           RIGHTBRACKET 
                                { 
                                    $$ = makeBfnd(fi,READ_STAT);
                                    $$ = makeReadBfnd($$,LLNULL,$3,LLNULL); 
                                }
                          | READ format COMMA input_item_list 
                                  {
                                          $$ = makeBfnd(fi,READ_STAT);
                                   $$ = makeReadBfnd($$,$2,LLNULL,$4); 
                                  }
                         | READ format 
                                { 
                                     $$ = makeBfnd(fi,READ_STAT);
                                 $$ = makeReadBfnd($$,$2,LLNULL,LLNULL); 
                                }
                         ;

input_item_list                 : input_item
                        {
                           $$ = set_ll_list($1,LLNULL,EXPR_LIST);
                            /* $$ = makeLlnd(fi,EXPR_LIST,$1,LLNULL,SMNULL);*/
                        }        
                             | input_item_list COMMA input_item
                        { 
                          $$ = set_ll_list($1,$3,EXPR_LIST);
                                  /* PTR_LLND llnd;
                            llnd = makeLlnd(fi,EXPR_LIST,$3,LLNULL,SMNULL);
                            $$ = AppendllndList($1,llnd); */
                        }
                         ;

input_item               : variable
                          {
                                       $$ = $1;
                          }                  
                                | io_implied_do
                          {
                                 $$ = $1; 
                          }        
                         ;

io_implied_do            : LEFTBRACKET io_implied_do_object_list COMMA
                                   io_implied_do_control RIGHTBRACKET
                                { 
                                $$ = makeLlnd(fi,IMPLIED_DO,$2,$4,SMNULL); 
                                 }
                         ;

io_implied_do_object_list: io_implied_do_object
                                {
                                  $$ = set_ll_list($1,LLNULL,EXPR_LIST);
                                }                
                         | io_implied_do_object_list
                                COMMA  io_implied_do_object
                                {
                                   $$ = set_ll_list($1,$3,EXPR_LIST);
                                }
                         ;

io_implied_do_object     : expr /*  array_element  input_item  */
                         | io_implied_do /*output_item  */
                         ;

io_implied_do_control    : variable EQUAL numeric_expr COMMA
                             numeric_expr COMMA
                                 numeric_expr
                                { 
                                   PTR_LLND p;
                                   p = makeLlnd(fi,RANGE_OP,$3,$5,SMNULL);
                                    $$ = makeLlnd(fi,DDOT,p,$7,SMNULL);
                                }
                         | variable EQUAL numeric_expr COMMA
                             numeric_expr        
                                {
                                 PTR_LLND p;
                                   p = makeLlnd(fi,RANGE_OP,$3,$5,SMNULL);
                                   $$ = makeLlnd(fi,DDOT,p,LLNULL,SMNULL);
                                }
                         ;

write_stmt               : WRITE LEFTBRACKET io_control_spec_list
                           RIGHTBRACKET output_item_list 
                                {  
                                    $$ = makeBfnd(fi,WRITE_STAT);
                                    $$ = makeWriteBfnd($$,$3,$5);
                                 }
                         | WRITE LEFTBRACKET io_control_spec_list
                             RIGHTBRACKET 
                                { 
                                        $$ = makeBfnd(fi,WRITE_STAT);
                                        $$ = makeWriteBfnd($$,$3,LLNULL);                         
                                }
                         ;

io_control_spec_list     : io_control_spec
                                {
                                 $$ = set_ll_list($1,LLNULL,EXPR_LIST);
                                }
                         | io_control_spec_list COMMA2 io_control_spec
                                {
                                 $$ = set_ll_list($1,$3,EXPR_LIST);
                                }
                         ;

io_control_spec          : UNIT io_unit
                                { 
                                 PTR_LLND p;
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"unit";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         | NML /*namelist_group_*/name
                                {
                                 PTR_SYMB s;
                                  PTR_LLND ss,ll;

                                 s = makeSymbVar(fi,cur_scope(),LOCAL,$2,0); 
                                       ss = makeLlnd(fi,VAR_REF, LLNULL, LLNULL,s);
                                      ll = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 ll->entry.string_val = (char *)"nml";
                                      $$ = makeLlnd(fi,SPEC_PAIR,ss,ll,SMNULL);         
                                }
                         | FMT format
                                { 
                                 PTR_LLND p;
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"fmt";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         | REC expr
                                { 
                                 PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"rec";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                }
                         | IOSTAT variable
                                {
                                PTR_LLND p;

                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"iostat";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | ERR label
                                {
                                PTR_LLND ss,ll;

                                ss = makeLblLst(fi,ERR_LABEL,LLNULL,$2);
                                 ll = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 ll->entry.string_val = (char *)"err";
                                 $$ = makeLlnd(fi,SPEC_PAIR,ll,ss,SMNULL);
                                 }
                         | END label
                                {
                                PTR_LLND p,ll;
                                ll = makeLblLst(fi,END_LABEL,LLNULL,$2);
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                  p->entry.string_val = (char *)"end";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,ll,SMNULL);
                                }
                         | ADVANCE default_char_expr
                                {
                                 PTR_LLND p;
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"advance";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | SIZE variable
                                {
                                  PTR_LLND p;        
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"size";
                                   $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
                                 }
                         | EOR label  
                                { 
                                 PTR_LLND p;

                                   p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                   p->entry.string_val = (char *)"eor"; 
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,$2,SMNULL);
 	                         }

                         | STRING  
                                {
                                   PTR_LLND p,ll;
					/* modified by Yanmi*/
                                   p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                   p->entry.string_val = (char *)"";

                                    ll = makeLlnd(fi,STRING_VAL,LLNULL,LLNULL,SMNULL);
                                   ll->entry.string_val = copys(yytext);
                                   $$ = makeLlnd(fi,SPEC_PAIR,ll,LLNULL,SMNULL);
                                  }

                         | label 
                                {
                                   PTR_LLND p,ss;

                                   p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                   p->entry.string_val = (char *)"";  
                                   $$ = makeLlnd(fi,SPEC_PAIR,p,$1,SMNULL);
                                }        
                         | MULTIPLY 
                                {
                                 PTR_LLND p,q;
                                 p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);

                                 p->entry.string_val = (char *)"";
				 q= makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
				q->entry.string_val=(char *)"*";
                                 $$ = makeLlnd(fi,SPEC_PAIR,p,q,SMNULL); 
                                 }
                         | variable  
                                 {
                                   PTR_LLND p;
                                   p = makeLlnd(fi,KEYWORD_VAL,LLNULL,LLNULL,SMNULL);
                                   $$ = makeLlnd(fi,SPEC_PAIR,p,$1,SMNULL);
                                }  
			;
io_unit                  : MULTIPLY
                                { 
                                 $$ =  makeLlnd(fi,KIND_VAL,LLNULL,LLNULL,SMNULL);
                                 $$->entry.var_ref_s.symbol= fi->head_symb;

                                   /* PTR_LLND p;
                                 p = makeLlnd(fi,KEYWORD_ARG,LLNULL,LLNULL,SMNULL);
                                 p->entry.string_val = (char *)"*";
                                 $$ = makeLlnd(fi,KEYWORD_ARG,p,LLNULL,SMNULL); */
                                }
                         | expr
                         ;

format_stmt              : /*_labelnu*/ FORMAT format_specification  {
          if(debugFlag_g==1) printf("format :%s\n",$$);
                $$ = makeBfnd(fi,FORMAT_STAT);
                $$ = makeFmtBfnd($$,$2);
          }
    ;
       
format_specification     
    :  LEFTBRACKET format_item_list RIGHTBRACKET {
          char sp1[STR_LENGTH];
          
          if(debugFlag_g==1)
          printf("format_spec :%s\n",$$);

          strcpy(sp1,"(");
          strcat(sp1,$2);
          strcat(sp1,")");
          $$ = makeLlnd(fi,STMT_STR,LLNULL,LLNULL,SMNULL);
          $$->entry.string_val = sp1;
          $$->type = global_string;
          }
    |  LEFTBRACKET RIGHTBRACKET {
          $$ = makeLlnd(fi,STMT_STR,LLNULL,LLNULL,SMNULL);
          $$->entry.string_val = "()";
          $$->type = global_string;
          }
    ;
       
format_item_list         
    :  format_item 
    |  format_item_list COMMA format_item {
          if(debugFlag_g==1) printf("format_item :%s\n",$$);
          strcat($1,(char *)",");
          strcat($1,$3);
          strcpy($$,$1);
          }
    ;

format_item              
    :  r data_edit_desc {
        strcpy($$,$1);
        strcat($$,$2);
        }
    |  data_edit_desc {
        strcpy($$,$1);
        }
    |  control_edit_desc {
        strcpy($$,$1);
        }
    |  char_string_edit_desc {
        strcpy($$,$1);
        }
    |  r LEFTBRACKET format_item_list RIGHTBRACKET {
        strcpy($$,$1);
        strcat($$,(char *)"(");
        strcat($$,$3);
        strcat($$,(char *)")");
        }
    |  LEFTBRACKET format_item_list RIGHTBRACKET {
        strcpy($$,(char *)"(");
        strcat($$,$2);
        strcat($$,(char *)")");
        }
    ;

r                        
    :  digit_string 
    ;
       
data_edit_desc           : I real_literal_constant /* w FULLPOINT m */ {
        $$ = strcat((char *)"I",$2->entry.string_val);
          }
    |  I w {
        $$ = strcat((char *)"I",$2);
          }
    | B real_literal_constant /* w FULLPOINT m */ {
        $$ = strcat((char *)"B",$2->entry.string_val);
          }
    |  B w {
        $$ = strcat((char *)"B",$2);
          }
    | O real_literal_constant /* w FULLPOINT m */ {
        $$ = strcat((char *)"O",$2->entry.string_val);
          }
    |  O w {
        $$ = strcat((char *)"O",$2);
          }
    | Z real_literal_constant /* w FULLPOINT m */ {
        $$ = strcat((char *)"Z",$2->entry.string_val);
          }
    |  Z w {
        $$ = strcat((char *)"Z",$2);
          }
    | F real_literal_constant /* w FULLPOINT d */ {
        $$ = strcat((char *)"F",$2->entry.string_val);
          }
    |  F w {
        $$ = strcat((char *)"F",$2);
          }
    | E real_literal_constant /* w FULLPOINT d */ {
        $$ = strcat((char *)"E",$2->entry.string_val);
          }
    | EN real_literal_constant /* w FULLPOINT d E e */ {
        $$ = strcat((char *)"EN",$2->entry.string_val);
          }
    | ES real_literal_constant /*w FULLPOINT d E e */ {
        $$ = strcat((char *)"ES",$2->entry.string_val);
          }
    | G real_literal_constant /*w FULLPOINT d E e*/ {
        $$ = strcat((char *)"G",$2->entry.string_val);
          }
    |  L w {
        $$ = strcat((char *)"L",$2);
          }
    |  A w {
        $$ = strcat((char *)"A",$2);
          }
    | D real_literal_constant /*w FULLPOINT d*/ {
        $$ = strcat((char *)"D",$2->entry.string_val);
          }
    |  A {
        $$ = (char *)"A";
          }
    ;
       
w                        
    :  digit_string 
    ;
       
control_edit_desc        
    :  position_edit_desc
    |  r DIVIDE {
        $$ = strcat($1,(char *)" /");
          }
    |  DIVIDE {
        $$ = (char *)"/";
          }
    |  COLON {
        $$ = (char *)":";
          }
    |  sign_edit_desc
           {
            $$ = $1;
           }
    |  k P {
        $$ = strcat($1,(char *)"P");
          }
    |  blank_interp_edit_desc
    ;
       
k                        
    :  digit_string 
    ;
       
position_edit_desc       
    :  T n {
        $$ = strcat((char *)"T",$2);
          }
    |  TL n {
        $$ = strcat((char *)"TL",$2);
          }
    |  TR n {
        $$ = strcat((char *)"TR",$2);
          }
    |  n X {
        $$ = strcat($1,(char *)"X");
          }
    ;
       
n                        
    :  digit_string 
    ;
       
sign_edit_desc           
    :  S {
         $$ = "S";  
          }
    |  SP {
         $$ = "SP";  
          }
    |  SS {
         $$ = "SS";  
          }
    ;
       
blank_interp_edit_desc   
    :  BN {
         $$ = "BN";  
          }
    |  BZ {
          $$ = "BZ";
          }
    ;
       
char_string_edit_desc    
    :  STRING 
    |  c H rep_char1 {
        $$ = strcat($1,(char *)"H");
        $$ = strcat($$,$3);
          }
    ;
       
rep_char1                
    :  HCHAR  {
        $$ = (char *)"HCHAR";
          }
    |  rep_char1 HCHAR {
        $$ = strcat($1,(char *)"HCHAR");
          }
    ;
       
c                        
    :  digit_string
    ;

---

From: Yan Mi <[email-masked]>
Date: Wed, 24 Apr 1996 08:59:32 +0900 (CDT)

Hi,Zhang Guansong:
	Will you please tell me whatis your purpose of yuor unparsing work?
It is like :HPF source program --> .dep -->HPF program? Do you work in 
order to if our .dep has faithfully reprenent the source program ? Otherwise,
is your unparse  get another language program  from .dep of HPF? If your 
purpose is the latter, I think you'd better unparse after hpfcc, because your
work need know explicitly about semantic and many work can't be finished 
in yacc itself and hpfcc has complement many semantic information.
	I modify the left son of SPEC_PAIR in order to work easy in my semantic
routine, when I see the string_val is "", I'll  write  the omitting 
keyword in this place without making new llnd. Perhaps you may say that I 
shouldn't complement the omitting word. I do so on the base of my 
comprehension of Prof. Li_xiaoming's request about faithfully repesent. I 
think "faithfully" is not literally faithfully but semanticlly faithfully,
and it is better to provide sufficently semantic information in .dep, so 
when unparse the HPF to other language we needn't know so many details about
HPF grammar.

	If you think it is better to let the son of SPEC_PAIR be null 
when omitting keyword, you may do as you want and send the new version to me
as quickly as possible or you can tell me your plan about IO part and let 
me change it myself. I've wait for IO part for too long time, without 
a presice intermidiate represent I can't do my semantic work fluently.
	I have another e_mail address: [email-masked], but I don't 
often use it. 
							Yan mi
							4/24/1996

---

From: Yan Mi <[email-masked]>
Date: Thu, 25 Apr 1996 08:57:28 +0900 (CDT)

Hi,Guansong Zhang :
	I am reponsible for program unit ,subprogram and io part. I 
defined the bfnd and llnd tree of theses parts and have done semantic 
routine except io. Now When I do semantic routine, I'll condiser the 
definition of AST more pratically.
	I completely under your comprehension about SPEC_PAIR. We need 
travese the AST in our work, I know the rules. I just had little 
information about your unparse work. A problem can be solved in many ways , 
every methord has its resonability for some way.I chose one for my 
convenience in my semantic routine. You chose for your convenience. I 
think there is not necessary to argue about this problem. If you'd like 
to do so, I'll change my ideas. 
	Since your unparse just change .dep back to HPF source program
and just check the intermidiate represtion ,of cource you needn't work 
after hpfcc. 
						Yan mi