develooper Front page | perl.perl6.internals.api.parser | Postings from December 2000

Re: A parser that can handle partial programs (was Re: Now, totry again...)

Thread Previous | Thread Next
Dan Sugalski
December 17, 2000 12:59
Re: A parser that can handle partial programs (was Re: Now, totry again...)
Message ID:
At 12:41 PM 12/17/00 -0500, Bradley M. Kuhn wrote:
>Nicholas Clark <> wrote:
> > Something I though of:
> > If you're trying to write an interactive perl inputer - either a perl shell
> > or just the command prompt on the debugger it would be useful if you
> > could tell the parser that the chunk of source you're giving it may be
> > incomplete.
>I really like this idea, although I am unsure of how we might implement it.
>I don't recall any of the compiler texts I have read over the years talking
>about formal methods for writing such a "partial programs are acceptable"
>Lisp-like languages handle this, but s-expressions are so trivial to parse
>that it's no help to simply "follow" their example.

BASICs generally allow this.

The rule I was thinking was we'd take source on the fly, and execute bare 
statements and (opionally) print the results. Blocks wouldn't get executed 
until they were closed, and things like "sub" wouldn't get executed, only 
parsed. (Like they are now)

Basically read to the end of a statement and eval the statement, only do it 
with a scopeless eval, so things like lexical variables wouldn't 
immediately disappear.


--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai                         have teddy bears and even
                                      teddy bears get drunk

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About