POV-Ray : Newsgroups : povray.programming : Pasing pov in C Server Time
23 Dec 2024 06:20:30 EST (-0500)
  Pasing pov in C (Message 1 to 9 of 9)  
From: Skinou
Subject: Pasing pov in C
Date: 25 Nov 2002 21:23:03
Message: <3de2db07@news.povray.org>
Hello I am a french student and I work for a school project on a raytracer
in C wich take a pov file and give a tga file.

Can some one help me please ?

Skinou


Post a reply to this message

From: Christopher James Huff
Subject: Re: Pasing pov in C
Date: 25 Nov 2002 21:31:48
Message: <chrishuff-08B6EA.21285625112002@netplex.aussie.org>
In article <3de2db07@news.povray.org>, "Skinou" <ski### [at] wanadoofr> 
wrote:

> Hello I am a french student and I work for a school project on a raytracer
> in C wich take a pov file and give a tga file.

It already exists and is called "POV-Ray". ;-)

Seriously, what you are talking about is basically a complete clone of 
POV, far too much work for a "school project". Just parsing the language 
would be a huge amount of work, assuming you only partially implement 
the renderer and don't require an exactly identical image. POV has 
developed bit by bit over many years and has countless odd little 
quirks, there is no language specification other than the documentation.

A simple language which would be similar enough to POV to render some 
POV scenes would be more doable, but I think you would be better off 
improving on it than doing a blind copy.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: ABX
Subject: Re: Pasing pov in C
Date: 26 Nov 2002 02:36:19
Message: <ug86uuceqpla68acrfpe6k7u40pcr5chhh@4ax.com>
On Tue, 26 Nov 2002 03:23:05 +0100, "Skinou" <ski### [at] wanadoofr> wrote:
> Hello I am a french student and I work for a school project on a raytracer
> in C wich take a pov file and give a tga file.

There is more than ten years behind POV-Ray. I doubt it is a good idea to
duplicate all features within school project. But if you do not want all
features then you don't need POV-parser probably. Just define some subset of
features you plan to support and then you can create own simple format.

Playing with DocBook I have readed there are some tools to automatically
create parsers for C++ - you only have to define syntax/grammar in XML iirc.
Sorry, I don't remember details.

ABX


Post a reply to this message

From: Alex
Subject: Re: Pasing pov in C
Date: 5 Dec 2002 09:25:07
Message: <web.3def609ec2e254ed15e7f0160@news.povray.org>
>Playing with DocBook I have readed there are some tools to automatically
>create parsers for C++ - you only have to define syntax/grammar in XML iirc.
>Sorry, I don't remember details.
>
>ABX
>
 Two words:

 flex, bison

Alex


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Pasing pov in C
Date: 5 Dec 2002 09:51:48
Message: <3def6804$1@news.povray.org>
In article <web.3def609ec2e254ed15e7f0160@news.povray.org> , "Alex" 
<ale### [at] alphacit> wrote:

> Two words:
>
> flex, bison

Two words ;-)

Not feasible.


    thorsten


Post a reply to this message

From: Philippe Lhoste
Subject: Re: Pasing pov in C
Date: 6 Dec 2002 08:15:16
Message: <Xns92DC90B2EA3BBPhiLho@204.213.191.226>
"Skinou" <ski### [at] wanadoofr> wrote in news:3de2db07@news.povray.org:

> Hello I am a french student and I work for a school project on a
> raytracer in C wich take a pov file and give a tga file.
> 
> Can some one help me please ?

You may want to use the FreeType library to render the POV-Ray source file 
text on a TGA page... Or ImageMagick library, perhaps.
Can be interesting if you use syntax highlighting.

Or, perhaps that's not what you meant ;-P

-- 
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist
http://jove.prohosting.com/~philho/


Post a reply to this message

From: Mike Lundy
Subject: Re: Pasing pov in C
Date: 13 May 2003 18:22:09
Message: <3EC1704B.8030200@netscape.net>
/* FILE: pov2html.yy */






