Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

One more // syntax incompatibility

1 view
Skip to first unread message

Rafael Garcia-Suarez

unread,
Sep 12, 2002, 9:17:31 AM9/12/02
to perl5-...@perl.org
Not sure what's causing this... I'll investigate...

$ cat foo.pl
sub f($);
f $x / 2;
$ perl5.8.0 -c foo.pl
foo.pl syntax OK
$ bleadperl -c foo.pl
Search pattern not terminated at foo.pl line 2.

Andreas J. Koenig

unread,
Sep 12, 2002, 11:40:53 AM9/12/02
to Rafael Garcia-Suarez, perl5-...@perl.org

In the unlikely event that it helps you... it was indeed 17682

--
andreas

Rafael Garcia-Suarez

unread,
Sep 12, 2002, 11:59:04 AM9/12/02
to Andreas J. Koenig, perl5-...@perl.org
andreas...@anima.de (Andreas J. Koenig) wrote:
> > $ cat foo.pl
> > sub f($);
> > f $x / 2;
> > $ perl5.8.0 -c foo.pl
> > foo.pl syntax OK
> > $ bleadperl -c foo.pl
> > Search pattern not terminated at foo.pl line 2.
>
> In the unlikely event that it helps you... it was indeed 17682

Thanks very much. I think I've found the origin of the problem
(around line 3550 in toke.c).

BTW it was sensitive to whitespace.

$ perl5.8.0 -ce 'sub f ($) { } f $x / 2;'
-e syntax OK
$ perl5.8.0 -ce 'sub f ($) { } f $x /2;'
Search pattern not terminated at -e line 1.

I'll have to write more regression tests to restore perl 5.8.0's behaviour
as much as possible.

H.Merijn Brand

unread,
Sep 12, 2002, 12:11:19 PM9/12/02
to Rafael Garcia-Suarez, Perl 5 Porters
On Thu 12 Sep 2002 17:59, Rafael Garcia-Suarez <rgarci...@free.fr> wrote:
> andreas...@anima.de (Andreas J. Koenig) wrote:
> > > $ cat foo.pl
> > > sub f($);
> > > f $x / 2;
^

> > > $ perl5.8.0 -c foo.pl
> > > foo.pl syntax OK
> > > $ bleadperl -c foo.pl
> > > Search pattern not terminated at foo.pl line 2.
> >
> > In the unlikely event that it helps you... it was indeed 17682
>
> Thanks very much. I think I've found the origin of the problem
> (around line 3550 in toke.c).
>
> BTW it was sensitive to whitespace.
>
> $ perl5.8.0 -ce 'sub f ($) { } f $x / 2;'
> -e syntax OK
> $ perl5.8.0 -ce 'sub f ($) { } f $x /2;'
> Search pattern not terminated at -e line 1.

Which shows the opposite of the original post. Puzzled.

> I'll have to write more regression tests to restore perl 5.8.0's behaviour
> as much as possible.

--
H.Merijn Brand Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using perl-5.6.1, 5.8.0 & 633 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
WinNT 4, Win2K pro & WinCE 2.11. Smoking perl CORE: smo...@perl.org
http://archives.develooper.com/daily...@perl.org/ per...@perl.org
send smoke reports to: smokers...@perl.org, QA: http://qa.perl.org


Rafael Garcia-Suarez

unread,
Sep 12, 2002, 12:18:20 PM9/12/02
to H.Merijn Brand, perl5-...@perl.org
"H.Merijn Brand" <h.m....@hccnet.nl> wrote:
> On Thu 12 Sep 2002 17:59, Rafael Garcia-Suarez <rgarci...@free.fr> wrote:
> > andreas...@anima.de (Andreas J. Koenig) wrote:
> > > > $ cat foo.pl
> > > > sub f($);
> > > > f $x / 2;
> ^
> > > > $ perl5.8.0 -c foo.pl
> > > > foo.pl syntax OK
> > > > $ bleadperl -c foo.pl
> > > > Search pattern not terminated at foo.pl line 2.
> > >
> > > In the unlikely event that it helps you... it was indeed 17682
> >
> > Thanks very much. I think I've found the origin of the problem
> > (around line 3550 in toke.c).
> >
> > BTW it was sensitive to whitespace.
> >
> > $ perl5.8.0 -ce 'sub f ($) { } f $x / 2;'
> > -e syntax OK
> > $ perl5.8.0 -ce 'sub f ($) { } f $x /2;'
> > Search pattern not terminated at -e line 1.
>
> Which shows the opposite of the original post. Puzzled.

Read it again.

H.Merijn Brand

unread,
Sep 12, 2002, 12:38:07 PM9/12/02
to Rafael Garcia-Suarez, Perl 5 Porters

OK. Understood. (My 5.8.0 has 17682, 17690, and 17777)

l1:/pro/3gl/CPAN 148 > perl5.6.1 -ce 'sub f ($) { } f $x / 2;'
-e syntax OK
l1:/pro/3gl/CPAN 149 > perl5.8.0 -ce 'sub f ($) { } f $x / 2;'


Search pattern not terminated at -e line 1.

Exit 255
l1:/pro/3gl/CPAN 150 > perl5.9.0 -ce 'sub f ($) { } f $x / 2;'


Search pattern not terminated at -e line 1.

Exit 255
l1:/pro/3gl/CPAN 151 > perl5.6.1 -ce 'sub f ($) { } f $x /2;'


Search pattern not terminated at -e line 1.

Exit 255
l1:/pro/3gl/CPAN 152 > perl5.8.0 -ce 'sub f ($) { } f $x /2;'


Search pattern not terminated at -e line 1.

Exit 255
l1:/pro/3gl/CPAN 153 > perl5.9.0 -ce 'sub f ($) { } f $x /2;'


Search pattern not terminated at -e line 1.

Exit 255
l1:/pro/3gl/CPAN 154 > perl5.6.1 -ce 'sub f ($) { } f ($x / 2);'
-e syntax OK
l1:/pro/3gl/CPAN 155 > perl5.8.0 -ce 'sub f ($) { } f ($x / 2);'
-e syntax OK
l1:/pro/3gl/CPAN 156 > perl5.9.0 -ce 'sub f ($) { } f ($x / 2);'
-e syntax OK
l1:/pro/3gl/CPAN 157 > perl5.6.1 -ce 'sub f ($) { } f ($x /2);'
-e syntax OK
l1:/pro/3gl/CPAN 158 > perl5.8.0 -ce 'sub f ($) { } f ($x /2);'
-e syntax OK
l1:/pro/3gl/CPAN 159 > perl5.9.0 -ce 'sub f ($) { } f ($x /2);'
-e syntax OK
l1:/pro/3gl/CPAN 160 >

Brent Dax

unread,
Sep 12, 2002, 12:40:57 PM9/12/02
to Rafael Garcia-Suarez, perl5-...@perl.org
Rafael Garcia-Suarez:
# Not sure what's causing this... I'll investigate...
#
# $ cat foo.pl
# sub f($);
# f $x / 2;
# $ perl5.8.0 -c foo.pl
# foo.pl syntax OK
# $ bleadperl -c foo.pl
# Search pattern not terminated at foo.pl line 2.

In (I think) the part of toke.c that handles lookahead after scalars,
there's a big if/else if with lookaheads to decide if the next thing is
a term or an operator (so it can decide if we're using an indirect
object). Apparently another case needs to be added to that.

--Brent Dax <bren...@cpan.org>
@roles=map {"Parrot $_"} qw(embedding regexen Configure)

"In other words, it's the 'Blow up this Entire Planet and Possibly One
or Two Others We Noticed on our Way Out Here' operator."
--Damian Conway

Rafael Garcia-Suarez

unread,
Sep 12, 2002, 4:50:01 PM9/12/02
to Brent Dax, perl5-...@perl.org
Brent Dax wrote:
> Rafael Garcia-Suarez:
> # Not sure what's causing this... I'll investigate...
> #
> # $ cat foo.pl
> # sub f($);
> # f $x / 2;
> # $ perl5.8.0 -c foo.pl
> # foo.pl syntax OK
> # $ bleadperl -c foo.pl
> # Search pattern not terminated at foo.pl line 2.
>
> In (I think) the part of toke.c that handles lookahead after scalars,
> there's a big if/else if with lookaheads to decide if the next thing is
> a term or an operator (so it can decide if we're using an indirect
> object). Apparently another case needs to be added to that.

You're right. Here's the fix (it mostly restores 5.8.0's behavior.)

Change 17900 by rgs@rgs-home on 2002/09/12 19:33:06

Fix a syntax incompatibility introduced by the // operator.
(Note that C<print $fh //> is still a syntax error, it
wasn't with perl 5.8.0.)

Affected files ...

.... //depot/perl/t/op/dor.t#3 edit
.... //depot/perl/toke.c#442 edit

Differences ...

==== //depot/perl/t/op/dor.t#3 (text) ====

@@ -10,7 +10,7 @@
package main;
require './test.pl';

-plan( tests => 25 );
+plan( tests => 30 );

my($x);

@@ -59,3 +59,16 @@
eval "sub { $_ // 0 }";
is($@, '', "$_ // ... compiles");
}
+
+# Test for some ambiguous syntaxes
+
+eval q# sub f ($) { } f $x / 2; #;
+is( $@, '' );
+eval q# sub f ($):lvalue { $y } f $x /= 2; #;
+is( $@, '' );
+eval q# sub f ($) { } f $x /2; #;
+like( $@, qr/^Search pattern not terminated/ );
+eval q# sub { print $fh / 2 } #;
+is( $@, '' );
+eval q# sub { print $fh /2 } #;
+like( $@, qr/^Search pattern not terminated/ );

==== //depot/perl/toke.c#442 (text) ====

@@ -3554,14 +3554,9 @@
PL_expect = XTERM; /* e.g. print $fh .3 */
else if (strchr("?-+", *s) && !isSPACE(s[1]) && s[1] != '=')
PL_expect = XTERM; /* e.g. print $fh -1 */
- else if (*s == '/') {
- if(s[1] == '/') {
- PL_expect=XOPERATOR;
- }
- else {
- PL_expect=XTERM;
- }
- }
+ else if (*s == '/' && !isSPACE(s[1]) && s[1] != '=' && s[1] != '/')
+ PL_expect = XTERM; /* e.g. print $fh /.../
+ XXX except DORDOR operator */
else if (*s == '<' && s[1] == '<' && !isSPACE(s[2]) && s[2] != '=')
PL_expect = XTERM; /* print $fh <<"EOF" */
}

> "In other words, it's the 'Blow up this Entire Planet and Possibly One
> or Two Others We Noticed on our Way Out Here' operator."
> --Damian Conway

Is it ? ;-)

--
If strain on the lexer were a design criterion, I blew it long ago.
-- Larry Wall

h...@crypt.org

unread,
Sep 23, 2002, 12:17:58 PM9/23/02
to Rafael Garcia-Suarez, perl5-...@perl.org
Rafael Garcia-Suarez <rgarci...@free.fr> wrote:
:Change 17900 by rgs@rgs-home on 2002/09/12 19:33:06

:
: Fix a syntax incompatibility introduced by the // operator.
: (Note that C<print $fh //> is still a syntax error, it
: wasn't with perl 5.8.0.)
[...]
:+eval q# sub f ($) { } f $x /2; #;

:+like( $@, qr/^Search pattern not terminated/ );
:+eval q# sub { print $fh /2 } #;

:+like( $@, qr/^Search pattern not terminated/ );

These tests look strange to me: can you explain why C< f $x /2 > should
be a syntax error, but not C< f 1 /2 >?

Hugo

Rafael Garcia-Suarez

unread,
Sep 24, 2002, 3:17:45 AM9/24/02
to h...@crypt.org, perl5-...@perl.org

For backward compatibility with the indirect object notation :
(the perl parser has to make some guesses on this rather ambiguous
syntax and this should not be modified in a incompatible way)

$ perl -MO=Deparse -e 'f $x /2/'
$x->f(/2/);

0 new messages