Commit Graph

12 Commits

Author SHA1 Message Date
Timothy Sample 91cfdac307 Throw an error when missing a single quote
We used to loop forever here because of the lack of 'eof-object?'
test!

* geesh/lexer.scm (get-single-quotation): Throw an error on unexpected
end-of-file.
2018-11-28 23:00:10 -05:00
Timothy Sample 73414716bb Fix lexing of empty double quotes
* geesh/lexer.scm (get-double-quotation): Handle empty quotation.
* tests/lexer.scm: Add a test for this and for empty single
quotes (which already worked correctly).
2018-11-09 16:22:11 -05:00
Timothy Sample 2aa8615f9e Update AST for command substitutions
The AST generated by the parser did not match the syntax document.
However, neither were right.  This commit updates the syntax document
to describe a more consistent form, and fixes the code to follow it.

* doc/syntax.txt (word): Make the children of '<sh-cmd-sub>' a
possibly empty list of 'list's.
* geesh/lexer.scm (get-bracketed-command): Splice in children for
'<sh-cmd-sub>'.
(get-backquoted-command): Ditto.
* geesh/parser.scm (read-sh/bracketed): Make sure that result is
always a list.
(read-sh/backquoted): Ditto.
* tests/lexer.scm: Update tests accordingly.
* tests/parser.scm: Ditto.
2018-07-18 14:27:11 -04:00
Timothy Sample 5605ea993a Fix AST for quoted words
* geesh/lexer.scm (get-double-quotation): Make sure that '<sh-quote>'
forms only have one sub-word.
(get-unquoted-here-doc): Ditto.
* tests/lexer.scm: Update tests accordingly.
2018-07-18 09:29:33 -04:00
Timothy Sample 8b945a77a9 Fix reading multi-line quoted here-documents
* geesh/lexer.scm (get-quoted-here-doc): Use the correct line-reading
procedure when looping.
* tests/lexer.scm: Add test.
2018-07-17 21:59:09 -04:00
Timothy Sample 3e0872ee3e Add a function for more accurate here-end lexing
When lexing a here-end word, expansions should be ignored.  That is,
"$x" should be treated as the string "$x" and not a reference to the
parameter named "x".

* geesh/lexer.scm (expansions?): New parameter to enable or disable
treating expansions specially.
(get-double-quotation): Use it.
(get-word): Ditto.
(get-here-end): New public function that reads a token without
treating expansions specially.
* tests/lexer.scm: Test it.
2018-07-15 20:16:27 -04:00
Timothy Sample a43d97dd09 Add here-document support to the lexer
* geesh/lexer.scm (get-quoted-here-doc): New function.
(get-unquoted-here-doc): New function.
(wrap-port-with-tab-trimming): New function.
(get-here-doc): New public function.
* tests/lexer.scm: Test it.
2018-07-15 20:16:17 -04:00
Timothy Sample be5b305de6 Fix dollar sign handling before non-name
If a dollar sign does not precede a name, it gets treated normally.

* geesh/lexer.scm (get-parameter): Return '#f' if the first character
is not a name character.
(get-parameter-expansion): Propagate the '#f' value.
(get-word): Replace the '#f' value with last character read.
(get-parameter-word): Ditto.
(get-double-quotation): Ditto.
* tests/lexer.scm: Test this.
2018-07-15 19:48:20 -04:00
Timothy Sample 01e8a7bf24 Fix line-joining when there are extra spaces
* geesh/lexer.scm (get-token): Add a case to skip an escaped newline.
* tests/lexer.scm: Test it.
2018-07-15 19:48:20 -04:00
Timothy Sample 0afb2523f7 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.
2018-07-11 21:54:43 -04:00
Timothy Sample c802fd2fca Make reference operator names more "Scheme-y"
* geesh/lexer.scm (*parameter-operators*): Update the names of the
operators.
* tests/lexer.scm: Fix tests accordingly.
2018-07-11 21:54:35 -04:00
Timothy Sample 95181a98b5 Add lexer
* geesh/lexer.scm: New file.
* tests/lexer.scm: New file.
* Makefile.am: Add them.
2018-01-31 15:09:51 -05:00