Re: How to parse keywords that can be used as identifiers?

David L Moore <dlmoore@ix.netcom.com>
24 Aug 1996 21:34:44 -0400

          From comp.compilers

Related articles
How to parse keywords that can be used as identifiers? mark@research.techforce.nl (Mark Thiehatten) (1996-08-19)
Re: How to parse keywords that can be used as identifiers? anton@a0.complang.tuwien.ac.at (1996-08-20)
Re: How to parse keywords that can be used as identifiers? kanze@lts.sel.alcatel.de (1996-08-20)
Re: How to parse keywords that can be used as identifiers? leichter@smarts.com (Jerry Leichter) (1996-08-21)
Re: How to parse keywords that can be used as identifiers? ph@anweald.exnet.co.uk (1996-08-24)
Re: How to parse keywords that can be used as identifiers? grosch@cocolab.sub.com (1996-08-24)
Re: How to parse keywords that can be used as identifiers? dlmoore@ix.netcom.com (David L Moore) (1996-08-24)
Re: How to parse keywords that can be used as identifiers? itz@rahul.net (1996-08-24)
Re: How to parse keywords that can be used as identifiers? peter@bj-ig.de (Peter Brueckner) (1996-08-27)
Re: How to parse keywords that can be used as identifiers? stefan.monnier@lia.di.epfl.ch (Stefan Monnier) (1996-08-27)
Re: How to parse keywords that can be used as identifiers? fjh@mundook.cs.mu.OZ.AU (1996-08-27)
Re: How to parse keywords that can be used as identifiers? iwm@doc.ic.ac.uk (Ian Moor) (1996-09-03)
Re: How to parse keywords that can be used as identifiers? ok@cs.rmit.edu.au (1996-09-05)
[1 later articles]
| List of all articles for this month |

From: David L Moore <dlmoore@ix.netcom.com>
Newsgroups: comp.compilers
Date: 24 Aug 1996 21:34:44 -0400
Organization: Netcom
References: 96-08-058 96-08-067
Keywords: parse

James Kanze US/ESC 60/3/141 #40763 wrote:
>
> Mark Thiehatten <mark@research.techforce.nl> writes:
>
> |> I am working on a parser for a language that allows keywords to
> |> be used as identifiers.


> I had a paper in SIGPLAN notices about this some time back.
> The basic idea was to extend the lexer to
> be able to return alternate tokens; and yacc to ask the lexer for the
> alternate token when it found an error. The modifications to yacc were in
> fact done by running an sed script over the generated parser, and so didn't
> require access to the sources.


If the alternatives are tried only when you get an error, then this technique
is not very powerful. It will not work when you need to look ahead to
determine which symbol was required.


It is, however, the basic idea used in the programming language ICON.
Functions in ICON (actually, a special type of function called generators)
can return multiple values. If you don't like the first result, ask for
another.


ICON is available by FTP from http://ftp.cs.arizona.edu/icon/


It may be worth your while to build a parser in ICON first, even if you
don't ultimately use it, since you can write the parser as a recursive
descent parser and get the back-tracking "for free". You have to be careful
to not emit semantic actions too early, of course.


It is then not hard to write an interpreter which will do the same
back-track parsing in your own implementation language.
--


Post a followup to this message

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