2007-06-28 10:47:08 -07:00
|
|
|
%{
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
/* include framework */
|
|
|
|
#include "frame.h"
|
|
|
|
|
|
|
|
#include "parser.h"
|
|
|
|
|
|
|
|
/* Get the Yacc definitions */
|
2005-12-02 05:22:19 -08:00
|
|
|
#include "audp_parser.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/* Maximum length for any TEXT value */
|
|
|
|
#define YYLMAX 255
|
|
|
|
|
|
|
|
/* global variables */
|
|
|
|
static BOOL g_bParsingSubFile;
|
|
|
|
static FILE *g_fpOld;
|
|
|
|
|
|
|
|
/* Pointer to the input buffer */
|
|
|
|
static UBYTE *pInputBuffer = NULL;
|
|
|
|
static UBYTE *pEndBuffer = NULL;
|
|
|
|
|
2005-12-02 05:22:19 -08:00
|
|
|
#define YY_INPUT(buf,result,max_size) \
|
|
|
|
if (pInputBuffer != pEndBuffer) { \
|
|
|
|
buf[0] = *(pInputBuffer++); result = 1; \
|
|
|
|
} else { \
|
|
|
|
buf[0] = EOF; result = YY_NULL; \
|
|
|
|
}
|
2006-02-28 22:12:28 -08:00
|
|
|
|
|
|
|
void audp_error(char *pMessage,...);
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
%}
|
|
|
|
|
2005-12-02 05:22:19 -08:00
|
|
|
%option nounput
|
|
|
|
%option prefix="audp_"
|
|
|
|
%option yylineno
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
%x COMMENT
|
|
|
|
%x QUOTE
|
|
|
|
|
|
|
|
%%
|
|
|
|
/* Match to key words */
|
|
|
|
oneshot { return ONESHOT; }
|
|
|
|
loop { return LOOP; }
|
|
|
|
audio { return AUDIO; }
|
|
|
|
anim3dfile { return ANIM3DFILE; }
|
|
|
|
audio_module { return AUDIO_MODULE; }
|
|
|
|
anim_module { return ANIM_MODULE; }
|
|
|
|
ANIM3DFRAMES { return ANIM3DFRAMES; }
|
|
|
|
ANIM3DTRANS { return ANIM3DTRANS; }
|
|
|
|
ANIMOBJECT { return ANIMOBJECT; }
|
|
|
|
|
|
|
|
/* Match floating point numbers */
|
|
|
|
/* This is a problem with the PSX so is disabled
|
|
|
|
-?[0-9]*"."[0-9]+ { audp_lval.fval = (float) atof(audp_text);
|
2005-12-05 08:47:41 -08:00
|
|
|
return FLOAT_T;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Match integer numbers */
|
|
|
|
-?[0-9]+ { audp_lval.ival = atoi(audp_text);
|
|
|
|
return INTEGER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Match quoted text */
|
|
|
|
\"[^\"\n]*[\"\n] {
|
|
|
|
/* skip opening quote */
|
|
|
|
strcpy( audp_lval.sval, audp_text+1 );
|
|
|
|
|
|
|
|
/* check for unterminated string */
|
|
|
|
if ( audp_text[audp_leng-1] != '"' )
|
|
|
|
{
|
|
|
|
sprintf( audp_lval.sval, "Unterminated string %s\n", audp_lval.sval );
|
|
|
|
audp_error( audp_lval.sval );
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set final quote in string to blank */
|
|
|
|
audp_lval.sval[audp_leng-2] = (char) NULL;
|
|
|
|
|
|
|
|
return QTEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Skip white space */
|
|
|
|
[ \t\n\x0d\x0a] ;
|
|
|
|
|
|
|
|
/* Strip comments */
|
|
|
|
"/*" { BEGIN COMMENT; }
|
|
|
|
<COMMENT>"*/" |
|
|
|
|
<COMMENT>"*/"\n { BEGIN 0; }
|
|
|
|
<COMMENT>. |
|
|
|
|
<COMMENT>\n ;
|
|
|
|
|
|
|
|
/* Match anything that's been missed and pass it as a char */
|
|
|
|
. return audp_text[0];
|
|
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
int
|
|
|
|
audp_wrap( void )
|
|
|
|
{
|
|
|
|
if ( g_bParsingSubFile == TRUE )
|
|
|
|
{
|
|
|
|
/* close current file and restore old file pointer */
|
|
|
|
fclose( audp_in );
|
|
|
|
audp_in = g_fpOld;
|
|
|
|
|
|
|
|
g_bParsingSubFile = FALSE;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/* Set the current input buffer for the lexer */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
parserSetInputBuffer( UBYTE *pBuffer, UDWORD size )
|
|
|
|
{
|
|
|
|
pInputBuffer = pBuffer;
|
|
|
|
pEndBuffer = pBuffer + size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
parseGetErrorData(int *pLine, char **ppText)
|
|
|
|
{
|
|
|
|
*pLine = audp_lineno;
|
|
|
|
*ppText = audp_text;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|