Skip to content

Commit

Permalink
Add ^ and $ support to ARE
Browse files Browse the repository at this point in the history
(bring t/cmd_array to 100%)
  • Loading branch information
coke committed Jun 28, 2010
1 parent e3a399e commit 297e2ca
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/ARE/Actions.pm
Expand Up @@ -66,6 +66,14 @@ method quantifier:sym<?>($/) {
make PAST::Regex.new( :pasttype<quant>, :min(0), :max(1), :node($/) );
}

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

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

method metachar:sym<.>($/) {
make PAST::Regex.new( :pasttype<charclass>, :subtype<.>, :node($/) );
}
Expand Down
4 changes: 3 additions & 1 deletion src/ARE/Grammar.pm
Expand Up @@ -24,14 +24,16 @@ token atom {
]
}

token barechar { <-[\\\[*+?]> }
token barechar { <-[\\\[*+?^$]> }

proto token quantifier { <...> }
token quantifier:sym<*> { <sym> }
token quantifier:sym<+> { <sym> }
token quantifier:sym<?> { <sym> }

proto token metachar { <...> }
token metachar:sym<^> { <sym> }
token metachar:sym<$> { <sym> }
token metachar:sym<.> { <sym> }
token metachar:sym<back> { \\ <backslash> }
token metachar:sym<[> {
Expand Down
2 changes: 1 addition & 1 deletion t/cmd_array.t
Expand Up @@ -278,7 +278,7 @@ eval_is {
set a(monkey2) do
set a(ferret) don't
lsort [array names a -regexp ^mon.*]
} {monkey1 monkey2} {array names, explicit regexp match} {TODO NQPRX}
} {monkey1 monkey2} {array names, explicit regexp match}

eval_is {
catch {unset a}
Expand Down

0 comments on commit 297e2ca

Please sign in to comment.