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

Report information
The Basics
Id:
69225
Status:
open
Priority:
Low/Low

People
Owner:
Nobody in particular
Requestors:
lhebblethwaite [...] btinternet.com
Cc:
AdminCc:

BugTracker
Severity:
(no value)
Broken in:
(no value)
Fixed in:
(no value)



Subject: <error: msg> does not appear
Date: Fri, 1 Jul 2011 11:27:11 +0100 (BST)
To: "bug-Regexp-Grammars@rt.cpan.org" <bug-Regexp-Grammars@rt.cpan.org>
From: Leigh Hebblethwaite <lhebblethwaite@btinternet.com>
Hi,

Please excuse me if this is a daft question.

I have a simple grammar as an example. The grammar includes a <error:> directive. The grammar seems to be correct in that it succeeds when it should and fails when it should. However, the error message is never output.

I don't know whether this is a user error or a problem with the module.

Here is the grammar:

    my $parser = qr{
        <dml_proc>

        <rule: dml_proc>  dml <name> <dml_attr> end-dml

        <rule: dml_attr>  current_of_cursor
                          | has_returning
                          | uses_current_user
                          | <error: Invalid attribute>

        <token: name>     [A-Za-z0-9_]+
    }xms;

Tested with the string "dml aname has_returning end-dml" the parse succeeds as it should.

Tested with the string "dml aname xxxx end-dml" the parse fails as it should. I would expect to see an error message produced by the <error: > directive as 'xxxx' does not match any of the possible attributes. I don't see this error message.

I am using Regexp::Grammars 1.012 on ActivePerl on Windows XP. Here is the 1st line output by 'perl -v': This is perl 5, version 12, subversion 3 (v5.12.3) built for MSWin32-x86-multi-thread

I attach a short script which demonstrates the problem.

Thank you for your attention. Any help is very much appreciated.

Regards,
Leigh.

Message body is not shown because sender requested not to inline it.

Subject: Re: [rt.cpan.org #69225] <error: msg> does not appear
Date: Fri, 1 Jul 2011 21:11:05 +1000
To: bug-Regexp-Grammars@rt.cpan.org
From: Damian Conway <damian@conway.org>
Hi Leigh, The module documentation explains how to access the error messages, which appear in the special @! variable: Error messages The "<error: MSG>" directive queues a conditional error message within @! and the demonstration files demo/demo_error.pl and demo/demo_pos.pl illustrate how to print the error messages. For example, in demo/demo_pos.pl: while (my $input = prompt) { if ($input =~ $grammar) { use Data::Show; show %/; } else { say 'Failed: '; say for @!; <----- This line prints the error messages if the grammar fails } } I will look at improving the documentation to make it clearer that this is how the error message interface works. Thanks for the feedback, Damian
Subject: Re: [rt.cpan.org #69225] <error: msg> does not appear
Date: Fri, 1 Jul 2011 12:41:17 +0100 (BST)
To: "bug-Regexp-Grammars@rt.cpan.org" <bug-Regexp-Grammars@rt.cpan.org>
From: Leigh Hebblethwaite <lhebblethwaite@btinternet.com>
Thanks Damian, That's a really quick response!

I missed the significance of @!. Thanks for putting me right.

Regards,
Leigh.


From: "damian@conway.org via RT" <bug-Regexp-Grammars@rt.cpan.org>
To: lhebblethwaite@btinternet.com
Sent: Friday, 1 July 2011, 12:11
Subject: Re: [rt.cpan.org #69225] <error: msg> does not appear

<URL: https://rt.cpan.org/Ticket/Display.html?id=69225 >

Hi Leigh,

The module documentation explains how to access the error messages,
which appear in the special @! variable:

    Error messages

      The "<error: MSG>" directive queues a conditional error message within @!

and the demonstration files demo/demo_error.pl and demo/demo_pos.pl
illustrate how to print the error messages. For example, in demo/demo_pos.pl:

    while (my $input = prompt) {
        if ($input =~ $grammar) {
            use Data::Show;
            show %/;
        }
        else {
            say 'Failed: ';
            say for @!;      <----- This line prints the error
messages if the grammar fails
        }
    }

I will look at improving the documentation to make it clearer that
this is how the
error message interface works.

Thanks for the feedback,

Damian





This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

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