2007-01-15 12:09:25 -08:00
|
|
|
/*
|
|
|
|
This file is part of Warzone 2100.
|
|
|
|
Copyright (C) 1999-2004 Eidos Interactive
|
|
|
|
Copyright (C) 2005-2007 Warzone Resurrection Project
|
|
|
|
|
|
|
|
Warzone 2100 is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Warzone 2100 is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Warzone 2100; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2007-06-28 10:47:08 -07:00
|
|
|
%{
|
|
|
|
|
|
|
|
/* include framework */
|
2006-06-02 12:34:58 -07:00
|
|
|
#include "lib/framework/frame.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-04-11 07:21:45 -07:00
|
|
|
#include <physfs.h>
|
|
|
|
|
2006-09-23 10:24:55 -07:00
|
|
|
#include "lib/gamelib/parser.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/* Get the Yacc definitions */
|
2007-01-09 13:13:58 -08:00
|
|
|
#include "audp_parser.tab.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/* Maximum length for any TEXT value */
|
|
|
|
#define YYLMAX 255
|
|
|
|
|
2008-05-12 13:06:19 -07:00
|
|
|
void audp_error(const char* fmt, ...) WZ_DECL_FORMAT(printf, 1, 2);
|
2006-02-28 22:12:28 -08:00
|
|
|
|
2008-05-12 13:29:13 -07:00
|
|
|
#include "lib/framework/lexer_input.h"
|
|
|
|
|
|
|
|
#ifndef yyextra
|
|
|
|
# define yyextra yyget_extra()
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Older GNU Flex versions don't define yyget_extra(), yyset_extra(),
|
|
|
|
* yyget_text() and yyget_lineno().
|
|
|
|
* (and neither define a subminor version)
|
|
|
|
*/
|
|
|
|
#if !defined(YY_FLEX_SUBMINOR_VERSION) || (YY_FLEX_SUBMINOR_VERSION < 9)
|
|
|
|
# define yyget_extra audp_get_extra
|
|
|
|
# define yyset_extra audp_set_extra
|
|
|
|
# define yyget_lineno audp_get_lineno
|
|
|
|
# define yyget_text audp_get_text
|
|
|
|
extern void yyset_extra(YY_EXTRA_TYPE user_defined);
|
|
|
|
extern YY_EXTRA_TYPE yyget_extra(void);
|
|
|
|
extern int yyget_lineno(void);
|
|
|
|
int yyget_lineno()
|
|
|
|
{
|
|
|
|
return yylineno;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern char* yyget_text(void);
|
|
|
|
char* yyget_text()
|
|
|
|
{
|
|
|
|
return yytext;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
%}
|
|
|
|
|
2008-05-12 13:09:10 -07:00
|
|
|
%option yylineno noyywrap nounput
|
2005-12-02 05:22:19 -08:00
|
|
|
%option prefix="audp_"
|
|
|
|
|
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
|
2008-05-12 13:06:19 -07:00
|
|
|
-?[0-9]*"."[0-9]+ { audp_lval.fval = (float) atof(yytext);
|
2005-12-05 08:47:41 -08:00
|
|
|
return FLOAT_T;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Match integer numbers */
|
2008-05-12 13:06:19 -07:00
|
|
|
-?[0-9]+ { audp_lval.ival = atoi(yytext);
|
2007-06-28 10:47:08 -07:00
|
|
|
return INTEGER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Match quoted text */
|
|
|
|
\"[^\"\n]*[\"\n] {
|
|
|
|
/* skip opening quote */
|
2008-05-12 13:06:19 -07:00
|
|
|
sstrcpy(audp_lval.sval, &yytext[1]);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/* check for unterminated string */
|
2008-05-12 13:06:19 -07:00
|
|
|
if (yytext[yyleng - 1] != '"' )
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-05-12 13:06:19 -07:00
|
|
|
audp_error("Unterminated string %s\n", audp_lval.sval);
|
2007-06-28 10:47:08 -07:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set final quote in string to blank */
|
2008-05-12 13:06:19 -07:00
|
|
|
audp_lval.sval[yyleng - 2] = (char)'\0';
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
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 */
|
2008-05-12 13:06:19 -07:00
|
|
|
. return yytext[0];
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
2008-05-12 13:29:13 -07:00
|
|
|
static YY_EXTRA_TYPE pBuffer = NULL;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2008-05-12 13:29:13 -07:00
|
|
|
void yyset_extra(YY_EXTRA_TYPE user_defined)
|
2007-04-08 16:25:48 -07:00
|
|
|
{
|
2008-05-12 13:29:13 -07:00
|
|
|
pBuffer = user_defined;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-05-12 13:29:13 -07:00
|
|
|
YY_EXTRA_TYPE yyget_extra()
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-05-12 13:29:13 -07:00
|
|
|
return pBuffer;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-03-27 10:09:16 -07:00
|
|
|
/* Older GNU Flex versions don't define yylex_destroy()
|
|
|
|
* (and neither define a subminor version)
|
|
|
|
*/
|
2008-03-28 04:05:19 -07:00
|
|
|
#if !defined(YY_FLEX_SUBMINOR_VERSION) || (YY_FLEX_SUBMINOR_VERSION < 9)
|
2008-03-27 10:09:16 -07:00
|
|
|
int audp_lex_destroy(void)
|
|
|
|
{
|
2008-03-28 04:05:19 -07:00
|
|
|
/* For non-reentrant C scanner only. */
|
|
|
|
yy_delete_buffer(YY_CURRENT_BUFFER);
|
|
|
|
yy_init = 1;
|
2008-03-27 10:09:16 -07:00
|
|
|
}
|
|
|
|
#endif
|