home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.compilers
- Path: sparky!uunet!world!iecc!compilers-sender
- From: drw@euclid.mit.edu (Dale R. Worley)
- Subject: Re: Introducing new operators (was: Re: Scientists as Programmers)
- Reply-To: drw@euclid.mit.edu (Dale R. Worley)
- Organization: MIT Dept. of Tetrapilotomy, Cambridge, MA, USA
- Date: Fri, 11 Sep 1992 18:11:33 GMT
- Approved: compilers@iecc.cambridge.ma.us
- Message-ID: <92-09-065@comp.compilers>
- Followup-To: comp.compilers
- References: <1992Sep3.112944.20996@dbsun.uucp> <92-09-053@comp.compilers>
- Keywords: parse, design, algol68
- Sender: compilers-sender@iecc.cambridge.ma.us
- Lines: 22
-
- fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
-
- >If your compiler uses ANY kind of table-driven parsing scheme, it is
- >next to impossible to allow programmer-defined operators. ...
-
- I think that "next to impossible" is perhaps overstating the case a
- little. If you have a small number of precedence levels (eg. Haskell has
- only 10 or 16 I think), then it is quite possible to code up each of these
- precedences as a production in the grammar.
-
- Yes. I once wrote an Algol 68 front-end, and the scanner simply
- translated all operators into one of 11 tokens (ten tokens for the ten
- precedence levels of binary operators and one token for unary operators).
- The tricky part was that Algol 68 allows one to use a user-defined
- operator before declaring it, so you have to pre-scan the text to build
- the part of the symbol table that defines the operator precedences, and
- then on a second pass actually parse the expressions.
-
- Dale Worley Dept. of Math., MIT drw@math.mit.edu
- --
- Send compilers articles to compilers@iecc.cambridge.ma.us or
- {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
-