Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!snorkelwacker!spdcc!ima!esegue!compilers-sender From: PIRINEN@CC.HELSINKI.FI (Pekka P. Pirinen) Newsgroups: comp.compilers Subject: Re: Compiler with adjustable parsers Summary: Lisp has even more! Keywords: parse, Lisp Message-ID: <2012.25effdcd@cc.helsinki.fi> Date: 4 Mar 90 04:01:05 GMT References: <1990Mar1.143905.14553@esegue.segue.boston.ma.us> Sender: compilers-sender@esegue.segue.boston.ma.us Reply-To: "Pekka P. Pirinen" Organization: University of Helsinki Lines: 38 Approved: compilers@esegue.segue.boston.ma.us In article <1990Mar1.143905.14553@esegue.segue.boston.ma.us>, hackeron@ATHENA.MIT.EDU writes: > Does anyone know of a compiler/language that allows you to specify changes > to how the language is parsed (in part at least) from withing the program. Most Lisp dialects have this ability. Lisp has evolved as the language of the AI research people, and devising new languages has always been a favorite technique of AI -- which is why it's easy in Lisp. (Yes, I believe in evolution: Lisp programs are sexier!) But then, the Lisp approach to parsing is unusual: - the structure of a program is defined in terms of data structures - the compiler is required to take these data structures as input Therefore the compiler usually works quite independently of the parser (which, I guess, makes this reply inappropriate for comp.compilers :-) - data structures have an external representation in terms of sequences of characters The agent in a Lisp system that creates data structures by reading sequences of characters is called 'the reader'. Most Lisps have a programmable reader, meaning you can define the reader to call a user-defined function when, say, encountering a certain character. This function can then read more characters (possibly by recursive calls to the reader), construct and return a data object. Since the full power of the language is available, this is a pretty powerful feature! For a modern implementation of this, see Guy L. Steele, Jr.: _Common Lisp, the Language_ chapter 22.1. Pekka P. Pirinen University of Helsinki Internet: pirinen@cc.helsinki.fi BITNET: pirinen@finuh UUCP: mcvax!cc.helsinki.fi!pirinen -- Send compilers articles to compilers@esegue.segue.boston.ma.us {spdcc | ima | lotus}!esegue. Meta-mail to compilers-request@esegue. Please send responses to the author of the message, not the poster.