/************************************************************************/
/*                             Code section                             */
/************************************************************************/

%{

/* Syntax highlite a POV-Ray 3.5 script using FLEX. Output is HTML.
  * by Mike Lundy - May 10, 2003
  *
  * To complie:
  *  flex pov.yy
  *  gcc lex.yy.c -lfl -opov2html
  *
  * Usage: pov2html <filename.pov >filename.html
  *    or: pov2html filename.pov >filename.html
  *    or: pov2html filename.pov filename.html
  */

#define PAGE_COLOR              "#FDF5E6"
#define TEXT_COLOR              "#000000"
#define KEYWORD_COLOR           "#0000BF"
#define DIRECTIVE_COLOR         "#0000FF"
#define COMMENT_COLOR           "#007F00"
#define STRING_COLOR            "#BF0000"
#define INTEGER_COLOR           "#800080"
#define FLOAT_COLOR             "#800080"
#define OPERATOR_COLOR          "#FF0000"
#define DELIMITER_COLOR         "#008080"

#define FONT_TAG(tExT, cOlOr)   fprintf(yyout, "<FONT COLOR=\"%s\">%s</FONT>",
(cOlOr), (tExT));
#define ECHO                    fprintf(yyout, "%s", yytext);
#define AUTHOR                  "mwl### [at] netscapenet"

/* tidy HTML source on '//' type comments */
char *kill_EOL (char* line)
{
     char *p1 = line;
     int len = 0;
     while(*p1++) len++;
     if( (line[--len]) == '\n') { line[len] = 0; }
     return line;
}

%}


/************************************************************************/
/*                          Definition section                          */
/************************************************************************/

%option noyywrap

DIGIT   [0-9]

INTEGER {DIGIT}+

FLOAT   ({DIGIT}+"."{DIGIT}*)|("."{DIGIT}+)|({DIGIT}+".")

STRING \"[^"]*[\"]*\"

OPERATOR [+*/|!:?=]|"-"

DELIMITER [;{}]

DIRECTIVE
break|case|debug|declare|default|else|end|error|fclose|fopen|if|ifdef|ifndef|include|local|macro|range|read|render|statistics|switch|undef|version|warning|while|write

%x comment1
%x comment2


/************************************************************************/
/*                             Rules section                            */
/************************************************************************/

%%

"/*"                     { BEGIN(comment1); fprintf(yyout, "<FONT COLOR=\"%s\">%s",
COMMENT_COLOR, yytext); }
<comment1>[^*\n]*        ECHO;
<comment1>[^*\n]*\n      ECHO;
<comment1>"*"+[^*/\n]*   ECHO;
<comment1>"*"+[^*/\n]*\n ECHO;
<comment1>"*"+"/"        { fprintf(yyout, "%s%s", yytext, "</FONT>"); BEGIN(INITIAL);
}

"//"                     { BEGIN(comment2); fprintf(yyout, "<FONT COLOR=\"%s\">%s",
COMMENT_COLOR, yytext);; }
<comment2>\n+            { fprintf(yyout, "%s%s", kill_EOL(yytext), "</FONT>\n");
BEGIN(INITIAL); }

<comment1,comment2><     { fprintf(yyout, "%s", "<"  ); }
<comment1,comment2>>     { fprintf(yyout, "%s", ">"  ); }
<comment1,comment2>&     { fprintf(yyout, "%s", "&" ); }
<comment1,comment2>\"    { fprintf(yyout, "%s", """); }

<INITIAL><               { FONT_TAG("<",   OPERATOR_COLOR); }
<INITIAL>>               { FONT_TAG(">",   OPERATOR_COLOR); }
<INITIAL>&               { FONT_TAG("&",  OPERATOR_COLOR); }
<INITIAL>\"              { FONT_TAG(""", STRING_COLOR);   }

