Skip to content

Commit

Permalink
Add dot metachar to ARE (metachar:sym<.>).
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Nov 29, 2009
1 parent ccab549 commit c61dca5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/ARE/Actions.pm
Expand Up @@ -50,7 +50,9 @@ method quantified_atom($/) {
}

method atom($/) {
my $past := PAST::Regex.new( ~$/, :pasttype<literal>, :node($/) );
my $past := $<metachar>
?? $<metachar>.ast
!! PAST::Regex.new( ~$/, :pasttype<literal>, :node($/) );
make $past;
}

Expand All @@ -64,6 +66,10 @@ method quantifier:sym<?>($/) {
make PAST::Regex.new( :pasttype<quant>, :min(0), :max(1), :node($/) );
}

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


sub buildsub($rpast, $block = PAST::Block.new() ) {
$rpast := PAST::Regex.new(
Expand Down
8 changes: 7 additions & 1 deletion src/ARE/Grammar.pm
Expand Up @@ -20,7 +20,7 @@ token quantified_atom {
token atom {
[
| \w [ \w+! <?before \w> ]?
# | <metachar>
| <metachar>
]
}

Expand All @@ -29,4 +29,10 @@ token quantifier:sym<*> { <sym> }
token quantifier:sym<+> { <sym> }
token quantifier:sym<?> { <sym> }

proto token metachar { <...> }
token metachar:sym<.> { <sym> }
token metachar:sym<back> { \\ <backslash> }

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

0 comments on commit c61dca5

Please sign in to comment.