Use '<sh-begin>' for lists of commands

* geesh/parser.scm (make-parser): Put '<sh-begin>' at the beginning of
lists of commands.
* tests/parser.scm: Update tests accordingly.
This commit is contained in:
Timothy Sample 2018-07-12 14:11:38 -04:00
parent a5773e90eb
commit 7d27433a32
2 changed files with 18 additions and 12 deletions

View File

@ -157,19 +157,25 @@ the same number of times.)"
(complete-commands newline-list complete-command)
: (begin
(command-hook)
(cons (if (null? (cdr $3)) (car $3) $3) $1))
(cons $3 $1))
(complete-command)
: (begin
(command-hook)
(if (null? (cdr $1)) `(,(car $1)) `(,$1))))
`(,$1)))
(complete-command
(list separator-op)
: (match $2
('AND (reverse! (cons `(<sh-async> ,(car $1)) (cdr $1))))
('SEMI (reverse! $1)))
: (let ((lst (match $2
('AND (reverse! (cons `(<sh-async> ,(car $1)) (cdr $1))))
('SEMI (reverse! $1)))))
(if (null? (cdr lst))
(car lst)
(cons '<sh-begin> lst)))
(list)
: (reverse! $1))
: (let ((lst (reverse! $1)))
(if (null? (cdr lst))
(car lst)
(cons '<sh-begin> lst))))
(list
(list separator-op and-or)

View File

@ -39,18 +39,18 @@
(parse "echo foo"))
(test-equal "Parses command lists"
'((<sh-exec> "echo" "foo")
(<sh-exec> "echo" "bar"))
'(<sh-begin> (<sh-exec> "echo" "foo")
(<sh-exec> "echo" "bar"))
(parse "echo foo; echo bar"))
(test-equal "Parses asynchronous command lists"
'((<sh-async> (<sh-exec> "echo" "foo"))
(<sh-async> (<sh-exec> "echo" "bar")))
'(<sh-begin> (<sh-async> (<sh-exec> "echo" "foo"))
(<sh-async> (<sh-exec> "echo" "bar")))
(parse "echo foo& echo bar&"))
(test-equal "Parses mixed command lists"
'((<sh-async> (<sh-exec> "echo" "foo"))
(<sh-exec> "echo" "bar"))
'(<sh-begin> (<sh-async> (<sh-exec> "echo" "foo"))
(<sh-exec> "echo" "bar"))
(parse "echo foo& echo bar"))
(test-equal "Parses commands with assignments"