From: | arnold@skeeve.com (Aharon Robbins) |
Newsgroups: | comp.compilers |
Date: | Tue, 18 Nov 2008 05:20:21 +0000 (UTC) |
Organization: | Pioneer Consulting, Ltd. |
References: | 08-11-061 08-11-079 |
Keywords: | parse, practice |
Posted-Date: | 18 Nov 2008 19:10:16 EST |
Originator: | arnold@skeeve.com (Aharon Robbins) |
"tuxisthebirdforme@gmail.com" <tuxisthebirdforme@gmail.com> writes:
> I know most people anymore use lex/yacc or some derivative of these
> tools to create scanner/parser modules for their compiler projects. I
> was wondering if anyone has developed a scanner or parser that they
> personally hand-wrote? If so, I would like to know what language you
> used and what type of grammar you parsed.
The scanner in GNU Awk (gawk) is hand-written, for a yacc parser. Gawk
builds a parse tree and then recursively evaluates it for each input
record. The lexer builds identifiers and then binary searches a table
indicating what kind of identifier it is (keyword, builtin function),
and if the identifier isn't found in the table, then it returns IDENTIFIER
to the parser.
Unix Awk ("the one true awk") is available from Brian Kernighan's home
pages at Bell Labs and Princeton. Some years ago he rewrote the lexer
from lex into hand-written C. A few bugs were introduced along the way
although there was definitely a portability gain, since the original
awk was pretty intimate with the lex internals. His CHANGES file makes
interesting reading.
Hope this is of interest,
--
Aharon (Arnold) Robbins arnold AT skeeve DOT com
P.O. Box 354 Home Phone: +972 8 979-0381
Nof Ayalon Cell Phone: +972 50 729-7545
D.N. Shimshon 99785 ISRAEL
Return to the
comp.compilers page.
Search the
comp.compilers archives again.