Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apparent parsing error with not(arg) #670

Closed
p5pRT opened this issue Oct 1, 1999 · 2 comments
Closed

apparent parsing error with not(arg) #670

p5pRT opened this issue Oct 1, 1999 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 1, 1999

Migrated from rt.perl.org#1550 (status was 'resolved')

Searchable as RT1550$

@p5pRT
Copy link
Author

p5pRT commented Oct 1, 1999

From sburke@netadventure.net

This
  print grep(not($_), 0,'', 0.0, 1,11),
generates a syntax error​:
  Not enough arguments for grep at - line 1, near "11)"

Of course, I simply do this instead​:
  print grep(!($_), 0,'', 0.0, 1,11),
which works fine, as does
  print grep { not($_) } 0,'', 0.0, 1,11,

Perlop says not() is the equivalent of "!" except for the very low
precedence. Since it's unary, and I'm providing parens, predecence
seems irrelevent here. I once mentioned this to Tom a long time ago,
and he mentioned something involving the difference between parsing
functions (as I wished to pretend not(ARG) is) and parsing operators
(which not() really is), but it all rather went over my head.

Here's my version info​:
ttyp5 sburke ~ stonehenge 21​: perl -V
Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration​:
  Platform​:
  osname=bsdos, osvers=3.0, archname=i386-bsdos
  uname='bsdos stonehenge.netadventure.com 3.0 bsdi bsdos 3.0 kernel #0​: mon jul 28 00​:40​:29 pdt 1997 ken@​stonehenge.netadventure.com​:usrsrcsyscompilelocal i386 '
  hint=recommended, useposix=true, d_sigaction=define
  bincompat3=y useperlio=undef d_sfio=undef
  Compiler​:
  cc='shlicc2', optimize='-O2', gccversion=2.7.2.1
  cppflags='-I/usr/local/include'
  ccflags ='-I/usr/local/include'
  stdchar='char', d_stdstdio=undef, usevfork=false
  voidflags=15, castflags=0, d_casti32=define, d_castneg=define
  intsize=4, alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries​:
  ld='shlicc2', ldflags =' -L/usr/X11/lib -L/usr/local/lib'
  libpth=/usr/local/lib /usr/shlib /shlib /usr/lib /usr/X11/lib
  libs=-lrpc -lcurses -ltermcap -lXpm -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11 -ldl -lm -lc
  libc=/usr/lib/libc.a, so=o
  useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=o, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags='-r -L/usr/X11/lib -L/usr/local/lib'

Characteristics of this binary (from libperl)​:
  Built under bsdos
  Compiled at Dec 31 1997 19​:45​:20
  @​INC​:
  /usr/local/lib/perl5/i386-bsdos/5.00404
  /usr/local/lib/perl5
  /usr/local/lib/perl5/site_perl/i386-bsdos
  /usr/local/lib/perl5/site_perl
  .

I get identical results on a box with this config info​:

lachler ~ musca​:pts/24 3​: perl -V
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration​:
  Platform​:
  osname=aix, osvers=4.3.1.0, archname=aix
  uname='aix pegasus 3 4 000165185700 '
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=undef useperlio=undef d_sfio=undef
  Compiler​:
  cc='cc', optimize='-O', gccversion=
  cppflags='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -qmaxmem=8192 -I/usr/local/include -I/usr/local/gnu/include'
  ccflags ='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -qmaxmem=8192 -I/usr/local/include -I/usr/local/gnu/include'
  stdchar='unsigned char', d_stdstdio=define, usevfork=false
  intsize=4, longsize=4, ptrsize=4, doublesize=8
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
  alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries​:
  ld='ld', ldflags ='-L/usr/local/lib -L/usr/local/gnu/lib -L/usr/ccs/lib -L/lib'
  libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib /usr/local/gnu/lib
  libs=-lnsl -lgdbm -ldbm -ldl -lld -lm -lc -lcrypt -lbsd -lPW
  libc=, so=a, useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_aix.xs, dlext=so, d_dlsymun=undef, ccdlflags='-bE​:perl.exp'
  cccdlflags=' ', lddlflags='-bhalt​:4 -bM​:SRE -bI​:$(PERL_INC)/perl.exp -bE​:$(BASEEXT).exp -b noentry -lc -L/usr/local/lib -L/usr/local/gnu/lib -L/usr/ccs/lib -L/lib'

