Re: AST must for xlator?

rkrayhawk@aol.com (RKRayhawk)
17 May 2002 00:20:52 -0400

          From comp.compilers

Related articles
AST must for xlator? rramsey500NOSPAM@earthlink.net (Russ Ramsey) (2002-05-12)
Re: AST must for xlator? rkrayhawk@aol.com (2002-05-17)
Re: AST must for xlator? jamesp_spam_me_not@silver-future.com (James Powell) (2002-05-31)
| List of all articles for this month |

From: rkrayhawk@aol.com (RKRayhawk)
Newsgroups: comp.compilers
Date: 17 May 2002 00:20:52 -0400
Organization: AOL http://www.aol.com
References: 02-05-057
Keywords: parse
Posted-Date: 17 May 2002 00:20:51 EDT

  "Russ Ramsey" rramsey500NOSPAM@earthlink.net;
Date: 12 May 2002 00:06:35 -0400, wrote
<<
    I wrote Lex & Yacc code to parse SAS; now how do I output the
symbols into COBOL?


    Assuming each statement of one equals only one statement of the
other. On the grammar rules actions can I just save to tree the
equivalent tokens and then print them out infix? Any examples out
there of the simplest data structure for this purpose?


>>


Well, you may have a partly easy task ahead of you, and a partly
difficult task.


Your data declarations should be analogous in each syntax. And the
sequence of detailed fields should be comparable. So for the emission
of data declarations (perhaps merely copybooks) the tree walk should
be literally straight forward.


The procedures are another matter. SAS has built in algorithms. You
will need similar 'canned' routines: created and perfected independent
of your syntax rule achievements thus far. These will be a library of
callable routines or includable paragraphs or sections that you can
PERFORM.


You will need major strategies to standardize this COBOL-side tool
set.


To some extent then you will need tree walks that emit invocations of
these routines, and in other cases you will need to emit detail
executable COBOL logic to MOVE, COMPUTE (or just formulas, of course),
and to engage the many COBOL I/O facilities in a way comparable to the
SAS behavior.


Some of the I/O and some calculation may require you to do things back
up in the DIVISIONS above the PROCEDURE DIVISION.


COBOL compilation, since the earliest days, has involved the
equivalent of a lot of intermediate files that get merged. The 'fourth
generation' syntax of SAS will require you to emit into several
DIVISIONs at once with a subsequent merge, or to do multiple passes of
your AST.


Robert Rayhawk
RKRayhawk@aol.com


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.