|Has anyone hand-written a scanner/parser module? firstname.lastname@example.org (email@example.com) (2008-11-15)|
|Re: Has anyone hand-written a scanner/parser module? firstname.lastname@example.org (Eric Christopher) (2008-11-15)|
|Re: Has anyone hand-written a scanner/parser module? email@example.com (Felipe Angriman) (2008-11-15)|
|Re: Has anyone hand-written a scanner/parser module? firstname.lastname@example.org (Dmitry A. Kazakov) (2008-11-16)|
|Re: Has anyone hand-written a scanner/parser module? email@example.com (Jeremy Bennett) (2008-11-16)|
|Re: Has anyone hand-written a scanner/parser module? firstname.lastname@example.org (Barry Kelly) (2008-11-16)|
|Re: Has anyone hand-written a scanner/parser module? email@example.com (Egdares Futch) (2008-11-16)|
|Re: Has anyone hand-written a scanner/parser module? firstname.lastname@example.org (2008-11-16)|
|Re: Has anyone hand-written a scanner/parser module? email@example.com (Ira Baxter) (2008-11-16)|
|[17 later articles]|
|From:||"Felipe Angriman" <firstname.lastname@example.org>|
|Date:||Sat, 15 Nov 2008 22:12:08 -0200|
|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,
Return to the
Search the comp.compilers archives again.