mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
Shell: Parse lists serially, and flatten them only when needed
This allows `((1 2 3) (4 5 6))` to remain nested until we explicitly flatten it out.
This commit is contained in:
parent
9c1da8fca1
commit
95fc7dd03a
4 changed files with 96 additions and 49 deletions
10
Shell/AST.h
10
Shell/AST.h
|
@ -164,6 +164,7 @@ public:
|
|||
virtual bool is_job() const { return false; }
|
||||
virtual bool is_list() const { return false; }
|
||||
virtual bool is_string() const { return false; }
|
||||
virtual bool is_list_without_resolution() const { return false; }
|
||||
};
|
||||
|
||||
class CommandValue final : public Value {
|
||||
|
@ -221,14 +222,18 @@ private:
|
|||
class ListValue final : public Value {
|
||||
public:
|
||||
virtual Vector<String> resolve_as_list(RefPtr<Shell>) override;
|
||||
virtual RefPtr<Value> resolve_without_cast(RefPtr<Shell>) override;
|
||||
virtual ~ListValue();
|
||||
virtual bool is_list() const override { return true; }
|
||||
virtual bool is_list_without_resolution() const override { return true; }
|
||||
ListValue(Vector<String> values);
|
||||
ListValue(Vector<RefPtr<Value>> values)
|
||||
: m_contained_values(move(values))
|
||||
{
|
||||
}
|
||||
|
||||
const Vector<RefPtr<Value>>& values() const { return m_contained_values; }
|
||||
|
||||
private:
|
||||
Vector<RefPtr<Value>> m_contained_values;
|
||||
};
|
||||
|
@ -389,7 +394,7 @@ private:
|
|||
|
||||
class ListConcatenate final : public Node {
|
||||
public:
|
||||
ListConcatenate(Position, RefPtr<Node>, RefPtr<Node>);
|
||||
ListConcatenate(Position, Vector<RefPtr<Node>>);
|
||||
virtual ~ListConcatenate();
|
||||
|
||||
private:
|
||||
|
@ -401,8 +406,7 @@ private:
|
|||
virtual bool is_list() const override { return true; }
|
||||
virtual RefPtr<Node> leftmost_trivial_literal() const override;
|
||||
|
||||
RefPtr<Node> m_element;
|
||||
RefPtr<Node> m_list;
|
||||
Vector<RefPtr<Node>> m_list;
|
||||
};
|
||||
|
||||
class Background final : public Node {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue