Appendix A: Scene File Grammar
This appendix contains the formal syntax of the mental images .mi scene description format. The grammar is in yacc format. Nonterminals that begin with T_ are typed values:
%start ray_input %token <symbol> T_SYMBOL %token <integer> T_INTEGER %token <floating> T_FLOAT %token <string> T_STRING %token <byte_string> T_BYTE_STRING %token <vect_type> T_VECTOR %token MAPSTO /* -> */ %token OPEN CLOSE /* ( ) */ %token COMMA /* , */ %token SUB BUS /* [ ] */ %token ACCELERATION ADAPTIVE APERTURE APPROXIMATE ARRAY %token ASPECT %token BACK BASIS BEZIER BLUE BOOLEAN BOTH BOX BSPLINE %token CARDINAL CLASSIFICATION CLIP CODE COLOR CONNECT %token CONTOUR CONTRAST CP CURVATURE CURVE CURVE3 %token DECLARE DEPTH DESATURATE DIRECTION DISC DISCONTINUITY %token DISPLACE DITHER %token ECHO END ENVIRONMENT EVEN %token FACE FALSE FIELD FILTER FOCAL FRAME FRONT %token GAMMA GAUSS GEOMETRY GREEN GROUP %token HOLE %token IMP IMPLICIT INFINITY INTEGER %token JITTER %token LBRACE LENS LIGHT LINE LINK LOAD LOCAL %token M MATERIAL MATRIX MAX MEMORY MERGE MIN %token N NOCONTOUR %token OBJECT ODD OFF ON OPAQUE OPTION ORIGIN OUTPUT %token P PAPER PARAMETRIC %token RATIONAL RAY RBRACE RECTANGLE RECURSIVE RED REMOVE %token RESOLUTION SAMPLES SAVE SCALAR SCALE SCANLINE SHADOW %token SHUTTER SIZE SORT SPATIAL STRING SPECIAL SPHERE %token STRUCT SUBDIVISION SURFACE SYSTEM %token T TAG TAYLOR TEXTURE TRACE TRANSFORM TRIANGLE TRIM %token TRUE %token V VECTOR VERBOSE VERSION VIEW VISIBLE VOLUME %token WHITE WIDTH WINDOW %% ray_input : command_list ; /*--------------------------------------------------------- * top-level commands *-------------------------------------------------------*/ command_list : command | command_list command ; command : frame | texture | VERSION T_STRING | VERBOSE boolean | ECHO T_STRING | SYSTEM T_STRING | MEMORY T_INTEGER | CODE T_STRING | CODE code_bytes_list | LINK T_STRING | DECLARE function_decl ; code_bytes_list : T_BYTE_STRING | code_bytes_list T_BYTE_STRING ; /*--------------------------------------------------------- * primitive types *-------------------------------------------------------*/ boolean : ON | OFF | TRUE | FALSE ; vector : T_FLOAT T_FLOAT T_FLOAT | T_VECTOR ; transform : TRANSFORM T_FLOAT T_FLOAT T_FLOAT T_FLOAT T_FLOAT T_FLOAT T_FLOAT T_FLOAT T_FLOAT T_FLOAT T_FLOAT T_FLOAT T_FLOAT T_FLOAT T_FLOAT T_FLOAT ; symbol : T_SYMBOL | T_STRING ; /*--------------------------------------------------------- * function declaration *-------------------------------------------------------*/ function_decl : T_STRING parm_decl_list ; parm_decl_list : OPEN parm_decl_seq CLOSE | OPEN CLOSE ; parm_decl_seq : parm_decl_seq COMMA parm_decl | parm_decl ; parm_decl : BOOLEAN symbol | INTEGER symbol | SCALAR symbol | STRING symbol | COLOR symbol | VECTOR symbol | TRANSFORM symbol | SCALAR TEXTURE symbol | VECTOR TEXTURE symbol | COLOR TEXTURE symbol | LIGHT symbol | STRUCT symbol LBRACE parm_decl_seq RBRACE | ARRAY parm_decl ; /*--------------------------------------------------------- * function instance *-------------------------------------------------------*/ function : T_STRING parameter_list ; parameter_list : OPEN CLOSE | OPEN parameter_seq CLOSE ; parameter_seq : parameter | parameter_seq COMMA parameter ; parameter : symbol value_list ; value_list : value | value_list value ; value : boolean | T_INTEGER | T_FLOAT | symbol | LBRACE parameter_seq RBRACE | SUB array_value_seq BUS | SUB BUS ; array_value_seq : value_list array_value_cont ; array_value_cont: | COMMA value_list array_value_cont ; /*--------------------------------------------------------- * frame *-------------------------------------------------------*/ frame : FRAME frame_number initial_frame_cmd_list view frame_command_list END FRAME ; frame_number : T_INTEGER | T_INTEGER T_FLOAT ; initial_frame_cmd_list : | initial_frame_cmd_list initial_frame_cmd ; initial_frame_cmd : texture | light | material ; frame_command_list : frame_command | frame_command_list frame_command ; frame_command : texture | light | material | object ; /*--------------------------------------------------------- * view *-------------------------------------------------------*/ view : VIEW output_list view_list END VIEW ; output_list : output | output_list output ; output : OUTPUT T_STRING T_STRING | OUTPUT T_STRING T_STRING T_STRING | OUTPUT T_STRING function ; view_list : | view_list view_item ; view_item : FOCAL focal_spec | APERTURE T_FLOAT | ASPECT T_FLOAT | SHUTTER T_FLOAT | RESOLUTION T_INTEGER T_INTEGER | WINDOW T_INTEGER T_INTEGER T_INTEGER T_INTEGER | RECURSIVE boolean | MIN SAMPLES T_INTEGER | MAX SAMPLES T_INTEGER | SAMPLES T_INTEGER | ADAPTIVE boolean | CONTRAST T_FLOAT T_FLOAT T_FLOAT | CONTRAST T_FLOAT T_FLOAT T_FLOAT T_FLOAT | FILTER filter_type T_FLOAT | FILTER filter_type T_FLOAT T_FLOAT | TRACE DEPTH T_INTEGER | TRACE DEPTH T_INTEGER T_INTEGER | TRACE DEPTH T_INTEGER T_INTEGER T_INTEGER | FACE face_spec | CLIP T_FLOAT T_FLOAT | VOLUME function | ENVIRONMENT function | LENS function | SHADOW boolean | TRACE boolean | DESATURATE boolean | DITHER boolean | JITTER T_FLOAT | FILTER T_FLOAT | GAMMA T_FLOAT | FIELD field_spec | RED T_FLOAT T_FLOAT | GREEN T_FLOAT T_FLOAT | BLUE T_FLOAT T_FLOAT | WHITE T_FLOAT T_FLOAT | SCANLINE boolean | SHADOW SORT boolean | CONTOUR boolean | PAPER SIZE T_STRING | PAPER SCALE T_FLOAT | DISCONTINUITY T_FLOAT | CONTOUR LINE WIDTH clw_spec | CONTOUR DEPTH T_FLOAT | PAPER TRANSFORM T_FLOAT T_FLOAT | SUBDIVISION MEMORY T_INTEGER | ACCELERATION accel_spec | SUBDIVISION T_INTEGER T_INTEGER | MAX SIZE T_INTEGER | MAX DEPTH T_INTEGER | transform ; focal_spec : T_FLOAT | INFINITY ; face_spec : FRONT | BACK | BOTH ; clw_spec : T_FLOAT | T_FLOAT T_FLOAT T_FLOAT ; field_spec : OFF | EVEN | ODD ; accel_spec : RAY CLASSIFICATION | SPATIAL SUBDIVISION ; filter_type : BOX | TRIANGLE | GAUSS ; /*--------------------------------------------------------- * texture *-------------------------------------------------------*/ texture : SCALAR TEXTURE symbol SUB T_INTEGER T_INTEGER BUS tex_bytes_list | SCALAR TEXTURE symbol SUB T_INTEGER T_INTEGER BUS tex_bytes_list | SCALAR TEXTURE symbol T_STRING | LOCAL SCALAR TEXTURE symbol T_STRING | SCALAR TEXTURE symbol function | COLOR TEXTURE symbol SUB T_INTEGER T_INTEGER BUS tex_bytes_list | COLOR TEXTURE symbol SUB T_INTEGER T_INTEGER BUS tex_bytes_list | COLOR TEXTURE symbol T_STRING | LOCAL COLOR TEXTURE symbol T_STRING | COLOR TEXTURE symbol function | VECTOR TEXTURE symbol SUB T_INTEGER T_INTEGER BUS tex_bytes_list | VECTOR TEXTURE symbol T_STRING | LOCAL VECTOR TEXTURE symbol T_STRING | VECTOR TEXTURE symbol function ; tex_bytes_list : | tex_bytes_list T_BYTE_STRING ; /*--------------------------------------------------------- * light *-------------------------------------------------------*/ light : LIGHT symbol function light_primitive origin direction END LIGHT ; light_primitive : | RECTANGLE vector vector | RECTANGLE vector vector T_INTEGER T_INTEGER | DISC vector T_FLOAT | DISC vector T_FLOAT T_INTEGER T_INTEGER | SPHERE T_FLOAT | SPHERE T_FLOAT T_INTEGER T_INTEGER ; direction : | DIRECTION vector ; origin : | ORIGIN vector ; /*--------------------------------------------------------- * material *-------------------------------------------------------*/ material : MATERIAL symbol nocontour opaque function displace_shader shadow_shader volume_shader env_shader END MATERIAL ; nocontour : | NOCONTOUR ; opaque : | OPAQUE ; displace_shader : | DISPLACE function ; shadow_shader : | SHADOW function ; volume_shader : | VOLUME function ; env_shader : | ENVIRONMENT function ; /*--------------------------------------------------------- * object *-------------------------------------------------------*/ object : OBJECT symbol visible shadow trace tag obj_transform geo_transform basis_list group_list END OBJECT ; visible : | VISIBLE ; shadow : | SHADOW ; trace : | TRACE ; tag : | TAG T_INTEGER ; obj_transform : | transform ; geo_transform : | GEOMETRY TRANSFORM function ; basis_list : | basis_list basis ; group_list : | group_list group ; basis : BASIS symbol is_rational MATRIX T_INTEGER T_INTEGER basis_matrix | BASIS symbol is_rational BEZIER T_INTEGER | BASIS symbol is_rational TAYLOR T_INTEGER | BASIS symbol is_rational BSPLINE T_INTEGER | BASIS symbol is_rational CARDINAL ; is_rational : | RATIONAL ; basis_matrix : T_FLOAT | basis_matrix T_FLOAT ; group : GROUP groupname merge_option vector_list vertex_list geometry_list END GROUP ; groupname : symbol | ; merge_option : | MERGE T_FLOAT ; vector_list : | vector_list vector ; vertex_list : | vertex_list vertex ; vertex : V T_INTEGER symbol n_vector tex_list m_vector | V T_INTEGER n_vector tex_list m_vector ; n_vector : | N T_INTEGER ; tex_list : | tex_seq ; tex_seq : tex | tex_seq tex ; tex : T T_INTEGER | T T_INTEGER T_INTEGER T_INTEGER ; m_vector : | M T_INTEGER ; vertex_ref_seq : vertex_ref | vertex_ref_seq vertex_ref ; vertex_ref : T_INTEGER ; h_vertex_ref_seq: h_vertex_ref | h_vertex_ref_seq h_vertex_ref ; h_vertex_ref : T_INTEGER | T_INTEGER T_FLOAT ; geometry_list : | geometry_list geometry ; geometry : polygon | implicit_patch | curve | curve3 | surface | min_surface | connection | approximation ; polygon : CP symbol vertex_ref_seq | P symbol vertex_ref_seq poly_hole_list ; poly_hole_list : | poly_hole_list poly_hole ; poly_hole : HOLE vertex_ref_seq ; implicit_patch : IMP symbol T_INTEGER vertex_ref vertex_ref vertex_ref vertex_ref para_list ; para_list : T_FLOAT | para_list T_FLOAT ; curve : CURVE symbol symbol para_list h_vertex_ref_seq curve_spec ; curve3 : CURVE3 symbol symbol T_FLOAT T_FLOAT para_list h_vertex_ref_seq tex_curve3_list ; tex_curve3_list : | tex_curve3_list tex_curve3 ; tex_curve3 : TEXTURE T_INTEGER symbol para_list h_vertex_ref_seq ; curve_spec : | SPECIAL curve_special_list ; curve_special_list : curve_special | curve_special_list curve_special ; curve_special : h_vertex_ref | h_vertex_ref MAPSTO h_vertex_ref ; surface : SURFACE symbol symbol symbol T_FLOAT T_FLOAT para_list symbol T_FLOAT T_FLOAT para_list h_vertex_ref_seq tex_surf_list surf_spec_list ; tex_surf_list : | tex_surf_list tex_surf ; tex_surf : opt_vector_flag opt_volume_flag TEXTURE symbol para_list symbol para_list h_vertex_ref_seq ; opt_vector_flag : | VECTOR ; opt_volume_flag : | VOLUME ; surf_spec_list : | surf_spec_list surf_spec ; surf_spec : TRIM trim_spec_list | HOLE hole_spec_list | SPECIAL special_spec_list ; trim_spec_list : trim_spec | trim_spec_list trim_spec ; trim_spec : symbol T_FLOAT T_FLOAT ; hole_spec_list : hole_spec | hole_spec_list hole_spec ; hole_spec : symbol T_FLOAT T_FLOAT ; special_spec_list : special_spec | special_spec_list special_spec ; special_spec : h_vertex_ref | h_vertex_ref MAPSTO h_vertex_ref | symbol T_FLOAT T_FLOAT ; min_surface : MIN SURFACE symbol symbol min_surf_spec_list ; min_surf_spec_list : min_surf_spec | min_surf_spec_list min_surf_spec ; min_surf_spec : TRIM min_surf_trim_spec_list | HOLE min_surf_hole_spec_list | SPECIAL min_surf_special_spec_list ; min_surf_trim_spec_list : min_surf_trim_spec | min_surf_trim_spec_list min_surf_trim_spec ; min_surf_trim_spec : symbol T_FLOAT T_FLOAT ; min_surf_hole_spec_list : min_surf_hole_spec | min_surf_hole_spec_list min_surf_hole_spec ; min_surf_hole_spec : symbol T_FLOAT T_FLOAT ; min_surf_special_spec_list : min_surf_special_spec | min_surf_special_spec_list min_surf_special_spec ; min_surf_special_spec : h_vertex_ref | symbol T_FLOAT T_FLOAT ; connection : CONNECT symbol symbol T_FLOAT T_FLOAT symbol symbol T_FLOAT T_FLOAT ; approximation : APPROXIMATE SURFACE surf_approx_tech surface_name_list | APPROXIMATE TRIM trim_approx_tech trim_name_list ; surf_approx_tech : PARAMETRIC T_FLOAT T_FLOAT | PARAMETRIC T_FLOAT | SPATIAL approx_view T_FLOAT | SPATIAL approx_view T_FLOAT T_INTEGER T_INTEGER | CURVATURE approx_view T_FLOAT T_FLOAT | CURVATURE approx_view T_FLOAT T_FLOAT T_INTEGER T_INTEGER | IMPLICIT ; trim_approx_tech : PARAMETRIC T_FLOAT | SPATIAL approx_view T_FLOAT | SPATIAL approx_view T_FLOAT T_INTEGER T_INTEGER | CURVATURE approx_view T_FLOAT T_FLOAT | CURVATURE approx_view T_FLOAT T_FLOAT T_INTEGER T_INTEGER ; approx_view : | VIEW ; surface_name_list : symbol | surface_name_list symbol ; trim_name_list : symbol | trim_name_list symbol ; %%