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

[GNU-COBOL] instant top-level parser



Randall Bart wrote: 
> COBOL-20XX has done away with margin B, so all recognition of headers is
> driven on separator-periods alone.  The ZIF should be parsed into a next
> intermediate form (NIF)  period delimited sentences.  Then the next
> intermediate form is to parse this into programs, divisions, sections, and
> paragraphs.  This form would identify the nesting of programs so we call
> this the nested intermediate form (NIF).

"separator periods" are periods followed by whitespace, except
for single periods in PIC clauses which can be replaced with Vs by
the programmer for identical functionality, correct? So the first
period on a line after the letters PIC can be changed into a V?



#!/usr/local/bin/perl

undef $/;

$WholeInput = <STDIN>;

# This will break on PIC clauses that end with dots --
# escape them somehow -- either by using a more complex
# regex to split the sentences or by converting them
# to something else -- like the V which can be put in there
# instead 

# change first dot after "PIC" on any line into a V except
# if it is followed by whitespace:

$WholeInput =~ s/(PIC[^\n\.]*)\.(\S)/$1V$2/g;

@PeriodDelimitedSentences = split(/\.\s/,$WholeInput);

@Program = map {ExpandSentence $_} @PeriodDelimitedSentences;

print join("\n",@Program,'');

__END__

ExpandSentence remains to be written, to divide these
sentences up.

Question -- Were separator periods optional in the
margin B days, or was the blocking redundant that way?




______________________________________________________________
                      David Nicol 816.235.1187 nicold@umkc.edu
 It is difficult to tell if your employees are doing real work
   or just goofing off when tools and games have the same GUI. 
                                                -- Dennis Chao

--
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.