mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 23:32:06 +00:00
Shell: Add support for heredocs
Closes #4283. Heredocs are implemented in a way that makes them feel more like a string (and not a weird redirection, a la bash). There are two tunables, whether the string is dedented (`<<-` vs `<<~`) and whether it allows interpolation (quoted key vs not). To the familiar people, this is how Ruby handles them, and I feel is the most elegant heredoc syntax. Unlike the oddjob that is bash, heredocs are treated exactly as normal strings, and can be used _anywhere_ where a string can be used. They are *required* to appear in the same order as used after a newline is seen when parsing the sequence that the heredoc is used in. For instance: ```sh echo <<-doc1 <<-doc2 | blah blah contents for doc1 doc1 contents for doc2 doc2 ``` The typical nice errors are also implemented :^)
This commit is contained in:
parent
7c8d39e002
commit
3048274f5e
7 changed files with 364 additions and 10 deletions
|
@ -30,6 +30,7 @@ public:
|
|||
virtual void visit(const AST::FunctionDeclaration*);
|
||||
virtual void visit(const AST::ForLoop*);
|
||||
virtual void visit(const AST::Glob*);
|
||||
virtual void visit(const AST::Heredoc*);
|
||||
virtual void visit(const AST::HistoryEvent*);
|
||||
virtual void visit(const AST::Execute*);
|
||||
virtual void visit(const AST::IfCond*);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue