Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Fix bug when protoregex is called directly from Grammar.parse (Coke++)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Dec 17, 2009
1 parent 503f76f commit 88757e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/Regex/Cursor-protoregex-peek.pir
Expand Up @@ -60,8 +60,8 @@ Perform a match for protoregex C<name>.
if $I0 goto rx_array
.local int rxaddr
rxaddr = get_addr rx
result = mcalled[rxaddr]
unless null result goto token_next
$P0 = mcalled[rxaddr]
unless null $P0 goto token_next
result = self.rx()
mcalled[rxaddr] = mcalled
if result goto done
Expand All @@ -73,8 +73,8 @@ Perform a match for protoregex C<name>.
unless rx_it goto cand_done
rx = shift rx_it
rxaddr = get_addr rx
result = mcalled[rxaddr]
unless null result goto token_next
$P0 = mcalled[rxaddr]
unless null $P0 goto token_next
result = self.rx()
mcalled[rxaddr] = mcalled
if result goto done
Expand All @@ -92,7 +92,11 @@ Perform a match for protoregex C<name>.

fail:
self.'!cursor_debug'('FAIL ', name)
.return (0)
unless null result goto fail_1
result = self.'!cursor_start'()
result.'!cursor_fail'()
fail_1:
.return (result)
.end


Expand Down
6 changes: 5 additions & 1 deletion t/nqp/32-protoregex.t
Expand Up @@ -2,7 +2,7 @@

# test protoregexes in grammars

plan(6);
plan(7);

grammar ABC {

Expand All @@ -29,4 +29,8 @@ ok( ?$/ , 'successfully matched grammar' );
$/ := ABC.parse('xxx');
ok( !$/ , 'successfully failed protoregex match' );

$/ := ABC.parse('xxx', :rule<symbols>);
ok( !$/ , 'successfully failed protoregex match' );



0 comments on commit 88757e9

Please sign in to comment.