Navigation Menu

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

Commit

Permalink
Remove some obsolete methods from Cursor.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Oct 10, 2009
1 parent 86f5d68 commit b0e696b
Showing 1 changed file with 0 additions and 133 deletions.
133 changes: 0 additions & 133 deletions src/Regex/Cursor.pir
Expand Up @@ -656,139 +656,6 @@ called C<name>.
.end


=item !literal(str [, pos :named('pos')] )

Perform a literal match of C<str> using the current cursor
(starting at C<pos>, if supplied). If the match is successful,
the cursor is moved to the end of the literal string.

=cut

.sub '!literal' :method
.param string str
.param pmc pos :named('pos') :optional
.param int has_pos :opt_flag

unless has_pos goto pos_0
setattribute self, '$!pos', pos
goto pos_done
pos_0:
pos = getattribute self, '$!pos'
pos_done:

.local string target
$P0 = getattribute self, '$!target'
target = $P0

$I0 = pos
$I1 = length str
$S0 = substr target, $I0, $I1
unless $S0 == str goto fail
add $P0, pos, $I1
setattribute self, '$!pos', $P0
.return (1, pos)
fail:
.return (0, pos)
.end


=item !subrule(subname [, bindnames :slurpy] [, pos :named('pos')] )

Perform a subrule match on C<name>, binding any successful
match objects into C<bindnames>. If the subrule successfully
matches, then the cursor invocant is updated to the end of
the subrule match, otherwise the cursor is unchanged.
Returns the cursor from the attempted subrule match.

=cut

.sub '!subrule' :method
.param string subname
.param pmc bindnames :slurpy
.param pmc pos :named('pos') :optional
.param int has_pos :opt_flag

unless has_pos goto pos_done
setattribute self, '$!pos', pos
pos_done:

# invoke the subrule
.local pmc subcur
subcur = self.subname()
# if the subrule failed, we're done
unless subcur goto done
# update current cursor's position
pos = getattribute subcur, '$!pos'
setattribute self, '$!pos', pos
# bind any results
unless bindnames goto done
self.'!match_bind'(subcur, bindnames :flat)
done:
.return (subcur, pos)
.end


=item !symtoken_add(name, sym)

Add a regex C<name> for matching fixed-string C<sym> tokens to
the current grammar.

=cut

.sub '!symtoken_add' :method
.param string name
.param string sym

# create a new symtoken method instance, name it, attach <sym>
.local pmc symtoken
.const 'Sub' $P99 = 'symtoken'
symtoken = clone $P99
# symtoken = name
$P0 = box sym
setprop symtoken, '$!sym', $P0

# add method to our class
$P0 = self.'HOW'()
$P0.'add_method'(self, name, symtoken)

self.'!protoregex_generation'()
.end

.sub '' :method :subid('symtoken')
.param pmc action :named('action') :optional
.param pmc peek :named('peek') :optional

# get the string to be matched
.local pmc sym
$P0 = getinterp
$P0 = $P0['sub';0]
sym = getprop '$!sym', $P0

if null peek goto peek_done
.return (sym)
peek_done:

# get a fresh cursor for matching
.local pmc cur
.local string target
.local int pos
(cur, pos, target) = self.'!cursor_start'()

# compare target with sym
$S0 = sym
$I0 = length $S0
$S1 = substr target, pos, $I0
if $S0 != $S1 goto fail
pos += $I0
pass:
.local pmc match
match = cur.'!matchify'('pos'=>pos)
match['sym'] = sym
fail:
.return (cur)
.end


=back

=head2 Vtable functions
Expand Down

0 comments on commit b0e696b

Please sign in to comment.