This repository has been archived by the owner on Feb 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some builtin subrules to Cursor.
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: |