[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnubol: Record delimiter clause and parse order



Tim Josling wrote:
> 
> Matthew,
> 
> Parsing
> *******
> 
> Where there are many clauses, I would use something like this.
> 
> select_clause:
> SELECT optional_clause_opt assign_clause
> select_sub_clause_rep_opt
> ;
> 
> _rep (obvious)
> _opt (obvious)
> 
> select_sub_clause:
>  access_mode_clause
> |file_status_clause
> |lock_mode_clause
> |organization_clause
> |padding_char_clause
> |record_delim_clause
> |reserve_area_clause
> |sharing_clause
> ;
> 
> The benefit is that you get maximum recognition out of the parser
> and if the clauses are out of order you don't get a dumb 'syntax
> error' message.
> 
> You then have the option of accepting the clauses out of order or
> doing a manual check. You would probably only do the manual check
> only in pedantic mode, at which time you can put out a good
> message.
> 

Just wanted to make sure I'm on the right track here.  Here's what I'v
got in the parser, so far.  Needs much more, etc, etc, and a few more
clauses.  Before I get to far, the specs describe 3 or 4 formats (4 with
the SORT file).  Do we want to use 3/4 different select_* clauses, or
roll them all into one?  Making separate parse rules for the different
formats might actually be better, and easier to maintain, and easier to
parse--options specific to a format could be shunted off into a
specialized rule.  At least, it'd be easier to see how it's  *supposed*
to parse a given input. ;)

The answer to the above question will determine somewhat where I go from
here.  I don't mind making unilateral decisions, but a consensus of
opinions would be nice.  I could do the parse rules for all 4 formats,
if y'all would like...

environment_division:
environment_header
configuration_section_opt {
  RSN;
}
input_output_section_opt
;
	/\
	 |
	 |
	 |
	\/

input_output_section_opt:
/* nothing */
| input_output_header input_output_section_paragraph_opt
;

input_output_header:
INPUT_OUTPUT SECTION FULLSTOP_sym
;

input_output_section_paragraph_opt:
/* nothing */
| file_control_opt
;

file_control_opt:
/* nothing */
| file_control_header select_clause_list_opt
;

file_control_header:
FILE_CONTROL FULLSTOP_sym
;

select_clause_list_opt:
/* nothing */
| select_clause_list_opt select_clause_opt
| select_clause_opt
;

select_clause_opt:
/* nothing */
| SELECT opt_optional_clause file_desc_name assign_clause
select_sub_clause_rep_opt
FULLSTOP_sym
;

select_sub_clause_rep_opt:
/* empty */
| select_sub_clause_rep_opt select_sub_clause
| select_sub_clause
;

select_sub_clause:
/* empty */
| opt_access_mode_clause
| opt_file_status_clause
| opt_lock_mode_clause
| opt_organization_clause
| opt_padding_char_clause
| opt_record_delim_clause
| opt_reserve_area_clause
| opt_sharing_clause
;


-- 
Matthew Vanecek
Visit my Website at http://mysite.directlink.net/linuxguy
For answers type: perl -e 'print
$i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'
*****************************************************************
For 93 million miles, there is nothing between the sun and my shadow
except me. I'm always getting in the way of something...

--
This message was sent through the gnu-cobol mailing list.  To remove yourself
from this mailing list, send a message to majordomo@lusars.net with the
words "unsubscribe gnu-cobol" in the message body.  For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@lusars.net.