[llvm] [llvm-lit] Support curly brace syntax in lit internal shell (PR #102830)
Paul Kirth via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 14 11:15:36 PDT 2024
================
@@ -255,18 +261,42 @@ def parse_pipeline(self):
self.lex()
commands.append(self.parse_command())
return Pipeline(commands, negate, self.pipefail)
+
+
+ # {echo foo; echo bar;} && echo hello
+ # echo hello && {echo foo; echo bar}
+
+ def parse(self, seq_type):
+ lhs = None
+ if isinstance(self.look(), tuple):
+ brace = self.lex()
+ self.brace_stack.append(brace)
+ if brace[0] == '{':
+ lhs = self.parse(('{', '}'))
+ else:
+ raise ValueError("syntax error near unexpected token %r" % brace[0])
- def parse(self):
- lhs = self.parse_pipeline()
+ else:
+ lhs = self.parse_pipeline()
while self.look():
operator = self.lex()
assert isinstance(operator, tuple) and len(operator) == 1
+ if operator == self.brace_dict[self.brace_stack.peek()]:
+ break
+
if not self.look():
raise ValueError("missing argument to operator %r" % operator[0])
# FIXME: Operator precedence!!
- lhs = Seq(lhs, operator[0], self.parse_pipeline())
+ if isinstance(self.look(), tuple):
+ lhs = self.parse(('{', '}'))
+ else:
+ lhs = Seq(lhs, operator[0], self.parse_pipeline(), seq_type)
+ seq_type = None
----------------
ilovepi wrote:
Why is the `seq_type` thrown away?
https://github.com/llvm/llvm-project/pull/102830
More information about the llvm-commits
mailing list