Skip Menu |
Report information
Id: 31321
Status: rejected
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: keith [at] batky-howell.com
Cc:
AdminCc:

Operating System: Linux
PatchStatus: (no value)
Severity: Wishlist
Type: utilities
Perl Version: 5.8.1
Fixed In: (no value)



Subject: a2p fails to parse valid do-while loop in awk script
Date: Tue, 24 Aug 2004 23:01:16 -0600
To: perlbug [...] perl.org
From: Keith Blackwell <keith [...] batky-howell.com>
Download (untitled) / with headers
text/plain 5.7k
This is a bug report for perl from keith AT batky-howell.com, generated with the help of perlbug 1.34 running under perl v5.8.1. ----------------------------------------------------------------- [Please enter your report here] a2p fails to translate valid awk syntax, saying "syntax error". Example input to demonstrate the problem: BEGIN{ do{ print a++ } while(a<2) exit(0); } If I call this "tmp.awk" and run "a2p tmp.awk", I get this output: syntax error in file tmp.awk at line 2 Translation aborted due to syntax errors. The line in error is the while(condition) after the closing "}". A similar, but different failure (probably deserving of a separate defect report) is a2p's failure to correctly parse complex boolean arithmetic. Consider the following, which encapsulates a few lines from a working "battleship" game written in AWK: function should_work(r,c,shot){ # excerpt taken from a battle ship game (HIT_AND_SUNK="#" or some such) l= (r>0)*((shot[r-1,c]=="")-(shot[r-1,c]==HIT_AND_SUNK)) l+=(r<9)*((shot[r+1,c]=="")-(shot[r+1,c]==HIT_AND_SUNK)) l+=(c>0)*((shot[r,c-1]=="")-(shot[r,c-1]==HIT_AND_SUNK)) l+=(c<9)*((shot[r,c+1]=="")-(shot[r,c+1]==HIT_AND_SUNK)) return l } BEGIN{ HIT_AND_SUNK="#"; print should_work(3,6,empty); exit(0); } If I put this into tmp2.awk and run "a2p tmp2.awk", I get this: syntax error in file tmp2.awk at line 3 Translation aborted due to syntax errors. Both of these examples not only are parsed correctly by AWK, but actually work as expected. Thank you for any consideration of this matter. My situation is that I am about to teach a 5-day perl class, and wanted to try translating some entertaining AWK scripts to see what came out, but a2p appears to only work on the simplest, shortest, awk scripts. I'm wondering if perhaps it's even worth the trouble to fix these issues, but then, if we can't use a2p, what is the alternative? You may contact me as user "keith" at the "batky-howell.com" domain or as user "keith.blackwell" at the "jymis.com" domain, but please do not allow my email addresses to be posted in any fashion to the web. Thank you again. [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=utilities severity=high --- Site configuration information for perl v5.8.1: Configured by bhcompile at Wed Oct 15 10:50:03 EDT 2003. Summary of my perl5 (revision 5.0 version 8 subversion 1) configuration: Platform: osname=linux, osvers=2.4.21-2.elsmp, archname=i386-linux-thread-multi uname='linux daffy.perf.redhat.com 2.4.21-2.elsmp #1 smp wed sep 17 15:00:55 edt 2003 i686 i686 i386 gnulinux ' config_args='-des -Doptimize=-O2 -g -pipe -march=i386 -mcpu=i686 -Dversion=5.8.1 -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux -Dvendorprefix=/usr -Dsiteprefix=/usr -Dotherlibdirs=/usr/lib/perl5/5.8.1 -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl -Ubincompat5005 -Uversiononly -Dinc_version_list=5.8.0/i386-linux-thread-multi 5.8.0 -Dpager=/usr/bin/less -isr' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm', optimize='-O2 -g -pipe -march=i386 -mcpu=i686', cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm' ccversion='', gccversion='3.3.1 20030930 (Red Hat Linux 3.3.1-6)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='gcc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='2.3.2' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5/5.8.1/i386-linux-thread-multi/CORE' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib' Locally applied patches: --- @INC for perl v5.8.1: /usr/lib/perl5/5.8.1/i386-linux-thread-multi /usr/lib/perl5/5.8.1 /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.1/i386-linux-thread-multi /usr/lib/perl5/5.8.1 . --- Environment for perl v5.8.1: HOME=/home/keith LANG=en_US LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/opt/j2sdk_nb/j2sdk1.4.2/bin:/opt/oracle/product/8.1.7/bin:/home/keith/bin PERL_BADLANG (unset) SHELL=/bin/bash
Subject: Re: [perl #31321] a2p fails to parse valid do-while loop in awk script
Date: Sun, 29 Aug 2004 20:28:47 +0200
To: perl5-porters [...] perl.org
From: Rafael Garcia-Suarez <rgarciasuarez [...] mandrakesoft.com>
Download (untitled) / with headers
text/plain 880b
keith (via RT) wrote: Show quoted text
> a2p fails to translate valid awk syntax, saying "syntax error".
I think that a2p comes from the good old days of awk, before it evolves into nawk and gawk. I'm not surprised limitations are found in it. Which awk are you using ? Show quoted text
> Thank you for any consideration of this matter. My situation is > that I am about to teach a 5-day perl class, and wanted to try > translating some entertaining AWK scripts to see what came out,
gee, there are still people who learn awk (and sed, I assume) before perl :) Show quoted text
> but a2p appears to only work on the simplest, shortest, awk scripts. > I'm wondering if perhaps it's even worth the trouble to fix these > issues, but then, if we can't use a2p, what is the alternative?
Silly idea: find a small group of CS students and make them work, as a project, on improving a2p. Note to self: I might even do this myself.
Subject: Re: [perl #31321] a2p fails to parse valid do-while loop in awk script
Date: Tue, 31 Aug 2004 09:43:05 -0600
To: perlbug-followup [...] perl.org
From: Keith Blackwell <keith [...] batky-howell.com>
Download (untitled) / with headers
text/plain 1.6k
Rafael Garcia-Suarez <rgarciasuarez@mandrakesoft.com> wrote: | keith (via RT) wrote: | > a2p fails to translate valid awk syntax, saying "syntax error". | | I think that a2p comes from the good old days of awk, before it evolves | into nawk and gawk. I'm not surprised limitations are found in it. Which | awk are you using ? I've used both gawk on linux and "nawk" (now just called "awk") on an SCO and HPUX system. I imagine I've probably just scratched the surface of a2p's limitations in this respect. | gee, there are still people who learn awk (and sed, I assume) before | perl :) I was an AWK hacker since the days when Larry Wall was known for "patch" instead of "perl". :-) Believe it or not, some of our student-clients *do* want to know AWK, but mainly for one-liners and such. They might change their mind once we show them what Perl can do, of course, but some of the folks wanting to learn AWK already know Perl! | Silly idea: find a small group of CS students and make them work, as a | project, on improving a2p. Note to self: I might even do this myself. Heh heh, that's what graduate students are for. But even though I'm in the field of "education" now, it's corporate-level technical instruction, not an academic insitution, so I don't have access to such free labor. If anyone wants to fix this, it could be useful for extending the life of complex AWK scripts (of which I have several), but it's not a real pressing need. I suppose that's true for almost everyone else (not an urgent need). So I don't have much hope of this getting fixed. Still, if you do it, let me know! :-) -- Keith W Blackwell
To: perl5-porters [...] perl.org
From: Zefram <zefram [...] fysh.org>
Date: Tue, 16 Jan 2018 22:05:48 +0000
Subject: Re: [perl #31321] a2p fails to parse valid do-while loop in awk script
Download (untitled) / with headers
text/plain 210b
a2p is no longer part of the Perl core distro, so this ticket should be closed. a2p is now maintained as a CPAN distro App-a2p; this bug could be sensibly re-reported to its bug queue at rt.cpan.org. -zefram
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 346b
On Tue, 16 Jan 2018 14:06:06 -0800, zefram@fysh.org wrote: Show quoted text
> a2p is no longer part of the Perl core distro, so this ticket should > be closed. a2p is now maintained as a CPAN distro App-a2p; this bug > could be sensibly re-reported to its bug queue at rt.cpan.org. > > -zefram
https://rt.cpan.org/Ticket/Display.html?id=124108 Closing. Tony


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org