POV-Ray : Newsgroups : povray.general : New SDL: support for lexical scanner generators : Re: New SDL: support for lexical scanner generators Server Time
31 Jul 2024 06:17:21 EDT (-0400)
  Re: New SDL: support for lexical scanner generators  
From: Bruno Cabasson
Date: 4 Oct 2007 19:50:00
Message: <web.47057b2484df998676e65db0@news.povray.org>
"Wolf" <nomail@nomail> wrote:
> "Bruno Cabasson" <bru### [at] alcatelaleniaspacefr> wrote:
>
> > Right. Perhaps its is a chance for us that the new grammar is intended to be
> > simple (which does not mean 'limited'). However, if it appears that
> > ready-made lexical scanner generators are not OK for our purpose, writing a
> > hand-made one will not be very difficult to specialists. I hope ....
>
> Well, if the new SDL has a grammar which is not representable by a
> general-purpose lexical scanner generator like ANTLR there should be a
> quite good reason to do so. Why would you want to write a complete scanner
> generator if you get one for free by using open source products?
>
> You have to implement the parsing rules anyway. If you implement them by
> hand you will probably end up producing spaghetti code containing lot of
> "IF" statements.
> By writing a grammar specification and using a scanner generator you get
> much cleaner entry points to parts of the grammar (high-level ones like
> textures as well as low-level ones like vectors).
>
>
> Maybe a hand-written scanner is faster than a generated one, but speed
> considerations should not be overweighted here as the parsing time is
> negligible  compared to the rendering time.
>
> - Wolf

If the new syntax does not break the limitations of lexers, we can use one
of them, of course!

If you express the syntax in BNF form as an LL(1) grammar, you can write
quite easily a syntax-directed parser by applying well known rules between
BNF and the language (control statements) you write the parser in. Without
obtaining spaghetti. Perhaps there are some specialists in programing
languages here who can tell more.

My opinion is that whatever parsing technique is used, performances are not
much of a concern: with the machines we have today it will be ALWAYS very
quick for any scene/module we will ever have to parse. The renderer, on the
other hand, must be highly optimized for massive (and vectorized, because
it's the nature of the problem) computations.

Bruno


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.