:: Re: [DNG] Studying C as told. (For …
Pàgina inicial
Delete this message
Reply to this message
Autor: KatolaZ
Data:  
A: dng
Assumpte: Re: [DNG] Studying C as told. (For help)
On Fri, Jul 08, 2016 at 11:48:25AM -0400, Hendrik Boom wrote:

[cut]

> >
> > I am not asking because I want to be pedantic, but rather because this
> > is usually where parsing context-free languages becomes an enormous
> > error-prone mess, and is the reason why we have tools like lex/flex
> > and yacc/bison which take care of constructing the parser associated
> > to a set of productions on your behalf.
>
> It is precisely where recursive descent becomes a really easy wy of
> writing a parser. This isn't a difficult language to hand-write a
> parser for. Look up "recursive descent parsing" in the Wikipedia, and
> you'll see how easy it is:
>


You should first put your language in LL(k) form, which is normally
done at the price of multiplying the number of productions, and the
number of functions to be implemented, unless the language is
extremely simple. And maybe Edward's language is simple enough.

I have done that for several languages in the past, and I didn't find
it particularly fun or instructive. Once you have your grammar in
LL(k) form (and the procedure to transform a language in LL(k) form is
basically automatic), it's just about writing mostly repetitive code
which can be efficiently generated by flex and bison in a few seconds.

But again, I agree that we can disagree on what is fun/instructive and
what is not :)

HND

KatolaZ

-- 
[ ~.,_  Enzo Nicosia aka KatolaZ - GLUGCT -- Freaknet Medialab  ]  
[     "+.  katolaz [at] freaknet.org --- katolaz [at] yahoo.it  ]
[       @)   http://kalos.mine.nu ---  Devuan GNU + Linux User  ]
[     @@)  http://maths.qmul.ac.uk/~vnicosia --  GPG: 0B5F062F  ] 
[ (@@@)  Twitter: @KatolaZ - skype: katolaz -- github: KatolaZ  ]