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

"Felipe Angriman" <felipeangriman@gmail.com>
Sat, 15 Nov 2008 22:12:08 -0200

          From comp.compilers

Related articles
Has anyone hand-written a scanner/parser module? tuxisthebirdforme@gmail.com (tuxisthebirdforme@gmail.com) (2008-11-15)
Re: Has anyone hand-written a scanner/parser module? echristo@gmail.com (Eric Christopher) (2008-11-15)
Re: Has anyone hand-written a scanner/parser module? felipeangriman@gmail.com (Felipe Angriman) (2008-11-15)
Re: Has anyone hand-written a scanner/parser module? mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2008-11-16)
Re: Has anyone hand-written a scanner/parser module? jeremy.bennett@embecosm.com (Jeremy Bennett) (2008-11-16)
Re: Has anyone hand-written a scanner/parser module? barry.j.kelly@gmail.com (Barry Kelly) (2008-11-16)
Re: Has anyone hand-written a scanner/parser module? efutch@gmail.com (Egdares Futch) (2008-11-16)
Re: Has anyone hand-written a scanner/parser module? jgd@cix.compulink.co.uk (2008-11-16)
Re: Has anyone hand-written a scanner/parser module? idbaxter@semdesigns.com (Ira Baxter) (2008-11-16)
[17 later articles]
| List of all articles for this month |

From: "Felipe Angriman" <felipeangriman@gmail.com>
Newsgroups: comp.compilers
Date: Sat, 15 Nov 2008 22:12:08 -0200
Organization: Compilers Central
References: 08-11-061
Keywords: lex, parse, practice
Posted-Date: 16 Nov 2008 17:51:01 EST

> 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?


Wrote an interpreter for a very simple imperative language at university.
Back then I was given the choice of using lex (or some other variant)
or make my custom lexer. I choose to write the lexer by hand because I din't
want to learn lex back. if you're doing some complex pattern matching try using
lex, it is more maintainable the handwritten code


> If so, I would like to know what language you
> used and what type of grammar you parsed.


I used plain old ANSI C 90,
The grammar was LL(1), -> this allows you to compute
First(1) And Follow(1) Sets very easily by hand.
The Parser was a Recursive descent parser


>If you feel divulgent, please tell me a little bit about you're
> implementation or what you did for intermediate representation.


The program generated an AST for intermediate representation.
Then I used a Series of recursive functions to interpret the AST.


> I'm curious and just a bit nosy and would like to know how you're
> experience went doing things this way


If I had to do something serious, I would do some things differently
now, I would choose C#, Java o some other Language which has better
Type Checking and Libraries than C. (I messed things up plenty times
during the construction of the interpreter)


Hope it helps,


-Felipe



Post a followup to this message

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