1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

Shell: Make caller specify the string parsing end condition

Heredocs have a different parse end condition than double-quoted
strings. parse_doublequoted_string_inner would assume that a string
would always end in a double quote, so let's generalize it to
parse_string_inner and have it take a StringEndCondition enum which
specifies how the string terminates.
This commit is contained in:
sin-ack 2021-08-11 21:40:26 +00:00 committed by Ali Mohammad Pur
parent c419b1ade6
commit 4c6a97e757
2 changed files with 16 additions and 6 deletions

View file

@ -40,6 +40,12 @@ private:
Yes,
No,
};
enum class StringEndCondition {
DoubleQuote,
Heredoc,
};
struct SequenceParseResult {
NonnullRefPtrVector<AST::Node> entries;
Vector<AST::Position, 1> separator_positions;
@ -76,7 +82,7 @@ private:
RefPtr<AST::Node> parse_expression();
RefPtr<AST::Node> parse_string_composite();
RefPtr<AST::Node> parse_string();
RefPtr<AST::Node> parse_doublequoted_string_inner();
RefPtr<AST::Node> parse_string_inner(StringEndCondition);
RefPtr<AST::Node> parse_variable();
RefPtr<AST::Node> parse_variable_ref();
RefPtr<AST::Node> parse_slice();