Re: what scanner scheme is efficient?

"Jan Gray" <jsgray@acm.org>
20 Oct 1996 16:53:48 -0400

          From comp.compilers

Related articles
what scanner scheme is efficient? lloix@star.spb.ru (1996-10-12)
Re: what scanner scheme is efficient? peter@bj-ig.de (1996-10-15)
Re: what scanner scheme is efficient? ramb@primenet.com (Ram Bhamidipaty) (1996-10-16)
Re: what scanner scheme is efficient? peter@peter.bj-ig.de (Peter Brueckner) (1996-10-18)
Re: what scanner scheme is efficient? roth@noel.cs.rice.edu (1996-10-20)
Re: what scanner scheme is efficient? jsgray@acm.org (Jan Gray) (1996-10-20)
Re: what scanner scheme is efficient? clark@quarry.zk3.dec.com (1996-10-24)
Re: what scanner scheme is efficient? james@wgold.demon.co.uk (James Mansion) (1996-10-24)
Re: what scanner scheme is efficient? jlilley@empathy.com (1996-10-30)
Re: what scanner scheme is efficient? vern@daffy.ee.lbl.gov (1996-11-12)
Re: what scanner scheme is efficient? jlilley@empathy.com (1996-11-15)
Re: what scanner scheme is efficient? adrian@dcs.rhbnc.ac.uk (1996-11-19)
[3 later articles]
| List of all articles for this month |
From: "Jan Gray" <jsgray@acm.org>
Newsgroups: comp.compilers
Date: 20 Oct 1996 16:53:48 -0400
Organization: Netcom
References: 96-10-041 96-10-051 96-10-076
Keywords: lex, performance

> Is scanning/parsing _speed_ ever reason to go toward using a hash
> table for identifying keywords?


Sure. In C like languages, really fast compilation may require an
integrated preprocessor, and since even keywords can be #define'd to
something else, it would be wrong to specifically scan for them as such.
Therefore, the best approach is often to recognise an identifier
([A-Za-z_][A-Za-z_0-9]*), then lookup (perhaps via hash table) several
properties of the identifier:
* is it a macro name? (and perhaps its macro definition)
* is it a keyword? (and its keyword token)
* other useful attributes of the id (id known to be, or definitely not be,
a type name, class name, member name, etc.)


Jan Gray
Redmond, WA
--


Post a followup to this message

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