summaryrefslogtreecommitdiff
path: root/Userland/Shell/Parser.h
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2021-03-05 16:33:23 +0330
committerAndreas Kling <kling@serenityos.org>2021-03-07 10:59:51 +0100
commita45b2ea6fb1917de9c2833764f3acf0cdf4e7eab (patch)
tree3bcef2fc5b6c49796f8de6215d5244ba5f4ec5e1 /Userland/Shell/Parser.h
parenta303b69caa74c6c2dbf44a851ea2eb46caf98678 (diff)
downloadserenity-a45b2ea6fb1917de9c2833764f3acf0cdf4e7eab.zip
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)
Diffstat (limited to 'Userland/Shell/Parser.h')
-rw-r--r--Userland/Shell/Parser.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/Userland/Shell/Parser.h b/Userland/Shell/Parser.h
index c699c0eb66..dfc253cfed 100644
--- a/Userland/Shell/Parser.h
+++ b/Userland/Shell/Parser.h
@@ -98,6 +98,7 @@ private:
RefPtr<AST::Node> parse_glob();
RefPtr<AST::Node> parse_brace_expansion();
RefPtr<AST::Node> parse_brace_expansion_spec();
+ RefPtr<AST::Node> parse_immediate_expression();
template<typename A, typename... Args>
NonnullRefPtr<A> create(Args... args);
@@ -238,6 +239,7 @@ list_expression :: ' '* expression (' '+ list_expression)?
expression :: evaluate expression?
| string_composite expression?
| comment expression?
+ | immediate_expression expression?
| history_designator expression?
| '(' list_expression ')' expression?
@@ -268,6 +270,10 @@ variable :: '$' identifier
comment :: '#' [^\n]*
+immediate_expression :: '$' '{' immediate_function expression* '}'
+
+immediate_function :: identifier { predetermined list of names, see Shell.h:ENUMERATE_SHELL_IMMEDIATE_FUNCTIONS }
+
history_designator :: '!' event_selector (':' word_selector_composite)?
event_selector :: '!' {== '-0'}