Message from discussion
, 'sub_name' ] syntax
Received: by 10.58.125.106 with SMTP id mp10mr4484687veb.33.1348649162233;
Wed, 26 Sep 2012 01:46:02 -0700 (PDT)
X-BeenThere: marpa-parser@googlegroups.com
Received: by 10.52.36.237 with SMTP id t13ls764941vdj.3.gmail; Wed, 26 Sep
2012 01:46:02 -0700 (PDT)
Received: by 10.58.132.238 with SMTP id ox14mr4894366veb.15.1348649161990;
Wed, 26 Sep 2012 01:46:01 -0700 (PDT)
Received: by 10.58.132.238 with SMTP id ox14mr4894365veb.15.1348649161979;
Wed, 26 Sep 2012 01:46:01 -0700 (PDT)
Return-Path: <peter.stuifz...@gmail.com>
Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179])
by gmr-mx.google.com with ESMTPS id s13si133986vde.2.2012.09.26.01.46.01
(version=TLSv1/SSLv3 cipher=OTHER);
Wed, 26 Sep 2012 01:46:01 -0700 (PDT)
Received-SPF: pass (google.com: domain of peter.stuifz...@gmail.com designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of peter.stuifz...@gmail.com designates 209.85.220.179 as permitted sender) smtp.mail=peter.stuifz...@gmail.com; dkim=pass header...@gmail.com
Received: by vcbf13 with SMTP id f13so351370vcb.38
for <marpa-parser@googlegroups.com>; Wed, 26 Sep 2012 01:46:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:date:message-id:subject:from:to
:content-type:content-transfer-encoding;
bh=wqtQgW/zxHZaCmQEEXejrm+MS7c3UxESqKvl+bFxUyc=;
b=SJ+hWmFraiMPISufwz6wA4uk+WZNRBjL8KvaROjA+28UaIINWm2i3BiAIzGVlkNm8H
/EcY12kfHblllQAu43IVQA/w93FfWPkLa9jyxwE0DZ9dgtZ/kTcbODp3jiBIiO8cT7Y/
doBtUHSOnZTCbtEfaPsfIY6oCaj9ufJ7lZ/MBRbMGt5b4Rebwf3mDgs+QrtlXCYv4QFy
cpnCNmj+lz90epecFXmwEGD0zRFTmesEOJGtmaMXdOuP8jM4/ll0UIbdQkl9mftyxiqd
zsVkoiLHDxtDRtKTci0Pl9GmFyMxv63Ucgs0G4CcHEhTXvVo7CclM61KUnVdbiDEigDp
STrw==
MIME-Version: 1.0
Received: by 10.58.179.39 with SMTP id dd7mr646677vec.2.1348649161802; Wed, 26
Sep 2012 01:46:01 -0700 (PDT)
Received: by 10.58.64.20 with HTTP; Wed, 26 Sep 2012 01:46:01 -0700 (PDT)
In-Reply-To: <70f87923-a4fa-493a-88f9-9d1f2100f241@googlegroups.com>
References: <0d3de2f1-582e-41a5-b774-a3914bb4f079@googlegroups.com>
<CAE05vi4RZT-B5EDQ0j72FYJNyj2z9mJBcEwEMvQUPNOQzcg...@mail.gmail.com>
<306ca23c-c65d-46de-99dd-ed544f55df07@googlegroups.com>
<CAE05vi4PWpoyu3QEFPOYpR4ghxqbFOvjZgUdP5hywRw4P6=...@mail.gmail.com>
<70f87923-a4fa-493a-88f9-9d1f2100f241@googlegroups.com>
Date: Wed, 26 Sep 2012 10:46:01 +0200
Message-ID: <CAE05vi7WEFYYc4zWdZL2=x_7nNtDNhYtxANSZJvdwPERQC0...@mail.gmail.com>
Subject: Re: [ lhs => [qw(symbol1 symbol2)], 'sub_name' ] syntax
From: Peter Stuifzand <peter.stuifz...@gmail.com>
To: marpa-parser@googlegroups.com
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
In Perl you can write these things in two ways. The =3D> operator is
called a fat comma, which can be used (almost?) everywhere where a
comma can be used. But on top of that the fat comma also stringifies
the left side. That would mean that
[ conditition =3D> [ qw(word) ] ]
is the same as
[ 'conditition', [ qw(word) ] ]
See this manpage:
http://perldoc.perl.org/perlop.html#Comma-Operator and
http://en.wikipedia.org/wiki/Fat_comma
--
Peter Stuifzand | peterstuifzand.nl | @pstuifzand
On Wed, Sep 26, 2012 at 10:39 AM, rns <sor...@gmail.com> wrote:
>
>
> On Wednesday, September 26, 2012 11:33:42 AM UTC+3, Peter Stuifzand wrote=
:
>>
>> No, it is documented. I even included a link to the documentation.
>> Method (2) is used in MarpaX::Simple::Lexer example.
>
> MarpaX::Simple::Lexer uses [ condition =3D> [qw(word)] ], a key/value pai=
r in
> a array (rather than hash) that seems to be undocumented.
>
>>
>>
>> --
>> Peter Stuifzand | peterstuifzand.nl | @pstuifzand
>>
>>
>> On Wed, Sep 26, 2012 at 10:29 AM, rns <sor...@gmail.com> wrote:
>> > So it's undocumented, unofficial and thus needs to be avoided, thanks
>> > for
>> > explaining.
>> >
>> > On Wednesday, September 26, 2012 11:23:05 AM UTC+3, Peter Stuifzand
>> > wrote:
>> >>
>> >> There are two ways to specify rules:
>> >>
>> >> 1. Hashes (key/value pairs)
>> >>
>> >> { lhs =3D> 'Term', rhs =3D> [qw/Term Add Term/], action =3D> 'do_=
add' }
>> >>
>> >>
>> >> 2. Arrays with short form syntax.
>> >>
>> >> https://metacpan.org/module/Marpa::R2::Grammar#Rule-descriptors-as-ar=
rays
>> >>
>> >> [ 'Term', [qw/Term Add Term/], 'do_add' ]
>> >>
>> >> So that would be:
>> >>
>> >> [ lhs, rhs, action ]
>> >>
>> >> where both rhs and action are optional. The rhs part should be an
>> >> array ref. You can't include more key/value type options in this
>> >> syntax. If you want that, you have to use the first method.
>> >>
>> >> --
>> >> Peter Stuifzand | peterstuifzand.nl | @pstuifzand
>> >>
>> >>
>> >> On Wed, Sep 26, 2012 at 10:11 AM, rns <sor...@gmail.com> wrote:
>> >> > Is _subj_ (used, e.g., in [1] Marpa-Simple-Lexer [1]) official?
>> >> >
>> >> > It worked for me in Marpa::R2 but will it be supported? I've found
>> >> > nothing
>> >> > about it in the R2's doc so it's probably not.
>> >> >
>> >> > A list of key/value pairs, e.g. [ lhs =3D> [qw(symbol1 symbol2)],
>> >> > action
>> >> > =3D>
>> >> > 'sub_name' ] doesn't work in R2 and probably shouldn't.
>> >> >
>> >> > I kind of like the terseness.
>> >> >
>> >> > [1]
>> >> >>
>> >> >> [ condition =3D> [qw(word)] ],
>> >> >> [ condition =3D> [qw(quoted)] ],
>> >> >> [ condition =3D> [qw(OPEN-PAREN SPACE? query SPACE?
>> >> >> CLOSE-PAREN)]
>> >> >> ],
>> >> >> [ condition =3D> [qw(NOT condition)] ],
>> >> >>
>> >> >> [ 'SPACE?' =3D> [] ],
>> >> >> [ 'SPACE?' =3D> [qw(SPACE)] ],
>> >> >
>> >> > =E2=80=94
>> >> >
>> >> > https://github.com/ruz/Marpa-Simple-Lexer/blob/master/examples/syno=
psis.pl