Checking (compile only) AWK programs 
Author Message
 Checking (compile only) AWK programs

I'm trying to set up a programming environment for awk. I would like to
use a regular awk processor to syntax check an awk program. I've not
found any command line flag to do that. I've tested the following trick
with gawk:

      gawk --source "BEGIN {exit}; END {exit}" -f myAWKprogram

It works but, is there a more direct or obvious way of doing compilation
only? Or with other awk processors: awk, nawk, mawk, ...?

Thanks,
--
------------------------------------------------------------------------
Manuel Collado Machuca                    | Facultad de Informatica UPM
Universidad Politecnica de Madrid         | Campus de Montegancedo
Dep. LSIIS                                | Boadilla del Monte
Tel.+34-91-336.74.57 Fax.+34-91-336.74.12 | 28660  MADRID  -  SPAIN
------------------------------------------------------------------------



Tue, 09 Jul 2002 03:00:00 GMT  
 Checking (compile only) AWK programs
Quote:

> I'm trying to set up a programming environment for awk. I would like to
> use a regular awk processor to syntax check an awk program. I've not
> found any command line flag to do that. I've tested the following trick
> with gawk:

>       gawk --source "BEGIN {exit}; END {exit}" -f myAWKprogram

> It works but, is there a more direct or obvious way of doing compilation
> only? Or with other awk processors: awk, nawk, mawk, ...?

<snip>
Maybe not exactly what you want, but gawk has a --lint option that
doesn't run the code, just checks it.

For example on NT:

C:\DATA\MiscAWK>gawk --lint -f sb2qb.awk
gawk: sb2qb.awk:25:         if (index($j,"_") = 0)    # no "_" in $j -
short cir
cuit
gawk: sb2qb.awk:25:                           ^ parse error
gawk: sb2qb.awk:40: warning: source file does not end in newline

HTH
Peter
--


Fax2Email               0870 052 2717
Opinions expressed are my own and not necessarily those of my employer.



Tue, 09 Jul 2002 03:00:00 GMT  
 Checking (compile only) AWK programs

Quote:

>> I'm trying to set up a programming environment for awk....



Quote:
>Maybe not exactly what you want, but gawk has a --lint option that
>doesn't run the code, just checks it.

Sorry, this is not true. The --lint option enables additional checks and
warnings, both at parse time and at run time.  There is no 'syntax check
only' option in gawk, although it'd be almost trivial to add one (Use
the Source, Luke).

Arnold
--
Arnold Robbins -- guest account at Emory Math/CS        | Laundry increases

                                                        | number of children.
                                                        | -- Miriam A. Robbins



Thu, 11 Jul 2002 03:00:00 GMT  
 Checking (compile only) AWK programs
Quote:


> >> I'm trying to set up a programming environment for awk....



> >Maybe not exactly what you want, but gawk has a --lint option that
> >doesn't run the code, just checks it.

> Sorry, this is not true. The --lint option enables additional checks and
> warnings, both at parse time and at run time.  There is no 'syntax check

<snip>

Oops, so it does!  I'd only ever used it to do quick checks before live
runs - apologies for the misinformation.

Peter
--


Fax2Email               0870 052 2717
Opinions expressed are my own and not necessarily those of my employer.



Fri, 12 Jul 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

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

2. Compiling awk Programs

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

4. File type checking in AWK - Can I do it

5. Checking that a file or directory is writable from an awk script

6. Program compiled with pgf77 uses location of program as default directory

7. Compile time Type checking

8. Compile time check for void entity?

9. Compile-time Checking

10. Compile-time Checking

11. ct: Re: Compile-time Checking

12. Compile-time Checking

 

 
Powered by phpBB® Forum Software