glycerine/zygomys

better errors messages for unbalanced parentheses.

owulveryck opened this issue · 1 comments

Hello,

I am trying to use zygomys as an embedded language for a project.
The go part is ok, but I have some troubles with the "lisp" part.

Actually this code is failing and I wonder why (there is probably a good reason):

(def num 5)
(for [(def i 0) (< i num) (def i (+ 1 i))] 
    (printf "Creating chopstick %v\n" i)
    (printf "Creating philosopher %v\n" i)
    (cond
        (< i (- num 1)) (
            (printf "room ticket"))
        null)
)

And the error:

➜ localhost cmd git:(lisp) ✗  zygo test.zy 
Creating chopstick 0
Creating philosopher 0
room ticketerror in __main:49: not a function on top of datastack: '*zygo.SexpSentinel/&zygo.SexpSentinel{Val:0}'
zygo version v4.8.3/30559cad6420826535259d5ba7950bbb10eaf156
press tab (repeatedly) to get completion suggestions. Shift-tab goes back. Ctrl-d to exit.
zygo> EOF

Any clue?

Many thanks.

Olivier

the error could be improved. It means you made a mistake with the parenthesis. There are other things that can cause a parse error too. When I fix your parenthesis, it runs like this:

zygo> (for [(def i 0) (< i num) (def i (+ 1 i))]
...     (printf "Creating chopstick %v\n" i)
...         (printf "Creating philosopher %v\n" i)
...             (cond
...                     (< i (- num 1))
...                                 (printf "room ticket")
...                                         null)
...                                         )
Creating chopstick 0
Creating philosopher 0
room ticketCreating chopstick 1
Creating philosopher 1
room ticketCreating chopstick 2
Creating philosopher 2
room ticketCreating chopstick 3
Creating philosopher 3
room ticketCreating chopstick 4
Creating philosopher 4
zygo>