2 Yacc file for parsing motion schemas.
15 %token
<strval
> STRING
26 /* motion schema specific tokens */
41 %token MOT_NECK_NOT_FIXED
43 %token MOT_BLEND_DEFAULT
45 %token MOT_BLEND_LENGTH
63 #define FILE_NAME_LEN 100
68 extern
void IncParseFile
(char *fileName
);
69 extern
void SchemaParseFile
(char *fileName
, int (*parseFn
)());
71 #define mscherror mprintf
73 #define kDefaultBlendLength 500 // msec
75 #define FreeString(ident) { free(ident); ident = NULL; }
78 #define kMaxTagsPerSchema 16
79 #define kMaxMotionsPerSchema 128
81 static sTagDesc g_aSchemaTags
[kMaxTagsPerSchema
];
82 static sMotDesc g_aSchemaMotions
[kMaxMotionsPerSchema
];
84 static int g_nSchemaTags
=0;
85 static int g_nSchemaMotions
=0;
87 static float g_TimeWarp
=0;
88 static float g_Stretch
=0;
89 static float g_Duration
=0;
90 static float g_Distance
=0;
92 static BOOL g_TagIsMandatory
=TRUE
;
93 static float g_TagWeight
=0;
95 static int g_TagVal
=0;
97 static BOOL g_ArchIsString
=FALSE
;
98 static int g_ArchInt
=0;
99 static Label g_ArchName
;
101 static BOOL g_NeckIsFixed
=FALSE
;
102 static int g_BlendLength
=kDefaultBlendLength
;
103 static BOOL g_IsTurn
=FALSE
;
104 static BOOL g_IsLoco
=FALSE
;
105 static BOOL g_InPlace
=FALSE
;
114 statements: statement | statement statements
;
115 statement: include | schema | tag | actors_declare
;
117 include: INCLUDE STRING
119 ConfigSpew
("yakspew",("include %s\n",$2));
125 opt_tag_spec: tag_spec | null
;
127 tag_spec: TAG_OPT FLOAT
129 g_TagIsMandatory
=FALSE
;
133 tag: TAG IDENT opt_tag_spec
137 if
(config_is_defined
("yakspew"))
139 mprintf
("tag %s mand %d",$2,g_TagIsMandatory
);
145 mprintf
(" weight %g\n",g_TagWeight
);
148 info.isMandatory
=g_TagIsMandatory
;
149 info.weight
= g_TagWeight
;
150 MotDBRegisterTag
((Label
*)($2),&info
);
152 g_TagIsMandatory
=TRUE
;
158 actors_declare: ACTORS_DECLARE INT
163 archetype: arch_string | arch_int
;
165 arch_string: ARCHETYPE IDENT
168 strncpy
(g_ArchName.text
,$2,sizeof
(g_ArchName
));
172 arch_int: ARCHETYPE INT
174 g_ArchIsString
=FALSE
;
178 schema: SCHEMA IDENT ACTOR INT archetype optparams taglist motlist
183 sMotSchemaDesc schema
;
185 if
(config_is_defined
("yakspew"))
188 mprintf
("schema %s\n with actor %d\n with archetype %s\n",$2,$4,g_ArchName.text
);
190 mprintf
("schema %s\n with actor %d\n with archetype %d\n",$2,$4,g_ArchInt
);
195 mprintf
(" duration %g\n",g_Duration
);
199 mprintf
(" distance %g\n",g_Distance
);
203 mprintf
(" timewarp %g\n",g_TimeWarp
);
207 mprintf
(" stretch %g\n",g_Stretch
);
210 // look at tag globals
211 pTagDesc
=g_aSchemaTags
;
212 for
(i
=0;i
<g_nSchemaTags
;i
++,pTagDesc
++)
214 mprintf
(" with tag %s value %d\n",pTagDesc
->type.text
,pTagDesc
->value
);
217 // look at motion globals
218 pMotDesc
=g_aSchemaMotions
;
219 for
(i
=0;i
<g_nSchemaMotions
;i
++,pMotDesc
++)
221 mprintf
(" with motion %s,",pMotDesc
->name.text
);
222 if
(pMotDesc
->stuff.flags
&kMSF_NECK_IS_FIXED
)
224 mprintf
(" neck_fixed");
226 if
(pMotDesc
->stuff.blendLength
!=kDefaultBlendLength
)
228 mprintf
(" blend %d",pMotDesc
->stuff.blendLength
);
230 if
(pMotDesc
->stuff.flags
&kMSF_IS_TURN
)
234 if
(pMotDesc
->stuff.flags
&kMSF_IS_LOCO
)
238 if
(pMotDesc
->stuff.flags
&kMSF_WANT_NO_XLAT
)
240 mprintf
(" in_place");
246 schema.nTags
=g_nSchemaTags
;
247 schema.pTags
=g_aSchemaTags
;
248 schema.nMots
=g_nSchemaMotions
;
249 schema.pMots
=g_aSchemaMotions
;
250 schema.duration
=g_Duration
;
251 schema.distance
=g_Distance
;
252 schema.timeWarp
=g_TimeWarp
;
253 schema.stretch
=g_Stretch
;
255 strncpy
(schema.name.text
,$2,15);
259 strncpy
(schema.archName.text
,g_ArchName.text
,sizeof
(schema.archName
));
260 schema.archIsString
=TRUE
;
263 schema.archInt
=g_ArchInt
;
264 schema.archIsString
=FALSE
;
266 MotDBAddSchema
(&schema
);
279 optparams: paraminsts | null
;
281 paraminsts: paraminsts paraminst | paraminst
;
283 paraminst: timewarp | duration | stretch | distance
;
285 timewarp: TIMEWARP FLOAT
290 duration: DURATION FLOAT
295 stretch: STRETCH FLOAT
300 distance: DISTANCE FLOAT
306 taglist: TAGLIST_HEADER opttaginsts
;
308 opttaginsts: taginsts | null
;
310 taginsts: taginsts taginst | taginst
;
312 opt_tag_val: tag_val | null
;
319 taginst: IDENT opt_tag_val
323 if
(g_nSchemaTags
<kMaxTagsPerSchema
)
325 size
=sizeof
(g_aSchemaTags
[0].type
);
326 strncpy
(g_aSchemaTags
[g_nSchemaTags
].type.text
,$1,size
);
327 g_aSchemaTags
[g_nSchemaTags
].value
=g_TagVal
;
331 Warning
(("Cannot add tag %s to schema - too many tags\n",$1));
338 motlist: MOTLIST_HEADER optmotions
;
340 optmotions: motinsts | null
;
342 motinsts: motinsts motinst | motinst
;
344 optmotparamlist: motparamlist | null
;
346 motparamlist: motparam motparamlist | motparam
;
348 motparam: neck_fixed | blend_length | is_turn | MOT_NECK_NOT_FIXED |
349 MOT_BLEND_DEFAULT | blend_none | is_loco | in_place
;
351 neck_fixed: MOT_NECK_FIXED
356 blend_none: MOT_BLEND_NONE
361 blend_length: MOT_BLEND_LENGTH INT
366 in_place: MOT_IN_PLACE
381 motinst: IDENT optmotparamlist
385 if
(g_nSchemaMotions
<kMaxMotionsPerSchema
)
387 size
=sizeof
(g_aSchemaMotions
[0].name
);
388 strncpy
(g_aSchemaMotions
[g_nSchemaMotions
].name.text
,$1,size
);
389 g_aSchemaMotions
[g_nSchemaMotions
].stuff.flags
=NULL
;
391 g_aSchemaMotions
[g_nSchemaMotions
].stuff.flags|
=kMSF_NECK_IS_FIXED
;
392 g_aSchemaMotions
[g_nSchemaMotions
].stuff.blendLength
=g_BlendLength
;
394 g_aSchemaMotions
[g_nSchemaMotions
].stuff.flags|
=kMSF_IS_TURN
;
396 g_aSchemaMotions
[g_nSchemaMotions
].stuff.flags|
=kMSF_IS_LOCO
;
398 g_aSchemaMotions
[g_nSchemaMotions
].stuff.flags|
=kMSF_WANT_NO_XLAT
;
402 Warning
(("Cannot add motion %s to schema - too many motions\n",$1));
405 // reset motion params
407 g_BlendLength
=kDefaultBlendLength
;
424 void MotSchemaYaccParse
(char *schemaFile
)
430 mprintf
("parsing file %s!\n",schemaFile
);
431 MschParseFile
(schemaFile
);