sweet-racket
sweet-racket copied to clipboard
Added \\ processing, fixed parsing bug
There was a bug.
list 1 2 3
list 4 5
raised a error, because it was parsed as (list 1 2 3 (list 4 . 5)) Now it's fixed.
And now \ can be not only an empty head, but also can be used to split a list.
let
\\
a 1 \\ b 2 \\ c 3
{a + b + c}
or
map $ lambda (x) {1 / x} \\ '(1 2 3)
In what situation did that nested list expression parse as (list 1 2 3 (list 4 . 5))?
I'm having trouble reproducing that bug:
#lang sweet-exp racket
list 1 2 3
list 4 5
produces (list 1 2 3 (list 4 5)) as expected.
Delete last newline. If "5" is the last character of the file, then branch [(eof-object? rest) (cons new-level first)] returns item, while a list is expected.
The precedence between $ sublist and \\ split is off. I thought something like
map $ lambda (x) {1 / x} \\ '(1 2 3)
was supposed to parse as
(map (lambda (x) (/ 1 x)))
'(1 2 3)
and not as
(map (lambda (x) (/ 1 x))
'(1 2 3))
Then raise block [(e1 ... (~and $ (~datum $)) e2 ...) ...] before [(before ... (e1 (~literal \\) e2) after ...). It will switch the precedence.
I'm wrong. \\ processed (in my commit) first, so map $ lambda (x) {1 / x} \\ '(1 2 3) is really
map $ lambda (x) {1 / x}
'(1 2 3)
Okay. This definitely needs some tests then.