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

Commit

Permalink
Add some builtin subrules to Cursor.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Oct 10, 2009
1 parent 8f22ee4 commit a0788f8
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/Regex/Cursor-builtins.pir
@@ -0,0 +1,47 @@
# Copyright (C) 2009, Patrick R. Michaud
# $Id$

=head1 NAME

Regex::Cursor-builtins - builtin regexes for Cursor objects

=cut

.include 'cclass.pasm'

.namespace ['Regex';'Cursor']

.sub '!cclass' :method
.param string name
.param int cclass
.local pmc cur
.local int pos
.local string tgt
(cur, pos, tgt) = self.'!cursor_start'()
$I0 = is_cclass cclass, tgt, pos
unless $I0 goto fail
inc pos
cur.'!matchify'(name, 'pos'=>pos)
fail:
.return (cur)
.end

.sub 'alpha' :method
.tailcall self.'!cclass'('alpha', .CCLASS_ALPHABETIC)
.end

.sub 'digit' :method
.tailcall self.'!cclass'('digit', .CCLASS_NUMERIC)
.end

=head1 AUTHORS

Patrick Michaud <pmichaud@pobox.com> is the author and maintainer.

=cut

# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:

0 comments on commit a0788f8

Please sign in to comment.