{STRING}                 { FONT_TAG(yytext, STRING_COLOR);    }
{OPERATOR}               { FONT_TAG(yytext, OPERATOR_COLOR);  }
{INTEGER}                { FONT_TAG(yytext, INTEGER_COLOR);   }
{FLOAT}                  { FONT_TAG(yytext, FLOAT_COLOR);     }
{DELIMITER}              { FONT_TAG(yytext, DELIMITER_COLOR); }
#+[ \t]*{DIRECTIVE}+     { FONT_TAG(yytext, DIRECTIVE_COLOR); }

aa_level                        |
aa_threshold                    |
abs                             |
absorption                      |
accuracy                        |
acos                            |
acosh                           |
adaptive                        |
adc_bailout                     |
agate                           |
agate_turb                      |
all                             |
all_intersections               |
alpha                           |
altitude                        |
always_sample                   |
ambient                         |
ambient_light                   |
angle                           |
aperture                        |
append                          |
arc_angle                       |
area_light                      |
array                           |
asc                             |
ascii                           |
asin                            |
asinh                           |
assumed_gamma                   |
atan                            |
atan2                           |
atanh                           |
autostop                        |
average                         |
b_spline                        |
background                      |
bezier_spline                   |
bicubic_patch                   |
black_hole                      |
blob                            |
blue                            |
blur_samples                    |
bounded_by                      |
box                             |
boxed                           |
bozo                            |
break                           |
brick                           |
brick_size                      |
brightness                      |
brilliance                      |
bump_map                        |
bump_size                       |
bumps                           |
camera                          |
case                            |
caustics                        |
ceil                            |
cells                           |
charset                         |
checker                         |
chr                             |
circular                        |
clipped_by                      |
clock                           |
clock_delta                     |
clock_on                        |
collect                         |
color                           |
color_map                       |
colour                          |
colour_map                      |
component                       |
composite                       |
concat                          |
cone                            |
confidence                      |
conic_sweep                     |
conserve_energy                 |
contained_by                    |
control0                        |
control1                        |
coords                          |
cos                             |
cosh                            |
count                           |
crackle                         |
crand                           |
cube                            |
cubic                           |
cubic_spline                    |
cubic_wave                      |
cutaway_textures                |
cylinder                        |
cylindrical                     |
debug                           |
declare                         |
default                         |
defined                         |
degrees                         |
density                         |
density_file                    |
density_map                     |
dents                           |
df3                             |
difference                      |
diffuse                         |
dimension_size                  |
dimensions                      |
direction                       |
disc                            |
dispersion                      |
dispersion_samples              |
dist_exp                        |
distance                        |
div                             |
double_illuminate               |
eccentricity                    |
else                            |
emission                        |
end                             |
error                           |
error_bound                     |
evaluate                        |
exp                             |
expand_thresholds               |
exponent                        |
exterior                        |
extinction                      |
face_indices                    |
facets                          |
fade_color                      |
fade_colour                     |
fade_distance                   |
fade_power                      |
falloff                         |
falloff_angle                   |
false                           |
fclose                          |
file_exists                     |
filter                          |
final_clock                     |
final_frame                     |
finish                          |
fisheye                         |
flatness                        |
flip                            |
floor                           |
focal_point                     |
fog                             |
fog_alt                         |
fog_offset                      |
fog_type                        |
fopen                           |
form                            |
frame_number                    |
frequency                       |
fresnel                         |
function                        |
gather                          |
gif                             |
global_lights                   |
global_settings                 |
gradient                        |
granite                         |
gray                            |
gray_threshold                  |
green                           |
height_field                    |
hexagon                         |
hf_gray_16                      |
hierarchy                       |
hypercomplex                    |
hollow                          |
if                              |
ifdef                           |
iff                             |
ifndef                          |
image_height                    |
image_map                       |
image_pattern                   |
image_width                     |
include                         |
initial_clock                   |
initial_frame                   |
inside                          |
inside_vector                   |
int                             |
interior                        |
interior_texture                |
internal                        |
interpolate                     |
intersection                    |
intervals                       |
inverse                         |
ior                             |
irid                            |
irid_wavelength                 |
isosurface                      |
jitter                          |
jpeg                            |
julia                           |
julia_fractal                   |
lambda                          |
lathe                           |
leopard                         |
light_group                     |
light_source                    |
linear_spline                   |
linear_sweep                    |
ln                              |
load_file                       |
local                           |
location                        |
log                             |
look_at                         |
looks_like                      |
low_error_factor                |
macro                           |
magnet                          |
major_radius                    |
mandel                          |
map_type                        |
marble                          |
material                        |
material_map                    |
matrix                          |
max                             |
max_extent                      |
max_gradient                    |
max_intersections               |
max_iteration                   |
max_sample                      |
max_trace                       |
max_trace_level                 |
media                           |
media_attenuation               |
media_interaction               |
merge                           |
mesh                            |
mesh2                           |
metallic                        |
method                          |
metric                          |
min                             |
min_extent                      |
minimum_reuse                   |
mod                             |
mortar                          |
natural_spline                  |
nearest_count                   |
no                              |
no_bump_scale                   |
no_image                        |
no_reflection                   |
no_shadow                       |
noise_generator                 |
normal                          |
normal_indices                  |
  normal_map                     |
