Make reference operators more consistent

* geesh/lexer.scm (get-parameter-expression): Use '#f' to signal an
omitted optional word instead of just omitting the word in the
resulting form.
* tests/lexer.scm: Add a test for omitted optional words.
This commit is contained in:
Timothy Sample 2018-07-11 20:13:50 -04:00
parent c802fd2fca
commit 0afb2523f7
2 changed files with 5 additions and 1 deletions

View File

@ -296,7 +296,7 @@ leading '$')."
(match (get-char port)
(#\} (match `(,parameter ,operator ,word)
((p #f #f) `(<sh-ref> ,p))
((p o #f) `(,o ,p))
((p o #f) `(,o ,p #f))
((p o w) `(,o ,p ,w)))))))))))
(define (get-parameter-expansion port)

View File

@ -161,6 +161,10 @@
("#" . <sh-ref-skip-min>)
("##" . <sh-ref-skip-max>)))
(test-equal "Recognizes a parameter expansion operator without default"
'((WORD (0 . 7) (<sh-ref-or> "foo" #f)))
(tokenize "${foo-}"))
(test-equal "Splits multidigit parameter name without braces"
'((WORD (0 . 3) ((<sh-ref> "1") "2")))
(tokenize "$12"))