Re: Has anyone hand-written a scanner/parser module?

Dustin Voss <d_j_v@mac.com>
Sat, 29 Nov 2008 14:35:56 -0800

          From comp.compilers

Related articles
[19 earlier articles]
Re: Has anyone hand-written a scanner/parser module? bobduff@shell01.TheWorld.com (Robert A Duff) (2008-11-23)
Re: Has anyone hand-written a scanner/parser module? bobduff@shell01.TheWorld.com (Robert A Duff) (2008-11-23)
Re: Has anyone hand-written a scanner/parser module? charlesb.cca@mpowercom.net (Charles E. Bortle, Jr.) (2008-11-24)
Re: Has anyone hand-written a scanner/parser module? charlesb.cca@mpowercom.net (Charles E. Bortle, Jr.) (2008-11-24)
Re: Has anyone hand-written a scanner/parser module? jmvdveer@xs4all.nl (Marcel van der Veer) (2008-11-25)
Re: Has anyone hand-written a scanner/parser module? baikaishiuc@gmail.com (xianwei) (2008-11-27)
Re: Has anyone hand-written a scanner/parser module? d_j_v@mac.com (Dustin Voss) (2008-11-29)
| List of all articles for this month |
From: Dustin Voss <d_j_v@mac.com>
Newsgroups: comp.compilers
Date: Sat, 29 Nov 2008 14:35:56 -0800
Organization: news.newsdemon.com
References: 08-11-061
Keywords: practice, parse
Posted-Date: 01 Dec 2008 06:58:22 EST

"tuxisthebirdforme@gmail.com" <tuxisthebirdforme@gmail.com> wrote:


> 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. If you feel divulgent,
> please tell me a little bit about you're implementation or what you
> did for intermediate representation. I'm curious and just a bit nosy
> and would like to know how you're experience went doing things this
> way. Thanks.
> [I hand-wrote a scanner for Fortran 77 about 30 years ago. It worked but
> it was pretty gross because Fortran's lexical structure is so strange. -John]


I wrote a PEG parser. I'm using it in a documentation tool, to parse
parts of the Dylan language and (separately) to parse markup.


The Dylan language grammar is hand-written but based on the BNF grammar.
So far, my intermediate representation is the AST, one per file. I then
examine the ASTs and convert them to the intermediate representation
that I'm using for the documentation (which is basically DITA).


The parser itself is written as a Dylan library, simply because that is
my preferred language. It works with grammars expressed as Dylan code
rather than in a separate file.


A top-down grammar can be converted into a recursive-descent parser
fairly directly. If you are doing RD parsing, I don't see much need for
tools like lex or yacc or bison except if you want to check the grammar
for errors.


Granted, it would have been nice to have had some sort of error- and
consistency-checker for the markup grammar. I've had trouble pinning
down some parsing mistakes.


At the time I started this project, I really didn't know much about
parsing at all. I chose to use a recursive descent grammar because
that's what made sense to me; it would have taken longer than I wanted
to understand bottom-up parsing.


Post a followup to this message

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