Making awk programs look pretty 
Author Message
 Making awk programs look pretty

When developing the more complex awk program, I find it useful to
break it into small chunks of the logic - each fitting on a (small)
screen-full. ie 20 lines

I do this by stringing together statements on a line using the ';'
I also dont break when encountering a '{' or '}'.

Although this is good for development, the resulting program very
dense, doesn't look good and can be a nightmare to debug after an
extended period

On many proper UNIX system there is a program called 'cb' (C-
beautifier) which expands such awk-programs into a prettier script

For my amu{*filter*}t I thought I'd try to write it in awk. The basic
script took 10 minutes and just 10 lines. Enhancing it to deal sensibly
with 'for' loops, text within quotes and regex's took another 2 hours,
brought it upto 40 (messy) lines of code and I'm not sure I am winning

Has anyone else done this - do you want to share it with us

Thanks
Mark
---
Mark Katz
Mark-IT, London. Delivering MR-IT/Internet solutions
Tel: (44) 20-8731 7516, Fax: (44) 20-8458 9554; http://www.*-*-*.com/



Mon, 15 Sep 2003 21:36:27 GMT  
 Making awk programs look pretty

...
Quote:
>On many proper UNIX system there is a program called 'cb' (C-
>beautifier) which expands such awk-programs into a prettier script

...

On the assumption that there's got to be a GNU version of this, the source
code would be available in a tarball somewhere. PowerArchiver at least
handles both ZIP and various compressed tar file formats. Download the GNU
source and compile a version for Win32 - it's highly likely such a program
would be easily ported to Win32 since it's just text processing.



Tue, 16 Sep 2003 07:58:39 GMT  
 Making awk programs look pretty
Nelson Beebe has written an Awk code formatter the source of which is
available at:

http://www.math.utah.edu:8080/pub/awkpretty/

I've managed to compile it for dos/windows, but the source is clearly
intended for Unix systems. It consists of a C program called awklex which
turns an awk file into a lexical token stream, and an awk script which turns
that back into awk code.

--
Edward Russell
Convenor, MBA Program
National Graduate School of Management
The Australian National University
Tel. +612 6125 9828
Fax. +612 6125 4895
http://ngsm.anu.edu.au
http://ngsm.anu.edu.au/aamc/staff_profiles/russell.html



Fri, 19 Sep 2003 19:12:58 GMT  
 Making awk programs look pretty

Quote:

>Nelson Beebe has written an Awk code formatter the source of which is
>available at:

>http://www.math.utah.edu:8080/pub/awkpretty/

>I've managed to compile it for dos/windows, but the source is clearly
>intended for Unix systems. It consists of a C program called awklex which
>turns an awk file into a lexical token stream, and an awk script which turns
>that back into awk code.

This looks intriguing (thanks ever so for the link), but I could not get it
to work (tested on a Sun/Solaris system).  The problem is that I have a
basic position that it should not be necessary to do a "make install" in
order to see if a program works.  That seems to be the case here.  It
violates the whole "try before you buy" philosophy of Unix freeware - i.e.,
it should always be possible to build it in the current dir and test it out
there.  In fact, I almost never do a "make install" at all.

And, in fact, even after I changed prefix to ., the "make install" still
crashed - thereby showing that he is doing too much in "make install".

Anyway, if you wanted to send me the Windows binary, that would be a Good
Thing.



Sat, 20 Sep 2003 02:05:55 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Making OS/2 look a little bit pretty?

2. Looking for "pretty-printer"/reformatter for AWK

3. AWK newbie is looking for a AWK help with his 1st program

4. An Awk Program to Create an Awk Program [Long]

5. Making source code "pretty"

6. Pretty 'print' files from awk

7. awk pretty printer?

8. C++ awk pretty printer?

9. Looking for an SML pretty printer

10. Still Looking: Pretty Printer for ada

11. Looking for Ada pretty printer

12. Looking for COBOL source formatter (pretty printer)

 

 
Powered by phpBB® Forum Software