# New Ticket Created by  Martin Kjeldsen 
# Please include the string:  [perl #61308]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=61308 >


When using rules at least with <ws> overwritten, the rule also captures 
whitespace. Please see attached file for example.

It is tested with revision 33823.

Martin
grammar NG {
        rule TOP { ^ <line>+ $ };

        #whitespace rules is borrowed from pipp
        # Whitespace and comments
        token ws_char           { \h | \v }

        token singlelinecomment { [ '#' || '//' ] \N* }    # end of line 
comment like Unix shell and C++

        token multilinecomment  { '/*' .*?  '*/' }         # C-like multiline 
comment

        token ws_all {
                                <.ws_char>
                        | <.singlelinecomment>
                        | <.multilinecomment>
        }

        token ws {
                <.ws_all>*   
        }

        rule line {
                'default' \w+   
        }
};

my $str = 'default testtesttest
// this is a comment shouldn\'t be outputted';

$str ~~ NG;

die("No match") unless ~$/;

say $/<line>[0];

Reply via email to