Flatten AST form for multiple assignments

* geesh/parser.scm (make-parser): Instead of using a nested list for
assignments, use a flat list.
* tests/parser.scm: Adjust existing test for this (which checks a
single assignment) and add a second test which checks multiple
assignments.
This commit is contained in:
Timothy Sample 2018-07-11 20:35:17 -04:00
parent 2f5d074ca3
commit 2b05199562
2 changed files with 6 additions and 2 deletions

View File

@ -383,7 +383,7 @@ the same number of times.)"
: (let*-values (((redirects assignments*) (partition io-redirect? $1))
((assignments) (map split-assignment assignments*)))
(match redirects
(() `(<sh-set!> ,assignments))
(() `(<sh-set!> ,@assignments))
(_ `(<sh-with-redirects> ,redirects
,(if (null? assignments)
#f

View File

@ -65,9 +65,13 @@
(parse "2>&1"))
(test-equal "Parses assignments"
'(<sh-set!> (("FOO" "bar")))
'(<sh-set!> ("FOO" "bar"))
(parse "FOO=bar"))
(test-equal "Parses multiple assignments"
'(<sh-set!> ("FOO" "bar") ("BAZ" "quux"))
(parse "FOO=bar BAZ=quux"))
;; Boolean expressions
(test-equal "Parses disjunctions"