sweet-racket icon indicating copy to clipboard operation
sweet-racket copied to clipboard

Added \\ processing, fixed parsing bug

Open Kalimehtar opened this issue 5 years ago • 6 comments

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)

Kalimehtar avatar Jun 25 '20 16:06 Kalimehtar

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.

AlexKnauth avatar Jul 23 '22 01:07 AlexKnauth

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.

Kalimehtar avatar Jul 24 '22 10:07 Kalimehtar

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))

AlexKnauth avatar Jul 30 '22 14:07 AlexKnauth

Then raise block [(e1 ... (~and $ (~datum $)) e2 ...) ...] before [(before ... (e1 (~literal \\) e2) after ...). It will switch the precedence.

Kalimehtar avatar Jul 31 '22 08:07 Kalimehtar

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)

Kalimehtar avatar Jul 31 '22 09:07 Kalimehtar

Okay. This definitely needs some tests then.

AlexKnauth avatar Jul 31 '22 14:07 AlexKnauth