POV-Ray : Newsgroups : povray.programming : Parsing a POV-Ray file : Re: Parsing a POV-Ray file Server Time
1 Jun 2024 09:45:13 EDT (-0400)
  Re: Parsing a POV-Ray file  
From: slinky
Date: 22 Jan 2007 13:25:01
Message: <web.45b500314ff92f74cb4b8a470@news.povray.org>
I need a parser for *.pov files, which will extract the relevant information
from the script so that it could be displayed/processed/modified by a
project that I am working on. Although it would be quite possible to write
such a thing myself, it would be better to not reinvent the wheel. Does
anyone
know where I could find already existing code to do this? ... or tell me how
povray itself does this? It occurred to me that povray MUST have code to do
this and that I could perhaps reuse their code. However, I been through the
source code several times and I cannot find the code which really parses
the file into useful information. I DID find a file which seemed to be able
to tokenize the script, but after that ... no luck. Thanks for your help.
"Paul Senzee" <pse### [at] yahoocom> wrote:
> Hi Oodini,
>
> If you're looking to use flex or bison I'd recommend the o'reilly book
> 'lex/yacc' by John Levine (I think).  However, given pov's grammar it's
> actually quite doable (and probably more maintainable) as a top-down hand
> written parser.  Given the pov syntax in BNF it's a mostly straightforward
> (although laborious) task to translate that into a C top-down parser.
>
> Either way, for moderate to complex parsing tasks, it's best to divide
> parsing into two activities:  lexing and parsing.  Lexing is separating your
> input stream of characters into 'tokens'.  A 'token' would be one meaningful
> symbol from the input stream, such as any keyword, non-character symbol
> (such as '{' or '<'), a string literal, a number, etc.  Parsing is combining
> those tokens into some other meaningful form, typically a syntax tree.
>
> Paul Senzee
>
> "Oodini" <svd### [at] freefr> wrote in message
> news:432da226$1@news.povray.org...
> > Hello,
> >
> > I programmed a simple 3D renderer in C, and I would like to include a
> > parsing functionnality.
> >
> > I don't know anything about parsing, BNF, flex and other bisons.
> > I supposed I am not the first one to do this kind of project. Could
> > anyone provide me some links to or advices to get some success with this
> > project ?
> >
> > Ideally: I'd like to have:
> >
> > 1 - some theory on BNF
> > 2 - some examples of grammar, possibly with a scene description language
> > 3 - some tutorials with flex or bison
> >
> > If you have any other material to provide, you're welcome. :-)


Post a reply to this message

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