normal_vectors                  |
number_of_waves                 |
object                          |
octaves                         |
off                             |
offset                          |
omega                           |
omnimax                         |
on                              |
once                            |
onion                           |
open                            |
orient                          |
orientation                     |
orthographic                    |
panoramic                       |
parallel                        |
parametric                      |
pass_through                    |
pattern                         |
perspective                     |
pgm                             |
phase                           |
phong                           |
phong_size                      |
photons                         |
pi                              |
pigment                         |
pigment_map                     |
pigment_pattern                 |
planar                          |
plane                           |
png                             |
point_at                        |
poly                            |
poly_wave                       |
polygon                         |
pot                             |
pow                             |
ppm                             |
precision                       |
precompute                      |
pretrace_end                    |
pretrace_start                  |
prism                           |
prod                            |
projected_through               |
pwr                             |
quadratic_spline                |
quadric                         |
quartic                         |
quaternion                      |
quick_color                     |
quick_colour                    |
quilted                         |
radial                          |
radians                         |
radiosity                       |
radius                          |
rainbow                         |
ramp_wave                       |
rand                            |
range                           |
ratio                           |
read                            |
reciprocal                      |
recursion_limit                 |
red                             |
reflection                      |
reflection_exponent             |
refraction                      |
render                          |
repeat                          |
rgb                             |
rgbf                            |
rgbft                           |
rgbt                            |
right                           |
ripples                         |
rotate                          |
roughness                       |
samples                         |
save_file                       |
scale                           |
scallop_wave                    |
scattering                      |
seed                            |
select                          |
shadowless                      |
sin                             |
sine_wave                       |
sinh                            |
size                            |
sky                             |
sky_sphere                      |
slice                           |
slope                           |
slope_map                       |
smooth                          |
smooth_triangle                 |
solid                           |
sor                             |
spacing                         |
specular                        |
sphere                          |
sphere_sweep                    |
spherical                       |
spiral1                         |
spiral2                         |
spline                          |
split_union                     |
spotlight                       |
spotted                         |
sqr                             |
sqrt                            |
statistics                      |
str                             |
strcmp                          |
strength                        |
strlen                          |
strlwr                          |
strupr                          |
sturm                           |
substr                          |
sum                             |
superellipsoid                  |
switch                          |
sys                             |
t                               |
tan                             |
tanh                            |
target                          |
text                            |
texture                         |
texture_list                    |
texture_map                     |
tga                             |
thickness                       |
threshold                       |
tiff                            |
tightness                       |
tile2                           |
tiles                           |
tolerance                       |
toroidal                        |
torus                           |
trace                           |
transform                       |
translate                       |
transmit                        |
triangle                        |
triangle_wave                   |
true                            |
ttf                             |
turb_depth                      |
turbulence                      |
type                            |
u                               |
u_steps                         |
ultra_wide_angle                |
undef                           |
union                           |
up                              |
use_alpha                       |
use_color                       |
use_colour                      |
use_index                       |
utf8                            |
uv_indices                      |
uv_mapping                      |
uv_vectors                      |
v                               |
v_steps                         |
val                             |
variance                        |
vaxis_rotate                    |
vcross                          |
vdot                            |
version                         |
vertex_vectors                  |
vlength                         |
vnormalize                      |
vrotate                         |
vstr                            |
vturbulence                     |
warning                         |
warp                            |
water_level                     |
waves                           |
while                           |
width                           |
wood                            |
wrinkles                        |
write                           |
x                               |
y                               |
yes                             |
z                        { FONT_TAG(yytext, KEYWORD_COLOR); }

