Hi
Has anyone ever come across a Lisp recognizer i.e. a program that takes
a source file and states whether it contains valid lisp code, if so could
you point me in the right direction
Shaw
--
****************************************
****************************************
Shaw Green, MSc Knowledge Based Systems
Dept of AI
80 South Bridge
Edinburgh
"Don't criticise what you don't understand"
****************************************
****************************************
: > Has anyone ever come across a Lisp recognizer
: You could call READ and check if it returns an error.
Naw; Maybe call compile-file and see if it returns an error! :)
Seriously, though, it depends what you mean. If you want it to be
syntactically correct, then calling read is really what you want. If
you want it to "look like lisp", then you might check that the car of
everything is a functionp and the cdr a list of things that are atoms,
numbers, nil, t, or (recursively) valid exprs (you'll also have to be
a little smart about macro-expansion). If you want it to RUN, well,
now you're talking next to impossible; if you figure that out, I know
a bunch of lisp compiler compnaies that have a job for you.
Cheers,
'Jeff
·······@neurocog.lrdc.pitt.edu (Jeff Shrager) wrote:
>: > Has anyone ever come across a Lisp recognizer
>: You could call READ and check if it returns an error.
>Naw; Maybe call compile-file and see if it returns an error! :)
>Seriously, though, it depends what you mean. If you want it to be
>syntactically correct, then calling read is really what you want. If
>you want it to "look like lisp", then you might check that the car of
>everything is a functionp and the cdr a list of things that are atoms,
>numbers, nil, t, or (recursively) valid exprs (you'll also have to be
>a little smart about macro-expansion). If you want it to RUN, well,
>now you're talking next to impossible;
I think it IS impossible.
If the question is: Can we write a program which will tell whether
some other Lisp code will execute without producing an error?
Then the answer is: No.
It's a variant of the halting problem.
(also easily seen as a result of Rice's theorem)
>if you figure that out, I know
>a bunch of lisp compiler compnaies that have a job for you.
>Cheers,
>'Jeff
In article <··········@news.abs.net> ·····@ezaccess.net (Bill Vanyo) writes:
>If the question is: Can we write a program which will tell whether
>some other Lisp code will execute without producing an error?
>Then the answer is: No.
Agreed. But I thought the question was "Can we write a program which
will tell whether some other Lisp code will load without producing an
error?" Ie "is this legal Lisp syntax"?
- Marty
(proclaim '(inline skates))
<http://www.apl.jhu.edu/~hall/lisp.html>
In article <·········@aplcenmp.apl.jhu.edu>, ····@aplcenmp.apl.jhu.edu (Marty Hall) wrote:
>In article <··········@news.abs.net> ·····@ezaccess.net (Bill Vanyo) writes:
>
>>If the question is: Can we write a program which will tell whether
>>some other Lisp code will execute without producing an error?
>>Then the answer is: No.
>
>Agreed. But I thought the question was "Can we write a program which
>will tell whether some other Lisp code will load without producing an
>error?" Ie "is this legal Lisp syntax"?
> - Marty
>(proclaim '(inline skates))
><http://www.apl.jhu.edu/~hall/lisp.html>
Maybe the question is:" Can we build software that will infer the most likely
language that a subject source file has been written in"...
I would argue "Sure": I remember, back in about 1970 -- when more of my brain
cells were active -- that a compiler existed on a Univac 1108 that would take a
source "deck" (i.e., cards -- those funny paper things that used to be used) and
determine the most likely language to assume for compilation (as I recall --
Fortran, MAD, Algol, and possibly 1100 Assembly. In fact, I think the thing
would even recognize Lisp(?) but would not "compile" such stuff -- but would, as
I recall, announce to the world that it had found a Lispy looking program...).
I recall looking at the source code for the parser -- it was a mess -- lotza "Is
there DO10K=1,100" looking thingi -- Probably Fortran. How 'bout something like
"FOR %^$ UNTIL" or some such, then probably ALGOL 60 etc etc. Very ugly code.
This curious creation was constructed, I think, by MADmen (pun) at the
University of Maryland which, at that time, built a lot of very good Univac
systems stuff. I would assume that they have gone on to other things by now.
Those were the days..
Regards to all.
Jack
---------------------------------------------------------------------
Jack Harper Bank Systems 2000, Inc.
e-mail: ·······@bs2000.com 350 Indiana Street, Suite 350
voice: 303-277-1892 fax: 303-277-1785 Golden, Colorado 80439
"21st Century Banking Applications"
Private Label Optical Bank Card Systems
Visit our Web Page: http://www.bs2000.com/talos
---------------------------------------------------------------------
Marty Hall wrote:
>
> In article <··········@news.abs.net> ·····@ezaccess.net (Bill Vanyo) writes:
>
> >If the question is: Can we write a program which will tell whether
> >some other Lisp code will execute without producing an error?
> >Then the answer is: No.
>
> Agreed. But I thought the question was "Can we write a program which
> will tell whether some other Lisp code will load without producing an
> error?" Ie "is this legal Lisp syntax"?
> - Marty
> (proclaim '(inline skates))
> <http://www.apl.jhu.edu/~hall/lisp.html>
Hang on. Doesn't code get executed when loaded? I am thinking of macros
and actual top-level forms such as (print "Hi Mom!"). In which case,
since McCarthy made sure Lisp was a Turing Machine, "Computable Numbers"
holds sway.
And the narrow question you are after, "is this legal Lisp syntax" then
seems *really* narrow: Is it contiguous characters or a parenthesiszed
list of white-space delimited contiguous characters?
Not that I have ever written a Lisp compiler or know what I am talking
about? <g>
Cheers,
Ken
In article <··········@usenet.srv.cis.pitt.edu>
·······@neurocog.lrdc.pitt.edu (Jeff Shrager) writes:
>Maybe we ought to quit jawwing until the original poster tells us what
>the goal is.
What, and violate the venerable Usenet tradition of speaking (loudly)
before we know what we are talking about?
- Marty
(proclaim '(inline skates))
<http://www.apl.jhu.edu/~hall/lisp.html>
In article <·········@usenet.srv.cis.pitt.edu>,
Jeff Shrager <·······@neurocog.lrdc.pitt.edu> wrote:
>: > Has anyone ever come across a Lisp recognizer
>: You could call READ and check if it returns an error.
>
>Naw; Maybe call compile-file and see if it returns an error! :)
>
>Seriously, though, it depends what you mean. If you want it to be
>syntactically correct, then calling read is really what you want.
Well, no. For instance, the following is a syntax error in code:
(function f g h i j k)
-- jd
····@interactive.co.uk (Jeff Dalton) wrote:
>In article <·········@usenet.srv.cis.pitt.edu>,
>Jeff Shrager <·······@neurocog.lrdc.pitt.edu> wrote:
>>: > Has anyone ever come across a Lisp recognizer
>>: You could call READ and check if it returns an error.
>>
>>Naw; Maybe call compile-file and see if it returns an error! :)
>>
>>Seriously, though, it depends what you mean. If you want it to be
>>syntactically correct, then calling read is really what you want.
>Well, no. For instance, the following is a syntax error in code:
> (function f g h i j k)
This is debatable. The Lisp parser (as simple as a programming
language parser gets) has no problem reading this and producing an
internal list representation. It only produces an error when
evaluated by the interpreter, i.e. during execution.
Bill
In article <··········@scotsman.ed.ac.uk> ·····@aisb.ed.ac.uk (Shaw Green) writes:
> Hi
> Has anyone ever come across a Lisp recognizer i.e. a program that takes
> a source file and states whether it contains valid lisp code, if so could
> you point me in the right direction
There's always the function COMPILE-FILE. It will give warnings (or
fail) on must invalid lisp code. Of course it doesn't guarantee correct
lisp code :)
Thomas A. Russ, USC/Information Sciences Institute ···@isi.edu
--
Thomas A. Russ, USC/Information Sciences Institute ···@isi.edu