Skip Menu |
 

This queue is for tickets about the Regexp-Grammars CPAN distribution.

Report information
The Basics
Id: 124825
Status: rejected
Priority: 0/
Queue: Regexp-Grammars

People
Owner: Nobody in particular
Requestors: alexchandel [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Subrule returns empty string instead of value with MATCH
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Message-ID: <rt-4.0.18-5461-1521489800-1819.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 590
Download (untitled) / with headers
text/plain 590b
When a subrule with a 0-or-more list fails matches 0 elements, and assigns that match to MATCH, an empty string is returned to the calling rule, rather than the value the expression (undef in this case, although an empty array would make more sense). <nocontext:> <token: decls> <[MATCH=decl]>* <token: body> <decls> Note that this does NOT happen with an explicit, separate MATCH tag: <nocontext:> <token: decls> <[decl]>* <MATCH=(?{ $MATCH{decl} })> <token: body> <decls> This may indicate an issue with the implementation of MATCH in a list-like subrule call.
MIME-Version: 1.0
X-Spam-Status: No, score=-5.356 tagged_above=-99.9 required=10 tests=[AWL=-0.123, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, FROM_OUR_RT=-4, HTML_MESSAGE=0.001, SPF_SOFTFAIL=0.665] autolearn=ham
In-Reply-To: <rt-4.0.18-5461-1521489800-1472.124825-4-0 [...] rt.cpan.org>
X-Cpan.org: This message routed through the cpan.org mail forwarding service. Please use PAUSE pause.perl.org to configure your delivery settings.
X-Spam-Flag: NO
X-RT-Interface: API
References: <RT-Ticket-124825 [...] rt.cpan.org> <rt-4.0.18-5461-1521489800-1472.124825-4-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Received: by 10.46.117.12 with SMTP id q12mr9555344ljc.65.1521501384329; Mon, 19 Mar 2018 16:16:24 -0700 (PDT)
Message-ID: <CAATtAp7jO-76D9YThh3GOaVXou4nKkp89v=bZqWpQkbdW0bR+w [...] mail.gmail.com>
Content-Type: multipart/alternative; boundary="089e082b131489cfc60567cc25e7"
X-Spam-Score: -5.356
X-Google-SMTP-Source: AG47ELvLz1yqhydgtKSO9pW917kXPKQrCzNLAGwAd+1324QWlapv0Oe18XJoSQruH14EQCtG1Ko6mvINHSdsV4DMS/g=
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] gmail.com
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 1B3C1240279 for <cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com>; Mon, 19 Mar 2018 19:16:42 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7Dh63vcgbTBO for <cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com>; Mon, 19 Mar 2018 19:16:40 -0400 (EDT)
Received: from xx1.develooper.com (xx1.develooper.com [207.171.7.115]) by hipster.bestpractical.com (Postfix) with ESMTPS id A5CAB24011F for <bug-Regexp-Grammars [...] rt.cpan.org>; Mon, 19 Mar 2018 19:16:39 -0400 (EDT)
Received: from localhost (xx1.develooper.com [127.0.0.1]) by localhost (Postfix) with ESMTP id 0980F11F23E for <bug-Regexp-Grammars [...] rt.cpan.org>; Mon, 19 Mar 2018 16:16:38 -0700 (PDT)
Received: from xx1.develooper.com (xx1.develooper.com [127.0.0.1]) by localhost (Postfix) with SMTP id 69D0411ED8A for <bug-Regexp-Grammars [...] rt.cpan.org>; Mon, 19 Mar 2018 16:16:35 -0700 (PDT)
Received: from mail-lf0-f41.google.com (mail-lf0-f41.google.com [209.85.215.41]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by xx1.develooper.com (Postfix) with ESMTPS id 22D5511FB34 for <bug-Regexp-Grammars [...] rt.cpan.org>; Mon, 19 Mar 2018 16:16:26 -0700 (PDT)
Received: by mail-lf0-f41.google.com with SMTP id o102-v6so5381268lfg.8 for <bug-Regexp-Grammars [...] rt.cpan.org>; Mon, 19 Mar 2018 16:16:26 -0700 (PDT)
Received: by 10.46.151.25 with HTTP; Mon, 19 Mar 2018 16:15:43 -0700 (PDT)
Delivered-To: cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #124825] Subrule returns empty string instead of value with MATCH
Return-Path: <thoughtstream [...] gmail.com>
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to; bh=KtcJA4lZFsR8Sfd8rktmHAEtWYrX6wzY91308H99E+k=; b=B8WZDJxiANhlhR2fB3eXmZNZsn31kPg/s5P9/VqiL3ygltrEgoYPT181xOX2+VuhIj V5rc2E4nIjaN2IrueKWaRVEY2eoHVHCnU51GnNN6JyksKueq6/I+mSUBRyJFlcZCYLCd 1Duv22JFd/gJCxJ37zksC3WacAiiPxXkb38Tl2HelCc3p2I2apG1q+wYCOyNPY373am4 BzbjoydmzB9ghpB4Z9YKjRr/LbXxwjUk0XHOy8EPWpDoYqIrnbIa9yUEEGU7R3HUGsAK hdW9wckf2NMNThzLmHWpbNvgbF/PlPYh24Z4Xy/hHtxkPxnKQrEyEyYCIe3ZpZJLykpm yAjw==
X-Original-To: cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com
X-RT-Mail-Extension: regexp-grammars
X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to; bh=KtcJA4lZFsR8Sfd8rktmHAEtWYrX6wzY91308H99E+k=; b=LC/XIzUg+Iaqo0Iz9FuBYUoUBusqKb9ySDfYVN1GeE6bDX9860OFBxP4jPXWE7bEHH DqQI+44fNMbr26NDgchAHMfEjTI/049beodYzwgtKw5tww79+yM+uXKwgOGsGKL8ktVf ksSnVfw1Jx5rNgvidzFZmil+mFeeeNSRveha0szP4b8UO5vaqiANQesWw2W4pmYL9fnM y71mqOPwTBj3CIpVQqXTVLz/ahpOQ/lOZYmXyTdqzkJbRmpTqzjaz5qcZBf9T5lYnFmM cfJPbDlUzL1LAXGUlXnG61qeADEvKLi4uJcukUu3MGO4Tt5LZaJQF+VttYJA62axVruh wfuA==
X-Google-Sender-Auth: bvPOy1mXFBLDg7jxBkIIw2n-uuo
Sender: thoughtstream [...] gmail.com
Date: Tue, 20 Mar 2018 10:15:43 +1100
X-PMX-Spam: Gauge=X, Probability=10%, Report=' WEBMAIL_REPLYTO_NOT_FROM 0.5, HTML_NO_HTTP 0.1, BODYTEXTH_SIZE_10000_LESS 0, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DKIM_SIGNATURE 0, IN_REP_TO 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, NO_URI_HTTPS 0, REFERENCES 0, SPF_PASS 0, WEBMAIL_SOURCE 0, __ANY_URI 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_ALT 0, __DQ_NEG_HEUR 0, __DQ_NEG_IP 0, __FRAUD_COMMON 0, __FRAUD_MONEY_CURRENCY 0, __FRAUD_MONEY_CURRENCY_DOLLAR 0, __FRAUD_REFNUM 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_SENDER 0, __HAS_FROM 0, __HAS_HTML 0, __HAS_MSGID 0, __HELO_GMAIL 0, __HEX28_LC_BOUNDARY 0, __HIGHBITS 0, __HTML_TAG_DIV 0, __IN_REP_TO 0, __MIME_HTML 0, __MIME_TEXT_H 0, __MIME_TEXT_H1 0, __MIME_TEXT_H2 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MIME_TEXT_P2 0, __MIME_VERSION 0, __PHISH_SPEAR_HTTP_RECEIVED 0, __PHISH_SPEAR_STRUCTURE_1 0, __PHISH_SPEAR_STRUCTURE_2 0, __RDNS_GMAIL 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_NEGATE 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_MAILTO 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 0, __zen.spamhaus.org_ERROR '
X-Spam-Level:
X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2018.3.19.230616
To: bug-Regexp-Grammars [...] rt.cpan.org
X-GM-Message-State: AElRT7E4iUCz6IsUeWrEOq9GZxnAhZTotE9NB8tNpkDvdVOEbS7Tzocs Db9vjTMsn/PV5TR5NWHwQt64kP7zgkDHNPQa0yZtWQ==
From: Damian Conway <damian [...] conway.org>
RT-Message-ID: <rt-4.0.18-4473-1521501403-1309.124825-0-0 [...] rt.cpan.org>
Content-Length: 0
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
Content-Length: 1094
Hi Alex, Thanks for the report, but (in my view) this is not a bug; it's the defined behaviour...albeit, perhaps a surprising one. You're assuming that: <[MATCH=decl]>* is a shorthand for: <[decl]>* <MATCH=(?{ $MATCH{decl} })> Although that is entire plausible, it's not the case. It's actually a shorthand for: (?: (<decl>) (?{ $MATCH = [] unless ref($MATCH) eq 'ARRAY'; push @$MATCH, $CAPTURE }) )* In other words, each time the <[decl]> subtoken matches, what it matches is pushed onto the $MATCH, converting it to an arrayref on the first occasion. But when the zero-or-more quantifier matches zero times, the trailing code is never executed, so the default value of $MATCH (an empty string) is never modified. I don't propose to change that behaviour, but I will add a caveat to the documentation pointing it out. Meanwhile, the workaround is to set up the default return value you want yourself, either using the variant you included in your report, or else with: (?{ $MATCH = [] }) <[decl]>* I'm sorry for the trouble this caused you. Damian
content-type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: utf-8
Content-Length: 1539
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-4473-1521501403-1309.124825-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: API
References: <RT-Ticket-124825 [...] rt.cpan.org> <rt-4.0.18-5461-1521489800-1472.124825-4-0 [...] rt.cpan.org> <CAATtAp7jO-76D9YThh3GOaVXou4nKkp89v=bZqWpQkbdW0bR+w [...] mail.gmail.com> <rt-4.0.18-4473-1521501403-1309.124825-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-14200-1521588767-156.0-0-0 [...] rt.cpan.org>
Message-ID: <rt-4.0.18-14200-1521588767-437.124825-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
From: alexchandel [...] gmail.com
Content-Length: 1685
Download (untitled) / with headers
text/plain 1.6k
On Mon Mar 19 19:16:43 2018, damian@conway.org wrote: Show quoted text
> Hi Alex, > > Thanks for the report, but (in my view) this is not a bug; > it's the defined behaviour...albeit, perhaps a surprising one. > > You're assuming that: > > <[MATCH=decl]>* > > is a shorthand for: > > <[decl]>* <MATCH=(?{ $MATCH{decl} })> > > Although that is entire plausible, it's not the case. > It's actually a shorthand for: > > (?: (<decl>) (?{ $MATCH = [] unless ref($MATCH) eq 'ARRAY'; push > @$MATCH, $CAPTURE }) )* > > In other words, each time the <[decl]> subtoken matches, > what it matches is pushed onto the $MATCH, converting it > to an arrayref on the first occasion. > > But when the zero-or-more quantifier matches zero times, > the trailing code is never executed, so the default value of $MATCH > (an empty string) is never modified. > > I don't propose to change that behaviour, but I will add a caveat > to the documentation pointing it out. > > Meanwhile, the workaround is to set up the default return value you want > yourself, either using the variant you included in your report, or else > with: > > (?{ $MATCH = [] }) > <[decl]>* > > I'm sorry for the trouble this caused you. > > Damian
Hi Damian, Thank you for the default value tip, I didn't realize it was possible to do something like that! With regards to $MATCH returning an empty string when the zero-or-like quantifier matches zero times, why does something like this: <nocontext:> <token: decls> <[decl]>* <token: body> <decls> result in <[decl]> being undef when it matches zero times, while the default $MATCH for <[decl]> is an empty string when it matches zero times?
MIME-Version: 1.0
X-Spam-Status: No, score=-5.356 tagged_above=-99.9 required=10 tests=[AWL=-0.123, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, FROM_OUR_RT=-4, HTML_MESSAGE=0.001, SPF_SOFTFAIL=0.665] autolearn=ham
In-Reply-To: <rt-4.0.18-14200-1521588767-1792.124825-5-0 [...] rt.cpan.org>
X-Cpan.org: This message routed through the cpan.org mail forwarding service. Please use PAUSE pause.perl.org to configure your delivery settings.
X-Spam-Flag: NO
X-RT-Interface: API
References: <RT-Ticket-124825 [...] rt.cpan.org> <rt-4.0.18-5461-1521489800-1472.124825-4-0 [...] rt.cpan.org> <CAATtAp7jO-76D9YThh3GOaVXou4nKkp89v=bZqWpQkbdW0bR+w [...] mail.gmail.com> <rt-4.0.18-4473-1521501403-1309.124825-5-0 [...] rt.cpan.org> <rt-4.0.18-14200-1521588767-1792.124825-5-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Received: by 2002:a19:f24c:: with SMTP id d12-v6mr1115039lfk.111.1521601068505; Tue, 20 Mar 2018 19:57:48 -0700 (PDT)
Message-ID: <CAATtAp77rKRY_MMiW5XotnUavfUmbeQuK2ddh75dwkqO8TOqWQ [...] mail.gmail.com>
Content-Type: multipart/alternative; boundary="0000000000002da22c0567e35b99"
X-Spam-Score: -5.356
X-Google-SMTP-Source: AG47ELv0emWQJsNJCP2OrDt+44Cey/E4CwsK7JEixcMu0gn6ruKVpg+w3OxKDC47RyTBWObjV1M+hK01l7+9+FXG67Q=
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] gmail.com
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 1A4C32402E3 for <cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com>; Tue, 20 Mar 2018 22:57:58 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id adXSWfprM3AV for <cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com>; Tue, 20 Mar 2018 22:57:56 -0400 (EDT)
Received: from xx1.develooper.com (xx1.develooper.com [207.171.7.115]) by hipster.bestpractical.com (Postfix) with ESMTPS id 40C5D24024A for <bug-Regexp-Grammars [...] rt.cpan.org>; Tue, 20 Mar 2018 22:57:55 -0400 (EDT)
Received: from localhost (xx1.develooper.com [127.0.0.1]) by localhost (Postfix) with ESMTP id D566F11D41B for <bug-Regexp-Grammars [...] rt.cpan.org>; Tue, 20 Mar 2018 19:57:54 -0700 (PDT)
Received: from xx1.develooper.com (xx1.develooper.com [127.0.0.1]) by localhost (Postfix) with SMTP id 74D1911D8BE for <bug-Regexp-Grammars [...] rt.cpan.org>; Tue, 20 Mar 2018 19:57:52 -0700 (PDT)
Received: from mail-lf0-f42.google.com (mail-lf0-f42.google.com [209.85.215.42]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by xx1.develooper.com (Postfix) with ESMTPS id 7132311D41B for <bug-Regexp-Grammars [...] rt.cpan.org>; Tue, 20 Mar 2018 19:57:50 -0700 (PDT)
Received: by mail-lf0-f42.google.com with SMTP id y2-v6so5677177lfc.5 for <bug-Regexp-Grammars [...] rt.cpan.org>; Tue, 20 Mar 2018 19:57:50 -0700 (PDT)
Received: by 10.46.151.25 with HTTP; Tue, 20 Mar 2018 19:57:08 -0700 (PDT)
Delivered-To: cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #124825] Subrule returns empty string instead of value with MATCH
Return-Path: <thoughtstream [...] gmail.com>
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to; bh=Bq/h1PfBg7HEKQGFZgDLFjuJsY1AGy/O72RHP8G7Dh0=; b=lSZ4yLySDE9dXqMhkPDs+WxigG+rQzZb+4/1CtQvNLOSikOZviiW4LB5oQYchML36u BJ2eQJlHzwJuafm5kFYUwoseohXDuhxajomsotK+9hSTq70WKcu2X4qWL/ANfVnV2kAR fmSU9SpWzMejuyu67m6wMUARC6GbknpT51MQ4YNb7lgMo8+c/gyv6NXpEBacSZ9mcUYd h5RQGeYfUkXVUy1VmfMUp/9GfF2s3DlMXv0GaljEvrehcKOZpz96e9hFDYLPvfhhZhA8 BSa1tKSVtuiyVTQDRO84gvNYrvoGtzic9QL0diPINUqUJ8vgtWHcPmIqtQ1p2MEmhs7P d16Q==
X-Original-To: cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com
X-RT-Mail-Extension: regexp-grammars
X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to; bh=Bq/h1PfBg7HEKQGFZgDLFjuJsY1AGy/O72RHP8G7Dh0=; b=K1BpgpD8h1JUZOMRbC1t2e6m4ukX+iPbDqoq43OEUiqmHrOQjEJfdT94fHRAvGOtFg Z+ChMLP/4oq0HP9kKZdhzzYysHXBTndS4zS4PN9tTxaTyN6uPCMOfXKgsC4ToMucOowX mZriMXxpHmrIqoue21hQ5pLVEGlirba0EgWPGvXy6VC3leswGGPKS+s5AKdA8uVeUtc4 RdHUuF5WHuTg00pj/qhmLkloTyVQprDO36HQIoVZ9ssSc0nXOniVd3QEEe2CXjzBODkd bcLsYCuzYYUDxayt4NfZ7t9b7i3X7ElyA+QIZ6N5roatuH0Ct+4TsQS3tMGn6VX2355Y Q9/w==
X-Google-Sender-Auth: nC_hjBA7kgNtlPrkL3iF6XlSZKE
Sender: thoughtstream [...] gmail.com
Date: Wed, 21 Mar 2018 13:57:08 +1100
X-PMX-Spam: Gauge=X, Probability=10%, Report=' WEBMAIL_REPLYTO_NOT_FROM 0.5, HTML_NO_HTTP 0.1, BODYTEXTH_SIZE_10000_LESS 0, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DKIM_SIGNATURE 0, IN_REP_TO 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, NO_URI_HTTPS 0, REFERENCES 0, SPF_PASS 0, WEBMAIL_SOURCE 0, __ANY_URI 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_ALT 0, __DQ_NEG_HEUR 0, __DQ_NEG_IP 0, __FORWARDED_MSG 0, __FRAUD_MONEY_CURRENCY 0, __FRAUD_MONEY_CURRENCY_DOLLAR 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_SENDER 0, __HAS_FROM 0, __HAS_HTML 0, __HAS_MSGID 0, __HELO_GMAIL 0, __HEX28_LC_BOUNDARY 0, __HIGHBITS 0, __HTML_TAG_DIV 0, __IN_REP_TO 0, __MIME_HTML 0, __MIME_TEXT_H 0, __MIME_TEXT_H1 0, __MIME_TEXT_H2 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MIME_TEXT_P2 0, __MIME_VERSION 0, __PHISH_SPEAR_HTTP_RECEIVED 0, __PHISH_SPEAR_STRUCTURE_1 0, __PHISH_SPEAR_STRUCTURE_2 0, __RDNS_GMAIL 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_NEGATE 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_MAILTO 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 0, __zen.spamhaus.org_ERROR '
X-Spam-Level:
X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2018.3.21.25116
To: bug-Regexp-Grammars [...] rt.cpan.org
X-GM-Message-State: AElRT7EKze+dNRHUpVVoRVElHcS0E84+9EmiAq1ZnQcH9ClMKoNAKFZ9 671w/cyvkOmkygtCCQMh5DAfXHLpwzjr3IqHCAylNg==
From: Damian Conway <damian [...] conway.org>
RT-Message-ID: <rt-4.0.18-18550-1521601079-838.124825-0-0 [...] rt.cpan.org>
Content-Length: 0
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
Content-Length: 830
Download (untitled) / with headers
text/plain 830b
Show quoted text
> With regards to $MATCH returning an empty string when the zero-or-like > quantifier matches zero times, why does something like this: > > <nocontext:> > <token: decls> > <[decl]>* > <token: body> > <decls> > > result in <[decl]> being undef when it matches zero times, > while the default $MATCH for <[decl]> is an empty string > when it matches zero times?
For more or less the same reason. The approximate translation of: <token: decls> <[decl]>* is: (?<decls> ( (?: ( (?&decl) ) (?{ push @{$MATCH{decl}}, $CAPTURE }) )* ) (?{ $MATCH //= $CAPTURE }) ) So, $MATCH{decl} is only autovivified if one or more of the subcalls succeeds, but $MATCH is set each time, even if the repetition matches zero times. Damian
content-type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: utf-8
Content-Length: 1156


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

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.