[a-zA-Z0-9_#]+         |
<*>.|\n                ECHO;

<<EOF>> yyterminate();
%%


/************************************************************************/
/*                          User code section                           */
/************************************************************************/

#include <time.h>

/* return current system date & time as char ptr */
char* get_time(void)
{
     static char *the_time_str;

     time_t the_time;
     time(&the_time);
     the_time_str = ctime(&the_time);
     return(the_time_str);
}

int main(int argc, char **argv)
{
     if (!yyin) yyin = stdin;
     if (!yyout) yyout = stdout;

     if(argc >= 2) {
         if( (yyin = fopen (argv[1], "r")) == NULL) {
             perror(argv[1]);
             return(1);
         }
         if(argc == 3) {
             if( (yyout = fopen (argv[2], "w")) == NULL) {
                 perror(argv[2]);
                 return(2);
             }
         }
     }

     fprintf(yyout, "<HTML>\n"
                    "<HEAD>\n"
                    "  <META NAME=\"GENERATOR\" CONTENT=\"%s by %s %s\">\n"
                    "  <TITLE>POV-Ray SDL: %s</TITLE>\n"
                    "</HEAD>\n"
                    "<BODY BGCOLOR=\"%s\" TEXT=\"%s\">\n\n"
                    "<PRE>\n",
                    argv[0], AUTHOR, __DATE__, get_time(), PAGE_COLOR, TEXT_COLOR );
     yylex();

     fprintf(yyout, "</PRE>\n"
                    "<BR>\n"
                    "</BODY>\n"
                    "</HTML>\n" );
     return(0);
}





/* EOF */



Alex wrote:
>>Playing with DocBook I have readed there are some tools to automatically
>>create parsers for C++ - you only have to define syntax/grammar in XML iirc.
>>Sorry, I don't remember details.
>>
>>ABX
>>
> 
>  Two words:
> 
>  flex, bison
> 
> Alex
>


Post a reply to this message

From: ABX
Subject: Re: Pasing pov in C
Date: 13 May 2003 18:33:49
Message: <n5s2cvkm64gqkgb48m2sdj5908oqtjdhvf@4ax.com>
On Tue, 13 May 2003 15:23:07 -0700, Mike Lundy <mwl### [at] netscapenet> wrote:
> /* Syntax highlite a POV-Ray 3.5 script using FLEX. Output is HTML.
>  * by Mike Lundy - May 10, 2003

While this file can be interesting for others, you missed that discussion was
about making working _parser_, not creating document with highlited syntax.
Scripts for making HTML from POV script were already made in various tools.
Sending long script without any comment into IMO wrong group is useless.
I see it is a fresh work - perhaps announcement in other group could make your
marketing better.

ABX


Post a reply to this message

From: Peter Popov
Subject: Re: Pasing pov in C
Date: 14 May 2003 02:09:14
Message: <r7n3cv0etvq5is6r88kvqtjhcljivpagss@4ax.com>
Why don't you try posting this in povray.binaries.utilities (as an
attachment) or povray.text.utilities (pasted in the body as you did
now)? This way your utility will get the attention it deserves which
is not likely to happen in the middle of this somewhat unrelated
thread. Just some friendly piece of advice :)


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

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