aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lexer.py2
-rw-r--r--std.py16
2 files changed, 16 insertions, 2 deletions
diff --git a/lexer.py b/lexer.py
index 0d9ed87..976bce8 100644
--- a/lexer.py
+++ b/lexer.py
@@ -9,7 +9,7 @@ OPEN_BRACE = "["
CLOSE_BRACE = "]"
DIGITS = "0123456789"
LETTERS = "abcdefghijklmnopqrstuvwxyz"
-PUNCTUATION = "-_!*$@%^&=+/?<>~"
+PUNCTUATION = "|-_!*$@%^&=+/?<>~"
SYMBOL_VALS = list(LETTERS + LETTERS.upper() + DIGITS + PUNCTUATION)
diff --git a/std.py b/std.py
index 1bb20d4..30d81c9 100644
--- a/std.py
+++ b/std.py
@@ -124,7 +124,19 @@ def std_literal_to_string(arg):
# shell
def std_shell(arg):
assert isinstance(arg, NebString)
- subprocess.run(arg.value)
+ lst = arg.value.split(" ")
+ subprocess.run(lst)
+ return NebBool(True)
+
+def std_shell_pipe(args):
+ prev = None
+ stdout = subprocess.PIPE
+ for idx, arg in enumerate(args.items):
+ if idx == len(args.items) - 1:
+ stdout = None
+ lst = arg.value.split(" ")
+ ret = subprocess.run(lst, stdout=stdout, input=prev)
+ prev = ret.stdout
return NebBool(True)
def evaluate_expression(expr):
@@ -229,5 +241,7 @@ def build_std():
# shell
shell_string = FuncImpl(NebFunction("$", [NebString], NebBool), std_shell)
STD["$"] = [shell_string]
+ shell_pipe = FuncImpl(NebFunction("$|", [NebList], NebBool), std_shell_pipe)
+ STD["$|"] = [shell_pipe]
build_std()