POV-Ray : Newsgroups : povray.programming : Parsing a POV-Ray file : Re: Parsing a POV-Ray file Server Time
1 Jun 2024 22:35:50 EDT (-0400)
  Re: Parsing a POV-Ray file  
From: slinky
Date: 22 Jan 2007 14:30:00
Message: <web.45b50fd34ff92f74cb4b8a470@news.povray.org>
Are there any tools/libraries to use if we don't want to write our own
parser? There seems to be a LOT of interest in having a parser which will
read *.pov
files into C or C++ objects so that the objects can be rendered by something
other than povray. The scene description language just forms a convenient
format. For instance, the source code for POV-ray MUST have code which
parses
*.pov files into 3D data, and materials definitions/etc. I've been looking
through this code with the intent of re-using it to do exactly what you are
talking about. I've found the code that tokenizes the pov file, but not the
code that takes these tokens and assigns spatial information/materials/etc.
Is
there some documentation for povrary which describes how file IO is handled?
"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.