gnucobol-users
[Top][All Lists]
Advanced

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

Re: [open-cobol-list] pretty print


From: Michael Welter
Subject: Re: [open-cobol-list] pretty print
Date: Fri, 17 Aug 2012 08:51:11 -0600

A typical compiler uses a predefined grammar to translate source code into a 
"parse tree".  The code generation phase of the compilation then "walks" the 
tree and produces executable code.

In the case of OpenCOBOL, it is a two-step process: first, a COBOL program is 
translated into a parse tree.  The parse tree is then traversed and 'C' code is 
generated.  Then a C compiler compiles the C code into an executable module.

What I would like to do is write an extension to the OpenCOBOL compiler that 
traverses the parse tree and generates COBOL (not C) source code.  The net 
effect is that the resulting source code is reformatted in a standardized 
manner.  This is called a "pretty print" function.

Does anyone have experience with the OpenCOBOL parse tree, and can they show me 
how to get started?

Thanks,

On Aug 17, 2012, at 7:51 AM, john Culleton wrote:

> On Thu, 16 Aug 2012 17:33:13 -0600
> Michael Welter <address@hidden> wrote:
> 
>> Hello,
>> 
>> I would like to parse my COBOL program (with COPY statements) and
>> then traverse the parse tree and pretty print the COBOL.
>> 
>> Is there a plugin interface to OC?
>> Can anyone point me to a section of the code that traverses the parse
>> tree?
>> 
>> Thanks
>> Mike
>> 
> A COBOL program in source form is a text file. I suggest that you
> write a COBOL program that takes a given source file as input and
> then opens each copy statement in turn, adding its code to the
> output, and when a copy statement is encountered then closing the
> current file, opening the copy file encountered etc. In other 
> words one can write a COBOL program to do what you want. 
> 
> When you complete that task I hope you share it with the rest of
> us.
> -- 
> John Culleton
> Free list of books for self-publishers:
> http://wexfordpress.net/shortlist.html
> Police Procedural and Expose: "Death Wore Black"
> "Create Book Covers with Scribus"
> http://www.booklocker.com/books/4055.html
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> open-cobol-list mailing list
> address@hidden
> https://lists.sourceforge.net/lists/listinfo/open-cobol-list



reply via email to

[Prev in Thread] Current Thread [Next in Thread]