Re: Compiler with adjustable parsers

"Pekka P. Pirinen" <PIRINEN@CC.HELSINKI.FI>
3 Mar 90 17:24:29 EET

          From comp.compilers

Related articles
Compiler with adjustable parsers hackeron@ATHENA.MIT.EDU (1990-03-01)
Re: Compiler with adjustable parsers grunwald@foobar.Colorado.EDU (Dirk Grunwald) (1990-03-01)
Re: Compiler with adjustable parsers arnold@audiofax.com (Arnold Robbins) (1990-03-01)
Re: Compiler with adjustable parsers steve@hubcap.clemson.edu (1990-03-01)
Re: Compiler with adjustable parsers dhw@itivax.iti.org (1990-03-02)
Re: Compiler with adjustable parsers pgl@cup.portal.com (1990-03-15)
Re: Compiler with adjustable parsers ipser@vaxa.isi.edu (Ed Ipser) (1990-03-03)
Re: Compiler with adjustable parsers PIRINEN@CC.HELSINKI.FI (Pekka P. Pirinen) (1990-03-03)
Re: Compiler with adjustable parsers fineman@ptolemy.arc.nasa.gov (Charles Fineman) (1990-03-05)
Re: Compiler with adjustable parsers webber@athos.rutgers.edu (1990-03-07)
Re: Compiler with adjustable parsers aarons@cogs.sussex.ac.uk (Aaron Sloman) (1990-03-08)
| List of all articles for this month |
Date: Sat, 3 Mar 90 17:25 EET DST
From: "Pekka P. Pirinen" <PIRINEN@CC.HELSINKI.FI>
Newsgroups: comp.compilers
Date: 3 Mar 90 17:24:29 EET
References: <1990Mar1.143905.14553@esegue.segue.boston.ma.us>
Summary: Lisp has even more!
Keywords: parse, Lisp
Organization: University of Helsinki

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





Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.