mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:07:36 +00:00
Shell: Add support for 'immediate' expressions as variable substitutions
This commit adds a few basic variable substitution operations: - length Find the length of a string or a list - length_across Find the lengths of things inside a list - remove_{suffix,prefix} Remove a suffix or a prefix from all the passed values - regex_replace Replace all matches of a given regex with a given template - split Split the given string with the given delimiter (or to its code points if the delimiter is empty) - concat_lists concatenates any given lists into one Closes #4316 (the ancient version of this same feature)
This commit is contained in:
parent
a303b69caa
commit
a45b2ea6fb
16 changed files with 911 additions and 37 deletions
|
@ -49,6 +49,12 @@ public:
|
|||
m_trivia = m_source.substring_view(m_source.length() - offset, offset);
|
||||
}
|
||||
|
||||
explicit Formatter(const AST::Node& node)
|
||||
: m_cursor(-1)
|
||||
, m_root_node(node)
|
||||
{
|
||||
}
|
||||
|
||||
String format();
|
||||
size_t cursor() const { return m_output_cursor; }
|
||||
|
||||
|
@ -74,6 +80,7 @@ private:
|
|||
virtual void visit(const AST::HistoryEvent*) override;
|
||||
virtual void visit(const AST::Execute*) override;
|
||||
virtual void visit(const AST::IfCond*) override;
|
||||
virtual void visit(const AST::ImmediateExpression*) override;
|
||||
virtual void visit(const AST::Join*) override;
|
||||
virtual void visit(const AST::MatchExpr*) override;
|
||||
virtual void visit(const AST::Or*) override;
|
||||
|
@ -119,6 +126,7 @@ private:
|
|||
StringView m_source;
|
||||
size_t m_output_cursor { 0 };
|
||||
ssize_t m_cursor { -1 };
|
||||
RefPtr<AST::Node> m_root_node;
|
||||
AST::Node* m_hit_node { nullptr };
|
||||
|
||||
const AST::Node* m_parent_node { nullptr };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue