Skip to content

Commit

Permalink
Add \d, \s, \w, \D, \S, \W backslash escapes to ARE.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Nov 29, 2009
1 parent c61dca5 commit 2bff6f8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/ARE/Actions.pm
Expand Up @@ -70,6 +70,11 @@ method metachar:sym<.>($/) {
make PAST::Regex.new( :pasttype<charclass>, :subtype<.>, :node($/) );
}

method metachar:sym<back>($/) { make $<backslash>.ast; }

method backslash:sym<w>($/) {
make PAST::Regex.new( :pasttype<charclass>, :subtype(~$<sym>), :node($/));
}

sub buildsub($rpast, $block = PAST::Block.new() ) {
$rpast := PAST::Regex.new(
Expand Down
2 changes: 1 addition & 1 deletion src/ARE/Grammar.pm
Expand Up @@ -34,5 +34,5 @@ token metachar:sym<.> { <sym> }
token metachar:sym<back> { \\ <backslash> }

proto token backslash { <...> }
token backslash:sym<w> { $<sym>=[<[dswnDSWN]>] }
token backslash:sym<w> { $<sym>=[<[dswDSW]>] }

2 changes: 2 additions & 0 deletions src/PmTcl/Commands.pm
Expand Up @@ -272,6 +272,8 @@ our sub puts(*@args) {
}

our sub regexp($exp, $string) {
## my &dumper := Q:PIR { %r = get_root_global ['parrot'], '_dumper' };
## &dumper(ARE::Compiler.compile($exp, :target<parse>));
my $regex := ARE::Compiler.compile($exp);
?Regex::Cursor.parse($string, :rule($regex), :c(0));
}
Expand Down

0 comments on commit 2bff6f8

Please sign in to comment.