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

Commit

Permalink
Add ability to use ? and ! with enumerated character lists <?[abc]> a…
Browse files Browse the repository at this point in the history
…nd <![def]>
  • Loading branch information
pmichaud committed Oct 13, 2009
1 parent fee0b48 commit 302f7f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/PAST/Compiler-Regex.pir
Expand Up @@ -526,17 +526,20 @@ character list.
.local string charlist
charlist = node[0]
charlist = self.'escape'(charlist)
.local pmc negate, testop
.local pmc subtype, negate, testop
subtype = node.'subtype'()
negate = node.'negate'()
testop = self.'??!!'(negate, 'ge', 'lt')

ops.'push_pirop'('inline', negate, 'inline'=>' # rx enumcharlist negate=%0')
ops.'push_pirop'('inline', negate, subtype, 'inline'=>' # rx enumcharlist negate=%0 %1')
ops.'push_pirop'('ge', pos, eos, fail)
ops.'push_pirop'('sub', '$I10', pos, off)
ops.'push_pirop'('substr', '$S10', tgt, '$I10', 1)
ops.'push_pirop'('index', '$I11', charlist, '$S10')
ops.'push_pirop'(testop, '$I11', 0, fail)
if subtype == 'zerowidth' goto skip_zerowidth
ops.'push_pirop'('inc', pos)
skip_zerowidth:
.return (ops)
.end

Expand Down
3 changes: 2 additions & 1 deletion src/Regex/P6Regex/Actions.pm
Expand Up @@ -121,7 +121,8 @@ method quantmod($/) {
my $str := ~$/;
if $str eq ':' { $past.backtrack('r'); }
elsif $str eq ':?' or $str eq '?' { $past.backtrack('f') }
elsif $str eq ':*' or $str eq '!' { $past.backtrack('g') }
elsif $str eq ':!' or $str eq '!' { $past.backtrack('g') }
elsif @MODIFIERS[0]<r> { $past.backtrack('r') }
make $past;
}

Expand Down

0 comments on commit 302f7f2

Please sign in to comment.