Re: AST must for xlator? (RKRayhawk)
17 May 2002 00:20:52 -0400

          From comp.compilers

Related articles
AST must for xlator? (Russ Ramsey) (2002-05-12)
Re: AST must for xlator? (2002-05-17)
Re: AST must for xlator? (James Powell) (2002-05-31)
| List of all articles for this month |

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

  "Russ Ramsey";
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

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

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

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

Post a followup to this message

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