Characteristics of this binary (from libperl)​:
  Built under aix
  Compiled at Aug 12 1999 09​:10​:29
  %ENV​:
  PERLLIB="/nfs/user/l/lachler/.bin/perl"
  @​INC​:
  /nfs/user/l/lachler/.bin/perl
  /usr/local/gnu/lib/perl5/5.00503/aix
  /usr/local/gnu/lib/perl5/5.00503
  /usr/local/gnu/lib/perl5/site_perl/5.005/aix
  /usr/local/gnu/lib/perl5/site_perl/5.005
  .

And even on MacPerl 5.2.0r4 (patchlevel 5.004) with the following -V​:
Summary of my ( patchlevel 0 subversion ) configuration​:
  Platform​:
  osname=MacOS, osvers=7.5, archname=
  uname=''
  hint=, useposix=true, d_sigaction=
  bincompat3= useperlio= d_sfio=
  Compiler​:
  cc='C', optimize='', gccversion=
  cppflags=''
  ccflags =''
  stdchar='', d_stdstdio=define, usevfork=
  voidflags=, castflags=0, d_casti32=32, d_castneg=define
  intsize=32, alignbytes=, usemymalloc=, randbits=
  Linker and Libraries​:
  ld='', ldflags =''
  libpth=
  libs=
  libc=, so=
  useshrplib=, libperl=
  Dynamic Linking​:
  dlsrc=, dlext=, d_dlsymun=, ccdlflags=''
  cccdlflags='', lddlflags=''

Characteristics of this binary (from libperl)​:
  Compile-time options​: MULTIPLICITY
  Built under MacOS
  Compiled at Apr 3 1998 21​:45​:13
  %ENV​:
  PERL5LIB="Slig​:MacPerl :site_perl,Slig​:MacPerl :lib,WebSites​:Sean,WebSites​:,Slig​:WIP Slig​:cgi-bin,Slig​:MacPerl :site_perl_dyna"
  @​INC​:
  Slig​:MacPerl :site_perl​:
  Slig​:MacPerl :lib​:MacPPC​:
  Slig​:MacPerl :lib​:
  WebSites​:Sean​:MacPPC​:
  WebSites​:Sean​:
  WebSites​:
  Slig​:WIP Slig​:cgi-bin​:
  Slig​:MacPerl :site_perl_dyna​:
  Slig​:MacPerl :lib​:MacPPC​:
  Slig​:MacPerl :lib​:
  Slig​:MacPerl :site_perl​:
  :
  Dev​:Pseudo​:

--
Sean M. Burke sburke@​netadventure.net http​://www.netadventure.net/~sburke/

@p5pRT
Copy link
Author

p5pRT commented Oct 6, 1999

From @TimToady

Sean M. Burke writes​:
: Not exactly an earth-shaking bug, but don't say I never told ya​:
:
: This
: print grep(not($_), 0,'', 0.0, 1,11),
: generates a syntax error​:
: Not enough arguments for grep at - line 1, near "11)"

Hmm. I wonder how many programs we'll break by fixing this.

Nevertheless, here's something resembling a patch, if we decide to
fix it.

Inline Patch
--- /kiev/src/perl5.005_61our/toke.c	Fri Sep 24 16:06:45 1999
+++ toke.c	Wed Oct  6 10:39:00 1999
@@ -120,7 +120,7 @@
  * LOOPX        : loop exiting command (goto, last, dump, etc)
  * FTST         : file test operator
  * FUN0         : zero-argument function
- * FUN1         : not used
+ * FUN1         : not used, except for not, which isn't a UNIOP
  * BOop         : bitwise or or xor
  * BAop         : bitwise and
  * SHop         : shift operator
@@ -4096,7 +4104,10 @@
 	    OPERATOR(USE);
 
 	case KEY_not:
-	    OPERATOR(NOTOP);
+	    if (*s == '(' || (s = skipspace(s), *s == '('))
+		FUN1(NOTOP);
+	    else
+		OPERATOR(NOTOP);
 
 	case KEY_open:
 	    s = skipspace(s);

Larry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant