Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

37 lines (22 sloc) 0.824 kb
#! nqp
# test protoregexes in grammars
plan(7);
grammar ABC {
token TOP { <symbols> .* }
proto token symbols { <...> }
token symbols:sym<abc> { <sym> }
token symbols:sym<a> { <sym> }
token symbols:sym<bang> { $<sym>=['!'] }
token symbols:sym<===> { <sym> }
}
my $/ := ABC.parse('abcdef');
ok( ?$/ , 'successfully matched grammar' );
ok( $/ eq 'abcdef', 'successful string match' );
ok( $<symbols> eq 'abc', 'successful protoregex match');
ok( $<symbols><sym> eq 'abc', 'correct proto candidate match' );
$/ := ABC.parse('adef');
ok( ?$/ , 'successfully matched grammar' );
$/ := ABC.parse('xxx');
ok( !$/ , 'successfully failed protoregex match' );
$/ := ABC.parse('xxx', :rule<symbols>);
ok( !$/ , 'successfully failed protoregex match' );
Jump to Line
Something went wrong with that request. Please try again.