updated parser rules a bit
git-svn-id: svn://anubis/fart/trunk@85 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
ba7190d7d8
commit
f5dc4c7f93
@ -29,13 +29,28 @@
|
|||||||
\< return LESS;
|
\< return LESS;
|
||||||
\> return GREATER;
|
\> return GREATER;
|
||||||
|
|
||||||
[0-9]+ return DEC_NUMBER;
|
-?[0-9]+ return DEC_NUMBER;
|
||||||
[0-9]*\.[0-9]+ return REAL_NUMBER;
|
-?[0-9]*\.[0-9]+ return REAL_NUMBER;
|
||||||
|
|
||||||
|
box return BOX;
|
||||||
camera return CAMERA;
|
camera return CAMERA;
|
||||||
color return COLOR;
|
color return COLOR;
|
||||||
|
height return HEIGHT;
|
||||||
|
look_at return LOOKAT;
|
||||||
|
material return MATERIAL;
|
||||||
|
multisample return MULTISAMPLE;
|
||||||
|
options return OPTIONS;
|
||||||
|
plane return PLANE;
|
||||||
position return POSITION;
|
position return POSITION;
|
||||||
|
radius return RADIUS;
|
||||||
|
reflectance return REFLECTANCE;
|
||||||
scene return SCENE;
|
scene return SCENE;
|
||||||
|
shininess return SHININESS;
|
||||||
|
size return SIZE;
|
||||||
|
sphere return SPHERE;
|
||||||
|
up return UP;
|
||||||
|
vfov return VFOV;
|
||||||
|
width return WIDTH;
|
||||||
|
|
||||||
\n /* ignore newlines */
|
\n /* ignore newlines */
|
||||||
[ \t\v] /* ignore whitespace */
|
[ \t\v] /* ignore whitespace */
|
||||||
|
@ -20,6 +20,8 @@ int yywrap()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define YYSTYPE void *
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%token PLUS;
|
%token PLUS;
|
||||||
@ -49,21 +51,105 @@ int yywrap()
|
|||||||
%token DEC_NUMBER;
|
%token DEC_NUMBER;
|
||||||
%token REAL_NUMBER;
|
%token REAL_NUMBER;
|
||||||
|
|
||||||
|
%token BOX;
|
||||||
%token CAMERA;
|
%token CAMERA;
|
||||||
%token COLOR;
|
%token COLOR;
|
||||||
|
%token HEIGHT;
|
||||||
|
%token LOOKAT;
|
||||||
|
%token MATERIAL;
|
||||||
|
%token MULTISAMPLE;
|
||||||
|
%token OPTIONS;
|
||||||
|
%token PLANE;
|
||||||
%token POSITION;
|
%token POSITION;
|
||||||
|
%token RADIUS;
|
||||||
|
%token REFLECTANCE;
|
||||||
%token SCENE;
|
%token SCENE;
|
||||||
|
%token SHININESS;
|
||||||
|
%token SIZE;
|
||||||
|
%token SPHERE;
|
||||||
|
%token UP;
|
||||||
|
%token VFOV;
|
||||||
|
%token WIDTH;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
scene: /* empty */
|
scene: /* empty */
|
||||||
| scene_spec { printf("Saw a number\n"); }
|
| scene_spec { printf("Saw a scene\n"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
box: BOX LCURLY box_items RCURLY
|
||||||
|
;
|
||||||
|
|
||||||
|
box_items: shape_items
|
||||||
|
| SIZE vector box_items
|
||||||
|
;
|
||||||
|
|
||||||
|
camera: CAMERA LCURLY camera_items RCURLY
|
||||||
|
;
|
||||||
|
|
||||||
|
camera_items: /* empty */
|
||||||
|
| camera_item camera_items
|
||||||
|
;
|
||||||
|
|
||||||
|
camera_item: POSITION vector
|
||||||
|
| LOOKAT vector
|
||||||
|
| UP vector
|
||||||
|
| VFOV vector
|
||||||
|
;
|
||||||
|
|
||||||
|
material: MATERIAL LCURLY material_items RCURLY
|
||||||
|
;
|
||||||
|
|
||||||
|
material_items: /* empty */
|
||||||
|
| material_item material_items
|
||||||
|
;
|
||||||
|
|
||||||
|
material_item: COLOR vector
|
||||||
|
| REFLECTANCE number
|
||||||
|
| SHININESS number
|
||||||
|
;
|
||||||
|
|
||||||
number: DEC_NUMBER
|
number: DEC_NUMBER
|
||||||
| REAL_NUMBER
|
| REAL_NUMBER
|
||||||
;
|
;
|
||||||
|
|
||||||
|
plane: PLANE LCURLY plane_items RCURLY
|
||||||
|
;
|
||||||
|
|
||||||
|
plane_items: shape_items
|
||||||
|
| POSITION vector COMMA number plane_items
|
||||||
|
;
|
||||||
|
|
||||||
|
scene_spec: SCENE LCURLY scene_items RCURLY
|
||||||
|
;
|
||||||
|
|
||||||
|
scene_items: /* empty */
|
||||||
|
| scene_item scene_items
|
||||||
|
;
|
||||||
|
|
||||||
|
scene_item: camera
|
||||||
|
| shape
|
||||||
|
;
|
||||||
|
|
||||||
|
shape: plane
|
||||||
|
| sphere
|
||||||
|
| box
|
||||||
|
;
|
||||||
|
|
||||||
|
shape_items: /* empty */
|
||||||
|
| material
|
||||||
|
;
|
||||||
|
|
||||||
|
sphere: SPHERE LCURLY sphere_items RCURLY
|
||||||
|
;
|
||||||
|
|
||||||
|
sphere_items: shape_items
|
||||||
|
| RADIUS number sphere_items
|
||||||
|
;
|
||||||
|
|
||||||
|
vector: LESS number COMMA number COMMA number GREATER
|
||||||
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
int parse(const char * fileName)
|
int parse(const char * fileName)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user