mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
Shell: Add support for regex match patterns
We previously allowed globs as match pattern, but for more complex matching needs, it's nice to have regular expressions. And as the existing "name a part of the match" concept maps nicely to named capture groups, we can simply reuse the same code and make groups with names available in the match body.
This commit is contained in:
parent
6aceec4535
commit
4ede121d31
6 changed files with 219 additions and 71 deletions
|
@ -141,8 +141,10 @@ void NodeVisitor::visit(const AST::MatchExpr* node)
|
|||
{
|
||||
node->matched_expr()->visit(*this);
|
||||
for (auto& entry : node->entries()) {
|
||||
for (auto& option : entry.options)
|
||||
option.visit(*this);
|
||||
if (auto* ptr = entry.options.get_pointer<NonnullRefPtrVector<Node>>()) {
|
||||
for (auto& option : *ptr)
|
||||
option.visit(*this);
|
||||
}
|
||||
if (entry.body)
|
||||
entry.body->visit(*this);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue