POV-Ray : Newsgroups : povray.general : using flex and bison to parse povray scenes Server Time
14 Aug 2024 07:16:46 EDT (-0400)
  using flex and bison to parse povray scenes (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From:
Subject: using flex and bison to parse povray scenes
Date: 12 Feb 1998 15:00:47
Message: <34E354EE.6A4B@HRZ.Uni-Bielefeld.DE>
Hi !

There's something I've been tossing around for some time: Parsing a
POVRAY scene, using a Parser built from flex and bison.
The idea is, that the parser generates an object-tree, than can be used
to generate the original scene (optinally: minus objects, that are not
referenced in the scene). Object in this context is everything from
Textures to Fog and geometric objects.

There would be several uses for this:
- pre-processor, to remove unused objects from the scene, remove
comments, unroll loops
- import POVRAY scenes into a modeller
- make scripts, that generate scenes from templates

I've done some first work on this, and I concentrated on textures first.
The current state of the code does nothing except parsing a file and
checking for syntax. There are a few problems, why I stopped this
project some time ago:
- The POVRAY syntax is very lazy, especially with textures. I used some
"strict" syntax, for example pigment-options can only be inside a
pigment - block.
- The mixture of vector and scalar expressions is difficult to parse. It
would be easier, if some explicit functions to convert between scalar
and vector would be used.
- It's difficult to find a clean object-structure for some of the POVRAY
concepts.

Questions:
- Has anybody else made a flex+bison parser for POVRAY scenes, where I
could get some ideas ?
- Is it possible, to write the POVRAY language in BNF notation ?
- Does anybody have some good ideas to store a POVRAY scene in memory?
  Specification for this:
  - not copied from the POVRAY source !
  - easy manipulation of Objects (rearranging the tree)
  - keeps ALL attributes of the Objekts

			Jens Ch. Restemeier


Post a reply to this message

From: Ken Cecka
Subject: Re: using flex and bison to parse povray scenes
Date: 12 Feb 1998 16:06:43
Message: <34e37136.0@news.povray.org>
You might check out libparpov at
http://wwwcip.informatik.uni-erlangen.de/~cnvogelg/parpov/index.html .
It's not flex or bison, but it's a fairly complete parser from what I've
heard.

Ken


>There's something I've been tossing around for some time: Parsing a
>POVRAY scene, using a Parser built from flex and bison.
>- Has anybody else made a flex+bison parser for POVRAY scenes, where I
>could get some ideas ?
>- Is it possible, to write the POVRAY language in BNF notation ?

> Jens Ch. Restemeier


Post a reply to this message

From: Jens Christian Restemeier
Subject: Re: using flex and bison to parse povray scenes
Date: 13 Feb 1998 10:01:57
Message: <34E46065.101A@hrz.uni-bielefeld.de>
Ken Cecka wrote:
> 
> You might check out libparpov at
> http://wwwcip.informatik.uni-erlangen.de/~cnvogelg/parpov/index.html .
> It's not flex or bison, but it's a fairly complete parser from what I've
> heard.

Yes, that library is mostly what I had in mind. Only problem is, that it
is based on C++, and I'd like to use plain 'c' and do a c++ wrapper
later.

			Jens Ch. Restemeier
----
"Five to one against and falling ...  four to one against and falling
... three to one ... two ... one ... probability factor one to one ...
we have normality, I repeat we have normality. Anything you still can't
cope with is therefore your own problem."


Post a reply to this message

From: Ken Cecka
Subject: Re: using flex and bison to parse povray scenes
Date: 13 Feb 1998 18:08:01
Message: <34e4df1b.0@news.povray.org>
Can't you write your program in c and use a c++ compiler (gcc or something)
to compile with it.  The library should work for you either way.

Ken

Jens Christian Restemeier wrote in message
<34E### [at] hrzuni-bielefeldde>...
>Ken Cecka wrote:
>>
>> You might check out libparpov at
>> http://wwwcip.informatik.uni-erlangen.de/~cnvogelg/parpov/index.html .
>> It's not flex or bison, but it's a fairly complete parser from what I've
>> heard.
>
>Yes, that library is mostly what I had in mind. Only problem is, that it
>is based on C++, and I'd like to use plain 'c' and do a c++ wrapper
>later.
>
> Jens Ch. Restemeier
>----
>"Five to one against and falling ...  four to one against and falling
>... three to one ... two ... one ... probability factor one to one ...
>we have normality, I repeat we have normality. Anything you still can't
>cope with is therefore your own problem."


Post a reply to this message

From: Thomas Baier
Subject: Re: using flex and bison to parse povray scenes
Date: 13 Feb 1998 00:44:40
Message: <34E3DDC8.FE2E8F40@ibm.net>
Hi


> Questions:
> - Has anybody else made a flex+bison parser for POVRAY scenes, where I
> could get some ideas ?
>

Yes. Please have a look at POV2MDL, a povray 2.2 to Moray converter.Yes, i
have done a Parser with Lex&Yacc. Povray has really a lazzy syntax.
I think it is a impossible to write a Lex&Yacc parser with the quality of


The SDK is at http://ourworld.compuserve.com/homepages/thbaier.


> - Is it possible, to write the POVRAY language in BNF notation ?
> - Does anybody have some good ideas to store a POVRAY scene in memory?
>   Specification for this:
>   - not copied from the POVRAY source !
>   - easy manipulation of Objects (rearranging the tree)
>   - keeps ALL attributes of the Objekts
>
>                         Jens Ch. Restemeier

  Thomas


Post a reply to this message

From: Jens Christian Restemeier
Subject: Re: using flex and bison to parse povray scenes
Date: 13 Feb 1998 10:09:19
Message: <34E4621F.293E@hrz.uni-bielefeld.de>
Thomas Baier wrote:
> 
> Hi
> 
> > Questions:
> > - Has anybody else made a flex+bison parser for POVRAY scenes, where I
> > could get some ideas ?
> >
> 
> Yes. Please have a look at POV2MDL, a povray 2.2 to Moray converter.Yes, i
> have done a Parser with Lex&Yacc. Povray has really a lazzy syntax.
> I think it is a impossible to write a Lex&Yacc parser with the quality of


> The SDK is at http://ourworld.compuserve.com/homepages/thbaier.

Hey, that's a cool idea. Have you contacted the POVRAY members, to
support POB as an official file-format ?
				Jens Ch. Restemeiers

----
"Five to one against and falling ...  four to one against and falling
... three to one ... two ... one ... probability factor one to one ...
we have normality, I repeat we have normality. Anything you still can't
cope with is therefore your own problem."


Post a reply to this message

From: Mathias Broxvall
Subject: Re: using flex and bison to parse povray scenes
Date: 13 Feb 1998 15:45:17
Message: <1d4eria.i06qbudukyc0N@dialup178-2-29.swipnet.se>
Jens Christian Restemeier <jch### [at] hrzuni-bielefeldde> wrote:


> Hey, that's a cool idea. Have you contacted the POVRAY members, to
> support POB as an official file-format ?

Oh no!!! Povray is a great language, but;

1] The povray language is turing complete -> no all
  3D applications want to allow "programs" in the documents.
  (For example - you can actually write postscript "viruses"
   and simply postscript files which loops indefinatly and have
   other "bugs" in them)

2] That would rather limit the possibilities of "enhancing" the
  language. Someone once claimed you where quite limited by not
  having any delimiters (like ';') between the "sentences" or
  objects. I'm not sure it's true - but maybe it's good if such
  a thing could be added to the language. (A small hack could
  probably convert all oldstyle includes/scenes to the new syntax)

/ Mathias Broxvall


Post a reply to this message

From: %
Subject: Re: using flex and bison to parse povray scenes
Date: 13 Feb 1998 16:18:53
Message: <34E4B8BB.1F52@HRZ.Uni-Bielefeld.DE>
Mathias Broxvall wrote:
> 
> Jens Christian Restemeier <jch### [at] hrzuni-bielefeldde> wrote:
> 
> > Hey, that's a cool idea. Have you contacted the POVRAY members, to
> > support POB as an official file-format ?
> 
> Oh no!!! Povray is a great language, but;
> 
> 1] The povray language is turing complete -> no all
>   3D applications want to allow "programs" in the documents.
>   (For example - you can actually write postscript "viruses"
>    and simply postscript files which loops indefinatly and have
>    other "bugs" in them)
> 
> 2] That would rather limit the possibilities of "enhancing" the
>   language. Someone once claimed you where quite limited by not
>   having any delimiters (like ';') between the "sentences" or
>   objects. I'm not sure it's true - but maybe it's good if such
>   a thing could be added to the language. (A small hack could
>   probably convert all oldstyle includes/scenes to the new syntax)

So what is this going to mean ? 
I was suggesting to support the binary POV format, as produced by the
patched POVRAY in the POB_SDK, as an additinal input-format in the
official POV.
The idea of POB is quite nice: POVRAY parses the scene, and writes a
binary object-file (like 3ds or lightwave), which can be easily loaded
by viewers, previewers, modelers and converters.

This could even simplify the normal POVRAY package: it is split into a
renderer and a parser (or better: compiler).
You write your normal scenes in the POVRAY script-language, and compile
it into a binary scene. Then you pass the binary file into the renderer.

But the current POB package has a major disadvantage, which makes it
unuseable for a project I had in mind: It doesn't store the names, that
are defined in a scene-name.

			Jens Ch. Restemeier


Post a reply to this message

From: %
Subject: Re: using flex and bison to parse povray scenes
Date: 13 Feb 1998 16:23:10
Message: <34E4B9BC.3AAA@HRZ.Uni-Bielefeld.DE>
> But the current POB package has a major disadvantage, which makes it
> unuseable for a project I had in mind: It doesn't store the names, that
> are defined in a scene-name.

#define My_cool_White_Texture ....

becomes

#define texture_63234 .....


Post a reply to this message

From: Thomas Baier
Subject: Re: using flex and bison to parse povray scenes
Date: 15 Feb 1998 03:20:47
Message: <34E6A55F.D0D3FFB9@ibm.net>
Hi Jens,

> But the current POB package has a major disadvantage, which makes it
> unuseable for a project I had in mind: It doesn't store the names, that
> are defined in a scene-name.
>
>                         Jens Ch. Restemeier

  You are right: all names dsiappear.
It takes some time to make it right. It was my first release :-))

Thomas


Post a reply to this message

Goto Latest 10 Messages Next 3 Messages >>>

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