Weird error

35 views
Skip to first unread message

JS

unread,
Oct 9, 2012, 2:07:34 AM10/9/12
to qil...@googlegroups.com
See this:

Shen 2010, copyright (C) 2010 Mark Tarver
www.shenlanguage.org, version 6.1
running under Common Lisp, implementation: CLisp
port 1.2 ported by Mark Tarver


(0-) (shen-fail!)
EVAL: undefined function s

(1-)


Note the error. function s. Not shen-fail! like you might expect. The
reason I found this is trying to compile "(defun fail () shen-fail!)"
which isn't working. Why? I'm using the built in shen parser to parse
kl. It parses that into:

[defun fail [] s hen-fail!]

Which is of course invalid. But why would it parse it like that
auto-separating the s for some reason? If you change any letter in the
shen-fail! part, it will work.

Mark Tarver

unread,
Oct 9, 2012, 8:21:04 AM10/9/12
to Qilang
Yes; (fail) evaluates to shen-fail! and this object is used to control
parsing so the parser cannot parse this object. It is to misquote
Oscar Wilde 'The object that dare not say its name' and is rather
unique in that respect.

Mark

On Oct 9, 7:07 am, JS <j...@mentics.com> wrote:
> See this:
>
> Shen 2010, copyright (C) 2010 Mark Tarverwww.shenlanguage.org, version 6.1

JS

unread,
Oct 9, 2012, 11:55:07 AM10/9/12
to qil...@googlegroups.com
All I want to do is parse, no semantics need to be known. I'm
bootstrapping shen-java, so I'm writing the compiler in shen itself.
So, I thought I would re-use the shen parser to get the AST. I managed
to come up with this:

(define parse-shen
Code-list -> (compile (lambda V971 (shen-<st_input> V971)) Code-list
(lambda V972 (shen-read-error V972))))

But it's not very pretty. Is there a more clean way to do it? And is
there a way to get it so it will parse that fail definition?
Otherwise, I guess I could put in a special check for that certain
line and handle it as a special case. Or maybe I'll skip it and define
fail directly in the platform.

Ramil Farkhshatov

unread,
Oct 9, 2012, 2:34:08 PM10/9/12
to qil...@googlegroups.com
JS <jo...@mentics.com> wrote:

> All I want to do is parse, no semantics need to be known. I'm
> bootstrapping shen-java, so I'm writing the compiler in shen itself.
> So, I thought I would re-use the shen parser to get the AST. I managed
> to come up with this:
>
> (define parse-shen
> Code-list -> (compile (lambda V971 (shen-<st_input> V971)) Code-list
> (lambda V972 (shen-read-error V972))))
>
> But it's not very pretty. Is there a more clean way to do it? And is
> there a way to get it so it will parse that fail definition?
> Otherwise, I guess I could put in a special check for that certain
> line and handle it as a special case. Or maybe I'll skip it and define
> fail directly in the platform.

In Shen-js (js-kl translator) for reading shen-sources I use this:

(define kl-from-shen
X -> (let X (shen-walk (function macroexpand) X)
X (if (shen-packaged? X)
(package-contents X)
X)
(shen-elim-define (shen-proc-input+ X))))

And I've removed `fail` function from shen kl-sources and defined it in
platform code where it must be in the first place.
Reply all
Reply to author
Forward
0 new messages