diff --git a/.gitignore b/.gitignore
index c4cd873da..d7ecb5739 100644
--- a/.gitignore
+++ b/.gitignore
@@ -80,10 +80,10 @@ win32/__BUILD_CONFIG.USER
*.tab.[ch]
*.lex.[ch]pp
*.tab.[ch]pp
-*lexer.[ch]pp
-*parser.[ch]pp
-*lexer.[ch]
-*parser.[ch]
+#*lexer.[ch]pp
+#*parser.[ch]pp
+#*lexer.[ch]
+#*parser.[ch]
/src/autorevision.h
/autorevision.tmp
/src/autorevision.cache
diff --git a/autogen.sh b/autogen.sh
index f6f1749fa..ca7ad13f6 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -148,11 +148,6 @@ not_version ()
# Chdir to the srcdir, then run auto* tools.
cd "$SRCDIR"
-version_check 0 "automake" "ftp://ftp.gnu.org/pub/gnu/automake/" 1 12 && {
- echo "Sorry, automake 1.12+ is not supported yet, please use 1.11."
- exit 1
-}
-
version_check 1 "autoconf" "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 56 || DIE=1
version_check 1 "automake" "ftp://ftp.gnu.org/pub/gnu/automake/" 1 11 || DIE=1
if [ "$DIE" -eq 1 ]; then
diff --git a/configure.ac b/configure.ac
index bca1bfe7d..9715d6dfc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,19 +30,6 @@ AC_PROG_CXX
AC_CHECK_PROG(CXXCOMPILER, ${CXX}, cxxcompiler)
test -z "${CXXCOMPILER}" && AC_MSG_ERROR(No C++ compiler found!)
-AC_PROG_YACC
-if test "x$YACC" != "xbison -y" ; then
- AC_MSG_ERROR([Bison is not installed])
-fi
-AC_PROG_VERSION_CHECK([bison], [1.31])
-
-AC_PROG_LEX
-test "x${LEX}" != "xflex" && AC_MSG_ERROR(flex not found!)
-AC_PROG_VERSION_CHECK([${LEX}], [2.5.33], [2.5.34])
-# Hack to make sure flex produces files with names ylwrap expects.
-FLEX_FLAGS="-o lex.yy.c"
-AC_SUBST([FLEX_FLAGS])
-
AX_WITH_PROG([PERL], [perl])
AX_PROG_PERL_VERSION([5.10], [], [ PERL="" ])
AC_SUBST([PERL])
diff --git a/lib/framework/Makefile.am b/lib/framework/Makefile.am
index b79c0b2bb..cf7dc959a 100644
--- a/lib/framework/Makefile.am
+++ b/lib/framework/Makefile.am
@@ -1,8 +1,6 @@
AM_CPPFLAGS = -DYY_NO_INPUT $(SDL_CFLAGS) $(WZ_CPPFLAGS) $(QT4_CFLAGS)
AM_CFLAGS = $(WZ_CFLAGS)
AM_CXXFLAGS = $(WZ_CXXFLAGS) $(QT4_CFLAGS)
-AM_LFLAGS = $(FLEX_FLAGS)
-AM_YFLAGS = -d
MOCHEADER = \
wzconfig.h
@@ -11,9 +9,6 @@ MOCEDFILES = $(MOCHEADER:%.h=%_moc.cpp)
%_moc.cpp: %.h
$(MOC4) -o $@ $<
-BUILT_SOURCES = \
- resource_parser.h \
- strres_parser.h
CLEANFILES = \
$(MOCEDFILES)
@@ -46,9 +41,11 @@ noinst_HEADERS = \
physfs_ext.h \
rational.h \
resly.h \
+ resource_parser.h \
stdio_ext.h \
string_ext.h \
strres.h \
+ strres_parser.h \
strresly.h \
treap.h \
trig.h \
@@ -70,12 +67,12 @@ libframework_a_SOURCES = \
geometry.cpp \
i18n.cpp \
lexer_input.cpp \
- resource_lexer.lpp \
- resource_parser.ypp \
+ resource_lexer.cpp \
+ resource_parser.cpp \
stdio_ext.cpp \
strres.cpp \
- strres_lexer.lpp \
- strres_parser.ypp \
+ strres_lexer.cpp \
+ strres_parser.cpp \
treap.cpp \
trig.cpp \
utf.cpp \
diff --git a/lib/framework/framework.vcxproj b/lib/framework/framework.vcxproj
index d00fb82fd..fc484a998 100644
--- a/lib/framework/framework.vcxproj
+++ b/lib/framework/framework.vcxproj
@@ -60,9 +60,7 @@
Unicode
-
-
-
+
@@ -102,9 +100,9 @@
..\devpkg\include;$(Qtdir)\include;$(IncludePath)
..\devpkg\stlport5.2.1\stlport;..\devpkg\include;$(Qtdir)\include;$(IncludePath)
..\devpkg\stlport5.2.1\stlport;..\devpkg\include;$(Qtdir)\include;$(IncludePath)
- *.lex.cpp;*.tab.cpp;*.tab.hpp;$(ExtensionsToDeleteOnClean)
- *.lex.cpp;*.tab.cpp;*.tab.hpp;$(ExtensionsToDeleteOnClean)
- *.lex.cpp;*.tab.cpp;*.tab.hpp;$(ExtensionsToDeleteOnClean)
+ $(ExtensionsToDeleteOnClean)
+ $(ExtensionsToDeleteOnClean)
+ $(ExtensionsToDeleteOnClean)
false
false
true
@@ -268,20 +266,7 @@
-
- $(IntDir)%(Filename)1.obj
- $(IntDir)%(Filename)1.obj
- $(IntDir)%(Filename)1.obj
- $(IntDir)%(Filename)1.xdc
- $(IntDir)%(Filename)1.xdc
- $(IntDir)%(Filename)1.xdc
- $(IntDir)%(Filename)1.obj
- $(IntDir)%(Filename)1.obj
- $(IntDir)%(Filename)1.obj
- $(IntDir)%(Filename)1.xdc
- $(IntDir)%(Filename)1.xdc
- $(IntDir)%(Filename)1.xdc
-
+
@@ -317,12 +302,12 @@
-
+
-
+
@@ -333,22 +318,6 @@
-
-
- Document
-
-
- Document
-
-
- Document
-
-
- Document
-
-
-
-
-
+
\ No newline at end of file
diff --git a/lib/framework/framework.vcxproj.filters b/lib/framework/framework.vcxproj.filters
index 2e2efc136..1854d6abf 100644
--- a/lib/framework/framework.vcxproj.filters
+++ b/lib/framework/framework.vcxproj.filters
@@ -9,9 +9,6 @@
{93995380-89BD-4b04-88EB-625FBE52EBFB}
h;hpp;hxx;hm;inl;inc;xsd
-
- {558c4d54-ca83-45b2-94bd-a22fe549de35}
-
@@ -50,6 +47,9 @@
Source Files
+
+ Source Files
+
Source Files
@@ -62,9 +62,6 @@
Source Files
-
- Source Files
-
@@ -157,30 +154,14 @@
Header Files
-
- Header Files
-
-
- Header Files
-
Header Files
-
-
-
- FlexBison
-
-
- FlexBison
-
-
-
-
- FlexBison
-
-
- FlexBison
-
+
+ Header Files
+
+
+ Header Files
+
\ No newline at end of file
diff --git a/lib/framework/resource_lexer.cpp b/lib/framework/resource_lexer.cpp
new file mode 100644
index 000000000..78cec1c68
--- /dev/null
+++ b/lib/framework/resource_lexer.cpp
@@ -0,0 +1,2018 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+#line 2 "resource_lexer.cpp"
+
+#line 4 "resource_lexer.cpp"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define yy_create_buffer res__create_buffer
+#define yy_delete_buffer res__delete_buffer
+#define yy_flex_debug res__flex_debug
+#define yy_init_buffer res__init_buffer
+#define yy_flush_buffer res__flush_buffer
+#define yy_load_buffer_state res__load_buffer_state
+#define yy_switch_to_buffer res__switch_to_buffer
+#define yyin res_in
+#define yyleng res_leng
+#define yylex res_lex
+#define yylineno res_lineno
+#define yyout res_out
+#define yyrestart res_restart
+#define yytext res_text
+#define yywrap res_wrap
+#define yyalloc res_alloc
+#define yyrealloc res_realloc
+#define yyfree res_free
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 35
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+#include "lib/framework/frame.h"
+/* begin standard C headers. */
+#include
+#include
+#include
+#include
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have . Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#endif /* ! C99 */
+
+#endif /* ! FLEXINT_H */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
+
+#define YY_USE_CONST
+
+#endif /* defined (__STDC__) */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index. If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN (yy_start) = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START (((yy_start) - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE res_restart(res_in )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
+#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
+#endif
+
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+extern int res_leng;
+
+extern FILE *res_in, *res_out;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+ /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
+ * access to the local variable yy_act. Since yyless() is a macro, it would break
+ * existing scanners that call yyless() from OUTSIDE res_lex.
+ * One obvious solution it to make yy_act a global. I tried that, and saw
+ * a 5% performance hit in a non-res_lineno scanner, because yy_act is
+ * normally declared as a register variable-- so it is not worth it.
+ */
+ #define YY_LESS_LINENO(n) \
+ do { \
+ int yyl;\
+ for ( yyl = n; yyl < res_leng; ++yyl )\
+ if ( res_text[yyl] == '\n' )\
+ --res_lineno;\
+ }while(0)
+
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up res_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ *yy_cp = (yy_hold_char); \
+ YY_RESTORE_YY_MORE_OFFSET \
+ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up res_text again */ \
+ } \
+ while ( 0 )
+
+#define unput(c) yyunput( c, (yytext_ptr) )
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via res_restart()), so that the user can continue scanning by
+ * just pointing res_in at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+ : NULL)
+
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+
+/* yy_hold_char holds the character lost when res_text is formed. */
+static char yy_hold_char;
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+int res_leng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 0; /* whether we need to initialize */
+static int yy_start = 0; /* start state number */
+
+/* Flag which is used to allow res_wrap()'s to do buffer switches
+ * instead of setting up a fresh res_in. A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void res_restart (FILE *input_file );
+void res__switch_to_buffer (YY_BUFFER_STATE new_buffer );
+YY_BUFFER_STATE res__create_buffer (FILE *file,int size );
+void res__delete_buffer (YY_BUFFER_STATE b );
+void res__flush_buffer (YY_BUFFER_STATE b );
+void res_push_buffer_state (YY_BUFFER_STATE new_buffer );
+void res_pop_buffer_state (void );
+
+static void res_ensure_buffer_stack (void );
+static void res__load_buffer_state (void );
+static void res__init_buffer (YY_BUFFER_STATE b,FILE *file );
+
+#define YY_FLUSH_BUFFER res__flush_buffer(YY_CURRENT_BUFFER )
+
+YY_BUFFER_STATE res__scan_buffer (char *base,yy_size_t size );
+YY_BUFFER_STATE res__scan_string (yyconst char *yy_str );
+YY_BUFFER_STATE res__scan_bytes (yyconst char *bytes,int len );
+
+void *res_alloc (yy_size_t );
+void *res_realloc (void *,yy_size_t );
+void res_free (void * );
+
+#define yy_new_buffer res__create_buffer
+
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ res_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ res__create_buffer(res_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+ }
+
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){\
+ res_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ res__create_buffer(res_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+ }
+
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* Begin user sect3 */
+
+#define res_wrap(n) 1
+#define YY_SKIP_YYWRAP
+
+typedef unsigned char YY_CHAR;
+
+FILE *res_in = (FILE *) 0, *res_out = (FILE *) 0;
+
+typedef int yy_state_type;
+
+extern int res_lineno;
+
+int res_lineno = 1;
+
+extern char *res_text;
+#define yytext_ptr res_text
+
+static yy_state_type yy_get_previous_state (void );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
+static int yy_get_next_buffer (void );
+static void yy_fatal_error (yyconst char msg[] );
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up res_text.
+ */
+#define YY_DO_BEFORE_ACTION \
+ (yytext_ptr) = yy_bp; \
+ res_leng = (size_t) (yy_cp - yy_bp); \
+ (yy_hold_char) = *yy_cp; \
+ *yy_cp = '\0'; \
+ (yy_c_buf_p) = yy_cp;
+
+#define YY_NUM_RULES 19
+#define YY_END_OF_BUFFER 20
+/* This struct is not used in this scanner,
+ but its presence is necessary. */
+struct yy_trans_info
+ {
+ flex_int32_t yy_verify;
+ flex_int32_t yy_nxt;
+ };
+static yyconst flex_int16_t yy_accept[46] =
+ { 0,
+ 0, 0, 0, 0, 8, 8, 17, 17, 20, 18,
+ 9, 9, 5, 18, 3, 3, 3, 13, 14, 13,
+ 8, 7, 6, 17, 16, 4, 10, 15, 3, 3,
+ 3, 11, 8, 17, 3, 3, 12, 3, 2, 3,
+ 3, 3, 3, 1, 0
+ } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 1, 4, 1, 1, 1, 1, 1, 1,
+ 1, 5, 1, 1, 6, 1, 7, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 1, 1, 1,
+ 1, 1, 1, 1, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 1, 1, 1, 1, 6, 1, 8, 8, 9, 10,
+
+ 11, 12, 8, 8, 13, 8, 8, 14, 8, 8,
+ 15, 8, 8, 16, 8, 17, 8, 8, 8, 8,
+ 18, 8, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1
+ } ;
+
+static yyconst flex_int32_t yy_meta[19] =
+ { 0,
+ 1, 1, 2, 3, 1, 4, 1, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4
+ } ;
+
+static yyconst flex_int16_t yy_base[52] =
+ { 0,
+ 0, 0, 16, 17, 20, 22, 60, 59, 61, 64,
+ 64, 64, 56, 22, 0, 46, 45, 64, 64, 50,
+ 0, 64, 64, 0, 64, 64, 64, 64, 0, 40,
+ 41, 51, 0, 0, 42, 41, 64, 42, 0, 33,
+ 32, 28, 25, 0, 64, 29, 33, 37, 24, 41,
+ 45
+ } ;
+
+static yyconst flex_int16_t yy_def[52] =
+ { 0,
+ 45, 1, 46, 46, 47, 47, 48, 48, 45, 45,
+ 45, 45, 45, 45, 49, 49, 49, 45, 45, 45,
+ 50, 45, 45, 51, 45, 45, 45, 45, 49, 49,
+ 49, 45, 50, 51, 49, 49, 45, 49, 49, 49,
+ 49, 49, 49, 49, 0, 45, 45, 45, 45, 45,
+ 45
+ } ;
+
+static yyconst flex_int16_t yy_nxt[83] =
+ { 0,
+ 10, 11, 12, 13, 10, 10, 14, 15, 15, 16,
+ 15, 17, 15, 15, 15, 15, 15, 15, 19, 19,
+ 20, 20, 22, 23, 22, 23, 27, 29, 28, 18,
+ 18, 18, 18, 21, 21, 21, 21, 24, 24, 24,
+ 24, 33, 44, 43, 33, 34, 42, 34, 34, 41,
+ 40, 39, 38, 37, 36, 35, 32, 31, 30, 26,
+ 45, 25, 25, 9, 45, 45, 45, 45, 45, 45,
+ 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+ 45, 45
+ } ;
+
+static yyconst flex_int16_t yy_chk[83] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 3, 4,
+ 3, 4, 5, 5, 6, 6, 14, 49, 14, 46,
+ 46, 46, 46, 47, 47, 47, 47, 48, 48, 48,
+ 48, 50, 43, 42, 50, 51, 41, 51, 51, 40,
+ 38, 36, 35, 32, 31, 30, 20, 17, 16, 13,
+ 9, 8, 7, 45, 45, 45, 45, 45, 45, 45,
+ 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+ 45, 45
+ } ;
+
+/* Table of booleans, true if rule could match eol. */
+static yyconst flex_int32_t yy_rule_can_match_eol[20] =
+ { 0,
+0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0,
+ };
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+extern int res__flex_debug;
+int res__flex_debug = 0;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *res_text;
+#line 1 "resource_lexer.lpp"
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 1999-2004 Eidos Interactive
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+#line 21 "resource_lexer.lpp"
+/** @file
+ *
+ * Lexical analyser for resource (*.wrf) files
+ */
+
+#include "lib/framework/frame.h"
+
+#include "lib/framework/resly.h"
+
+/* Get the Yacc definitions */
+#include "resource_parser.h"
+
+extern void res_error(const char* msg);
+
+#include "lib/framework/lexer_input.h"
+
+// fwrite declared with warn_unused_result, resulting in mysterious errors in "%%" on some distros.
+static inline bool no_warn_unused_result(int ignore) { if (ignore) {} return true; }
+#define fwrite(a, b, c, d) no_warn_unused_result(fwrite(a, b, c, d))
+
+#ifndef yyextra
+# define yyextra res_get_extra()
+#endif
+
+/* Older GNU Flex versions don't define res_get_extra(), res_set_extra(),
+ * res_get_text() and res_get_lineno().
+ * (and neither define a subminor version)
+ */
+#if !defined(YY_FLEX_SUBMINOR_VERSION) || (YY_FLEX_SUBMINOR_VERSION < 9)
+# define res_get_extra res_get_extra
+# define res_set_extra res_set_extra
+# define res_get_lineno res_get_lineno
+# define res_get_text res_get_text
+extern void res_set_extra(YY_EXTRA_TYPE user_defined);
+extern YY_EXTRA_TYPE res_get_extra(void);
+extern int res_get_lineno(void);
+int res_get_lineno()
+{
+ return res_lineno;
+}
+
+extern char* res_get_text(void);
+char* res_get_text()
+{
+ return res_text;
+}
+#elif defined(YY_FLEX_SUBMINOR_VERSION) && YY_FLEX_SUBMINOR_VERSION == 33
+extern YY_EXTRA_TYPE res_get_extra(void);
+extern int res_get_lineno(void);
+extern FILE *res_get_in(void);
+extern FILE *res_get_out(void);
+extern int res_get_leng(void);
+extern char *res_get_text(void);
+extern void res_set_lineno(int line_number);
+extern void res_set_in(FILE* in_str);
+extern void res_set_out(FILE* out_str);
+extern int res_get_debug(void);
+extern void res_set_debug(int bdebug);
+#endif
+
+
+
+
+#line 617 "resource_lexer.cpp"
+
+#define INITIAL 0
+#define COMMENT 1
+#define QUOTE 2
+#define SLCOMMENT 3
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#include
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+static int yy_init_globals (void );
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int res_lex_destroy (void );
+
+int res_get_debug (void );
+
+void res_set_debug (int debug_flag );
+
+YY_EXTRA_TYPE res_get_extra (void );
+
+void res_set_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *res_get_in (void );
+
+void res_set_in (FILE * in_str );
+
+FILE *res_get_out (void );
+
+void res_set_out (FILE * out_str );
+
+int res_get_leng (void );
+
+char *res_get_text (void );
+
+int res_get_lineno (void );
+
+void res_set_lineno (int line_number );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int res_wrap (void );
+#else
+extern int res_wrap (void );
+#endif
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int );
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * );
+#endif
+
+#ifndef YY_NO_INPUT
+
+#ifdef __cplusplus
+static int yyinput (void );
+#else
+static int input (void );
+#endif
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
+#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO do { if (fwrite( res_text, res_leng, 1, res_out )) {} } while (0)
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ { \
+ int c = '*'; \
+ size_t n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( res_in )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( res_in ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else \
+ { \
+ errno=0; \
+ while ( (result = fread(buf, 1, max_size, res_in))==0 && ferror(res_in)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(res_in); \
+ } \
+ }\
+\
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* end tables serialization structures and prototypes */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int res_lex (void);
+
+#define YY_DECL int res_lex (void)
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after res_text and res_leng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+ YY_USER_ACTION
+
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp, *yy_bp;
+ register int yy_act;
+
+#line 93 "resource_lexer.lpp"
+
+ /* Match to key words */
+#line 808 "resource_lexer.cpp"
+
+ if ( !(yy_init) )
+ {
+ (yy_init) = 1;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! (yy_start) )
+ (yy_start) = 1; /* first start state */
+
+ if ( ! res_in )
+ res_in = stdin;
+
+ if ( ! res_out )
+ res_out = stdout;
+
+ if ( ! YY_CURRENT_BUFFER ) {
+ res_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ res__create_buffer(res_in,YY_BUF_SIZE );
+ }
+
+ res__load_buffer_state( );
+ }
+
+ while ( 1 ) /* loops until end-of-file is reached */
+ {
+ yy_cp = (yy_c_buf_p);
+
+ /* Support of res_text. */
+ *yy_cp = (yy_hold_char);
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+ yy_current_state = (yy_start);
+yy_match:
+ do
+ {
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 46 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ ++yy_cp;
+ }
+ while ( yy_current_state != 45 );
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+
+yy_find_action:
+ yy_act = yy_accept[yy_current_state];
+
+ YY_DO_BEFORE_ACTION;
+
+ if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
+ {
+ int yyl;
+ for ( yyl = 0; yyl < res_leng; ++yyl )
+ if ( res_text[yyl] == '\n' )
+
+ res_lineno++;
+;
+ }
+
+do_action: /* This label is used only to access EOF actions. */
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = (yy_hold_char);
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 95 "resource_lexer.lpp"
+{ return DIRECTORY; }
+ YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 96 "resource_lexer.lpp"
+{ return FILETOKEN; }
+ YY_BREAK
+/* Match text values */
+case 3:
+YY_RULE_SETUP
+#line 99 "resource_lexer.lpp"
+{
+ res_lval.sval = strdup(res_text);
+ return TEXT_T;
+ }
+ YY_BREAK
+/* Match quoted text */
+case 4:
+YY_RULE_SETUP
+#line 105 "resource_lexer.lpp"
+{
+ res_lval.sval = strdup("");
+ return QTEXT_T;
+ }
+ YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 110 "resource_lexer.lpp"
+{ BEGIN QUOTE; }
+ YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 111 "resource_lexer.lpp"
+{ BEGIN 0; }
+ YY_BREAK
+case 7:
+/* rule 7 can match eol */
+YY_RULE_SETUP
+#line 112 "resource_lexer.lpp"
+{ res_error("Unexpected end of line in string"); }
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 113 "resource_lexer.lpp"
+{
+ res_lval.sval = strdup(res_text);
+ return QTEXT_T;
+ }
+ YY_BREAK
+/* Skip white space */
+case 9:
+/* rule 9 can match eol */
+YY_RULE_SETUP
+#line 118 "resource_lexer.lpp"
+;
+ YY_BREAK
+/* Strip comments */
+case 10:
+YY_RULE_SETUP
+#line 121 "resource_lexer.lpp"
+{ BEGIN COMMENT; }
+ YY_BREAK
+case 11:
+#line 123 "resource_lexer.lpp"
+case 12:
+/* rule 12 can match eol */
+YY_RULE_SETUP
+#line 123 "resource_lexer.lpp"
+{ BEGIN 0; }
+ YY_BREAK
+case 13:
+#line 125 "resource_lexer.lpp"
+case 14:
+/* rule 14 can match eol */
+YY_RULE_SETUP
+#line 125 "resource_lexer.lpp"
+;
+ YY_BREAK
+/* Strip single line comments */
+case 15:
+YY_RULE_SETUP
+#line 128 "resource_lexer.lpp"
+{ BEGIN SLCOMMENT; }
+ YY_BREAK
+case 16:
+/* rule 16 can match eol */
+YY_RULE_SETUP
+#line 129 "resource_lexer.lpp"
+{ BEGIN 0; }
+ YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 130 "resource_lexer.lpp"
+;
+ YY_BREAK
+/* Match anything that's been missed and pass it as a char */
+case 18:
+YY_RULE_SETUP
+#line 133 "resource_lexer.lpp"
+return res_text[0];
+ YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 135 "resource_lexer.lpp"
+ECHO;
+ YY_BREAK
+#line 1006 "resource_lexer.cpp"
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(COMMENT):
+case YY_STATE_EOF(QUOTE):
+case YY_STATE_EOF(SLCOMMENT):
+ yyterminate();
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = (yy_hold_char);
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed res_in at a new source and called
+ * res_lex(). If so, then we have to assure
+ * consistency between YY_CURRENT_BUFFER and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = res_in;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++(yy_c_buf_p);
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ (yy_did_buffer_switch_on_eof) = 0;
+
+ if ( res_wrap( ) )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * res_text, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) =
+ (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ (yy_c_buf_p) =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+} /* end of res_lex */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+static int yy_get_next_buffer (void)
+{
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ register char *source = (yytext_ptr);
+ register int number_to_move, i;
+ int ret_val;
+
+ if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
+
+ else
+ {
+ int num_to_read =
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+
+ int yy_c_buf_p_offset =
+ (int) ((yy_c_buf_p) - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ res_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = 0;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+ number_to_move - 1;
+
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+ (yy_n_chars), (size_t) num_to_read );
+
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ if ( (yy_n_chars) == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ res_restart(res_in );
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) res_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
+ (yy_n_chars) += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
+
+ (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+ return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+ static yy_state_type yy_get_previous_state (void)
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp;
+
+ yy_current_state = (yy_start);
+
+ for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
+ {
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 46 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ }
+
+ return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
+{
+ register int yy_is_jam;
+ register char *yy_cp = (yy_c_buf_p);
+
+ register YY_CHAR yy_c = 1;
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 46 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_is_jam = (yy_current_state == 45);
+
+ return yy_is_jam ? 0 : yy_current_state;
+}
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+ static int yyinput (void)
+#else
+ static int input (void)
+#endif
+
+{
+ int c;
+
+ *(yy_c_buf_p) = (yy_hold_char);
+
+ if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ /* This was really a NUL. */
+ *(yy_c_buf_p) = '\0';
+
+ else
+ { /* need more input */
+ int offset = (yy_c_buf_p) - (yytext_ptr);
+ ++(yy_c_buf_p);
+
+ switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ res_restart(res_in );
+
+ /*FALLTHROUGH*/
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( res_wrap( ) )
+ return EOF;
+
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput();
+#else
+ return input();
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) = (yytext_ptr) + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
+ *(yy_c_buf_p) = '\0'; /* preserve res_text */
+ (yy_hold_char) = *++(yy_c_buf_p);
+
+ if ( c == '\n' )
+
+ res_lineno++;
+;
+
+ return c;
+}
+#endif /* ifndef YY_NO_INPUT */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ *
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+ void res_restart (FILE * input_file )
+{
+
+ if ( ! YY_CURRENT_BUFFER ){
+ res_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ res__create_buffer(res_in,YY_BUF_SIZE );
+ }
+
+ res__init_buffer(YY_CURRENT_BUFFER,input_file );
+ res__load_buffer_state( );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ *
+ */
+ void res__switch_to_buffer (YY_BUFFER_STATE new_buffer )
+{
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * res_pop_buffer_state();
+ * res_push_buffer_state(new_buffer);
+ */
+ res_ensure_buffer_stack ();
+ if ( YY_CURRENT_BUFFER == new_buffer )
+ return;
+
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ res__load_buffer_state( );
+
+ /* We don't actually know whether we did this switch during
+ * EOF (res_wrap()) processing, but the only time this flag
+ * is looked at is after res_wrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+static void res__load_buffer_state (void)
+{
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ res_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ (yy_hold_char) = *(yy_c_buf_p);
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ *
+ * @return the allocated buffer state.
+ */
+ YY_BUFFER_STATE res__create_buffer (FILE * file, int size )
+{
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) res_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in res__create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) res_alloc(b->yy_buf_size + 2 );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in res__create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ res__init_buffer(b,file );
+
+ return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with res__create_buffer()
+ *
+ */
+ void res__delete_buffer (YY_BUFFER_STATE b )
+{
+
+ if ( ! b )
+ return;
+
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ res_free((void *) b->yy_ch_buf );
+
+ res_free((void *) b );
+}
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a res_restart() or at EOF.
+ */
+ static void res__init_buffer (YY_BUFFER_STATE b, FILE * file )
+
+{
+ int oerrno = errno;
+
+ res__flush_buffer(b );
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+ /* If b is the current buffer, then res__init_buffer was _probably_
+ * called from res_restart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
+
+ b->yy_is_interactive = 0;
+
+ errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ *
+ */
+ void res__flush_buffer (YY_BUFFER_STATE b )
+{
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == YY_CURRENT_BUFFER )
+ res__load_buffer_state( );
+}
+
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ *
+ */
+void res_push_buffer_state (YY_BUFFER_STATE new_buffer )
+{
+ if (new_buffer == NULL)
+ return;
+
+ res_ensure_buffer_stack();
+
+ /* This block is copied from res__switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ (yy_buffer_stack_top)++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from res__switch_to_buffer. */
+ res__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ *
+ */
+void res_pop_buffer_state (void)
+{
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ res__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if ((yy_buffer_stack_top) > 0)
+ --(yy_buffer_stack_top);
+
+ if (YY_CURRENT_BUFFER) {
+ res__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+ }
+}
+
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+static void res_ensure_buffer_stack (void)
+{
+ int num_to_alloc;
+
+ if (!(yy_buffer_stack)) {
+
+ /* First allocation is just for 2 elements, since we don't know if this
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
+ * immediate realloc on the next call.
+ */
+ num_to_alloc = 1;
+ (yy_buffer_stack) = (struct yy_buffer_state**)res_alloc
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in res_ensure_buffer_stack()" );
+
+ memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+
+ (yy_buffer_stack_max) = num_to_alloc;
+ (yy_buffer_stack_top) = 0;
+ return;
+ }
+
+ if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+
+ /* Increase the buffer to prepare for a possible push. */
+ int grow_size = 8 /* arbitrary grow size */;
+
+ num_to_alloc = (yy_buffer_stack_max) + grow_size;
+ (yy_buffer_stack) = (struct yy_buffer_state**)res_realloc
+ ((yy_buffer_stack),
+ num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in res_ensure_buffer_stack()" );
+
+ /* zero only the new slots.*/
+ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+ (yy_buffer_stack_max) = num_to_alloc;
+ }
+}
+
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE res__scan_buffer (char * base, yy_size_t size )
+{
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return 0;
+
+ b = (YY_BUFFER_STATE) res_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in res__scan_buffer()" );
+
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = 0;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ res__switch_to_buffer(b );
+
+ return b;
+}
+
+/** Setup the input buffer state to scan a string. The next call to res_lex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ *
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * res__scan_bytes() instead.
+ */
+YY_BUFFER_STATE res__scan_string (yyconst char * yystr )
+{
+
+ return res__scan_bytes(yystr,strlen(yystr) );
+}
+
+/** Setup the input buffer state to scan the given bytes. The next call to res_lex() will
+ * scan from a @e copy of @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE res__scan_bytes (yyconst char * yybytes, int _yybytes_len )
+{
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = _yybytes_len + 2;
+ buf = (char *) res_alloc(n );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in res__scan_bytes()" );
+
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
+
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = res__scan_buffer(buf,n );
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in res__scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+}
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+static void yy_fatal_error (yyconst char* msg )
+{
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+}
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up res_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ res_text[res_leng] = (yy_hold_char); \
+ (yy_c_buf_p) = res_text + yyless_macro_arg; \
+ (yy_hold_char) = *(yy_c_buf_p); \
+ *(yy_c_buf_p) = '\0'; \
+ res_leng = yyless_macro_arg; \
+ } \
+ while ( 0 )
+
+/* Accessor methods (get/set functions) to struct members. */
+
+/** Get the current line number.
+ *
+ */
+int res_get_lineno (void)
+{
+
+ return res_lineno;
+}
+
+/** Get the input stream.
+ *
+ */
+FILE *res_get_in (void)
+{
+ return res_in;
+}
+
+/** Get the output stream.
+ *
+ */
+FILE *res_get_out (void)
+{
+ return res_out;
+}
+
+/** Get the length of the current token.
+ *
+ */
+int res_get_leng (void)
+{
+ return res_leng;
+}
+
+/** Get the current token.
+ *
+ */
+
+char *res_get_text (void)
+{
+ return res_text;
+}
+
+/** Set the current line number.
+ * @param line_number
+ *
+ */
+void res_set_lineno (int line_number )
+{
+
+ res_lineno = line_number;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ *
+ * @see res__switch_to_buffer
+ */
+void res_set_in (FILE * in_str )
+{
+ res_in = in_str ;
+}
+
+void res_set_out (FILE * out_str )
+{
+ res_out = out_str ;
+}
+
+int res_get_debug (void)
+{
+ return res__flex_debug;
+}
+
+void res_set_debug (int bdebug )
+{
+ res__flex_debug = bdebug ;
+}
+
+static int yy_init_globals (void)
+{
+ /* Initialization is the same as for the non-reentrant scanner.
+ * This function is called from res_lex_destroy(), so don't allocate here.
+ */
+
+ /* We do not touch res_lineno unless the option is enabled. */
+ res_lineno = 1;
+
+ (yy_buffer_stack) = 0;
+ (yy_buffer_stack_top) = 0;
+ (yy_buffer_stack_max) = 0;
+ (yy_c_buf_p) = (char *) 0;
+ (yy_init) = 0;
+ (yy_start) = 0;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ res_in = stdin;
+ res_out = stdout;
+#else
+ res_in = (FILE *) 0;
+ res_out = (FILE *) 0;
+#endif
+
+ /* For future reference: Set errno on error, since we are called by
+ * res_lex_init()
+ */
+ return 0;
+}
+
+/* res_lex_destroy is for both reentrant and non-reentrant scanners. */
+int res_lex_destroy (void)
+{
+
+ /* Pop the buffer stack, destroying each element. */
+ while(YY_CURRENT_BUFFER){
+ res__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ res_pop_buffer_state();
+ }
+
+ /* Destroy the stack itself. */
+ res_free((yy_buffer_stack) );
+ (yy_buffer_stack) = NULL;
+
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * res_lex() is called, initialization will occur. */
+ yy_init_globals( );
+
+ return 0;
+}
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+{
+ register int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * s )
+{
+ register int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+}
+#endif
+
+void *res_alloc (yy_size_t size )
+{
+ return (void *) malloc( size );
+}
+
+void *res_realloc (void * ptr, yy_size_t size )
+{
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return (void *) realloc( (char *) ptr, size );
+}
+
+void res_free (void * ptr )
+{
+ free( (char *) ptr ); /* see res_realloc() for (char *) cast */
+}
+
+#define YYTABLES_NAME "yytables"
+
+#line 135 "resource_lexer.lpp"
+
+
+
+static YY_EXTRA_TYPE pBuffer = NULL;
+
+void res_set_extra(YY_EXTRA_TYPE user_defined)
+{
+ pBuffer = user_defined;
+}
+
+YY_EXTRA_TYPE res_get_extra()
+{
+ return pBuffer;
+}
+
+/* Older GNU Flex versions don't define res_lex_destroy()
+ * (and neither define a subminor version)
+ */
+#if !defined(YY_FLEX_SUBMINOR_VERSION) || (YY_FLEX_SUBMINOR_VERSION < 9)
+int res_lex_destroy(void)
+{
+ /* For non-reentrant C scanner only. */
+ res__delete_buffer(YY_CURRENT_BUFFER);
+ yy_init = 1;
+ return 0;
+}
+#endif
+
diff --git a/lib/framework/resource_parser.cpp b/lib/framework/resource_parser.cpp
new file mode 100644
index 000000000..937faf4e9
--- /dev/null
+++ b/lib/framework/resource_parser.cpp
@@ -0,0 +1,1686 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "2.5"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 0
+
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+/* Substitute the variable and function names. */
+#define yyparse res_parse
+#define yylex res_lex
+#define yyerror res_error
+#define yylval res_lval
+#define yychar res_char
+#define yydebug res_debug
+#define yynerrs res_nerrs
+
+
+/* Copy the first part of user declarations. */
+
+/* Line 268 of yacc.c */
+#line 21 "resource_parser.ypp"
+
+/** @file
+ *
+ * Parser for RES (*.wrf) files
+ */
+
+extern int res_lex(void);
+extern int res_get_lineno(void);
+extern char* res_get_text(void);
+
+/* Allow frame header files to be singly included */
+#define FRAME_LIB_INCLUDE
+
+#include "lib/framework/frame.h"
+#include
+#include
+
+#include "lib/framework/string_ext.h"
+#include "lib/framework/frameresource.h"
+#include "lib/framework/resly.h"
+
+extern void yyerror(const char* msg);
+void yyerror(const char* msg)
+{
+ debug(LOG_ERROR, "RES file parse error:\n%s at line %d\nText: '%s'\n", msg, res_get_lineno(), res_get_text());
+}
+
+
+
+/* Line 268 of yacc.c */
+#line 109 "resource_parser.cpp"
+
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
+#endif
+
+/* Enabling the token table. */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ TEXT_T = 258,
+ QTEXT_T = 259,
+ DIRECTORY = 260,
+ FILETOKEN = 261
+ };
+#endif
+/* Tokens. */
+#define TEXT_T 258
+#define QTEXT_T 259
+#define DIRECTORY 260
+#define FILETOKEN 261
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 293 of yacc.c */
+#line 52 "resource_parser.ypp"
+
+ char *sval;
+
+
+
+/* Line 293 of yacc.c */
+#line 163 "resource_parser.cpp"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+
+/* Copy the second part of user declarations. */
+
+
+/* Line 343 of yacc.c */
+#line 175 "resource_parser.cpp"
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if defined YYENABLE_NLS && YYENABLE_NLS
+# if ENABLE_NLS
+# include /* INFRINGES ON USER NAME SPACE */
+# define YY_(msgid) dgettext ("bison-runtime", msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions. */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int yyi)
+#else
+static int
+YYID (yyi)
+ int yyi;
+#endif
+{
+ return yyi;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined EXIT_SUCCESS \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+};
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+# define YYCOPY_NEEDED 1
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (YYID (0))
+
+#endif
+
+#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (YYID (0))
+# endif
+# endif
+#endif /* !YYCOPY_NEEDED */
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 9
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 8
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 7
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 5
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 7
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 12
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 261
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const yytype_uint8 yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const yytype_uint8 yyprhs[] =
+{
+ 0, 0, 3, 5, 8, 10, 12, 15
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yytype_int8 yyrhs[] =
+{
+ 8, 0, -1, 9, -1, 8, 9, -1, 10, -1,
+ 11, -1, 5, 4, -1, 6, 3, 4, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const yytype_uint8 yyrline[] =
+{
+ 0, 76, 76, 77, 80, 81, 84, 114
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "$end", "error", "$undefined", "TEXT_T", "QTEXT_T", "DIRECTORY",
+ "FILETOKEN", "$accept", "res_file", "res_line", "dir_line", "file_line", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const yytype_uint16 yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 260, 261
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const yytype_uint8 yyr1[] =
+{
+ 0, 7, 8, 8, 9, 9, 10, 11
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const yytype_uint8 yyr2[] =
+{
+ 0, 2, 1, 2, 1, 1, 2, 3
+};
+
+/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
+ Performed when YYTABLE doesn't specify something else to do. Zero
+ means the default is an error. */
+static const yytype_uint8 yydefact[] =
+{
+ 0, 0, 0, 0, 2, 4, 5, 6, 0, 1,
+ 3, 7
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const yytype_int8 yydefgoto[] =
+{
+ -1, 3, 4, 5, 6
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -5
+static const yytype_int8 yypact[] =
+{
+ -4, -1, 1, 0, -5, -5, -5, -5, 3, -5,
+ -5, -5
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const yytype_int8 yypgoto[] =
+{
+ -5, -5, 5, -5, -5
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If YYTABLE_NINF, syntax error. */
+#define YYTABLE_NINF -1
+static const yytype_uint8 yytable[] =
+{
+ 9, 1, 2, 7, 8, 1, 2, 11, 10
+};
+
+#define yypact_value_is_default(yystate) \
+ ((yystate) == (-5))
+
+#define yytable_value_is_error(yytable_value) \
+ YYID (0)
+
+static const yytype_uint8 yycheck[] =
+{
+ 0, 5, 6, 4, 3, 5, 6, 4, 3
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const yytype_uint8 yystos[] =
+{
+ 0, 5, 6, 8, 9, 10, 11, 4, 3, 0,
+ 9, 4
+};
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
+
+
+/* Like YYERROR except do call yyerror. This remains here temporarily
+ to ease the transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. However,
+ YYFAIL appears to be in use. Nevertheless, it is formally deprecated
+ in Bison 2.4.2's NEWS entry, where a plan to phase it out is
+ discussed. */
+
+#define YYFAIL goto yyerrlab
+#if defined YYFAIL
+ /* This is here to suppress warnings from the GCC cpp's
+ -Wunused-macros. Normally we don't worry about that warning, but
+ some users do, and we want to make it easy for users to remove
+ YYFAIL uses, which will produce warnings from Bison 2.5. */
+#endif
+
+#define YYRECOVERING() (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (1); \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+while (YYID (0))
+
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+ If N is 0, then set CURRENT to the empty location which ends
+ the previous symbol: RHS[0] (always defined). */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (YYID (N)) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ } \
+ while (YYID (0))
+#endif
+
+
+/* This macro is provided for backward compatibility. */
+
+#ifndef YY_LOCATION_PRINT
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+#endif
+
+
+/* YYLEX -- calling `yylex' with the right arguments. */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (YYLEX_PARAM)
+#else
+# define YYLEX yylex ()
+#endif
+
+/* Enable debugging if requested. */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+# include /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, \
+ Type, Value); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (YYID (0))
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (!yyvaluep)
+ return;
+# ifdef YYPRINT
+ if (yytype < YYNTOKENS)
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# else
+ YYUSE (yyoutput);
+# endif
+ switch (yytype)
+ {
+ default:
+ break;
+ }
+}
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (yytype < YYNTOKENS)
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+ else
+ YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+ yy_symbol_value_print (yyoutput, yytype, yyvaluep);
+ YYFPRINTF (yyoutput, ")");
+}
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included). |
+`------------------------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
+#else
+static void
+yy_stack_print (yybottom, yytop)
+ yytype_int16 *yybottom;
+ yytype_int16 *yytop;
+#endif
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
+ YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (YYID (0))
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
+#else
+static void
+yy_reduce_print (yyvsp, yyrule)
+ YYSTYPE *yyvsp;
+ int yyrule;
+#endif
+{
+ int yynrhs = yyr2[yyrule];
+ int yyi;
+ unsigned long int yylno = yyrline[yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+ yyrule - 1, yylno);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+ &(yyvsp[(yyi + 1) - (yynrhs)])
+ );
+ YYFPRINTF (stderr, "\n");
+ }
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyvsp, Rule); \
+} while (YYID (0))
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+# if defined __GLIBC__ && defined _STRING_H
+# define yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static YYSIZE_T
+yystrlen (const char *yystr)
+#else
+static YYSIZE_T
+yystrlen (yystr)
+ const char *yystr;
+#endif
+{
+ YYSIZE_T yylen;
+ for (yylen = 0; yystr[yylen]; yylen++)
+ continue;
+ return yylen;
+}
+# endif
+# endif
+
+# ifndef yystpcpy
+# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static char *
+yystpcpy (char *yydest, const char *yysrc)
+#else
+static char *
+yystpcpy (yydest, yysrc)
+ char *yydest;
+ const char *yysrc;
+#endif
+{
+ char *yyd = yydest;
+ const char *yys = yysrc;
+
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
+
+ return yyd - 1;
+}
+# endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+ if (*yystr == '"')
+ {
+ YYSIZE_T yyn = 0;
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
+ do_not_strip_quotes: ;
+ }
+
+ if (! yyres)
+ return yystrlen (yystr);
+
+ return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
+ about the unexpected token YYTOKEN for the state stack whose top is
+ YYSSP.
+
+ Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
+ not large enough to hold the message. In that case, also set
+ *YYMSG_ALLOC to the required number of bytes. Return 2 if the
+ required number of bytes is too large to store. */
+static int
+yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
+ yytype_int16 *yyssp, int yytoken)
+{
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
+ YYSIZE_T yysize = yysize0;
+ YYSIZE_T yysize1;
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ /* Internationalized format string. */
+ const char *yyformat = 0;
+ /* Arguments of yyformat. */
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ /* Number of reported tokens (one for the "unexpected", one per
+ "expected"). */
+ int yycount = 0;
+
+ /* There are many possibilities here to consider:
+ - Assume YYFAIL is not used. It's too flawed to consider. See
+
+ for details. YYERROR is fine as it does not invoke this
+ function.
+ - If this state is a consistent state with a default action, then
+ the only way this function was invoked is if the default action
+ is an error action. In that case, don't check for expected
+ tokens because there are none.
+ - The only way there can be no lookahead present (in yychar) is if
+ this state is a consistent state with a default action. Thus,
+ detecting the absence of a lookahead is sufficient to determine
+ that there is no unexpected or expected token to report. In that
+ case, just report a simple "syntax error".
+ - Don't assume there isn't a lookahead just because this state is a
+ consistent state with a default action. There might have been a
+ previous inconsistent state, consistent state with a non-default
+ action, or user semantic action that manipulated yychar.
+ - Of course, the expected token list depends on states to have
+ correct lookahead information, and it depends on the parser not
+ to perform extra reductions after fetching a lookahead from the
+ scanner and before detecting a syntax error. Thus, state merging
+ (from LALR or IELR) and default reductions corrupt the expected
+ token list. However, the list is correct for canonical LR with
+ one exception: it will still contain any token that will not be
+ accepted due to an error action in a later state.
+ */
+ if (yytoken != YYEMPTY)
+ {
+ int yyn = yypact[*yyssp];
+ yyarg[yycount++] = yytname[yytoken];
+ if (!yypact_value_is_default (yyn))
+ {
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. In other words, skip the first -YYN actions for
+ this state because they are default actions. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn + 1;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yyx;
+
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
+ && !yytable_value_is_error (yytable[yyx + yyn]))
+ {
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ yycount = 1;
+ yysize = yysize0;
+ break;
+ }
+ yyarg[yycount++] = yytname[yyx];
+ yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+ if (! (yysize <= yysize1
+ && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+ }
+ }
+ }
+
+ switch (yycount)
+ {
+# define YYCASE_(N, S) \
+ case N: \
+ yyformat = S; \
+ break
+ YYCASE_(0, YY_("syntax error"));
+ YYCASE_(1, YY_("syntax error, unexpected %s"));
+ YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
+ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
+ YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
+ YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
+# undef YYCASE_
+ }
+
+ yysize1 = yysize + yystrlen (yyformat);
+ if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+
+ if (*yymsg_alloc < yysize)
+ {
+ *yymsg_alloc = 2 * yysize;
+ if (! (yysize <= *yymsg_alloc
+ && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
+ *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
+ return 1;
+ }
+
+ /* Avoid sprintf, as that infringes on the user's name space.
+ Don't have undefined behavior even if the translation
+ produced a string with the wrong number of "%s"s. */
+ {
+ char *yyp = *yymsg;
+ int yyi = 0;
+ while ((*yyp = *yyformat) != '\0')
+ if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyformat += 2;
+ }
+ else
+ {
+ yyp++;
+ yyformat++;
+ }
+ }
+ return 0;
+}
+#endif /* YYERROR_VERBOSE */
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol. |
+`-----------------------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
+#else
+static void
+yydestruct (yymsg, yytype, yyvaluep)
+ const char *yymsg;
+ int yytype;
+ YYSTYPE *yyvaluep;
+#endif
+{
+ YYUSE (yyvaluep);
+
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+ switch (yytype)
+ {
+ case 3: /* "TEXT_T" */
+
+/* Line 1391 of yacc.c */
+#line 60 "resource_parser.ypp"
+ {
+#ifndef WZ_OS_WIN
+ // Force type checking by the compiler
+ char * const s = (yyvaluep->sval);
+
+ if (s)
+ free(s);
+#endif
+};
+
+/* Line 1391 of yacc.c */
+#line 1103 "resource_parser.cpp"
+ break;
+ case 4: /* "QTEXT_T" */
+
+/* Line 1391 of yacc.c */
+#line 60 "resource_parser.ypp"
+ {
+#ifndef WZ_OS_WIN
+ // Force type checking by the compiler
+ char * const s = (yyvaluep->sval);
+
+ if (s)
+ free(s);
+#endif
+};
+
+/* Line 1391 of yacc.c */
+#line 1120 "resource_parser.cpp"
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+/* Prevent warnings from -Wmissing-prototypes. */
+#ifdef YYPARSE_PARAM
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void *YYPARSE_PARAM);
+#else
+int yyparse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+/* The lookahead symbol. */
+int yychar;
+
+/* The semantic value of the lookahead symbol. */
+YYSTYPE yylval;
+
+/* Number of syntax errors so far. */
+int yynerrs;
+
+
+/*----------.
+| yyparse. |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *YYPARSE_PARAM)
+#else
+int
+yyparse (YYPARSE_PARAM)
+ void *YYPARSE_PARAM;
+#endif
+#else /* ! YYPARSE_PARAM */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void)
+#else
+int
+yyparse ()
+
+#endif
+#endif
+{
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
+
+ YYSIZE_T yystacksize;
+
+ int yyn;
+ int yyresult;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char yymsgbuf[128];
+ char *yymsg = yymsgbuf;
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+
+ /* The number of symbols on the RHS of the reduced rule.
+ Keep to zero when no symbol should be popped. */
+ int yylen = 0;
+
+ yytoken = 0;
+ yyss = yyssa;
+ yyvs = yyvsa;
+ yystacksize = YYINITDEPTH;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+ yyssp = yyss;
+ yyvsp = yyvs;
+
+ goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate. |
+`------------------------------------------------------------*/
+ yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. So pushing a state here evens the stacks. */
+ yyssp++;
+
+ yysetstate:
+ *yyssp = yystate;
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ {
+ /* Get the current used size of the three stacks, in elements. */
+ YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ {
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ yytype_int16 *yyss1 = yyss;
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
+ &yystacksize);
+
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+# else
+ /* Extend the stack our own way. */
+ if (YYMAXDEPTH <= yystacksize)
+ goto yyexhaustedlab;
+ yystacksize *= 2;
+ if (YYMAXDEPTH < yystacksize)
+ yystacksize = YYMAXDEPTH;
+
+ {
+ yytype_int16 *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyexhaustedlab;
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+# undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+ }
+# endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + yysize - 1;
+ yyvsp = yyvs + yysize - 1;
+
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ YYABORT;
+ }
+
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
+ goto yybackup;
+
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
+
+ /* Do appropriate processing given the current state. Read a
+ lookahead token if we need one and don't already have one. */
+
+ /* First try to decide what to do without reference to lookahead token. */
+ yyn = yypact[yystate];
+ if (yypact_value_is_default (yyn))
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
+ }
+
+ if (yychar <= YYEOF)
+ {
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ }
+
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
+ detect an error, take that action. */
+ yyn += yytoken;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+ goto yydefault;
+ yyn = yytable[yyn];
+ if (yyn <= 0)
+ {
+ if (yytable_value_is_error (yyn))
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
+
+ /* Shift the lookahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
+
+ yystate = yyn;
+ *++yyvsp = yylval;
+
+ goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+yydefault:
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction. |
+`-----------------------------*/
+yyreduce:
+ /* yyn is the number of a rule to reduce with. */
+ yylen = yyr2[yyn];
+
+ /* If YYLEN is nonzero, implement the default value of the action:
+ `$$ = $1'.
+
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ yyval = yyvsp[1-yylen];
+
+
+ YY_REDUCE_PRINT (yyn);
+ switch (yyn)
+ {
+ case 6:
+
+/* Line 1806 of yacc.c */
+#line 85 "resource_parser.ypp"
+ {
+ UDWORD len;
+
+ // set a new input directory
+ debug(LOG_NEVER, "directory: %s", (yyvsp[(2) - (2)].sval));
+ if (strncmp((yyvsp[(2) - (2)].sval), "/:", strlen("/:")) == 0)
+ {
+ // the new dir is rooted
+ sstrcpy(aCurrResDir, (yyvsp[(2) - (2)].sval));
+ }
+ else
+ {
+ sstrcpy(aCurrResDir, aResDir);
+ sstrcat(aCurrResDir, (yyvsp[(2) - (2)].sval));
+ }
+ if (strlen((yyvsp[(2) - (2)].sval)) > 0)
+ {
+ ASSERT(PHYSFS_isDirectory(aCurrResDir), "%s is not a directory!", aCurrResDir);
+ // Add a trailing '/'
+ len = strlen(aCurrResDir);
+ aCurrResDir[len] = '/';
+ aCurrResDir[len+1] = 0;
+ debug(LOG_NEVER, "Current resource directory: %s", aCurrResDir);
+ }
+ free((yyvsp[(2) - (2)].sval));
+ }
+ break;
+
+ case 7:
+
+/* Line 1806 of yacc.c */
+#line 115 "resource_parser.ypp"
+ {
+ bool succes;
+ /* load a data file */
+ debug(LOG_NEVER, "file: %s %s", (yyvsp[(2) - (3)].sval), (yyvsp[(3) - (3)].sval));
+ succes = resLoadFile((yyvsp[(2) - (3)].sval), (yyvsp[(3) - (3)].sval));
+ free((yyvsp[(2) - (3)].sval));
+ free((yyvsp[(3) - (3)].sval));
+
+ if (!succes)
+ {
+ YYABORT;
+ }
+ }
+ break;
+
+
+
+/* Line 1806 of yacc.c */
+#line 1474 "resource_parser.cpp"
+ default: break;
+ }
+ /* User semantic actions sometimes alter yychar, and that requires
+ that yytoken be updated with the new translation. We take the
+ approach of translating immediately before every use of yytoken.
+ One alternative is translating here after every semantic action,
+ but that translation would be missed if the semantic action invokes
+ YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
+ if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
+ incorrect destructor might then be invoked immediately. In the
+ case of YYERROR or YYBACKUP, subsequent parser actions might lead
+ to an incorrect destructor call or verbose syntax error message
+ before the lookahead is translated. */
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
+
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+
+ *++yyvsp = yyval;
+
+ /* Now `shift' the result of the reduction. Determine what state
+ that goes to, based on the state we popped back to and the rule
+ number reduced by. */
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTOKENS];
+
+ goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
+
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus)
+ {
+ ++yynerrs;
+#if ! YYERROR_VERBOSE
+ yyerror (YY_("syntax error"));
+#else
+# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
+ yyssp, yytoken)
+ {
+ char const *yymsgp = YY_("syntax error");
+ int yysyntax_error_status;
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ if (yysyntax_error_status == 0)
+ yymsgp = yymsg;
+ else if (yysyntax_error_status == 1)
+ {
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+ yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
+ if (!yymsg)
+ {
+ yymsg = yymsgbuf;
+ yymsg_alloc = sizeof yymsgbuf;
+ yysyntax_error_status = 2;
+ }
+ else
+ {
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ yymsgp = yymsg;
+ }
+ }
+ yyerror (yymsgp);
+ if (yysyntax_error_status == 2)
+ goto yyexhaustedlab;
+ }
+# undef YYSYNTAX_ERROR
+#endif
+ }
+
+
+
+ if (yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ if (yychar <= YYEOF)
+ {
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ YYABORT;
+ }
+ else
+ {
+ yydestruct ("Error: discarding",
+ yytoken, &yylval);
+ yychar = YYEMPTY;
+ }
+ }
+
+ /* Else will try to reuse lookahead token after shifting the error
+ token. */
+ goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR. |
+`---------------------------------------------------*/
+yyerrorlab:
+
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label yyerrorlab therefore never appears in user
+ code. */
+ if (/*CONSTCOND*/ 0)
+ goto yyerrorlab;
+
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYERROR. */
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+ yystate = *yyssp;
+ goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR. |
+`-------------------------------------------------------------*/
+yyerrlab1:
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
+
+ for (;;)
+ {
+ yyn = yypact[yystate];
+ if (!yypact_value_is_default (yyn))
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yyssp == yyss)
+ YYABORT;
+
+
+ yydestruct ("Error: popping",
+ yystos[yystate], yyvsp);
+ YYPOPSTACK (1);
+ yystate = *yyssp;
+ YY_STACK_PRINT (yyss, yyssp);
+ }
+
+ *++yyvsp = yylval;
+
+
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+#if !defined(yyoverflow) || YYERROR_VERBOSE
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here. |
+`-------------------------------------------------*/
+yyexhaustedlab:
+ yyerror (YY_("memory exhausted"));
+ yyresult = 2;
+ /* Fall through. */
+#endif
+
+yyreturn:
+ if (yychar != YYEMPTY)
+ {
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = YYTRANSLATE (yychar);
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval);
+ }
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYABORT or YYACCEPT. */
+ YYPOPSTACK (yylen);
+ YY_STACK_PRINT (yyss, yyssp);
+ while (yyssp != yyss)
+ {
+ yydestruct ("Cleanup: popping",
+ yystos[*yyssp], yyvsp);
+ YYPOPSTACK (1);
+ }
+#ifndef yyoverflow
+ if (yyss != yyssa)
+ YYSTACK_FREE (yyss);
+#endif
+#if YYERROR_VERBOSE
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+#endif
+ /* Make sure YYID is used. */
+ return YYID (yyresult);
+}
+
+
+
diff --git a/lib/framework/resource_parser.h b/lib/framework/resource_parser.h
new file mode 100644
index 000000000..98f10d261
--- /dev/null
+++ b/lib/framework/resource_parser.h
@@ -0,0 +1,63 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ TEXT_T = 258,
+ QTEXT_T = 259,
+ DIRECTORY = 260,
+ FILETOKEN = 261
+ };
+#endif
+/* Tokens. */
+#define TEXT_T 258
+#define QTEXT_T 259
+#define DIRECTORY 260
+#define FILETOKEN 261
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 2068 of yacc.c */
+#line 52 "resource_parser.ypp"
+
+ char *sval;
+
+
+
+/* Line 2068 of yacc.c */
+#line 68 "resource_parser.h"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+extern YYSTYPE res_lval;
+
+
diff --git a/lib/framework/strres_lexer.cpp b/lib/framework/strres_lexer.cpp
new file mode 100644
index 000000000..8777629c6
--- /dev/null
+++ b/lib/framework/strres_lexer.cpp
@@ -0,0 +1,1988 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+#line 2 "strres_lexer.cpp"
+
+#line 4 "strres_lexer.cpp"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define yy_create_buffer strres__create_buffer
+#define yy_delete_buffer strres__delete_buffer
+#define yy_flex_debug strres__flex_debug
+#define yy_init_buffer strres__init_buffer
+#define yy_flush_buffer strres__flush_buffer
+#define yy_load_buffer_state strres__load_buffer_state
+#define yy_switch_to_buffer strres__switch_to_buffer
+#define yyin strres_in
+#define yyleng strres_leng
+#define yylex strres_lex
+#define yylineno strres_lineno
+#define yyout strres_out
+#define yyrestart strres_restart
+#define yytext strres_text
+#define yywrap strres_wrap
+#define yyalloc strres_alloc
+#define yyrealloc strres_realloc
+#define yyfree strres_free
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 35
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+#include "lib/framework/frame.h"
+/* begin standard C headers. */
+#include
+#include
+#include
+#include
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have . Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#endif /* ! C99 */
+
+#endif /* ! FLEXINT_H */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
+
+#define YY_USE_CONST
+
+#endif /* defined (__STDC__) */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index. If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN (yy_start) = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START (((yy_start) - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE strres_restart(strres_in )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
+#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
+#endif
+
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+extern int strres_leng;
+
+extern FILE *strres_in, *strres_out;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+ /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
+ * access to the local variable yy_act. Since yyless() is a macro, it would break
+ * existing scanners that call yyless() from OUTSIDE strres_lex.
+ * One obvious solution it to make yy_act a global. I tried that, and saw
+ * a 5% performance hit in a non-strres_lineno scanner, because yy_act is
+ * normally declared as a register variable-- so it is not worth it.
+ */
+ #define YY_LESS_LINENO(n) \
+ do { \
+ int yyl;\
+ for ( yyl = n; yyl < strres_leng; ++yyl )\
+ if ( strres_text[yyl] == '\n' )\
+ --strres_lineno;\
+ }while(0)
+
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up strres_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ *yy_cp = (yy_hold_char); \
+ YY_RESTORE_YY_MORE_OFFSET \
+ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up strres_text again */ \
+ } \
+ while ( 0 )
+
+#define unput(c) yyunput( c, (yytext_ptr) )
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via strres_restart()), so that the user can continue scanning by
+ * just pointing strres_in at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+ : NULL)
+
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+
+/* yy_hold_char holds the character lost when strres_text is formed. */
+static char yy_hold_char;
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+int strres_leng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 0; /* whether we need to initialize */
+static int yy_start = 0; /* start state number */
+
+/* Flag which is used to allow strres_wrap()'s to do buffer switches
+ * instead of setting up a fresh strres_in. A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void strres_restart (FILE *input_file );
+void strres__switch_to_buffer (YY_BUFFER_STATE new_buffer );
+YY_BUFFER_STATE strres__create_buffer (FILE *file,int size );
+void strres__delete_buffer (YY_BUFFER_STATE b );
+void strres__flush_buffer (YY_BUFFER_STATE b );
+void strres_push_buffer_state (YY_BUFFER_STATE new_buffer );
+void strres_pop_buffer_state (void );
+
+static void strres_ensure_buffer_stack (void );
+static void strres__load_buffer_state (void );
+static void strres__init_buffer (YY_BUFFER_STATE b,FILE *file );
+
+#define YY_FLUSH_BUFFER strres__flush_buffer(YY_CURRENT_BUFFER )
+
+YY_BUFFER_STATE strres__scan_buffer (char *base,yy_size_t size );
+YY_BUFFER_STATE strres__scan_string (yyconst char *yy_str );
+YY_BUFFER_STATE strres__scan_bytes (yyconst char *bytes,int len );
+
+void *strres_alloc (yy_size_t );
+void *strres_realloc (void *,yy_size_t );
+void strres_free (void * );
+
+#define yy_new_buffer strres__create_buffer
+
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ strres_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ strres__create_buffer(strres_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+ }
+
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){\
+ strres_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ strres__create_buffer(strres_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+ }
+
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* Begin user sect3 */
+
+#define strres_wrap(n) 1
+#define YY_SKIP_YYWRAP
+
+typedef unsigned char YY_CHAR;
+
+FILE *strres_in = (FILE *) 0, *strres_out = (FILE *) 0;
+
+typedef int yy_state_type;
+
+extern int strres_lineno;
+
+int strres_lineno = 1;
+
+extern char *strres_text;
+#define yytext_ptr strres_text
+
+static yy_state_type yy_get_previous_state (void );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
+static int yy_get_next_buffer (void );
+static void yy_fatal_error (yyconst char msg[] );
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up strres_text.
+ */
+#define YY_DO_BEFORE_ACTION \
+ (yytext_ptr) = yy_bp; \
+ strres_leng = (size_t) (yy_cp - yy_bp); \
+ (yy_hold_char) = *yy_cp; \
+ *yy_cp = '\0'; \
+ (yy_c_buf_p) = yy_cp;
+
+#define YY_NUM_RULES 16
+#define YY_END_OF_BUFFER 17
+/* This struct is not used in this scanner,
+ but its presence is necessary. */
+struct yy_trans_info
+ {
+ flex_int32_t yy_verify;
+ flex_int32_t yy_nxt;
+ };
+static yyconst flex_int16_t yy_accept[32] =
+ { 0,
+ 0, 0, 0, 0, 5, 5, 14, 14, 17, 15,
+ 6, 6, 2, 15, 1, 10, 11, 10, 5, 4,
+ 3, 14, 13, 7, 12, 1, 8, 5, 14, 9,
+ 0
+ } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 1, 4, 1, 1, 1, 1, 1, 1,
+ 1, 5, 1, 1, 6, 1, 7, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 1, 1, 1,
+ 1, 1, 1, 1, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 1, 1, 1, 1, 6, 1, 8, 8, 8, 8,
+
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1
+ } ;
+
+static yyconst flex_int32_t yy_meta[9] =
+ { 0,
+ 1, 1, 2, 3, 1, 4, 1, 4
+ } ;
+
+static yyconst flex_int16_t yy_base[38] =
+ { 0,
+ 0, 0, 6, 9, 12, 14, 36, 33, 35, 42,
+ 42, 42, 42, 14, 0, 42, 42, 13, 0, 42,
+ 42, 0, 42, 42, 42, 0, 10, 0, 0, 42,
+ 42, 21, 25, 29, 6, 33, 37
+ } ;
+
+static yyconst flex_int16_t yy_def[38] =
+ { 0,
+ 31, 1, 32, 32, 33, 33, 34, 34, 31, 31,
+ 31, 31, 31, 31, 35, 31, 31, 31, 36, 31,
+ 31, 37, 31, 31, 31, 35, 31, 36, 37, 31,
+ 0, 31, 31, 31, 31, 31, 31
+ } ;
+
+static yyconst flex_int16_t yy_nxt[51] =
+ { 0,
+ 10, 11, 12, 13, 10, 10, 14, 15, 17, 26,
+ 18, 17, 30, 18, 20, 21, 20, 21, 24, 27,
+ 25, 16, 16, 16, 16, 19, 19, 19, 19, 22,
+ 22, 22, 22, 28, 31, 23, 28, 29, 23, 29,
+ 29, 9, 31, 31, 31, 31, 31, 31, 31, 31
+ } ;
+
+static yyconst flex_int16_t yy_chk[51] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 3, 35,
+ 3, 4, 27, 4, 5, 5, 6, 6, 14, 18,
+ 14, 32, 32, 32, 32, 33, 33, 33, 33, 34,
+ 34, 34, 34, 36, 9, 8, 36, 37, 7, 37,
+ 37, 31, 31, 31, 31, 31, 31, 31, 31, 31
+ } ;
+
+/* Table of booleans, true if rule could match eol. */
+static yyconst flex_int32_t yy_rule_can_match_eol[17] =
+ { 0,
+0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, };
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+extern int strres__flex_debug;
+int strres__flex_debug = 0;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *strres_text;
+#line 1 "strres_lexer.lpp"
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 1999-2004 Eidos Interactive
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+#line 21 "strres_lexer.lpp"
+/** @file
+ *
+ * Lexical analyser resource files
+ */
+
+#include "lib/framework/frame.h"
+
+/* Allow frame header files to be singly included */
+#define FRAME_LIB_INCLUDE
+
+#include "lib/framework/strres.h"
+#include "lib/framework/strresly.h"
+
+#include
+
+/* Get the Yacc definitions */
+#include "strres_parser.h"
+
+#include "lib/framework/lexer_input.h"
+
+// fwrite declared with warn_unused_result, resulting in mysterious errors in "%%" on some distros.
+static inline bool no_warn_unused_result(int ignore) { if (ignore) {} return true; }
+#define fwrite(a, b, c, d) no_warn_unused_result(fwrite(a, b, c, d))
+
+#ifndef yyextra
+# define yyextra strres_get_extra()
+#endif
+
+/* Older GNU Flex versions don't define strres_get_extra(), strres_set_extra(),
+ * strres_get_text() and strres_get_lineno().
+ * (and neither define a subminor version)
+ */
+#if !defined(YY_FLEX_SUBMINOR_VERSION) || (YY_FLEX_SUBMINOR_VERSION < 9)
+# define strres_get_extra strres_get_extra
+# define strres_set_extra strres_set_extra
+# define strres_get_lineno strres_get_lineno
+# define strres_get_text strres_get_text
+extern void strres_set_extra(YY_EXTRA_TYPE user_defined);
+extern YY_EXTRA_TYPE strres_get_extra(void);
+extern int strres_get_lineno(void);
+int strres_get_lineno()
+{
+ return strres_lineno;
+}
+
+extern char* strres_get_text(void);
+char* strres_get_text()
+{
+ return strres_text;
+}
+#elif defined(YY_FLEX_SUBMINOR_VERSION) && YY_FLEX_SUBMINOR_VERSION == 33
+extern YY_EXTRA_TYPE strres_get_extra(void);
+extern int strres_get_lineno(void);
+extern FILE *strres_get_in(void);
+extern FILE *strres_get_out(void);
+extern int strres_get_leng(void);
+extern char *strres_get_text(void);
+extern void strres_set_lineno(int line_number);
+extern void strres_set_in(FILE* in_str);
+extern void strres_set_out(FILE* out_str);
+extern int strres_get_debug(void);
+extern void strres_set_debug(int bdebug);
+#endif
+
+
+
+
+#line 606 "strres_lexer.cpp"
+
+#define INITIAL 0
+#define COMMENT 1
+#define QUOTE 2
+#define SLCOMMENT 3
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#include
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+static int yy_init_globals (void );
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int strres_lex_destroy (void );
+
+int strres_get_debug (void );
+
+void strres_set_debug (int debug_flag );
+
+YY_EXTRA_TYPE strres_get_extra (void );
+
+void strres_set_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *strres_get_in (void );
+
+void strres_set_in (FILE * in_str );
+
+FILE *strres_get_out (void );
+
+void strres_set_out (FILE * out_str );
+
+int strres_get_leng (void );
+
+char *strres_get_text (void );
+
+int strres_get_lineno (void );
+
+void strres_set_lineno (int line_number );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int strres_wrap (void );
+#else
+extern int strres_wrap (void );
+#endif
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int );
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * );
+#endif
+
+#ifndef YY_NO_INPUT
+
+#ifdef __cplusplus
+static int yyinput (void );
+#else
+static int input (void );
+#endif
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
+#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO do { if (fwrite( strres_text, strres_leng, 1, strres_out )) {} } while (0)
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ { \
+ int c = '*'; \
+ size_t n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( strres_in )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( strres_in ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else \
+ { \
+ errno=0; \
+ while ( (result = fread(buf, 1, max_size, strres_in))==0 && ferror(strres_in)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(strres_in); \
+ } \
+ }\
+\
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* end tables serialization structures and prototypes */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int strres_lex (void);
+
+#define YY_DECL int strres_lex (void)
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after strres_text and strres_leng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+ YY_USER_ACTION
+
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp, *yy_bp;
+ register int yy_act;
+
+#line 97 "strres_lexer.lpp"
+
+
+ /* Match text values */
+#line 798 "strres_lexer.cpp"
+
+ if ( !(yy_init) )
+ {
+ (yy_init) = 1;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! (yy_start) )
+ (yy_start) = 1; /* first start state */
+
+ if ( ! strres_in )
+ strres_in = stdin;
+
+ if ( ! strres_out )
+ strres_out = stdout;
+
+ if ( ! YY_CURRENT_BUFFER ) {
+ strres_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ strres__create_buffer(strres_in,YY_BUF_SIZE );
+ }
+
+ strres__load_buffer_state( );
+ }
+
+ while ( 1 ) /* loops until end-of-file is reached */
+ {
+ yy_cp = (yy_c_buf_p);
+
+ /* Support of strres_text. */
+ *yy_cp = (yy_hold_char);
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+ yy_current_state = (yy_start);
+yy_match:
+ do
+ {
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 32 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ ++yy_cp;
+ }
+ while ( yy_current_state != 31 );
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+
+yy_find_action:
+ yy_act = yy_accept[yy_current_state];
+
+ YY_DO_BEFORE_ACTION;
+
+ if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
+ {
+ int yyl;
+ for ( yyl = 0; yyl < strres_leng; ++yyl )
+ if ( strres_text[yyl] == '\n' )
+
+ strres_lineno++;
+;
+ }
+
+do_action: /* This label is used only to access EOF actions. */
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = (yy_hold_char);
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 100 "strres_lexer.lpp"
+{
+ strres_lval.sval = strdup(strres_text);
+ return TEXT_T;
+ }
+ YY_BREAK
+/* Match quoted text */
+case 2:
+YY_RULE_SETUP
+#line 106 "strres_lexer.lpp"
+{ BEGIN QUOTE; }
+ YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 107 "strres_lexer.lpp"
+{ BEGIN 0; }
+ YY_BREAK
+case 4:
+/* rule 4 can match eol */
+YY_RULE_SETUP
+#line 108 "strres_lexer.lpp"
+{ strres_error("Unexpected end of line in string"); }
+ YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 109 "strres_lexer.lpp"
+{
+ strres_lval.sval = strdup(strres_text);
+ return QTEXT_T;
+ }
+ YY_BREAK
+/* Skip white space */
+case 6:
+/* rule 6 can match eol */
+YY_RULE_SETUP
+#line 115 "strres_lexer.lpp"
+;
+ YY_BREAK
+/* Strip comments */
+case 7:
+YY_RULE_SETUP
+#line 118 "strres_lexer.lpp"
+{ BEGIN COMMENT; }
+ YY_BREAK
+case 8:
+#line 120 "strres_lexer.lpp"
+case 9:
+/* rule 9 can match eol */
+YY_RULE_SETUP
+#line 120 "strres_lexer.lpp"
+{ BEGIN 0; }
+ YY_BREAK
+case 10:
+#line 122 "strres_lexer.lpp"
+case 11:
+/* rule 11 can match eol */
+YY_RULE_SETUP
+#line 122 "strres_lexer.lpp"
+;
+ YY_BREAK
+/* Strip single line comments */
+case 12:
+YY_RULE_SETUP
+#line 125 "strres_lexer.lpp"
+{ BEGIN SLCOMMENT; }
+ YY_BREAK
+case 13:
+/* rule 13 can match eol */
+YY_RULE_SETUP
+#line 126 "strres_lexer.lpp"
+{ BEGIN 0; }
+ YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 127 "strres_lexer.lpp"
+;
+ YY_BREAK
+/* Match anything that's been missed and pass it as a char */
+case 15:
+YY_RULE_SETUP
+#line 130 "strres_lexer.lpp"
+return strres_text[0];
+ YY_BREAK
+case 16:
+YY_RULE_SETUP
+#line 132 "strres_lexer.lpp"
+ECHO;
+ YY_BREAK
+#line 977 "strres_lexer.cpp"
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(COMMENT):
+case YY_STATE_EOF(QUOTE):
+case YY_STATE_EOF(SLCOMMENT):
+ yyterminate();
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = (yy_hold_char);
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed strres_in at a new source and called
+ * strres_lex(). If so, then we have to assure
+ * consistency between YY_CURRENT_BUFFER and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = strres_in;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++(yy_c_buf_p);
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ (yy_did_buffer_switch_on_eof) = 0;
+
+ if ( strres_wrap( ) )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * strres_text, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) =
+ (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ (yy_c_buf_p) =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+} /* end of strres_lex */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+static int yy_get_next_buffer (void)
+{
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ register char *source = (yytext_ptr);
+ register int number_to_move, i;
+ int ret_val;
+
+ if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
+
+ else
+ {
+ int num_to_read =
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+
+ int yy_c_buf_p_offset =
+ (int) ((yy_c_buf_p) - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ strres_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = 0;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+ number_to_move - 1;
+
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+ (yy_n_chars), (size_t) num_to_read );
+
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ if ( (yy_n_chars) == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ strres_restart(strres_in );
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) strres_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
+ (yy_n_chars) += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
+
+ (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+ return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+ static yy_state_type yy_get_previous_state (void)
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp;
+
+ yy_current_state = (yy_start);
+
+ for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
+ {
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 32 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ }
+
+ return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
+{
+ register int yy_is_jam;
+ register char *yy_cp = (yy_c_buf_p);
+
+ register YY_CHAR yy_c = 1;
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 32 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_is_jam = (yy_current_state == 31);
+
+ return yy_is_jam ? 0 : yy_current_state;
+}
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+ static int yyinput (void)
+#else
+ static int input (void)
+#endif
+
+{
+ int c;
+
+ *(yy_c_buf_p) = (yy_hold_char);
+
+ if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ /* This was really a NUL. */
+ *(yy_c_buf_p) = '\0';
+
+ else
+ { /* need more input */
+ int offset = (yy_c_buf_p) - (yytext_ptr);
+ ++(yy_c_buf_p);
+
+ switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ strres_restart(strres_in );
+
+ /*FALLTHROUGH*/
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( strres_wrap( ) )
+ return EOF;
+
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput();
+#else
+ return input();
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) = (yytext_ptr) + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
+ *(yy_c_buf_p) = '\0'; /* preserve strres_text */
+ (yy_hold_char) = *++(yy_c_buf_p);
+
+ if ( c == '\n' )
+
+ strres_lineno++;
+;
+
+ return c;
+}
+#endif /* ifndef YY_NO_INPUT */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ *
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+ void strres_restart (FILE * input_file )
+{
+
+ if ( ! YY_CURRENT_BUFFER ){
+ strres_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ strres__create_buffer(strres_in,YY_BUF_SIZE );
+ }
+
+ strres__init_buffer(YY_CURRENT_BUFFER,input_file );
+ strres__load_buffer_state( );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ *
+ */
+ void strres__switch_to_buffer (YY_BUFFER_STATE new_buffer )
+{
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * strres_pop_buffer_state();
+ * strres_push_buffer_state(new_buffer);
+ */
+ strres_ensure_buffer_stack ();
+ if ( YY_CURRENT_BUFFER == new_buffer )
+ return;
+
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ strres__load_buffer_state( );
+
+ /* We don't actually know whether we did this switch during
+ * EOF (strres_wrap()) processing, but the only time this flag
+ * is looked at is after strres_wrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+static void strres__load_buffer_state (void)
+{
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ strres_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ (yy_hold_char) = *(yy_c_buf_p);
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ *
+ * @return the allocated buffer state.
+ */
+ YY_BUFFER_STATE strres__create_buffer (FILE * file, int size )
+{
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) strres_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in strres__create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) strres_alloc(b->yy_buf_size + 2 );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in strres__create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ strres__init_buffer(b,file );
+
+ return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with strres__create_buffer()
+ *
+ */
+ void strres__delete_buffer (YY_BUFFER_STATE b )
+{
+
+ if ( ! b )
+ return;
+
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ strres_free((void *) b->yy_ch_buf );
+
+ strres_free((void *) b );
+}
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a strres_restart() or at EOF.
+ */
+ static void strres__init_buffer (YY_BUFFER_STATE b, FILE * file )
+
+{
+ int oerrno = errno;
+
+ strres__flush_buffer(b );
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+ /* If b is the current buffer, then strres__init_buffer was _probably_
+ * called from strres_restart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
+
+ b->yy_is_interactive = 0;
+
+ errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ *
+ */
+ void strres__flush_buffer (YY_BUFFER_STATE b )
+{
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == YY_CURRENT_BUFFER )
+ strres__load_buffer_state( );
+}
+
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ *
+ */
+void strres_push_buffer_state (YY_BUFFER_STATE new_buffer )
+{
+ if (new_buffer == NULL)
+ return;
+
+ strres_ensure_buffer_stack();
+
+ /* This block is copied from strres__switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ (yy_buffer_stack_top)++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from strres__switch_to_buffer. */
+ strres__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ *
+ */
+void strres_pop_buffer_state (void)
+{
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ strres__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if ((yy_buffer_stack_top) > 0)
+ --(yy_buffer_stack_top);
+
+ if (YY_CURRENT_BUFFER) {
+ strres__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+ }
+}
+
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+static void strres_ensure_buffer_stack (void)
+{
+ int num_to_alloc;
+
+ if (!(yy_buffer_stack)) {
+
+ /* First allocation is just for 2 elements, since we don't know if this
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
+ * immediate realloc on the next call.
+ */
+ num_to_alloc = 1;
+ (yy_buffer_stack) = (struct yy_buffer_state**)strres_alloc
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in strres_ensure_buffer_stack()" );
+
+ memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+
+ (yy_buffer_stack_max) = num_to_alloc;
+ (yy_buffer_stack_top) = 0;
+ return;
+ }
+
+ if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+
+ /* Increase the buffer to prepare for a possible push. */
+ int grow_size = 8 /* arbitrary grow size */;
+
+ num_to_alloc = (yy_buffer_stack_max) + grow_size;
+ (yy_buffer_stack) = (struct yy_buffer_state**)strres_realloc
+ ((yy_buffer_stack),
+ num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in strres_ensure_buffer_stack()" );
+
+ /* zero only the new slots.*/
+ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+ (yy_buffer_stack_max) = num_to_alloc;
+ }
+}
+
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE strres__scan_buffer (char * base, yy_size_t size )
+{
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return 0;
+
+ b = (YY_BUFFER_STATE) strres_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in strres__scan_buffer()" );
+
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = 0;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ strres__switch_to_buffer(b );
+
+ return b;
+}
+
+/** Setup the input buffer state to scan a string. The next call to strres_lex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ *
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * strres__scan_bytes() instead.
+ */
+YY_BUFFER_STATE strres__scan_string (yyconst char * yystr )
+{
+
+ return strres__scan_bytes(yystr,strlen(yystr) );
+}
+
+/** Setup the input buffer state to scan the given bytes. The next call to strres_lex() will
+ * scan from a @e copy of @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE strres__scan_bytes (yyconst char * yybytes, int _yybytes_len )
+{
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = _yybytes_len + 2;
+ buf = (char *) strres_alloc(n );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in strres__scan_bytes()" );
+
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
+
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = strres__scan_buffer(buf,n );
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in strres__scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+}
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+static void yy_fatal_error (yyconst char* msg )
+{
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+}
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up strres_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ strres_text[strres_leng] = (yy_hold_char); \
+ (yy_c_buf_p) = strres_text + yyless_macro_arg; \
+ (yy_hold_char) = *(yy_c_buf_p); \
+ *(yy_c_buf_p) = '\0'; \
+ strres_leng = yyless_macro_arg; \
+ } \
+ while ( 0 )
+
+/* Accessor methods (get/set functions) to struct members. */
+
+/** Get the current line number.
+ *
+ */
+int strres_get_lineno (void)
+{
+
+ return strres_lineno;
+}
+
+/** Get the input stream.
+ *
+ */
+FILE *strres_get_in (void)
+{
+ return strres_in;
+}
+
+/** Get the output stream.
+ *
+ */
+FILE *strres_get_out (void)
+{
+ return strres_out;
+}
+
+/** Get the length of the current token.
+ *
+ */
+int strres_get_leng (void)
+{
+ return strres_leng;
+}
+
+/** Get the current token.
+ *
+ */
+
+char *strres_get_text (void)
+{
+ return strres_text;
+}
+
+/** Set the current line number.
+ * @param line_number
+ *
+ */
+void strres_set_lineno (int line_number )
+{
+
+ strres_lineno = line_number;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ *
+ * @see strres__switch_to_buffer
+ */
+void strres_set_in (FILE * in_str )
+{
+ strres_in = in_str ;
+}
+
+void strres_set_out (FILE * out_str )
+{
+ strres_out = out_str ;
+}
+
+int strres_get_debug (void)
+{
+ return strres__flex_debug;
+}
+
+void strres_set_debug (int bdebug )
+{
+ strres__flex_debug = bdebug ;
+}
+
+static int yy_init_globals (void)
+{
+ /* Initialization is the same as for the non-reentrant scanner.
+ * This function is called from strres_lex_destroy(), so don't allocate here.
+ */
+
+ /* We do not touch strres_lineno unless the option is enabled. */
+ strres_lineno = 1;
+
+ (yy_buffer_stack) = 0;
+ (yy_buffer_stack_top) = 0;
+ (yy_buffer_stack_max) = 0;
+ (yy_c_buf_p) = (char *) 0;
+ (yy_init) = 0;
+ (yy_start) = 0;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ strres_in = stdin;
+ strres_out = stdout;
+#else
+ strres_in = (FILE *) 0;
+ strres_out = (FILE *) 0;
+#endif
+
+ /* For future reference: Set errno on error, since we are called by
+ * strres_lex_init()
+ */
+ return 0;
+}
+
+/* strres_lex_destroy is for both reentrant and non-reentrant scanners. */
+int strres_lex_destroy (void)
+{
+
+ /* Pop the buffer stack, destroying each element. */
+ while(YY_CURRENT_BUFFER){
+ strres__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ strres_pop_buffer_state();
+ }
+
+ /* Destroy the stack itself. */
+ strres_free((yy_buffer_stack) );
+ (yy_buffer_stack) = NULL;
+
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * strres_lex() is called, initialization will occur. */
+ yy_init_globals( );
+
+ return 0;
+}
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+{
+ register int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * s )
+{
+ register int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+}
+#endif
+
+void *strres_alloc (yy_size_t size )
+{
+ return (void *) malloc( size );
+}
+
+void *strres_realloc (void * ptr, yy_size_t size )
+{
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return (void *) realloc( (char *) ptr, size );
+}
+
+void strres_free (void * ptr )
+{
+ free( (char *) ptr ); /* see strres_realloc() for (char *) cast */
+}
+
+#define YYTABLES_NAME "yytables"
+
+#line 132 "strres_lexer.lpp"
+
+
+
+static YY_EXTRA_TYPE pBuffer = NULL;
+
+void strres_set_extra(YY_EXTRA_TYPE user_defined)
+{
+ pBuffer = user_defined;
+}
+
+YY_EXTRA_TYPE strres_get_extra()
+{
+ return pBuffer;
+}
+
+/* Older GNU Flex versions don't define strres_lex_destroy()
+ * (and neither define a subminor version)
+ */
+#if !defined(YY_FLEX_SUBMINOR_VERSION) || (YY_FLEX_SUBMINOR_VERSION < 9)
+int strres_lex_destroy(void)
+{
+ /* For non-reentrant C scanner only. */
+ strres__delete_buffer(YY_CURRENT_BUFFER);
+ yy_init = 1;
+ return 0;
+}
+#endif
+
diff --git a/lib/framework/strres_parser.cpp b/lib/framework/strres_parser.cpp
new file mode 100644
index 000000000..46952ad3a
--- /dev/null
+++ b/lib/framework/strres_parser.cpp
@@ -0,0 +1,1675 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "2.5"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 0
+
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+/* Substitute the variable and function names. */
+#define yyparse strres_parse
+#define yylex strres_lex
+#define yyerror strres_error
+#define yylval strres_lval
+#define yychar strres_char
+#define yydebug strres_debug
+#define yynerrs strres_nerrs
+
+
+/* Copy the first part of user declarations. */
+
+/* Line 268 of yacc.c */
+#line 21 "strres_parser.ypp"
+
+/** @file
+ *
+ * Parser for string resource files
+ */
+
+#include "lib/framework/frame.h"
+#include "lib/framework/strres.h"
+#include "lib/framework/strresly.h"
+
+extern int strres_lex(void);
+extern int strres_get_lineno(void);
+extern char* strres_get_text(void);
+
+void yyerror(const char* msg)
+{
+ debug(LOG_ERROR, "STRRES file parse error:\n%s at line %d\nText: '%s'", msg, strres_get_lineno(), strres_get_text());
+}
+
+// Forward declaration to allow pointers to this type
+struct STR_RES;
+
+#define YYPARSE_PARAM psStrRes
+
+
+
+/* Line 268 of yacc.c */
+#line 106 "strres_parser.cpp"
+
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
+#endif
+
+/* Enabling the token table. */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ TEXT_T = 258,
+ QTEXT_T = 259
+ };
+#endif
+/* Tokens. */
+#define TEXT_T 258
+#define QTEXT_T 259
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 293 of yacc.c */
+#line 49 "strres_parser.ypp"
+
+ char *sval;
+
+
+
+/* Line 293 of yacc.c */
+#line 156 "strres_parser.cpp"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+
+/* Copy the second part of user declarations. */
+
+
+/* Line 343 of yacc.c */
+#line 168 "strres_parser.cpp"
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if defined YYENABLE_NLS && YYENABLE_NLS
+# if ENABLE_NLS
+# include /* INFRINGES ON USER NAME SPACE */
+# define YY_(msgid) dgettext ("bison-runtime", msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions. */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int yyi)
+#else
+static int
+YYID (yyi)
+ int yyi;
+#endif
+{
+ return yyi;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined EXIT_SUCCESS \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+};
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+# define YYCOPY_NEEDED 1
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (YYID (0))
+
+#endif
+
+#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (YYID (0))
+# endif
+# endif
+#endif /* !YYCOPY_NEEDED */
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 7
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 10
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 8
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 4
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 6
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 12
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 259
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const yytype_uint8 yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 6, 7, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 5, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const yytype_uint8 yyprhs[] =
+{
+ 0, 0, 3, 5, 8, 11, 13
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yytype_int8 yyrhs[] =
+{
+ 9, 0, -1, 10, -1, 9, 10, -1, 3, 11,
+ -1, 4, -1, 5, 6, 4, 7, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const yytype_uint8 yyrline[] =
+{
+ 0, 72, 72, 73, 76, 92, 93
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "$end", "error", "$undefined", "TEXT_T", "QTEXT_T", "'_'", "'('", "')'",
+ "$accept", "file", "line", "string", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const yytype_uint16 yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 95, 40, 41
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const yytype_uint8 yyr1[] =
+{
+ 0, 8, 9, 9, 10, 11, 11
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const yytype_uint8 yyr2[] =
+{
+ 0, 2, 1, 2, 2, 1, 4
+};
+
+/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
+ Performed when YYTABLE doesn't specify something else to do. Zero
+ means the default is an error. */
+static const yytype_uint8 yydefact[] =
+{
+ 0, 0, 0, 2, 5, 0, 4, 1, 3, 0,
+ 0, 6
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const yytype_int8 yydefgoto[] =
+{
+ -1, 2, 3, 6
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -4
+static const yytype_int8 yypact[] =
+{
+ 1, -3, 0, -4, -4, -1, -4, -4, -4, 2,
+ 3, -4
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const yytype_int8 yypgoto[] =
+{
+ -4, -4, 5, -4
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If YYTABLE_NINF, syntax error. */
+#define YYTABLE_NINF -1
+static const yytype_uint8 yytable[] =
+{
+ 7, 4, 5, 1, 1, 9, 10, 8, 0, 0,
+ 11
+};
+
+#define yypact_value_is_default(yystate) \
+ ((yystate) == (-4))
+
+#define yytable_value_is_error(yytable_value) \
+ YYID (0)
+
+static const yytype_int8 yycheck[] =
+{
+ 0, 4, 5, 3, 3, 6, 4, 2, -1, -1,
+ 7
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const yytype_uint8 yystos[] =
+{
+ 0, 3, 9, 10, 4, 5, 11, 0, 10, 6,
+ 4, 7
+};
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
+
+
+/* Like YYERROR except do call yyerror. This remains here temporarily
+ to ease the transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. However,
+ YYFAIL appears to be in use. Nevertheless, it is formally deprecated
+ in Bison 2.4.2's NEWS entry, where a plan to phase it out is
+ discussed. */
+
+#define YYFAIL goto yyerrlab
+#if defined YYFAIL
+ /* This is here to suppress warnings from the GCC cpp's
+ -Wunused-macros. Normally we don't worry about that warning, but
+ some users do, and we want to make it easy for users to remove
+ YYFAIL uses, which will produce warnings from Bison 2.5. */
+#endif
+
+#define YYRECOVERING() (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (1); \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+while (YYID (0))
+
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+ If N is 0, then set CURRENT to the empty location which ends
+ the previous symbol: RHS[0] (always defined). */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (YYID (N)) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ } \
+ while (YYID (0))
+#endif
+
+
+/* This macro is provided for backward compatibility. */
+
+#ifndef YY_LOCATION_PRINT
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+#endif
+
+
+/* YYLEX -- calling `yylex' with the right arguments. */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (YYLEX_PARAM)
+#else
+# define YYLEX yylex ()
+#endif
+
+/* Enable debugging if requested. */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+# include /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, \
+ Type, Value); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (YYID (0))
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (!yyvaluep)
+ return;
+# ifdef YYPRINT
+ if (yytype < YYNTOKENS)
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# else
+ YYUSE (yyoutput);
+# endif
+ switch (yytype)
+ {
+ default:
+ break;
+ }
+}
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (yytype < YYNTOKENS)
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+ else
+ YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+ yy_symbol_value_print (yyoutput, yytype, yyvaluep);
+ YYFPRINTF (yyoutput, ")");
+}
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included). |
+`------------------------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
+#else
+static void
+yy_stack_print (yybottom, yytop)
+ yytype_int16 *yybottom;
+ yytype_int16 *yytop;
+#endif
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
+ YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (YYID (0))
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
+#else
+static void
+yy_reduce_print (yyvsp, yyrule)
+ YYSTYPE *yyvsp;
+ int yyrule;
+#endif
+{
+ int yynrhs = yyr2[yyrule];
+ int yyi;
+ unsigned long int yylno = yyrline[yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+ yyrule - 1, yylno);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+ &(yyvsp[(yyi + 1) - (yynrhs)])
+ );
+ YYFPRINTF (stderr, "\n");
+ }
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyvsp, Rule); \
+} while (YYID (0))
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+# if defined __GLIBC__ && defined _STRING_H
+# define yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static YYSIZE_T
+yystrlen (const char *yystr)
+#else
+static YYSIZE_T
+yystrlen (yystr)
+ const char *yystr;
+#endif
+{
+ YYSIZE_T yylen;
+ for (yylen = 0; yystr[yylen]; yylen++)
+ continue;
+ return yylen;
+}
+# endif
+# endif
+
+# ifndef yystpcpy
+# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static char *
+yystpcpy (char *yydest, const char *yysrc)
+#else
+static char *
+yystpcpy (yydest, yysrc)
+ char *yydest;
+ const char *yysrc;
+#endif
+{
+ char *yyd = yydest;
+ const char *yys = yysrc;
+
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
+
+ return yyd - 1;
+}
+# endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+ if (*yystr == '"')
+ {
+ YYSIZE_T yyn = 0;
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
+ do_not_strip_quotes: ;
+ }
+
+ if (! yyres)
+ return yystrlen (yystr);
+
+ return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
+ about the unexpected token YYTOKEN for the state stack whose top is
+ YYSSP.
+
+ Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
+ not large enough to hold the message. In that case, also set
+ *YYMSG_ALLOC to the required number of bytes. Return 2 if the
+ required number of bytes is too large to store. */
+static int
+yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
+ yytype_int16 *yyssp, int yytoken)
+{
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
+ YYSIZE_T yysize = yysize0;
+ YYSIZE_T yysize1;
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ /* Internationalized format string. */
+ const char *yyformat = 0;
+ /* Arguments of yyformat. */
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ /* Number of reported tokens (one for the "unexpected", one per
+ "expected"). */
+ int yycount = 0;
+
+ /* There are many possibilities here to consider:
+ - Assume YYFAIL is not used. It's too flawed to consider. See
+
+ for details. YYERROR is fine as it does not invoke this
+ function.
+ - If this state is a consistent state with a default action, then
+ the only way this function was invoked is if the default action
+ is an error action. In that case, don't check for expected
+ tokens because there are none.
+ - The only way there can be no lookahead present (in yychar) is if
+ this state is a consistent state with a default action. Thus,
+ detecting the absence of a lookahead is sufficient to determine
+ that there is no unexpected or expected token to report. In that
+ case, just report a simple "syntax error".
+ - Don't assume there isn't a lookahead just because this state is a
+ consistent state with a default action. There might have been a
+ previous inconsistent state, consistent state with a non-default
+ action, or user semantic action that manipulated yychar.
+ - Of course, the expected token list depends on states to have
+ correct lookahead information, and it depends on the parser not
+ to perform extra reductions after fetching a lookahead from the
+ scanner and before detecting a syntax error. Thus, state merging
+ (from LALR or IELR) and default reductions corrupt the expected
+ token list. However, the list is correct for canonical LR with
+ one exception: it will still contain any token that will not be
+ accepted due to an error action in a later state.
+ */
+ if (yytoken != YYEMPTY)
+ {
+ int yyn = yypact[*yyssp];
+ yyarg[yycount++] = yytname[yytoken];
+ if (!yypact_value_is_default (yyn))
+ {
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. In other words, skip the first -YYN actions for
+ this state because they are default actions. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn + 1;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yyx;
+
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
+ && !yytable_value_is_error (yytable[yyx + yyn]))
+ {
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ yycount = 1;
+ yysize = yysize0;
+ break;
+ }
+ yyarg[yycount++] = yytname[yyx];
+ yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+ if (! (yysize <= yysize1
+ && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+ }
+ }
+ }
+
+ switch (yycount)
+ {
+# define YYCASE_(N, S) \
+ case N: \
+ yyformat = S; \
+ break
+ YYCASE_(0, YY_("syntax error"));
+ YYCASE_(1, YY_("syntax error, unexpected %s"));
+ YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
+ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
+ YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
+ YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
+# undef YYCASE_
+ }
+
+ yysize1 = yysize + yystrlen (yyformat);
+ if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+
+ if (*yymsg_alloc < yysize)
+ {
+ *yymsg_alloc = 2 * yysize;
+ if (! (yysize <= *yymsg_alloc
+ && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
+ *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
+ return 1;
+ }
+
+ /* Avoid sprintf, as that infringes on the user's name space.
+ Don't have undefined behavior even if the translation
+ produced a string with the wrong number of "%s"s. */
+ {
+ char *yyp = *yymsg;
+ int yyi = 0;
+ while ((*yyp = *yyformat) != '\0')
+ if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyformat += 2;
+ }
+ else
+ {
+ yyp++;
+ yyformat++;
+ }
+ }
+ return 0;
+}
+#endif /* YYERROR_VERBOSE */
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol. |
+`-----------------------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
+#else
+static void
+yydestruct (yymsg, yytype, yyvaluep)
+ const char *yymsg;
+ int yytype;
+ YYSTYPE *yyvaluep;
+#endif
+{
+ YYUSE (yyvaluep);
+
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+ switch (yytype)
+ {
+ case 3: /* "TEXT_T" */
+
+/* Line 1391 of yacc.c */
+#line 60 "strres_parser.ypp"
+ {
+#ifndef WZ_OS_WIN
+ // Force type checking by the compiler
+ char * const s = (yyvaluep->sval);
+
+ if (s)
+ free(s);
+#endif
+};
+
+/* Line 1391 of yacc.c */
+#line 1097 "strres_parser.cpp"
+ break;
+ case 4: /* "QTEXT_T" */
+
+/* Line 1391 of yacc.c */
+#line 60 "strres_parser.ypp"
+ {
+#ifndef WZ_OS_WIN
+ // Force type checking by the compiler
+ char * const s = (yyvaluep->sval);
+
+ if (s)
+ free(s);
+#endif
+};
+
+/* Line 1391 of yacc.c */
+#line 1114 "strres_parser.cpp"
+ break;
+ case 11: /* "string" */
+
+/* Line 1391 of yacc.c */
+#line 60 "strres_parser.ypp"
+ {
+#ifndef WZ_OS_WIN
+ // Force type checking by the compiler
+ char * const s = (yyvaluep->sval);
+
+ if (s)
+ free(s);
+#endif
+};
+
+/* Line 1391 of yacc.c */
+#line 1131 "strres_parser.cpp"
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+/* Prevent warnings from -Wmissing-prototypes. */
+#ifdef YYPARSE_PARAM
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void *YYPARSE_PARAM);
+#else
+int yyparse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+/* The lookahead symbol. */
+int yychar;
+
+/* The semantic value of the lookahead symbol. */
+YYSTYPE yylval;
+
+/* Number of syntax errors so far. */
+int yynerrs;
+
+
+/*----------.
+| yyparse. |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *YYPARSE_PARAM)
+#else
+int
+yyparse (YYPARSE_PARAM)
+ void *YYPARSE_PARAM;
+#endif
+#else /* ! YYPARSE_PARAM */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void)
+#else
+int
+yyparse ()
+
+#endif
+#endif
+{
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
+
+ YYSIZE_T yystacksize;
+
+ int yyn;
+ int yyresult;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char yymsgbuf[128];
+ char *yymsg = yymsgbuf;
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+
+ /* The number of symbols on the RHS of the reduced rule.
+ Keep to zero when no symbol should be popped. */
+ int yylen = 0;
+
+ yytoken = 0;
+ yyss = yyssa;
+ yyvs = yyvsa;
+ yystacksize = YYINITDEPTH;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+ yyssp = yyss;
+ yyvsp = yyvs;
+
+ goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate. |
+`------------------------------------------------------------*/
+ yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. So pushing a state here evens the stacks. */
+ yyssp++;
+
+ yysetstate:
+ *yyssp = yystate;
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ {
+ /* Get the current used size of the three stacks, in elements. */
+ YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ {
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ yytype_int16 *yyss1 = yyss;
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
+ &yystacksize);
+
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+# else
+ /* Extend the stack our own way. */
+ if (YYMAXDEPTH <= yystacksize)
+ goto yyexhaustedlab;
+ yystacksize *= 2;
+ if (YYMAXDEPTH < yystacksize)
+ yystacksize = YYMAXDEPTH;
+
+ {
+ yytype_int16 *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyexhaustedlab;
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+# undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+ }
+# endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + yysize - 1;
+ yyvsp = yyvs + yysize - 1;
+
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ YYABORT;
+ }
+
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
+ goto yybackup;
+
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
+
+ /* Do appropriate processing given the current state. Read a
+ lookahead token if we need one and don't already have one. */
+
+ /* First try to decide what to do without reference to lookahead token. */
+ yyn = yypact[yystate];
+ if (yypact_value_is_default (yyn))
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
+ }
+
+ if (yychar <= YYEOF)
+ {
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ }
+
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
+ detect an error, take that action. */
+ yyn += yytoken;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+ goto yydefault;
+ yyn = yytable[yyn];
+ if (yyn <= 0)
+ {
+ if (yytable_value_is_error (yyn))
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
+
+ /* Shift the lookahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
+
+ yystate = yyn;
+ *++yyvsp = yylval;
+
+ goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+yydefault:
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction. |
+`-----------------------------*/
+yyreduce:
+ /* yyn is the number of a rule to reduce with. */
+ yylen = yyr2[yyn];
+
+ /* If YYLEN is nonzero, implement the default value of the action:
+ `$$ = $1'.
+
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ yyval = yyvsp[1-yylen];
+
+
+ YY_REDUCE_PRINT (yyn);
+ switch (yyn)
+ {
+ case 4:
+
+/* Line 1806 of yacc.c */
+#line 77 "strres_parser.ypp"
+ {
+ /* Pass the text string to the string manager */
+ const bool success = strresStoreString((struct STR_RES*)psStrRes, (yyvsp[(1) - (2)].sval), (yyvsp[(2) - (2)].sval));
+
+ // Clean up our tokens
+ free((yyvsp[(1) - (2)].sval));
+ free((yyvsp[(2) - (2)].sval));
+
+ if (!success)
+ {
+ YYABORT;
+ }
+ }
+ break;
+
+ case 6:
+
+/* Line 1806 of yacc.c */
+#line 94 "strres_parser.ypp"
+ {
+ (yyval.sval) = strdup(gettext((yyvsp[(3) - (4)].sval)));
+ free((yyvsp[(3) - (4)].sval));
+ }
+ break;
+
+
+
+/* Line 1806 of yacc.c */
+#line 1463 "strres_parser.cpp"
+ default: break;
+ }
+ /* User semantic actions sometimes alter yychar, and that requires
+ that yytoken be updated with the new translation. We take the
+ approach of translating immediately before every use of yytoken.
+ One alternative is translating here after every semantic action,
+ but that translation would be missed if the semantic action invokes
+ YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
+ if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
+ incorrect destructor might then be invoked immediately. In the
+ case of YYERROR or YYBACKUP, subsequent parser actions might lead
+ to an incorrect destructor call or verbose syntax error message
+ before the lookahead is translated. */
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
+
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+
+ *++yyvsp = yyval;
+
+ /* Now `shift' the result of the reduction. Determine what state
+ that goes to, based on the state we popped back to and the rule
+ number reduced by. */
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTOKENS];
+
+ goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
+
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus)
+ {
+ ++yynerrs;
+#if ! YYERROR_VERBOSE
+ yyerror (YY_("syntax error"));
+#else
+# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
+ yyssp, yytoken)
+ {
+ char const *yymsgp = YY_("syntax error");
+ int yysyntax_error_status;
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ if (yysyntax_error_status == 0)
+ yymsgp = yymsg;
+ else if (yysyntax_error_status == 1)
+ {
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+ yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
+ if (!yymsg)
+ {
+ yymsg = yymsgbuf;
+ yymsg_alloc = sizeof yymsgbuf;
+ yysyntax_error_status = 2;
+ }
+ else
+ {
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ yymsgp = yymsg;
+ }
+ }
+ yyerror (yymsgp);
+ if (yysyntax_error_status == 2)
+ goto yyexhaustedlab;
+ }
+# undef YYSYNTAX_ERROR
+#endif
+ }
+
+
+
+ if (yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ if (yychar <= YYEOF)
+ {
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ YYABORT;
+ }
+ else
+ {
+ yydestruct ("Error: discarding",
+ yytoken, &yylval);
+ yychar = YYEMPTY;
+ }
+ }
+
+ /* Else will try to reuse lookahead token after shifting the error
+ token. */
+ goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR. |
+`---------------------------------------------------*/
+yyerrorlab:
+
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label yyerrorlab therefore never appears in user
+ code. */
+ if (/*CONSTCOND*/ 0)
+ goto yyerrorlab;
+
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYERROR. */
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+ yystate = *yyssp;
+ goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR. |
+`-------------------------------------------------------------*/
+yyerrlab1:
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
+
+ for (;;)
+ {
+ yyn = yypact[yystate];
+ if (!yypact_value_is_default (yyn))
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yyssp == yyss)
+ YYABORT;
+
+
+ yydestruct ("Error: popping",
+ yystos[yystate], yyvsp);
+ YYPOPSTACK (1);
+ yystate = *yyssp;
+ YY_STACK_PRINT (yyss, yyssp);
+ }
+
+ *++yyvsp = yylval;
+
+
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+#if !defined(yyoverflow) || YYERROR_VERBOSE
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here. |
+`-------------------------------------------------*/
+yyexhaustedlab:
+ yyerror (YY_("memory exhausted"));
+ yyresult = 2;
+ /* Fall through. */
+#endif
+
+yyreturn:
+ if (yychar != YYEMPTY)
+ {
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = YYTRANSLATE (yychar);
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval);
+ }
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYABORT or YYACCEPT. */
+ YYPOPSTACK (yylen);
+ YY_STACK_PRINT (yyss, yyssp);
+ while (yyssp != yyss)
+ {
+ yydestruct ("Cleanup: popping",
+ yystos[*yyssp], yyvsp);
+ YYPOPSTACK (1);
+ }
+#ifndef yyoverflow
+ if (yyss != yyssa)
+ YYSTACK_FREE (yyss);
+#endif
+#if YYERROR_VERBOSE
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+#endif
+ /* Make sure YYID is used. */
+ return YYID (yyresult);
+}
+
+
+
diff --git a/lib/framework/strres_parser.h b/lib/framework/strres_parser.h
new file mode 100644
index 000000000..a45710687
--- /dev/null
+++ b/lib/framework/strres_parser.h
@@ -0,0 +1,59 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ TEXT_T = 258,
+ QTEXT_T = 259
+ };
+#endif
+/* Tokens. */
+#define TEXT_T 258
+#define QTEXT_T 259
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 2068 of yacc.c */
+#line 49 "strres_parser.ypp"
+
+ char *sval;
+
+
+
+/* Line 2068 of yacc.c */
+#line 64 "strres_parser.h"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+extern YYSTYPE strres_lval;
+
+
diff --git a/lib/gamelib/Makefile.am b/lib/gamelib/Makefile.am
index 3c9cd9722..31c4669bd 100644
--- a/lib/gamelib/Makefile.am
+++ b/lib/gamelib/Makefile.am
@@ -1,16 +1,13 @@
AM_CPPFLAGS = -DYY_NO_INPUT $(SDL_CFLAGS) $(WZ_CPPFLAGS) $(QT4_CFLAGS)
AM_CFLAGS = $(WZ_CFLAGS)
AM_CXXFLAGS = $(WZ_CXXFLAGS) $(QT4_CFLAGS)
-AM_LFLAGS = $(FLEX_FLAGS)
-AM_YFLAGS = -d
-BUILT_SOURCES = \
- audp_parser.h
noinst_LIBRARIES = libgamelib.a
noinst_HEADERS = \
anim.h \
animobj.h \
+ audp_parser.h \
gtime.h \
hashtable.h \
parser.h
@@ -18,8 +15,8 @@ noinst_HEADERS = \
libgamelib_a_SOURCES = \
anim.cpp \
animobj.cpp \
- audp_lexer.lpp \
- audp_parser.ypp \
+ audp_lexer.cpp \
+ audp_parser.cpp \
gtime.cpp \
hashtable.cpp
diff --git a/lib/gamelib/audp_lexer.cpp b/lib/gamelib/audp_lexer.cpp
new file mode 100644
index 000000000..d1f30d40f
--- /dev/null
+++ b/lib/gamelib/audp_lexer.cpp
@@ -0,0 +1,2099 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+#line 2 "audp_lexer.cpp"
+
+#line 4 "audp_lexer.cpp"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define yy_create_buffer audp__create_buffer
+#define yy_delete_buffer audp__delete_buffer
+#define yy_flex_debug audp__flex_debug
+#define yy_init_buffer audp__init_buffer
+#define yy_flush_buffer audp__flush_buffer
+#define yy_load_buffer_state audp__load_buffer_state
+#define yy_switch_to_buffer audp__switch_to_buffer
+#define yyin audp_in
+#define yyleng audp_leng
+#define yylex audp_lex
+#define yylineno audp_lineno
+#define yyout audp_out
+#define yyrestart audp_restart
+#define yytext audp_text
+#define yywrap audp_wrap
+#define yyalloc audp_alloc
+#define yyrealloc audp_realloc
+#define yyfree audp_free
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 35
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+#include "lib/framework/frame.h"
+/* begin standard C headers. */
+#include
+#include
+#include
+#include
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have . Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#endif /* ! C99 */
+
+#endif /* ! FLEXINT_H */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
+
+#define YY_USE_CONST
+
+#endif /* defined (__STDC__) */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index. If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN (yy_start) = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START (((yy_start) - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE audp_restart(audp_in )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
+#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
+#endif
+
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+extern int audp_leng;
+
+extern FILE *audp_in, *audp_out;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+ /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
+ * access to the local variable yy_act. Since yyless() is a macro, it would break
+ * existing scanners that call yyless() from OUTSIDE audp_lex.
+ * One obvious solution it to make yy_act a global. I tried that, and saw
+ * a 5% performance hit in a non-audp_lineno scanner, because yy_act is
+ * normally declared as a register variable-- so it is not worth it.
+ */
+ #define YY_LESS_LINENO(n) \
+ do { \
+ int yyl;\
+ for ( yyl = n; yyl < audp_leng; ++yyl )\
+ if ( audp_text[yyl] == '\n' )\
+ --audp_lineno;\
+ }while(0)
+
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up audp_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ *yy_cp = (yy_hold_char); \
+ YY_RESTORE_YY_MORE_OFFSET \
+ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up audp_text again */ \
+ } \
+ while ( 0 )
+
+#define unput(c) yyunput( c, (yytext_ptr) )
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via audp_restart()), so that the user can continue scanning by
+ * just pointing audp_in at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+ : NULL)
+
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+
+/* yy_hold_char holds the character lost when audp_text is formed. */
+static char yy_hold_char;
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+int audp_leng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 0; /* whether we need to initialize */
+static int yy_start = 0; /* start state number */
+
+/* Flag which is used to allow audp_wrap()'s to do buffer switches
+ * instead of setting up a fresh audp_in. A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void audp_restart (FILE *input_file );
+void audp__switch_to_buffer (YY_BUFFER_STATE new_buffer );
+YY_BUFFER_STATE audp__create_buffer (FILE *file,int size );
+void audp__delete_buffer (YY_BUFFER_STATE b );
+void audp__flush_buffer (YY_BUFFER_STATE b );
+void audp_push_buffer_state (YY_BUFFER_STATE new_buffer );
+void audp_pop_buffer_state (void );
+
+static void audp_ensure_buffer_stack (void );
+static void audp__load_buffer_state (void );
+static void audp__init_buffer (YY_BUFFER_STATE b,FILE *file );
+
+#define YY_FLUSH_BUFFER audp__flush_buffer(YY_CURRENT_BUFFER )
+
+YY_BUFFER_STATE audp__scan_buffer (char *base,yy_size_t size );
+YY_BUFFER_STATE audp__scan_string (yyconst char *yy_str );
+YY_BUFFER_STATE audp__scan_bytes (yyconst char *bytes,int len );
+
+void *audp_alloc (yy_size_t );
+void *audp_realloc (void *,yy_size_t );
+void audp_free (void * );
+
+#define yy_new_buffer audp__create_buffer
+
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ audp_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ audp__create_buffer(audp_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+ }
+
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){\
+ audp_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ audp__create_buffer(audp_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+ }
+
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* Begin user sect3 */
+
+#define audp_wrap(n) 1
+#define YY_SKIP_YYWRAP
+
+typedef unsigned char YY_CHAR;
+
+FILE *audp_in = (FILE *) 0, *audp_out = (FILE *) 0;
+
+typedef int yy_state_type;
+
+extern int audp_lineno;
+
+int audp_lineno = 1;
+
+extern char *audp_text;
+#define yytext_ptr audp_text
+
+static yy_state_type yy_get_previous_state (void );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
+static int yy_get_next_buffer (void );
+static void yy_fatal_error (yyconst char msg[] );
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up audp_text.
+ */
+#define YY_DO_BEFORE_ACTION \
+ (yytext_ptr) = yy_bp; \
+ audp_leng = (size_t) (yy_cp - yy_bp); \
+ (yy_hold_char) = *yy_cp; \
+ *yy_cp = '\0'; \
+ (yy_c_buf_p) = yy_cp;
+
+#define YY_NUM_RULES 26
+#define YY_END_OF_BUFFER 27
+/* This struct is not used in this scanner,
+ but its presence is necessary. */
+struct yy_trans_info
+ {
+ flex_int32_t yy_verify;
+ flex_int32_t yy_nxt;
+ };
+static yyconst flex_int16_t yy_accept[96] =
+ { 0,
+ 0, 0, 0, 0, 15, 15, 24, 24, 27, 25,
+ 16, 16, 12, 25, 25, 10, 25, 25, 25, 25,
+ 20, 21, 20, 15, 14, 13, 24, 23, 11, 10,
+ 17, 22, 0, 0, 0, 0, 0, 18, 15, 24,
+ 0, 0, 0, 0, 0, 19, 0, 0, 0, 2,
+ 0, 0, 0, 0, 0, 3, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 9, 4, 0, 0, 0, 8,
+ 6, 0, 7, 5, 0
+
+ } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 1, 4, 1, 1, 1, 1, 1, 1,
+ 1, 5, 1, 1, 6, 1, 7, 8, 8, 8,
+ 9, 8, 8, 8, 8, 8, 8, 1, 1, 1,
+ 1, 1, 1, 1, 10, 11, 12, 13, 14, 15,
+ 1, 1, 16, 17, 1, 1, 18, 19, 20, 1,
+ 1, 21, 22, 23, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 24, 1, 25, 1, 1, 26,
+
+ 27, 28, 1, 29, 30, 1, 1, 31, 32, 33,
+ 34, 35, 1, 1, 36, 37, 38, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1
+ } ;
+
+static yyconst flex_int32_t yy_meta[39] =
+ { 0,
+ 1, 1, 2, 3, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1
+ } ;
+
+static yyconst flex_int16_t yy_base[102] =
+ { 0,
+ 0, 33, 8, 9, 12, 14, 116, 115, 117, 120,
+ 120, 120, 112, 11, 16, 18, 96, 0, 80, 80,
+ 120, 120, 105, 0, 120, 120, 0, 120, 120, 20,
+ 120, 120, 95, 80, 83, 74, 80, 103, 0, 0,
+ 87, 72, 73, 67, 65, 120, 35, 21, 66, 120,
+ 70, 85, 86, 70, 63, 70, 59, 9, 75, 63,
+ 56, 57, 51, 66, 65, 71, 54, 57, 47, 120,
+ 56, 55, 51, 31, 23, 34, 41, 38, 33, 27,
+ 22, 14, 37, 28, 120, 120, 22, 17, 25, 120,
+ 120, 19, 120, 120, 120, 67, 70, 73, 76, 0,
+
+ 79
+ } ;
+
+static yyconst flex_int16_t yy_def[102] =
+ { 0,
+ 96, 96, 97, 97, 98, 98, 99, 99, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 100, 95, 95, 101, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95, 100, 101,
+ 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 0, 95, 95, 95, 95, 95,
+
+ 95
+ } ;
+
+static yyconst flex_int16_t yy_nxt[159] =
+ { 0,
+ 39, 11, 12, 13, 95, 14, 15, 16, 16, 17,
+ 22, 22, 23, 23, 25, 26, 25, 26, 30, 30,
+ 31, 95, 32, 64, 18, 30, 30, 30, 30, 54,
+ 19, 65, 34, 20, 11, 12, 13, 35, 14, 15,
+ 16, 16, 17, 52, 55, 94, 93, 92, 91, 90,
+ 89, 88, 87, 86, 53, 85, 84, 18, 83, 82,
+ 81, 80, 79, 19, 78, 77, 20, 10, 10, 10,
+ 21, 21, 21, 24, 24, 24, 27, 27, 27, 40,
+ 76, 40, 75, 74, 73, 72, 71, 70, 69, 68,
+ 67, 66, 63, 62, 61, 60, 59, 58, 57, 56,
+
+ 51, 50, 49, 48, 47, 46, 45, 44, 43, 42,
+ 41, 38, 37, 36, 33, 29, 95, 28, 28, 9,
+ 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95
+ } ;
+
+static yyconst flex_int16_t yy_chk[159] =
+ { 0,
+ 100, 1, 1, 1, 0, 1, 1, 1, 1, 1,
+ 3, 4, 3, 4, 5, 5, 6, 6, 14, 14,
+ 15, 0, 15, 58, 1, 16, 16, 30, 30, 48,
+ 1, 58, 18, 1, 2, 2, 2, 18, 2, 2,
+ 2, 2, 2, 47, 48, 92, 89, 88, 87, 84,
+ 83, 82, 81, 80, 47, 79, 78, 2, 77, 76,
+ 75, 74, 73, 2, 72, 71, 2, 96, 96, 96,
+ 97, 97, 97, 98, 98, 98, 99, 99, 99, 101,
+ 69, 101, 68, 67, 66, 65, 64, 63, 62, 61,
+ 60, 59, 57, 56, 55, 54, 53, 52, 51, 49,
+
+ 45, 44, 43, 42, 41, 38, 37, 36, 35, 34,
+ 33, 23, 20, 19, 17, 13, 9, 8, 7, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 95, 95, 95, 95, 95, 95
+ } ;
+
+/* Table of booleans, true if rule could match eol. */
+static yyconst flex_int32_t yy_rule_can_match_eol[27] =
+ { 0,
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1,
+ 0, 1, 0, 1, 0, 0, 0, };
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+extern int audp__flex_debug;
+int audp__flex_debug = 0;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *audp_text;
+#line 1 "audp_lexer.lpp"
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 1999-2004 Eidos Interactive
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+#line 21 "audp_lexer.lpp"
+
+/* include framework */
+#include "lib/framework/frame.h"
+
+#include
+
+#include "lib/gamelib/parser.h"
+
+/* Get the Yacc definitions */
+#include "audp_parser.h"
+
+
+// fwrite declared with warn_unused_result, resulting in mysterious errors in "%%" on some distros.
+static inline bool no_warn_unused_result(int ignore) { if (ignore) {} return true; }
+#define fwrite(a, b, c, d) no_warn_unused_result(fwrite(a, b, c, d))
+
+/* Maximum length for any TEXT value */
+#define YYLMAX 255
+
+void audp_error(const char* fmt);
+
+#include "lib/framework/lexer_input.h"
+
+#ifndef yyextra
+# define yyextra audp_get_extra()
+#endif
+
+/* Older GNU Flex versions don't define audp_get_extra(), audp_set_extra(),
+ * audp_get_text() and audp_get_lineno().
+ * (and neither define a subminor version)
+ */
+#if !defined(YY_FLEX_SUBMINOR_VERSION) || (YY_FLEX_SUBMINOR_VERSION < 9)
+# define audp_get_extra audp_get_extra
+# define audp_set_extra audp_set_extra
+# define audp_get_lineno audp_get_lineno
+# define audp_get_text audp_get_text
+extern void audp_set_extra(YY_EXTRA_TYPE user_defined);
+extern YY_EXTRA_TYPE audp_get_extra(void);
+extern int audp_get_lineno(void);
+int audp_get_lineno()
+{
+ return audp_lineno;
+}
+
+extern char* audp_get_text(void);
+char* audp_get_text()
+{
+ return audp_text;
+}
+#elif defined(YY_FLEX_SUBMINOR_VERSION) && YY_FLEX_SUBMINOR_VERSION == 33
+extern YY_EXTRA_TYPE audp_get_extra(void);
+extern int audp_get_lineno(void);
+extern FILE *audp_get_in(void);
+extern FILE *audp_get_out(void);
+extern int audp_get_leng(void);
+extern char *audp_get_text(void);
+extern void audp_set_lineno(int line_number);
+extern void audp_set_in(FILE* in_str);
+extern void audp_set_out(FILE* out_str);
+extern int audp_get_debug(void);
+extern void audp_set_debug(int bdebug);
+extern int audp_lex_destroy(void);
+extern void audp_set_extra(YY_EXTRA_TYPE user_defined);
+#endif
+
+
+
+
+#line 658 "audp_lexer.cpp"
+
+#define INITIAL 0
+#define COMMENT 1
+#define QUOTE 2
+#define SLCOMMENT 3
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#include
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+static int yy_init_globals (void );
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int audp_lex_destroy (void );
+
+int audp_get_debug (void );
+
+void audp_set_debug (int debug_flag );
+
+YY_EXTRA_TYPE audp_get_extra (void );
+
+void audp_set_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *audp_get_in (void );
+
+void audp_set_in (FILE * in_str );
+
+FILE *audp_get_out (void );
+
+void audp_set_out (FILE * out_str );
+
+int audp_get_leng (void );
+
+char *audp_get_text (void );
+
+int audp_get_lineno (void );
+
+void audp_set_lineno (int line_number );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int audp_wrap (void );
+#else
+extern int audp_wrap (void );
+#endif
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int );
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * );
+#endif
+
+#ifndef YY_NO_INPUT
+
+#ifdef __cplusplus
+static int yyinput (void );
+#else
+static int input (void );
+#endif
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
+#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO do { if (fwrite( audp_text, audp_leng, 1, audp_out )) {} } while (0)
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ { \
+ int c = '*'; \
+ size_t n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( audp_in )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( audp_in ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else \
+ { \
+ errno=0; \
+ while ( (result = fread(buf, 1, max_size, audp_in))==0 && ferror(audp_in)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(audp_in); \
+ } \
+ }\
+\
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* end tables serialization structures and prototypes */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int audp_lex (void);
+
+#define YY_DECL int audp_lex (void)
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after audp_text and audp_leng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+ YY_USER_ACTION
+
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp, *yy_bp;
+ register int yy_act;
+
+#line 98 "audp_lexer.lpp"
+
+ /* Match to key words */
+#line 849 "audp_lexer.cpp"
+
+ if ( !(yy_init) )
+ {
+ (yy_init) = 1;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! (yy_start) )
+ (yy_start) = 1; /* first start state */
+
+ if ( ! audp_in )
+ audp_in = stdin;
+
+ if ( ! audp_out )
+ audp_out = stdout;
+
+ if ( ! YY_CURRENT_BUFFER ) {
+ audp_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ audp__create_buffer(audp_in,YY_BUF_SIZE );
+ }
+
+ audp__load_buffer_state( );
+ }
+
+ while ( 1 ) /* loops until end-of-file is reached */
+ {
+ yy_cp = (yy_c_buf_p);
+
+ /* Support of audp_text. */
+ *yy_cp = (yy_hold_char);
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+ yy_current_state = (yy_start);
+yy_match:
+ do
+ {
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 96 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ ++yy_cp;
+ }
+ while ( yy_current_state != 95 );
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+
+yy_find_action:
+ yy_act = yy_accept[yy_current_state];
+
+ YY_DO_BEFORE_ACTION;
+
+ if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
+ {
+ int yyl;
+ for ( yyl = 0; yyl < audp_leng; ++yyl )
+ if ( audp_text[yyl] == '\n' )
+
+ audp_lineno++;
+;
+ }
+
+do_action: /* This label is used only to access EOF actions. */
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = (yy_hold_char);
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 100 "audp_lexer.lpp"
+{ return ONESHOT; }
+ YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 101 "audp_lexer.lpp"
+{ return LOOP; }
+ YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 102 "audp_lexer.lpp"
+{ return AUDIO; }
+ YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 103 "audp_lexer.lpp"
+{ return ANIM3DFILE; }
+ YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 104 "audp_lexer.lpp"
+{ return AUDIO_MODULE; }
+ YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 105 "audp_lexer.lpp"
+{ return ANIM_MODULE; }
+ YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 106 "audp_lexer.lpp"
+{ return ANIM3DFRAMES; }
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 107 "audp_lexer.lpp"
+{ return ANIM3DTRANS; }
+ YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 108 "audp_lexer.lpp"
+{ return ANIMOBJECT; }
+ YY_BREAK
+/* 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);
+ return FLOAT_T;
+ }
+ */
+/* Match integer numbers */
+case 10:
+YY_RULE_SETUP
+#line 118 "audp_lexer.lpp"
+{ audp_lval.ival = atoi(audp_text);
+ return INTEGER;
+ }
+ YY_BREAK
+/* Match quoted text */
+case 11:
+YY_RULE_SETUP
+#line 123 "audp_lexer.lpp"
+{
+ audp_lval.sval = strdup("");
+ return QTEXT;
+ }
+ YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 128 "audp_lexer.lpp"
+{ BEGIN QUOTE; }
+ YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 129 "audp_lexer.lpp"
+{ BEGIN INITIAL; }
+ YY_BREAK
+case 14:
+/* rule 14 can match eol */
+YY_RULE_SETUP
+#line 130 "audp_lexer.lpp"
+{ audp_error("Unexpected end of line in string"); }
+ YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 131 "audp_lexer.lpp"
+{
+ audp_lval.sval = strdup(audp_text);
+ return QTEXT;
+ }
+ YY_BREAK
+/* Skip white space */
+case 16:
+/* rule 16 can match eol */
+YY_RULE_SETUP
+#line 137 "audp_lexer.lpp"
+;
+ YY_BREAK
+/* Strip comments */
+case 17:
+YY_RULE_SETUP
+#line 140 "audp_lexer.lpp"
+{ BEGIN COMMENT; }
+ YY_BREAK
+case 18:
+#line 142 "audp_lexer.lpp"
+case 19:
+/* rule 19 can match eol */
+YY_RULE_SETUP
+#line 142 "audp_lexer.lpp"
+{ BEGIN INITIAL; }
+ YY_BREAK
+case 20:
+#line 144 "audp_lexer.lpp"
+case 21:
+/* rule 21 can match eol */
+YY_RULE_SETUP
+#line 144 "audp_lexer.lpp"
+;
+ YY_BREAK
+/* Strip single line comments */
+case 22:
+YY_RULE_SETUP
+#line 147 "audp_lexer.lpp"
+{ BEGIN SLCOMMENT; }
+ YY_BREAK
+case 23:
+/* rule 23 can match eol */
+YY_RULE_SETUP
+#line 148 "audp_lexer.lpp"
+{ BEGIN INITIAL; }
+ YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 149 "audp_lexer.lpp"
+;
+ YY_BREAK
+/* Match anything that's been missed and pass it as a char */
+case 25:
+YY_RULE_SETUP
+#line 152 "audp_lexer.lpp"
+return audp_text[0];
+ YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 155 "audp_lexer.lpp"
+ECHO;
+ YY_BREAK
+#line 1087 "audp_lexer.cpp"
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(COMMENT):
+case YY_STATE_EOF(QUOTE):
+case YY_STATE_EOF(SLCOMMENT):
+ yyterminate();
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = (yy_hold_char);
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed audp_in at a new source and called
+ * audp_lex(). If so, then we have to assure
+ * consistency between YY_CURRENT_BUFFER and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = audp_in;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++(yy_c_buf_p);
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ (yy_did_buffer_switch_on_eof) = 0;
+
+ if ( audp_wrap( ) )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * audp_text, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) =
+ (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ (yy_c_buf_p) =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+} /* end of audp_lex */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+static int yy_get_next_buffer (void)
+{
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ register char *source = (yytext_ptr);
+ register int number_to_move, i;
+ int ret_val;
+
+ if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
+
+ else
+ {
+ int num_to_read =
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+
+ int yy_c_buf_p_offset =
+ (int) ((yy_c_buf_p) - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ audp_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = 0;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+ number_to_move - 1;
+
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+ (yy_n_chars), (size_t) num_to_read );
+
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ if ( (yy_n_chars) == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ audp_restart(audp_in );
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) audp_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
+ (yy_n_chars) += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
+
+ (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+ return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+ static yy_state_type yy_get_previous_state (void)
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp;
+
+ yy_current_state = (yy_start);
+
+ for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
+ {
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 96 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ }
+
+ return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
+{
+ register int yy_is_jam;
+ register char *yy_cp = (yy_c_buf_p);
+
+ register YY_CHAR yy_c = 1;
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 96 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_is_jam = (yy_current_state == 95);
+
+ return yy_is_jam ? 0 : yy_current_state;
+}
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+ static int yyinput (void)
+#else
+ static int input (void)
+#endif
+
+{
+ int c;
+
+ *(yy_c_buf_p) = (yy_hold_char);
+
+ if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ /* This was really a NUL. */
+ *(yy_c_buf_p) = '\0';
+
+ else
+ { /* need more input */
+ int offset = (yy_c_buf_p) - (yytext_ptr);
+ ++(yy_c_buf_p);
+
+ switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ audp_restart(audp_in );
+
+ /*FALLTHROUGH*/
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( audp_wrap( ) )
+ return EOF;
+
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput();
+#else
+ return input();
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) = (yytext_ptr) + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
+ *(yy_c_buf_p) = '\0'; /* preserve audp_text */
+ (yy_hold_char) = *++(yy_c_buf_p);
+
+ if ( c == '\n' )
+
+ audp_lineno++;
+;
+
+ return c;
+}
+#endif /* ifndef YY_NO_INPUT */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ *
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+ void audp_restart (FILE * input_file )
+{
+
+ if ( ! YY_CURRENT_BUFFER ){
+ audp_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ audp__create_buffer(audp_in,YY_BUF_SIZE );
+ }
+
+ audp__init_buffer(YY_CURRENT_BUFFER,input_file );
+ audp__load_buffer_state( );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ *
+ */
+ void audp__switch_to_buffer (YY_BUFFER_STATE new_buffer )
+{
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * audp_pop_buffer_state();
+ * audp_push_buffer_state(new_buffer);
+ */
+ audp_ensure_buffer_stack ();
+ if ( YY_CURRENT_BUFFER == new_buffer )
+ return;
+
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ audp__load_buffer_state( );
+
+ /* We don't actually know whether we did this switch during
+ * EOF (audp_wrap()) processing, but the only time this flag
+ * is looked at is after audp_wrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+static void audp__load_buffer_state (void)
+{
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ audp_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ (yy_hold_char) = *(yy_c_buf_p);
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ *
+ * @return the allocated buffer state.
+ */
+ YY_BUFFER_STATE audp__create_buffer (FILE * file, int size )
+{
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) audp_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in audp__create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) audp_alloc(b->yy_buf_size + 2 );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in audp__create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ audp__init_buffer(b,file );
+
+ return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with audp__create_buffer()
+ *
+ */
+ void audp__delete_buffer (YY_BUFFER_STATE b )
+{
+
+ if ( ! b )
+ return;
+
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ audp_free((void *) b->yy_ch_buf );
+
+ audp_free((void *) b );
+}
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a audp_restart() or at EOF.
+ */
+ static void audp__init_buffer (YY_BUFFER_STATE b, FILE * file )
+
+{
+ int oerrno = errno;
+
+ audp__flush_buffer(b );
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+ /* If b is the current buffer, then audp__init_buffer was _probably_
+ * called from audp_restart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
+
+ b->yy_is_interactive = 0;
+
+ errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ *
+ */
+ void audp__flush_buffer (YY_BUFFER_STATE b )
+{
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == YY_CURRENT_BUFFER )
+ audp__load_buffer_state( );
+}
+
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ *
+ */
+void audp_push_buffer_state (YY_BUFFER_STATE new_buffer )
+{
+ if (new_buffer == NULL)
+ return;
+
+ audp_ensure_buffer_stack();
+
+ /* This block is copied from audp__switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ (yy_buffer_stack_top)++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from audp__switch_to_buffer. */
+ audp__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ *
+ */
+void audp_pop_buffer_state (void)
+{
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ audp__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if ((yy_buffer_stack_top) > 0)
+ --(yy_buffer_stack_top);
+
+ if (YY_CURRENT_BUFFER) {
+ audp__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+ }
+}
+
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+static void audp_ensure_buffer_stack (void)
+{
+ int num_to_alloc;
+
+ if (!(yy_buffer_stack)) {
+
+ /* First allocation is just for 2 elements, since we don't know if this
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
+ * immediate realloc on the next call.
+ */
+ num_to_alloc = 1;
+ (yy_buffer_stack) = (struct yy_buffer_state**)audp_alloc
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in audp_ensure_buffer_stack()" );
+
+ memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+
+ (yy_buffer_stack_max) = num_to_alloc;
+ (yy_buffer_stack_top) = 0;
+ return;
+ }
+
+ if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+
+ /* Increase the buffer to prepare for a possible push. */
+ int grow_size = 8 /* arbitrary grow size */;
+
+ num_to_alloc = (yy_buffer_stack_max) + grow_size;
+ (yy_buffer_stack) = (struct yy_buffer_state**)audp_realloc
+ ((yy_buffer_stack),
+ num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in audp_ensure_buffer_stack()" );
+
+ /* zero only the new slots.*/
+ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+ (yy_buffer_stack_max) = num_to_alloc;
+ }
+}
+
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE audp__scan_buffer (char * base, yy_size_t size )
+{
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return 0;
+
+ b = (YY_BUFFER_STATE) audp_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in audp__scan_buffer()" );
+
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = 0;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ audp__switch_to_buffer(b );
+
+ return b;
+}
+
+/** Setup the input buffer state to scan a string. The next call to audp_lex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ *
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * audp__scan_bytes() instead.
+ */
+YY_BUFFER_STATE audp__scan_string (yyconst char * yystr )
+{
+
+ return audp__scan_bytes(yystr,strlen(yystr) );
+}
+
+/** Setup the input buffer state to scan the given bytes. The next call to audp_lex() will
+ * scan from a @e copy of @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE audp__scan_bytes (yyconst char * yybytes, int _yybytes_len )
+{
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = _yybytes_len + 2;
+ buf = (char *) audp_alloc(n );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in audp__scan_bytes()" );
+
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
+
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = audp__scan_buffer(buf,n );
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in audp__scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+}
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+static void yy_fatal_error (yyconst char* msg )
+{
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+}
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up audp_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ audp_text[audp_leng] = (yy_hold_char); \
+ (yy_c_buf_p) = audp_text + yyless_macro_arg; \
+ (yy_hold_char) = *(yy_c_buf_p); \
+ *(yy_c_buf_p) = '\0'; \
+ audp_leng = yyless_macro_arg; \
+ } \
+ while ( 0 )
+
+/* Accessor methods (get/set functions) to struct members. */
+
+/** Get the current line number.
+ *
+ */
+int audp_get_lineno (void)
+{
+
+ return audp_lineno;
+}
+
+/** Get the input stream.
+ *
+ */
+FILE *audp_get_in (void)
+{
+ return audp_in;
+}
+
+/** Get the output stream.
+ *
+ */
+FILE *audp_get_out (void)
+{
+ return audp_out;
+}
+
+/** Get the length of the current token.
+ *
+ */
+int audp_get_leng (void)
+{
+ return audp_leng;
+}
+
+/** Get the current token.
+ *
+ */
+
+char *audp_get_text (void)
+{
+ return audp_text;
+}
+
+/** Set the current line number.
+ * @param line_number
+ *
+ */
+void audp_set_lineno (int line_number )
+{
+
+ audp_lineno = line_number;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ *
+ * @see audp__switch_to_buffer
+ */
+void audp_set_in (FILE * in_str )
+{
+ audp_in = in_str ;
+}
+
+void audp_set_out (FILE * out_str )
+{
+ audp_out = out_str ;
+}
+
+int audp_get_debug (void)
+{
+ return audp__flex_debug;
+}
+
+void audp_set_debug (int bdebug )
+{
+ audp__flex_debug = bdebug ;
+}
+
+static int yy_init_globals (void)
+{
+ /* Initialization is the same as for the non-reentrant scanner.
+ * This function is called from audp_lex_destroy(), so don't allocate here.
+ */
+
+ /* We do not touch audp_lineno unless the option is enabled. */
+ audp_lineno = 1;
+
+ (yy_buffer_stack) = 0;
+ (yy_buffer_stack_top) = 0;
+ (yy_buffer_stack_max) = 0;
+ (yy_c_buf_p) = (char *) 0;
+ (yy_init) = 0;
+ (yy_start) = 0;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ audp_in = stdin;
+ audp_out = stdout;
+#else
+ audp_in = (FILE *) 0;
+ audp_out = (FILE *) 0;
+#endif
+
+ /* For future reference: Set errno on error, since we are called by
+ * audp_lex_init()
+ */
+ return 0;
+}
+
+/* audp_lex_destroy is for both reentrant and non-reentrant scanners. */
+int audp_lex_destroy (void)
+{
+
+ /* Pop the buffer stack, destroying each element. */
+ while(YY_CURRENT_BUFFER){
+ audp__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ audp_pop_buffer_state();
+ }
+
+ /* Destroy the stack itself. */
+ audp_free((yy_buffer_stack) );
+ (yy_buffer_stack) = NULL;
+
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * audp_lex() is called, initialization will occur. */
+ yy_init_globals( );
+
+ return 0;
+}
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+{
+ register int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * s )
+{
+ register int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+}
+#endif
+
+void *audp_alloc (yy_size_t size )
+{
+ return (void *) malloc( size );
+}
+
+void *audp_realloc (void * ptr, yy_size_t size )
+{
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return (void *) realloc( (char *) ptr, size );
+}
+
+void audp_free (void * ptr )
+{
+ free( (char *) ptr ); /* see audp_realloc() for (char *) cast */
+}
+
+#define YYTABLES_NAME "yytables"
+
+#line 155 "audp_lexer.lpp"
+
+
+
+static YY_EXTRA_TYPE pBuffer = NULL;
+
+void audp_set_extra(YY_EXTRA_TYPE user_defined)
+{
+ pBuffer = user_defined;
+}
+
+YY_EXTRA_TYPE audp_get_extra()
+{
+ return pBuffer;
+}
+
+/* Older GNU Flex versions don't define audp_lex_destroy()
+ * (and neither define a subminor version)
+ */
+#if !defined(YY_FLEX_SUBMINOR_VERSION) || (YY_FLEX_SUBMINOR_VERSION < 9)
+int audp_lex_destroy(void)
+{
+ /* For non-reentrant C scanner only. */
+ audp__delete_buffer(YY_CURRENT_BUFFER);
+ yy_init = 1;
+ return 0;
+}
+#endif
+
diff --git a/lib/gamelib/audp_parser.cpp b/lib/gamelib/audp_parser.cpp
new file mode 100644
index 000000000..774a05514
--- /dev/null
+++ b/lib/gamelib/audp_parser.cpp
@@ -0,0 +1,1852 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "2.5"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 0
+
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+/* Substitute the variable and function names. */
+#define yyparse audp_parse
+#define yylex audp_lex
+#define yyerror audp_error
+#define yylval audp_lval
+#define yychar audp_char
+#define yydebug audp_debug
+#define yynerrs audp_nerrs
+
+
+/* Copy the first part of user declarations. */
+
+/* Line 268 of yacc.c */
+#line 21 "audp_parser.ypp"
+
+
+#include "lib/framework/frame.h"
+#include "lib/gamelib/parser.h"
+#include "lib/sound/audio.h"
+#include "lib/gamelib/anim.h"
+#include "lib/framework/lexer_input.h"
+
+static int g_iCurAnimID = 0;
+static Vector3i vecPos, vecRot, vecScale;
+
+extern int audp_lex(void);
+extern int audp_lex_destroy(void);
+extern int audp_get_lineno(void);
+extern char* audp_get_text(void);
+extern void audp_set_extra(YY_EXTRA_TYPE user_defined);
+
+void yyerror(const char* fmt);
+
+
+
+/* Line 268 of yacc.c */
+#line 101 "audp_parser.cpp"
+
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
+#endif
+
+/* Enabling the token table. */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ FLOAT_T = 258,
+ INTEGER = 259,
+ QTEXT = 260,
+ ONESHOT = 261,
+ LOOP = 262,
+ AUDIO = 263,
+ ANIM3DFRAMES = 264,
+ ANIM3DTRANS = 265,
+ ANIM3DFILE = 266,
+ AUDIO_MODULE = 267,
+ ANIM_MODULE = 268,
+ ANIMOBJECT = 269
+ };
+#endif
+/* Tokens. */
+#define FLOAT_T 258
+#define INTEGER 259
+#define QTEXT 260
+#define ONESHOT 261
+#define LOOP 262
+#define AUDIO 263
+#define ANIM3DFRAMES 264
+#define ANIM3DTRANS 265
+#define ANIM3DFILE 266
+#define AUDIO_MODULE 267
+#define ANIM_MODULE 268
+#define ANIMOBJECT 269
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 293 of yacc.c */
+#line 44 "audp_parser.ypp"
+
+ float fval;
+ long ival;
+ bool bval;
+ char* sval;
+
+
+
+/* Line 293 of yacc.c */
+#line 174 "audp_parser.cpp"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+
+/* Copy the second part of user declarations. */
+
+
+/* Line 343 of yacc.c */
+#line 186 "audp_parser.cpp"
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if defined YYENABLE_NLS && YYENABLE_NLS
+# if ENABLE_NLS
+# include /* INFRINGES ON USER NAME SPACE */
+# define YY_(msgid) dgettext ("bison-runtime", msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions. */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int yyi)
+#else
+static int
+YYID (yyi)
+ int yyi;
+#endif
+{
+ return yyi;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined EXIT_SUCCESS \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+};
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+# define YYCOPY_NEEDED 1
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (YYID (0))
+
+#endif
+
+#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (YYID (0))
+# endif
+# endif
+#endif /* !YYCOPY_NEEDED */
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 19
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 81
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 17
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 25
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 37
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 78
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 269
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const yytype_uint8 yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 15, 2, 16, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const yytype_uint8 yyprhs[] =
+{
+ 0, 0, 3, 5, 7, 10, 12, 14, 16, 19,
+ 23, 26, 29, 31, 37, 39, 41, 44, 48, 52,
+ 55, 57, 60, 62, 64, 66, 69, 70, 80, 81,
+ 82, 92, 95, 97, 98, 106, 109, 111
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yytype_int8 yyrhs[] =
+{
+ 18, 0, -1, 19, -1, 30, -1, 19, 20, -1,
+ 20, -1, 22, -1, 27, -1, 12, 15, -1, 21,
+ 23, 16, -1, 21, 16, -1, 23, 24, -1, 24,
+ -1, 8, 5, 25, 4, 4, -1, 7, -1, 6,
+ -1, 13, 15, -1, 26, 29, 16, -1, 26, 28,
+ 16, -1, 28, 31, -1, 31, -1, 29, 30, -1,
+ 30, -1, 32, -1, 34, -1, 5, 4, -1, -1,
+ 10, 5, 4, 4, 4, 33, 15, 37, 16, -1,
+ -1, -1, 9, 5, 4, 4, 35, 15, 36, 40,
+ 16, -1, 38, 37, -1, 38, -1, -1, 14, 4,
+ 5, 15, 39, 40, 16, -1, 40, 41, -1, 41,
+ -1, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const yytype_uint8 yyrline[] =
+{
+ 0, 82, 82, 82, 85, 86, 89, 89, 92, 95,
+ 96, 99, 100, 106, 113, 115, 119, 124, 125, 129,
+ 130, 134, 135, 139, 139, 142, 156, 155, 167, 172,
+ 166, 182, 183, 187, 186, 197, 198, 201
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "$end", "error", "$undefined", "FLOAT_T", "INTEGER", "QTEXT", "ONESHOT",
+ "LOOP", "AUDIO", "ANIM3DFRAMES", "ANIM3DTRANS", "ANIM3DFILE",
+ "AUDIO_MODULE", "ANIM_MODULE", "ANIMOBJECT", "'{'", "'}'", "$accept",
+ "data_file", "module_file", "data_list", "audio_header", "audio_module",
+ "audio_list", "audio_track", "looping", "anim_module_header",
+ "anim_module", "anim_config_list", "anim_file_list", "anim_file",
+ "anim_config", "anim_trans", "$@1", "anim_frames", "$@2", "$@3",
+ "anim_obj_list", "anim_obj", "$@4", "anim_script", "anim_state", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const yytype_uint16 yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 267, 268, 269, 123, 125
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const yytype_uint8 yyr1[] =
+{
+ 0, 17, 18, 18, 19, 19, 20, 20, 21, 22,
+ 22, 23, 23, 24, 25, 25, 26, 27, 27, 28,
+ 28, 29, 29, 30, 30, 31, 33, 32, 35, 36,
+ 34, 37, 37, 39, 38, 40, 40, 41
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const yytype_uint8 yyr2[] =
+{
+ 0, 2, 1, 1, 2, 1, 1, 1, 2, 3,
+ 2, 2, 1, 5, 1, 1, 2, 3, 3, 2,
+ 1, 2, 1, 1, 1, 2, 0, 9, 0, 0,
+ 9, 2, 1, 0, 7, 2, 1, 10
+};
+
+/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
+ Performed when YYTABLE doesn't specify something else to do. Zero
+ means the default is an error. */
+static const yytype_uint8 yydefact[] =
+{
+ 0, 0, 0, 0, 0, 0, 2, 5, 0, 6,
+ 0, 7, 3, 23, 24, 0, 0, 8, 16, 1,
+ 4, 0, 10, 0, 12, 0, 0, 0, 22, 20,
+ 0, 0, 0, 9, 11, 25, 18, 19, 17, 21,
+ 28, 0, 15, 14, 0, 0, 26, 0, 29, 0,
+ 13, 0, 0, 0, 0, 36, 0, 0, 32, 0,
+ 30, 35, 0, 27, 31, 0, 0, 0, 33, 0,
+ 0, 0, 0, 0, 34, 0, 0, 37
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const yytype_int8 yydefgoto[] =
+{
+ -1, 5, 6, 7, 8, 9, 23, 24, 44, 10,
+ 11, 26, 27, 12, 29, 13, 49, 14, 45, 51,
+ 57, 58, 70, 54, 55
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -55
+static const yytype_int8 yypact[] =
+{
+ 17, 4, 23, 6, 18, 31, -5, -55, -4, -55,
+ 15, -55, -55, -55, -55, 28, 30, -55, -55, -55,
+ -55, 32, -55, -2, -55, 34, 0, 1, -55, -55,
+ 35, 36, 16, -55, -55, -55, -55, -55, -55, -55,
+ -55, 37, -55, -55, 38, 20, -55, 39, -55, 21,
+ -55, 40, 33, 41, -3, -55, 42, 43, 33, 44,
+ -55, -55, 45, -55, -55, 47, 46, 48, -55, 49,
+ 40, 50, -1, 51, -55, 52, 53, -55
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const yytype_int8 yypgoto[] =
+{
+ -55, -55, -55, 54, -55, -55, -55, 26, -55, -55,
+ -55, -55, -55, -8, 55, -55, -55, -55, -55, -55,
+ 5, -55, -55, -12, -54
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If YYTABLE_NINF, syntax error. */
+#define YYTABLE_NINF -1
+static const yytype_uint8 yytable[] =
+{
+ 61, 53, 28, 53, 21, 25, 21, 3, 4, 15,
+ 1, 2, 22, 60, 33, 74, 36, 38, 61, 39,
+ 25, 17, 42, 43, 1, 2, 1, 2, 16, 3,
+ 4, 19, 30, 18, 31, 48, 52, 32, 35, 40,
+ 41, 46, 47, 50, 53, 59, 62, 56, 65, 34,
+ 66, 67, 69, 71, 73, 75, 76, 77, 72, 63,
+ 20, 68, 0, 64, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 37
+};
+
+#define yypact_value_is_default(yystate) \
+ ((yystate) == (-55))
+
+#define yytable_value_is_error(yytable_value) \
+ YYID (0)
+
+static const yytype_int8 yycheck[] =
+{
+ 54, 4, 10, 4, 8, 5, 8, 12, 13, 5,
+ 9, 10, 16, 16, 16, 16, 16, 16, 72, 27,
+ 5, 15, 6, 7, 9, 10, 9, 10, 5, 12,
+ 13, 0, 4, 15, 4, 15, 15, 5, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 14, 4, 23,
+ 5, 4, 4, 4, 4, 4, 4, 4, 70, 16,
+ 6, 15, -1, 58, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 26
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const yytype_uint8 yystos[] =
+{
+ 0, 9, 10, 12, 13, 18, 19, 20, 21, 22,
+ 26, 27, 30, 32, 34, 5, 5, 15, 15, 0,
+ 20, 8, 16, 23, 24, 5, 28, 29, 30, 31,
+ 4, 4, 5, 16, 24, 4, 16, 31, 16, 30,
+ 4, 4, 6, 7, 25, 35, 4, 4, 15, 33,
+ 4, 36, 15, 4, 40, 41, 14, 37, 38, 4,
+ 16, 41, 4, 16, 37, 4, 5, 4, 15, 4,
+ 39, 4, 40, 4, 16, 4, 4, 4
+};
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
+
+
+/* Like YYERROR except do call yyerror. This remains here temporarily
+ to ease the transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. However,
+ YYFAIL appears to be in use. Nevertheless, it is formally deprecated
+ in Bison 2.4.2's NEWS entry, where a plan to phase it out is
+ discussed. */
+
+#define YYFAIL goto yyerrlab
+#if defined YYFAIL
+ /* This is here to suppress warnings from the GCC cpp's
+ -Wunused-macros. Normally we don't worry about that warning, but
+ some users do, and we want to make it easy for users to remove
+ YYFAIL uses, which will produce warnings from Bison 2.5. */
+#endif
+
+#define YYRECOVERING() (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (1); \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+while (YYID (0))
+
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+ If N is 0, then set CURRENT to the empty location which ends
+ the previous symbol: RHS[0] (always defined). */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (YYID (N)) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ } \
+ while (YYID (0))
+#endif
+
+
+/* This macro is provided for backward compatibility. */
+
+#ifndef YY_LOCATION_PRINT
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+#endif
+
+
+/* YYLEX -- calling `yylex' with the right arguments. */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (YYLEX_PARAM)
+#else
+# define YYLEX yylex ()
+#endif
+
+/* Enable debugging if requested. */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+# include /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, \
+ Type, Value); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (YYID (0))
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (!yyvaluep)
+ return;
+# ifdef YYPRINT
+ if (yytype < YYNTOKENS)
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# else
+ YYUSE (yyoutput);
+# endif
+ switch (yytype)
+ {
+ default:
+ break;
+ }
+}
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (yytype < YYNTOKENS)
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+ else
+ YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+ yy_symbol_value_print (yyoutput, yytype, yyvaluep);
+ YYFPRINTF (yyoutput, ")");
+}
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included). |
+`------------------------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
+#else
+static void
+yy_stack_print (yybottom, yytop)
+ yytype_int16 *yybottom;
+ yytype_int16 *yytop;
+#endif
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
+ YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (YYID (0))
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
+#else
+static void
+yy_reduce_print (yyvsp, yyrule)
+ YYSTYPE *yyvsp;
+ int yyrule;
+#endif
+{
+ int yynrhs = yyr2[yyrule];
+ int yyi;
+ unsigned long int yylno = yyrline[yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+ yyrule - 1, yylno);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+ &(yyvsp[(yyi + 1) - (yynrhs)])
+ );
+ YYFPRINTF (stderr, "\n");
+ }
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyvsp, Rule); \
+} while (YYID (0))
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+# if defined __GLIBC__ && defined _STRING_H
+# define yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static YYSIZE_T
+yystrlen (const char *yystr)
+#else
+static YYSIZE_T
+yystrlen (yystr)
+ const char *yystr;
+#endif
+{
+ YYSIZE_T yylen;
+ for (yylen = 0; yystr[yylen]; yylen++)
+ continue;
+ return yylen;
+}
+# endif
+# endif
+
+# ifndef yystpcpy
+# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static char *
+yystpcpy (char *yydest, const char *yysrc)
+#else
+static char *
+yystpcpy (yydest, yysrc)
+ char *yydest;
+ const char *yysrc;
+#endif
+{
+ char *yyd = yydest;
+ const char *yys = yysrc;
+
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
+
+ return yyd - 1;
+}
+# endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+ if (*yystr == '"')
+ {
+ YYSIZE_T yyn = 0;
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
+ do_not_strip_quotes: ;
+ }
+
+ if (! yyres)
+ return yystrlen (yystr);
+
+ return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
+ about the unexpected token YYTOKEN for the state stack whose top is
+ YYSSP.
+
+ Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
+ not large enough to hold the message. In that case, also set
+ *YYMSG_ALLOC to the required number of bytes. Return 2 if the
+ required number of bytes is too large to store. */
+static int
+yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
+ yytype_int16 *yyssp, int yytoken)
+{
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
+ YYSIZE_T yysize = yysize0;
+ YYSIZE_T yysize1;
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ /* Internationalized format string. */
+ const char *yyformat = 0;
+ /* Arguments of yyformat. */
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ /* Number of reported tokens (one for the "unexpected", one per
+ "expected"). */
+ int yycount = 0;
+
+ /* There are many possibilities here to consider:
+ - Assume YYFAIL is not used. It's too flawed to consider. See
+
+ for details. YYERROR is fine as it does not invoke this
+ function.
+ - If this state is a consistent state with a default action, then
+ the only way this function was invoked is if the default action
+ is an error action. In that case, don't check for expected
+ tokens because there are none.
+ - The only way there can be no lookahead present (in yychar) is if
+ this state is a consistent state with a default action. Thus,
+ detecting the absence of a lookahead is sufficient to determine
+ that there is no unexpected or expected token to report. In that
+ case, just report a simple "syntax error".
+ - Don't assume there isn't a lookahead just because this state is a
+ consistent state with a default action. There might have been a
+ previous inconsistent state, consistent state with a non-default
+ action, or user semantic action that manipulated yychar.
+ - Of course, the expected token list depends on states to have
+ correct lookahead information, and it depends on the parser not
+ to perform extra reductions after fetching a lookahead from the
+ scanner and before detecting a syntax error. Thus, state merging
+ (from LALR or IELR) and default reductions corrupt the expected
+ token list. However, the list is correct for canonical LR with
+ one exception: it will still contain any token that will not be
+ accepted due to an error action in a later state.
+ */
+ if (yytoken != YYEMPTY)
+ {
+ int yyn = yypact[*yyssp];
+ yyarg[yycount++] = yytname[yytoken];
+ if (!yypact_value_is_default (yyn))
+ {
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. In other words, skip the first -YYN actions for
+ this state because they are default actions. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn + 1;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yyx;
+
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
+ && !yytable_value_is_error (yytable[yyx + yyn]))
+ {
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ yycount = 1;
+ yysize = yysize0;
+ break;
+ }
+ yyarg[yycount++] = yytname[yyx];
+ yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+ if (! (yysize <= yysize1
+ && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+ }
+ }
+ }
+
+ switch (yycount)
+ {
+# define YYCASE_(N, S) \
+ case N: \
+ yyformat = S; \
+ break
+ YYCASE_(0, YY_("syntax error"));
+ YYCASE_(1, YY_("syntax error, unexpected %s"));
+ YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
+ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
+ YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
+ YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
+# undef YYCASE_
+ }
+
+ yysize1 = yysize + yystrlen (yyformat);
+ if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+
+ if (*yymsg_alloc < yysize)
+ {
+ *yymsg_alloc = 2 * yysize;
+ if (! (yysize <= *yymsg_alloc
+ && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
+ *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
+ return 1;
+ }
+
+ /* Avoid sprintf, as that infringes on the user's name space.
+ Don't have undefined behavior even if the translation
+ produced a string with the wrong number of "%s"s. */
+ {
+ char *yyp = *yymsg;
+ int yyi = 0;
+ while ((*yyp = *yyformat) != '\0')
+ if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyformat += 2;
+ }
+ else
+ {
+ yyp++;
+ yyformat++;
+ }
+ }
+ return 0;
+}
+#endif /* YYERROR_VERBOSE */
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol. |
+`-----------------------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
+#else
+static void
+yydestruct (yymsg, yytype, yyvaluep)
+ const char *yymsg;
+ int yytype;
+ YYSTYPE *yyvaluep;
+#endif
+{
+ YYUSE (yyvaluep);
+
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+ switch (yytype)
+ {
+ case 5: /* "QTEXT" */
+
+/* Line 1391 of yacc.c */
+#line 56 "audp_parser.ypp"
+ {
+#ifndef WZ_OS_WIN
+ // Force type checking by the compiler
+ char * const s = (yyvaluep->sval);
+
+ if (s)
+ free(s);
+#endif
+};
+
+/* Line 1391 of yacc.c */
+#line 1182 "audp_parser.cpp"
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+/* Prevent warnings from -Wmissing-prototypes. */
+#ifdef YYPARSE_PARAM
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void *YYPARSE_PARAM);
+#else
+int yyparse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+/* The lookahead symbol. */
+int yychar;
+
+/* The semantic value of the lookahead symbol. */
+YYSTYPE yylval;
+
+/* Number of syntax errors so far. */
+int yynerrs;
+
+
+/*----------.
+| yyparse. |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *YYPARSE_PARAM)
+#else
+int
+yyparse (YYPARSE_PARAM)
+ void *YYPARSE_PARAM;
+#endif
+#else /* ! YYPARSE_PARAM */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void)
+#else
+int
+yyparse ()
+
+#endif
+#endif
+{
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
+
+ YYSIZE_T yystacksize;
+
+ int yyn;
+ int yyresult;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char yymsgbuf[128];
+ char *yymsg = yymsgbuf;
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+
+ /* The number of symbols on the RHS of the reduced rule.
+ Keep to zero when no symbol should be popped. */
+ int yylen = 0;
+
+ yytoken = 0;
+ yyss = yyssa;
+ yyvs = yyvsa;
+ yystacksize = YYINITDEPTH;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+ yyssp = yyss;
+ yyvsp = yyvs;
+
+ goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate. |
+`------------------------------------------------------------*/
+ yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. So pushing a state here evens the stacks. */
+ yyssp++;
+
+ yysetstate:
+ *yyssp = yystate;
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ {
+ /* Get the current used size of the three stacks, in elements. */
+ YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ {
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ yytype_int16 *yyss1 = yyss;
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
+ &yystacksize);
+
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+# else
+ /* Extend the stack our own way. */
+ if (YYMAXDEPTH <= yystacksize)
+ goto yyexhaustedlab;
+ yystacksize *= 2;
+ if (YYMAXDEPTH < yystacksize)
+ yystacksize = YYMAXDEPTH;
+
+ {
+ yytype_int16 *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyexhaustedlab;
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+# undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+ }
+# endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + yysize - 1;
+ yyvsp = yyvs + yysize - 1;
+
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ YYABORT;
+ }
+
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
+ goto yybackup;
+
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
+
+ /* Do appropriate processing given the current state. Read a
+ lookahead token if we need one and don't already have one. */
+
+ /* First try to decide what to do without reference to lookahead token. */
+ yyn = yypact[yystate];
+ if (yypact_value_is_default (yyn))
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
+ }
+
+ if (yychar <= YYEOF)
+ {
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ }
+
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
+ detect an error, take that action. */
+ yyn += yytoken;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+ goto yydefault;
+ yyn = yytable[yyn];
+ if (yyn <= 0)
+ {
+ if (yytable_value_is_error (yyn))
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
+
+ /* Shift the lookahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
+
+ yystate = yyn;
+ *++yyvsp = yylval;
+
+ goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+yydefault:
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction. |
+`-----------------------------*/
+yyreduce:
+ /* yyn is the number of a rule to reduce with. */
+ yylen = yyr2[yyn];
+
+ /* If YYLEN is nonzero, implement the default value of the action:
+ `$$ = $1'.
+
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ yyval = yyvsp[1-yylen];
+
+
+ YY_REDUCE_PRINT (yyn);
+ switch (yyn)
+ {
+ case 13:
+
+/* Line 1806 of yacc.c */
+#line 107 "audp_parser.ypp"
+ {
+ audio_SetTrackVals((yyvsp[(2) - (5)].sval), (yyvsp[(3) - (5)].bval), (yyvsp[(4) - (5)].ival), (yyvsp[(5) - (5)].ival));
+ free((yyvsp[(2) - (5)].sval));
+ }
+ break;
+
+ case 14:
+
+/* Line 1806 of yacc.c */
+#line 114 "audp_parser.ypp"
+ { (yyval.bval) = true; }
+ break;
+
+ case 15:
+
+/* Line 1806 of yacc.c */
+#line 116 "audp_parser.ypp"
+ { (yyval.bval) = false; }
+ break;
+
+ case 16:
+
+/* Line 1806 of yacc.c */
+#line 120 "audp_parser.ypp"
+ {
+ }
+ break;
+
+ case 25:
+
+/* Line 1806 of yacc.c */
+#line 143 "audp_parser.ypp"
+ {
+ g_iCurAnimID = (yyvsp[(2) - (2)].ival);
+ anim_SetVals( (yyvsp[(1) - (2)].sval), (yyvsp[(2) - (2)].ival) );
+ free((yyvsp[(1) - (2)].sval));
+ }
+ break;
+
+ case 26:
+
+/* Line 1806 of yacc.c */
+#line 156 "audp_parser.ypp"
+ {
+ anim_Create3D( (yyvsp[(2) - (5)].sval), (yyvsp[(3) - (5)].ival), (yyvsp[(4) - (5)].ival), (yyvsp[(5) - (5)].ival), ANIM_3D_TRANS, g_iCurAnimID );
+ free((yyvsp[(2) - (5)].sval));
+ }
+ break;
+
+ case 27:
+
+/* Line 1806 of yacc.c */
+#line 161 "audp_parser.ypp"
+ {
+ g_iCurAnimID++;
+ }
+ break;
+
+ case 28:
+
+/* Line 1806 of yacc.c */
+#line 167 "audp_parser.ypp"
+ {
+ anim_Create3D( (yyvsp[(2) - (4)].sval), (yyvsp[(3) - (4)].ival), (yyvsp[(4) - (4)].ival), 1, ANIM_3D_FRAMES, g_iCurAnimID );
+ free((yyvsp[(2) - (4)].sval));
+ }
+ break;
+
+ case 29:
+
+/* Line 1806 of yacc.c */
+#line 172 "audp_parser.ypp"
+ {
+ anim_BeginScript();
+ }
+ break;
+
+ case 30:
+
+/* Line 1806 of yacc.c */
+#line 176 "audp_parser.ypp"
+ {
+ anim_EndScript();
+ g_iCurAnimID++;
+ }
+ break;
+
+ case 33:
+
+/* Line 1806 of yacc.c */
+#line 187 "audp_parser.ypp"
+ {
+ anim_BeginScript();
+ free((yyvsp[(3) - (4)].sval));
+ }
+ break;
+
+ case 34:
+
+/* Line 1806 of yacc.c */
+#line 192 "audp_parser.ypp"
+ {
+ anim_EndScript();
+ }
+ break;
+
+ case 37:
+
+/* Line 1806 of yacc.c */
+#line 202 "audp_parser.ypp"
+ {
+ vecPos.x = (yyvsp[(2) - (10)].ival);
+ vecPos.y = (yyvsp[(3) - (10)].ival);
+ vecPos.z = (yyvsp[(4) - (10)].ival);
+ vecRot.x = (yyvsp[(5) - (10)].ival);
+ vecRot.y = (yyvsp[(6) - (10)].ival);
+ vecRot.z = (yyvsp[(7) - (10)].ival);
+ vecScale.x = (yyvsp[(8) - (10)].ival);
+ vecScale.y = (yyvsp[(9) - (10)].ival);
+ vecScale.z = (yyvsp[(10) - (10)].ival);
+ anim_AddFrameToAnim( (yyvsp[(1) - (10)].ival), vecPos, vecRot, vecScale );
+ }
+ break;
+
+
+
+/* Line 1806 of yacc.c */
+#line 1613 "audp_parser.cpp"
+ default: break;
+ }
+ /* User semantic actions sometimes alter yychar, and that requires
+ that yytoken be updated with the new translation. We take the
+ approach of translating immediately before every use of yytoken.
+ One alternative is translating here after every semantic action,
+ but that translation would be missed if the semantic action invokes
+ YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
+ if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
+ incorrect destructor might then be invoked immediately. In the
+ case of YYERROR or YYBACKUP, subsequent parser actions might lead
+ to an incorrect destructor call or verbose syntax error message
+ before the lookahead is translated. */
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
+
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+
+ *++yyvsp = yyval;
+
+ /* Now `shift' the result of the reduction. Determine what state
+ that goes to, based on the state we popped back to and the rule
+ number reduced by. */
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTOKENS];
+
+ goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
+
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus)
+ {
+ ++yynerrs;
+#if ! YYERROR_VERBOSE
+ yyerror (YY_("syntax error"));
+#else
+# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
+ yyssp, yytoken)
+ {
+ char const *yymsgp = YY_("syntax error");
+ int yysyntax_error_status;
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ if (yysyntax_error_status == 0)
+ yymsgp = yymsg;
+ else if (yysyntax_error_status == 1)
+ {
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+ yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
+ if (!yymsg)
+ {
+ yymsg = yymsgbuf;
+ yymsg_alloc = sizeof yymsgbuf;
+ yysyntax_error_status = 2;
+ }
+ else
+ {
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ yymsgp = yymsg;
+ }
+ }
+ yyerror (yymsgp);
+ if (yysyntax_error_status == 2)
+ goto yyexhaustedlab;
+ }
+# undef YYSYNTAX_ERROR
+#endif
+ }
+
+
+
+ if (yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ if (yychar <= YYEOF)
+ {
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ YYABORT;
+ }
+ else
+ {
+ yydestruct ("Error: discarding",
+ yytoken, &yylval);
+ yychar = YYEMPTY;
+ }
+ }
+
+ /* Else will try to reuse lookahead token after shifting the error
+ token. */
+ goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR. |
+`---------------------------------------------------*/
+yyerrorlab:
+
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label yyerrorlab therefore never appears in user
+ code. */
+ if (/*CONSTCOND*/ 0)
+ goto yyerrorlab;
+
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYERROR. */
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+ yystate = *yyssp;
+ goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR. |
+`-------------------------------------------------------------*/
+yyerrlab1:
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
+
+ for (;;)
+ {
+ yyn = yypact[yystate];
+ if (!yypact_value_is_default (yyn))
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yyssp == yyss)
+ YYABORT;
+
+
+ yydestruct ("Error: popping",
+ yystos[yystate], yyvsp);
+ YYPOPSTACK (1);
+ yystate = *yyssp;
+ YY_STACK_PRINT (yyss, yyssp);
+ }
+
+ *++yyvsp = yylval;
+
+
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+#if !defined(yyoverflow) || YYERROR_VERBOSE
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here. |
+`-------------------------------------------------*/
+yyexhaustedlab:
+ yyerror (YY_("memory exhausted"));
+ yyresult = 2;
+ /* Fall through. */
+#endif
+
+yyreturn:
+ if (yychar != YYEMPTY)
+ {
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = YYTRANSLATE (yychar);
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval);
+ }
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYABORT or YYACCEPT. */
+ YYPOPSTACK (yylen);
+ YY_STACK_PRINT (yyss, yyssp);
+ while (yyssp != yyss)
+ {
+ yydestruct ("Cleanup: popping",
+ yystos[*yyssp], yyvsp);
+ YYPOPSTACK (1);
+ }
+#ifndef yyoverflow
+ if (yyss != yyssa)
+ YYSTACK_FREE (yyss);
+#endif
+#if YYERROR_VERBOSE
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+#endif
+ /* Make sure YYID is used. */
+ return YYID (yyresult);
+}
+
+
+
+/* Line 2067 of yacc.c */
+#line 216 "audp_parser.ypp"
+
+
+/* A simple error reporting routine */
+void yyerror(const char* msg)
+{
+ debug(LOG_ERROR, "RES file parse error:\n%s at line %d\nToken: %d, Text: '%s'\n", msg, audp_get_lineno(), audp_char, audp_get_text());
+}
+
+/** Read an audio properties file
+ */
+bool ParseResourceFile(PHYSFS_file* fileHandle)
+{
+ bool retval;
+ lexerinput_t input;
+ input.type = LEXINPUT_PHYSFS;
+ input.input.physfsfile = fileHandle;
+
+ audp_set_extra(&input);
+
+ retval = (audp_parse() == 0);
+ audp_lex_destroy();
+
+ return retval;
+}
+
diff --git a/lib/gamelib/audp_parser.h b/lib/gamelib/audp_parser.h
new file mode 100644
index 000000000..e18d58456
--- /dev/null
+++ b/lib/gamelib/audp_parser.h
@@ -0,0 +1,82 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ FLOAT_T = 258,
+ INTEGER = 259,
+ QTEXT = 260,
+ ONESHOT = 261,
+ LOOP = 262,
+ AUDIO = 263,
+ ANIM3DFRAMES = 264,
+ ANIM3DTRANS = 265,
+ ANIM3DFILE = 266,
+ AUDIO_MODULE = 267,
+ ANIM_MODULE = 268,
+ ANIMOBJECT = 269
+ };
+#endif
+/* Tokens. */
+#define FLOAT_T 258
+#define INTEGER 259
+#define QTEXT 260
+#define ONESHOT 261
+#define LOOP 262
+#define AUDIO 263
+#define ANIM3DFRAMES 264
+#define ANIM3DTRANS 265
+#define ANIM3DFILE 266
+#define AUDIO_MODULE 267
+#define ANIM_MODULE 268
+#define ANIMOBJECT 269
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 2068 of yacc.c */
+#line 44 "audp_parser.ypp"
+
+ float fval;
+ long ival;
+ bool bval;
+ char* sval;
+
+
+
+/* Line 2068 of yacc.c */
+#line 87 "audp_parser.h"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+extern YYSTYPE audp_lval;
+
+
diff --git a/lib/gamelib/gamelib.vcxproj b/lib/gamelib/gamelib.vcxproj
index 0b1c5fa48..4b1462bdd 100644
--- a/lib/gamelib/gamelib.vcxproj
+++ b/lib/gamelib/gamelib.vcxproj
@@ -60,9 +60,7 @@
Unicode
-
-
-
+
@@ -235,21 +233,11 @@
-
+
-
-
- Document
-
-
- Document
-
-
-
-
-
+
\ No newline at end of file
diff --git a/lib/gamelib/gamelib.vcxproj.filters b/lib/gamelib/gamelib.vcxproj.filters
index 154189cce..83d3ab27d 100644
--- a/lib/gamelib/gamelib.vcxproj.filters
+++ b/lib/gamelib/gamelib.vcxproj.filters
@@ -9,9 +9,6 @@
{93995380-89BD-4b04-88EB-625FBE52EBFB}
h;hpp;hxx;hm;inl;inc;xsd
-
- {d9ee26c1-75fa-4dc9-bd73-146c94d60e3e}
-
@@ -40,9 +37,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -52,15 +46,8 @@
Header Files
-
-
-
- FlexBison
-
-
-
-
- FlexBison
-
+
+ Header Files
+
\ No newline at end of file
diff --git a/lib/script/Makefile.am b/lib/script/Makefile.am
index 2664d71ef..6270bebf0 100644
--- a/lib/script/Makefile.am
+++ b/lib/script/Makefile.am
@@ -1,15 +1,11 @@
AM_CPPFLAGS = -DYY_NO_INPUT $(WZ_CPPFLAGS) $(QT4_CFLAGS)
AM_CFLAGS = $(WZ_CFLAGS)
AM_CXXFLAGS = $(WZ_CXXFLAGS) $(QT4_CFLAGS)
-AM_LFLAGS = $(FLEX_FLAGS)
-AM_YFLAGS = -d
-BUILT_SOURCES = \
- chat_parser.h \
- script_parser.h
noinst_LIBRARIES = libscript.a
noinst_HEADERS = \
+ chat_parser.h \
chat_processing.h \
codeprint.h \
event.h \
@@ -17,17 +13,18 @@ noinst_HEADERS = \
interpreter.h \
parse.h \
script.h \
+ script_parser.h \
stack.h
libscript_a_SOURCES = \
- chat_lexer.lpp \
- chat_parser.ypp \
+ chat_lexer.cpp \
+ chat_parser.cpp \
codeprint.cpp \
event.cpp \
eventsave.cpp \
interpreter.cpp \
script.cpp \
- script_lexer.lpp \
- script_parser.ypp \
+ script_lexer.cpp \
+ script_parser.cpp \
stack.cpp
diff --git a/lib/script/chat_lexer.cpp b/lib/script/chat_lexer.cpp
new file mode 100644
index 000000000..5aa60573e
--- /dev/null
+++ b/lib/script/chat_lexer.cpp
@@ -0,0 +1,2535 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+#line 2 "chat_lexer.cpp"
+
+#line 4 "chat_lexer.cpp"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define yy_create_buffer chat__create_buffer
+#define yy_delete_buffer chat__delete_buffer
+#define yy_flex_debug chat__flex_debug
+#define yy_init_buffer chat__init_buffer
+#define yy_flush_buffer chat__flush_buffer
+#define yy_load_buffer_state chat__load_buffer_state
+#define yy_switch_to_buffer chat__switch_to_buffer
+#define yyin chat_in
+#define yyleng chat_leng
+#define yylex chat_lex
+#define yylineno chat_lineno
+#define yyout chat_out
+#define yyrestart chat_restart
+#define yytext chat_text
+#define yywrap chat_wrap
+#define yyalloc chat_alloc
+#define yyrealloc chat_realloc
+#define yyfree chat_free
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 35
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+#include "lib/framework/frame.h"
+/* begin standard C headers. */
+#include
+#include
+#include
+#include
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have . Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#endif /* ! C99 */
+
+#endif /* ! FLEXINT_H */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
+
+#define YY_USE_CONST
+
+#endif /* defined (__STDC__) */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index. If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN (yy_start) = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START (((yy_start) - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE chat_restart(chat_in )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
+#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
+#endif
+
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+extern int chat_leng;
+
+extern FILE *chat_in, *chat_out;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+ /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
+ * access to the local variable yy_act. Since yyless() is a macro, it would break
+ * existing scanners that call yyless() from OUTSIDE chat_lex.
+ * One obvious solution it to make yy_act a global. I tried that, and saw
+ * a 5% performance hit in a non-chat_lineno scanner, because yy_act is
+ * normally declared as a register variable-- so it is not worth it.
+ */
+ #define YY_LESS_LINENO(n) \
+ do { \
+ int yyl;\
+ for ( yyl = n; yyl < chat_leng; ++yyl )\
+ if ( chat_text[yyl] == '\n' )\
+ --chat_lineno;\
+ }while(0)
+
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up chat_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ *yy_cp = (yy_hold_char); \
+ YY_RESTORE_YY_MORE_OFFSET \
+ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up chat_text again */ \
+ } \
+ while ( 0 )
+
+#define unput(c) yyunput( c, (yytext_ptr) )
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via chat_restart()), so that the user can continue scanning by
+ * just pointing chat_in at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+ : NULL)
+
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+
+/* yy_hold_char holds the character lost when chat_text is formed. */
+static char yy_hold_char;
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+int chat_leng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 0; /* whether we need to initialize */
+static int yy_start = 0; /* start state number */
+
+/* Flag which is used to allow chat_wrap()'s to do buffer switches
+ * instead of setting up a fresh chat_in. A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void chat_restart (FILE *input_file );
+void chat__switch_to_buffer (YY_BUFFER_STATE new_buffer );
+YY_BUFFER_STATE chat__create_buffer (FILE *file,int size );
+void chat__delete_buffer (YY_BUFFER_STATE b );
+void chat__flush_buffer (YY_BUFFER_STATE b );
+void chat_push_buffer_state (YY_BUFFER_STATE new_buffer );
+void chat_pop_buffer_state (void );
+
+static void chat_ensure_buffer_stack (void );
+static void chat__load_buffer_state (void );
+static void chat__init_buffer (YY_BUFFER_STATE b,FILE *file );
+
+#define YY_FLUSH_BUFFER chat__flush_buffer(YY_CURRENT_BUFFER )
+
+YY_BUFFER_STATE chat__scan_buffer (char *base,yy_size_t size );
+YY_BUFFER_STATE chat__scan_string (yyconst char *yy_str );
+YY_BUFFER_STATE chat__scan_bytes (yyconst char *bytes,int len );
+
+void *chat_alloc (yy_size_t );
+void *chat_realloc (void *,yy_size_t );
+void chat_free (void * );
+
+#define yy_new_buffer chat__create_buffer
+
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ chat_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ chat__create_buffer(chat_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+ }
+
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){\
+ chat_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ chat__create_buffer(chat_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+ }
+
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* Begin user sect3 */
+
+typedef unsigned char YY_CHAR;
+
+FILE *chat_in = (FILE *) 0, *chat_out = (FILE *) 0;
+
+typedef int yy_state_type;
+
+extern int chat_lineno;
+
+int chat_lineno = 1;
+
+extern char *chat_text;
+#define yytext_ptr chat_text
+
+static yy_state_type yy_get_previous_state (void );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
+static int yy_get_next_buffer (void );
+static void yy_fatal_error (yyconst char msg[] );
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up chat_text.
+ */
+#define YY_DO_BEFORE_ACTION \
+ (yytext_ptr) = yy_bp; \
+ chat_leng = (size_t) (yy_cp - yy_bp); \
+ (yy_hold_char) = *yy_cp; \
+ *yy_cp = '\0'; \
+ (yy_c_buf_p) = yy_cp;
+
+#define YY_NUM_RULES 85
+#define YY_END_OF_BUFFER 86
+/* This struct is not used in this scanner,
+ but its presence is necessary. */
+struct yy_trans_info
+ {
+ flex_int32_t yy_verify;
+ flex_int32_t yy_nxt;
+ };
+static yyconst flex_int16_t yy_accept[262] =
+ { 0,
+ 83, 83, 86, 85, 84, 4, 85, 8, 85, 5,
+ 1, 6, 7, 3, 9, 83, 83, 83, 83, 83,
+ 83, 83, 42, 83, 83, 83, 83, 83, 83, 83,
+ 83, 73, 83, 83, 83, 4, 2, 1, 5, 1,
+ 83, 3, 83, 83, 13, 14, 83, 83, 83, 83,
+ 83, 83, 83, 26, 83, 83, 83, 83, 33, 83,
+ 83, 83, 83, 0, 44, 83, 83, 47, 83, 83,
+ 50, 83, 53, 54, 83, 83, 83, 83, 83, 83,
+ 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
+ 83, 83, 83, 83, 15, 16, 83, 83, 83, 83,
+
+ 83, 83, 83, 83, 83, 83, 29, 31, 83, 83,
+ 36, 83, 39, 83, 83, 83, 43, 83, 83, 83,
+ 83, 51, 0, 83, 83, 83, 83, 83, 59, 83,
+ 83, 83, 83, 64, 65, 83, 83, 83, 83, 83,
+ 72, 83, 83, 83, 83, 78, 80, 81, 82, 83,
+ 83, 12, 19, 83, 83, 83, 0, 83, 24, 83,
+ 27, 28, 83, 83, 83, 83, 83, 38, 40, 41,
+ 83, 0, 48, 49, 0, 83, 83, 83, 83, 83,
+ 83, 83, 63, 66, 83, 68, 69, 83, 83, 83,
+ 76, 83, 79, 83, 11, 83, 83, 83, 22, 83,
+
+ 83, 30, 83, 34, 35, 37, 83, 46, 0, 55,
+ 83, 57, 83, 60, 83, 62, 83, 83, 74, 75,
+ 77, 83, 17, 20, 83, 23, 83, 83, 45, 0,
+ 83, 83, 83, 67, 0, 71, 83, 83, 83, 25,
+ 32, 0, 83, 58, 61, 0, 83, 83, 21, 0,
+ 83, 0, 83, 18, 52, 83, 70, 83, 56, 10,
+ 0
+ } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
+ 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 3, 4, 1, 1, 1, 1, 1, 5, 1,
+ 1, 1, 1, 6, 7, 8, 1, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 10, 11, 1,
+ 1, 1, 12, 1, 13, 14, 15, 16, 17, 18,
+ 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
+ 29, 30, 31, 32, 33, 34, 35, 22, 36, 22,
+ 1, 1, 1, 1, 22, 1, 37, 38, 39, 40,
+
+ 41, 42, 43, 44, 45, 22, 46, 47, 48, 49,
+ 50, 51, 52, 53, 54, 55, 56, 57, 58, 22,
+ 59, 22, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1
+ } ;
+
+static yyconst flex_int32_t yy_meta[60] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 1,
+ 1, 1, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2
+ } ;
+
+static yyconst flex_int16_t yy_base[263] =
+ { 0,
+ 0, 0, 150, 523, 523, 139, 29, 523, 128, 125,
+ 120, 523, 523, 113, 66, 44, 52, 77, 0, 52,
+ 82, 107, 57, 69, 99, 111, 113, 118, 136, 139,
+ 43, 46, 46, 147, 137, 72, 523, 66, 66, 62,
+ 0, 58, 158, 56, 0, 157, 122, 126, 68, 96,
+ 149, 153, 169, 0, 158, 162, 166, 169, 183, 105,
+ 176, 179, 188, 189, 0, 186, 186, 0, 190, 188,
+ 186, 65, 196, 0, 212, 196, 220, 226, 215, 205,
+ 245, 217, 240, 217, 244, 227, 224, 235, 247, 263,
+ 233, 248, 254, 237, 0, 0, 243, 269, 268, 263,
+
+ 62, 260, 281, 269, 273, 286, 289, 276, 283, 285,
+ 0, 292, 0, 295, 288, 297, 523, 287, 61, 302,
+ 304, 0, 308, 302, 311, 299, 316, 307, 0, 322,
+ 307, 325, 325, 0, 0, 329, 317, 323, 335, 328,
+ 0, 323, 332, 327, 330, 341, 0, 0, 0, 334,
+ 335, 0, 0, 352, 344, 352, 341, 358, 0, 359,
+ 0, 0, 364, 363, 367, 376, 361, 0, 0, 0,
+ 377, 364, 0, 0, 370, 381, 383, 372, 382, 370,
+ 386, 379, 0, 0, 378, 0, 0, 389, 384, 386,
+ 0, 402, 0, 396, 0, 400, 400, 407, 523, 400,
+
+ 418, 0, 410, 0, 0, 0, 405, 523, 406, 0,
+ 410, 0, 416, 0, 415, 0, 416, 445, 0, 0,
+ 0, 437, 430, 0, 428, 0, 432, 437, 0, 428,
+ 430, 444, 449, 0, 433, 0, 439, 446, 448, 0,
+ 0, 442, 458, 0, 0, 455, 462, 466, 0, 469,
+ 461, 456, 459, 0, 523, 471, 523, 481, 0, 0,
+ 523, 62
+ } ;
+
+static yyconst flex_int16_t yy_def[263] =
+ { 0,
+ 261, 1, 261, 261, 261, 261, 261, 261, 261, 261,
+ 262, 261, 261, 261, 262, 262, 262, 262, 262, 262,
+ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262,
+ 262, 262, 262, 262, 262, 261, 261, 261, 261, 262,
+ 262, 261, 262, 262, 262, 262, 262, 262, 262, 262,
+ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262,
+ 262, 262, 262, 261, 262, 262, 262, 262, 262, 262,
+ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262,
+ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262,
+ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262,
+
+ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262,
+ 262, 262, 262, 262, 262, 262, 261, 262, 262, 262,
+ 262, 262, 261, 262, 262, 262, 262, 262, 262, 262,
+ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262,
+ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262,
+ 262, 262, 262, 262, 262, 262, 261, 262, 262, 262,
+ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262,
+ 262, 261, 262, 262, 261, 262, 262, 262, 262, 262,
+ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262,
+ 262, 262, 262, 262, 262, 262, 262, 262, 261, 262,
+
+ 262, 262, 262, 262, 262, 262, 262, 261, 261, 262,
+ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262,
+ 262, 262, 262, 262, 262, 262, 262, 262, 262, 261,
+ 262, 262, 262, 262, 261, 262, 262, 262, 262, 262,
+ 262, 261, 262, 262, 262, 261, 262, 262, 262, 261,
+ 262, 261, 262, 262, 261, 262, 261, 262, 262, 262,
+ 0, 261
+ } ;
+
+static yyconst flex_int16_t yy_nxt[583] =
+ { 0,
+ 4, 5, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
+ 23, 19, 19, 24, 25, 26, 27, 28, 19, 29,
+ 30, 31, 32, 33, 34, 35, 15, 16, 17, 18,
+ 19, 20, 21, 22, 23, 19, 24, 25, 26, 27,
+ 28, 19, 29, 30, 31, 32, 33, 34, 35, 37,
+ 49, 64, 85, 41, 51, 172, 157, 123, 52, 42,
+ 40, 86, 56, 39, 38, 36, 50, 87, 57, 94,
+ 99, 66, 37, 43, 49, 67, 85, 65, 51, 44,
+ 45, 46, 52, 53, 86, 47, 56, 48, 58, 50,
+
+ 87, 57, 94, 54, 99, 66, 55, 43, 59, 67,
+ 65, 60, 44, 45, 46, 68, 100, 53, 47, 61,
+ 48, 112, 58, 62, 42, 69, 54, 70, 40, 55,
+ 72, 59, 39, 63, 60, 73, 38, 71, 74, 68,
+ 100, 75, 36, 61, 76, 112, 97, 62, 69, 261,
+ 77, 70, 78, 90, 72, 81, 63, 98, 73, 88,
+ 71, 74, 79, 91, 75, 82, 89, 76, 80, 97,
+ 83, 84, 95, 77, 101, 92, 78, 90, 102, 81,
+ 98, 103, 261, 88, 105, 79, 91, 106, 82, 93,
+ 89, 80, 96, 83, 84, 107, 95, 101, 104, 92,
+
+ 108, 102, 115, 109, 121, 103, 113, 105, 110, 114,
+ 106, 116, 93, 117, 111, 96, 118, 119, 107, 120,
+ 122, 104, 124, 108, 125, 115, 126, 109, 121, 113,
+ 127, 110, 114, 132, 116, 133, 117, 111, 130, 118,
+ 119, 136, 120, 122, 128, 124, 139, 142, 125, 126,
+ 143, 129, 137, 127, 131, 144, 140, 132, 133, 134,
+ 141, 135, 130, 145, 136, 149, 138, 128, 150, 139,
+ 151, 142, 152, 143, 129, 146, 137, 131, 153, 144,
+ 140, 154, 155, 134, 141, 135, 156, 145, 149, 138,
+ 147, 158, 150, 148, 151, 152, 159, 261, 160, 146,
+
+ 161, 153, 162, 163, 167, 154, 155, 164, 165, 156,
+ 166, 168, 170, 147, 158, 169, 148, 171, 173, 174,
+ 159, 160, 175, 161, 73, 176, 162, 163, 167, 177,
+ 164, 165, 178, 166, 179, 168, 170, 180, 169, 181,
+ 171, 182, 173, 174, 183, 184, 175, 73, 185, 176,
+ 186, 187, 177, 188, 189, 190, 178, 179, 191, 192,
+ 193, 180, 181, 194, 195, 182, 196, 198, 183, 184,
+ 197, 185, 199, 186, 200, 187, 188, 189, 190, 201,
+ 202, 191, 192, 203, 193, 204, 194, 195, 205, 207,
+ 196, 198, 206, 197, 208, 199, 209, 210, 200, 211,
+
+ 261, 212, 213, 201, 202, 214, 215, 203, 216, 204,
+ 217, 218, 205, 207, 219, 206, 220, 208, 221, 209,
+ 222, 210, 223, 211, 212, 224, 213, 225, 214, 226,
+ 215, 216, 227, 217, 218, 228, 229, 219, 230, 220,
+ 231, 232, 221, 222, 233, 223, 234, 235, 224, 237,
+ 238, 225, 226, 239, 240, 241, 227, 242, 228, 229,
+ 243, 230, 244, 231, 232, 245, 249, 233, 246, 234,
+ 247, 248, 250, 237, 238, 236, 239, 240, 251, 241,
+ 242, 252, 253, 243, 254, 255, 244, 256, 257, 245,
+ 249, 246, 258, 247, 248, 250, 259, 260, 236, 261,
+
+ 261, 261, 251, 261, 252, 261, 253, 261, 254, 255,
+ 256, 257, 261, 261, 261, 258, 261, 261, 261, 259,
+ 261, 260, 3, 261, 261, 261, 261, 261, 261, 261,
+ 261, 261, 261, 261, 261, 261, 261, 261, 261, 261,
+ 261, 261, 261, 261, 261, 261, 261, 261, 261, 261,
+ 261, 261, 261, 261, 261, 261, 261, 261, 261, 261,
+ 261, 261, 261, 261, 261, 261, 261, 261, 261, 261,
+ 261, 261, 261, 261, 261, 261, 261, 261, 261, 261,
+ 261, 261
+ } ;
+
+static yyconst flex_int16_t yy_chk[583] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 7,
+ 16, 23, 31, 262, 17, 119, 101, 72, 17, 42,
+ 40, 32, 20, 39, 38, 36, 16, 33, 20, 44,
+ 49, 24, 7, 15, 16, 24, 31, 23, 17, 15,
+ 15, 15, 17, 18, 32, 15, 20, 15, 21, 16,
+
+ 33, 20, 44, 18, 49, 24, 18, 15, 21, 24,
+ 23, 21, 15, 15, 15, 25, 50, 18, 15, 22,
+ 15, 60, 21, 22, 14, 25, 18, 26, 11, 18,
+ 27, 21, 10, 22, 21, 27, 9, 26, 27, 25,
+ 50, 28, 6, 22, 28, 60, 47, 22, 25, 3,
+ 28, 26, 29, 35, 27, 30, 22, 48, 27, 34,
+ 26, 27, 29, 35, 28, 30, 34, 28, 29, 47,
+ 30, 30, 46, 28, 51, 43, 29, 35, 52, 30,
+ 48, 53, 0, 34, 55, 29, 35, 56, 30, 43,
+ 34, 29, 46, 30, 30, 57, 46, 51, 53, 43,
+
+ 58, 52, 62, 59, 70, 53, 61, 55, 59, 61,
+ 56, 63, 43, 64, 59, 46, 66, 67, 57, 69,
+ 71, 53, 73, 58, 75, 62, 76, 59, 70, 61,
+ 76, 59, 61, 79, 63, 80, 64, 59, 78, 66,
+ 67, 82, 69, 71, 77, 73, 84, 86, 75, 76,
+ 87, 77, 83, 76, 78, 88, 85, 79, 80, 81,
+ 85, 81, 78, 89, 82, 91, 83, 77, 92, 84,
+ 93, 86, 94, 87, 77, 90, 83, 78, 97, 88,
+ 85, 98, 99, 81, 85, 81, 100, 89, 91, 83,
+ 90, 102, 92, 90, 93, 94, 103, 0, 104, 90,
+
+ 105, 97, 106, 107, 112, 98, 99, 108, 109, 100,
+ 110, 114, 116, 90, 102, 115, 90, 118, 120, 121,
+ 103, 104, 123, 105, 124, 125, 106, 107, 112, 126,
+ 108, 109, 127, 110, 128, 114, 116, 130, 115, 131,
+ 118, 132, 120, 121, 133, 136, 123, 124, 137, 125,
+ 138, 139, 126, 140, 142, 143, 127, 128, 144, 145,
+ 146, 130, 131, 150, 151, 132, 154, 156, 133, 136,
+ 155, 137, 157, 138, 158, 139, 140, 142, 143, 160,
+ 163, 144, 145, 164, 146, 165, 150, 151, 166, 171,
+ 154, 156, 167, 155, 172, 157, 175, 176, 158, 177,
+
+ 0, 178, 179, 160, 163, 180, 181, 164, 182, 165,
+ 185, 188, 166, 171, 189, 167, 190, 172, 192, 175,
+ 194, 176, 196, 177, 178, 197, 179, 198, 180, 200,
+ 181, 182, 201, 185, 188, 203, 207, 189, 209, 190,
+ 211, 213, 192, 194, 215, 196, 217, 218, 197, 222,
+ 223, 198, 200, 225, 227, 228, 201, 230, 203, 207,
+ 231, 209, 232, 211, 213, 233, 239, 215, 235, 217,
+ 237, 238, 242, 222, 223, 218, 225, 227, 243, 228,
+ 230, 246, 247, 231, 248, 250, 232, 251, 252, 233,
+ 239, 235, 253, 237, 238, 242, 256, 258, 218, 0,
+
+ 0, 0, 243, 0, 246, 0, 247, 0, 248, 250,
+ 251, 252, 0, 0, 0, 253, 0, 0, 0, 256,
+ 0, 258, 261, 261, 261, 261, 261, 261, 261, 261,
+ 261, 261, 261, 261, 261, 261, 261, 261, 261, 261,
+ 261, 261, 261, 261, 261, 261, 261, 261, 261, 261,
+ 261, 261, 261, 261, 261, 261, 261, 261, 261, 261,
+ 261, 261, 261, 261, 261, 261, 261, 261, 261, 261,
+ 261, 261, 261, 261, 261, 261, 261, 261, 261, 261,
+ 261, 261
+ } ;
+
+/* Table of booleans, true if rule could match eol. */
+static yyconst flex_int32_t yy_rule_can_match_eol[86] =
+ { 0,
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, };
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+extern int chat__flex_debug;
+int chat__flex_debug = 0;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *chat_text;
+#line 1 "chat_lexer.lpp"
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2006-2008 Roman
+ Copyright (C) 2006-2012 Warzone 2100 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
+*/
+#line 21 "chat_lexer.lpp"
+/** @file
+ *
+ * Lexical analyser for multiplayer chat messages.
+ */
+
+#include "lib/framework/frame.h"
+
+// FIXME: #include from src/
+#include "src/scriptfuncs.h"
+
+#include "lib/script/script.h"
+#include "lib/script/chat_processing.h"
+
+/* Get the Yacc definitions */
+#include "chat_parser.h"
+
+// fwrite declared with warn_unused_result, resulting in mysterious errors in "%%" on some distros.
+static inline bool no_warn_unused_result(int ignore) { if (ignore) {} return true; }
+#define fwrite(a, b, c, d) no_warn_unused_result(fwrite(a, b, c, d))
+
+/* Maximum length for any TEXT value */
+#ifndef YYLMAX
+#define YYLMAX 255
+#endif
+
+#if defined(YY_FLEX_SUBMINOR_VERSION) && YY_FLEX_SUBMINOR_VERSION == 33
+extern int chat_get_lineno(void);
+extern FILE *chat_get_in(void);
+extern FILE *chat_get_out(void);
+extern int chat_get_leng(void);
+extern char *chat_get_text(void);
+extern void chat_set_lineno(int line_number);
+extern void chat_set_in(FILE* in_str);
+extern void chat_set_out(FILE* out_str);
+extern int chat_get_debug(void);
+extern void chat_set_debug(int bdebug);
+extern int chat_lex_destroy(void);
+#endif
+
+/* Pointer to the input buffer */
+static const char *pInputBuffer = NULL;
+static const char *pEndBuffer = NULL;
+
+static SDWORD playerIndex;
+
+#undef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if (pInputBuffer != pEndBuffer) { \
+ buf[0] = *(pInputBuffer++); result = 1; \
+ } else { \
+ buf[0] = EOF; result = YY_NULL; \
+ }
+
+#undef chat_getc
+#define chat_getc() (pInputBuffer != pEndBuffer ? *(pInputBuffer++) : EOF)
+
+#line 795 "chat_lexer.cpp"
+
+#define INITIAL 0
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#include
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+static int yy_init_globals (void );
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int chat_lex_destroy (void );
+
+int chat_get_debug (void );
+
+void chat_set_debug (int debug_flag );
+
+YY_EXTRA_TYPE chat_get_extra (void );
+
+void chat_set_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *chat_get_in (void );
+
+void chat_set_in (FILE * in_str );
+
+FILE *chat_get_out (void );
+
+void chat_set_out (FILE * out_str );
+
+int chat_get_leng (void );
+
+char *chat_get_text (void );
+
+int chat_get_lineno (void );
+
+void chat_set_lineno (int line_number );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int chat_wrap (void );
+#else
+extern int chat_wrap (void );
+#endif
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int );
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * );
+#endif
+
+#ifndef YY_NO_INPUT
+
+#ifdef __cplusplus
+static int yyinput (void );
+#else
+static int input (void );
+#endif
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
+#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO do { if (fwrite( chat_text, chat_leng, 1, chat_out )) {} } while (0)
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ { \
+ int c = '*'; \
+ size_t n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( chat_in )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( chat_in ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else \
+ { \
+ errno=0; \
+ while ( (result = fread(buf, 1, max_size, chat_in))==0 && ferror(chat_in)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(chat_in); \
+ } \
+ }\
+\
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* end tables serialization structures and prototypes */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int chat_lex (void);
+
+#define YY_DECL int chat_lex (void)
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after chat_text and chat_leng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+ YY_USER_ACTION
+
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp, *yy_bp;
+ register int yy_act;
+
+#line 89 "chat_lexer.lpp"
+
+
+ /* Match integer numbers */
+#line 984 "chat_lexer.cpp"
+
+ if ( !(yy_init) )
+ {
+ (yy_init) = 1;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! (yy_start) )
+ (yy_start) = 1; /* first start state */
+
+ if ( ! chat_in )
+ chat_in = stdin;
+
+ if ( ! chat_out )
+ chat_out = stdout;
+
+ if ( ! YY_CURRENT_BUFFER ) {
+ chat_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ chat__create_buffer(chat_in,YY_BUF_SIZE );
+ }
+
+ chat__load_buffer_state( );
+ }
+
+ while ( 1 ) /* loops until end-of-file is reached */
+ {
+ yy_cp = (yy_c_buf_p);
+
+ /* Support of chat_text. */
+ *yy_cp = (yy_hold_char);
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+ yy_current_state = (yy_start);
+yy_match:
+ do
+ {
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 262 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ ++yy_cp;
+ }
+ while ( yy_current_state != 261 );
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+
+yy_find_action:
+ yy_act = yy_accept[yy_current_state];
+
+ YY_DO_BEFORE_ACTION;
+
+ if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
+ {
+ int yyl;
+ for ( yyl = 0; yyl < chat_leng; ++yyl )
+ if ( chat_text[yyl] == '\n' )
+
+ chat_lineno++;
+;
+ }
+
+do_action: /* This label is used only to access EOF actions. */
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = (yy_hold_char);
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 92 "chat_lexer.lpp"
+{ chat_lval.ival = atol(chat_text); return R_INTEGER; }
+ YY_BREAK
+/* Keywords - Terminals */
+case 2:
+YY_RULE_SETUP
+#line 95 "chat_lexer.lpp"
+{ return R_POSSESSION; }
+ YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 96 "chat_lexer.lpp"
+{ return _T_QM; }
+ YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 97 "chat_lexer.lpp"
+{ return _T_EM; }
+ YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 98 "chat_lexer.lpp"
+{ return _T_FULLSTOP; }
+ YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 99 "chat_lexer.lpp"
+{ return _T_COLON; };
+ YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 100 "chat_lexer.lpp"
+{ return _T_SEMICOLON; };
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 101 "chat_lexer.lpp"
+{ return _T_COMMA; };
+ YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 102 "chat_lexer.lpp"
+{ return _T_A; }
+ YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 103 "chat_lexer.lpp"
+{ return _T_AFFIRMATIVE; }
+ YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 104 "chat_lexer.lpp"
+{ return _T_AFTER; }
+ YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 105 "chat_lexer.lpp"
+{ return _T_ALLY; }
+ YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 106 "chat_lexer.lpp"
+{ return _T_AM; }
+ YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 107 "chat_lexer.lpp"
+{ return _T_AN; }
+ YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 108 "chat_lexer.lpp"
+{ return _T_AND; }
+ YY_BREAK
+case 16:
+YY_RULE_SETUP
+#line 109 "chat_lexer.lpp"
+{ return _T_ANY; }
+ YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 110 "chat_lexer.lpp"
+{ return _T_ATTACK; }
+ YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 111 "chat_lexer.lpp"
+{ return _T_ATTACKING; }
+ YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 112 "chat_lexer.lpp"
+{ return _T_ARMY; }
+ YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 113 "chat_lexer.lpp"
+{ return _T_BEACON; }
+ YY_BREAK
+case 21:
+YY_RULE_SETUP
+#line 114 "chat_lexer.lpp"
+{ return _T_BUILDING; }
+ YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 115 "chat_lexer.lpp"
+{ return _T_CANT; }
+ YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 116 "chat_lexer.lpp"
+{ return _T_CENTER; }
+ YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 117 "chat_lexer.lpp"
+{ return _T_DEAD; }
+ YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 118 "chat_lexer.lpp"
+{ return _T_DERRICK; }
+ YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 119 "chat_lexer.lpp"
+{ return _T_DO; }
+ YY_BREAK
+case 27:
+YY_RULE_SETUP
+#line 120 "chat_lexer.lpp"
+{ return _T_DROP; }
+ YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 121 "chat_lexer.lpp"
+{ return _T_FINE; }
+ YY_BREAK
+case 29:
+YY_RULE_SETUP
+#line 122 "chat_lexer.lpp"
+{ return _T_FOR; }
+ YY_BREAK
+case 30:
+YY_RULE_SETUP
+#line 123 "chat_lexer.lpp"
+{ return _T_FORCE; }
+ YY_BREAK
+case 31:
+YY_RULE_SETUP
+#line 124 "chat_lexer.lpp"
+{ return _T_GET; }
+ YY_BREAK
+case 32:
+YY_RULE_SETUP
+#line 125 "chat_lexer.lpp"
+{ return _T_GETTING; }
+ YY_BREAK
+case 33:
+YY_RULE_SETUP
+#line 126 "chat_lexer.lpp"
+{ return _T_GO; }
+ YY_BREAK
+case 34:
+YY_RULE_SETUP
+#line 127 "chat_lexer.lpp"
+{ return _T_GOING; }
+ YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 128 "chat_lexer.lpp"
+{ return _T_GONNA; }
+ YY_BREAK
+case 36:
+YY_RULE_SETUP
+#line 129 "chat_lexer.lpp"
+{ return _T_GOT; }
+ YY_BREAK
+case 37:
+YY_RULE_SETUP
+#line 130 "chat_lexer.lpp"
+{ return _T_GREAT; }
+ YY_BREAK
+case 38:
+YY_RULE_SETUP
+#line 131 "chat_lexer.lpp"
+{ return _T_HAVE; }
+ YY_BREAK
+case 39:
+YY_RULE_SETUP
+#line 132 "chat_lexer.lpp"
+{ return _T_HAS; }
+ YY_BREAK
+case 40:
+YY_RULE_SETUP
+#line 133 "chat_lexer.lpp"
+{ return _T_HELP; }
+ YY_BREAK
+case 41:
+YY_RULE_SETUP
+#line 134 "chat_lexer.lpp"
+{ return _T_HOLD; }
+ YY_BREAK
+case 42:
+YY_RULE_SETUP
+#line 135 "chat_lexer.lpp"
+{ return _T_I; }
+ YY_BREAK
+case 43:
+YY_RULE_SETUP
+#line 136 "chat_lexer.lpp"
+{ return _T_IM; }
+ YY_BREAK
+case 44:
+YY_RULE_SETUP
+#line 137 "chat_lexer.lpp"
+{ return _T_IS; }
+ YY_BREAK
+case 45:
+YY_RULE_SETUP
+#line 138 "chat_lexer.lpp"
+{ return _T_LASSAT; }
+ YY_BREAK
+case 46:
+YY_RULE_SETUP
+#line 139 "chat_lexer.lpp"
+{ return _T_LETS; }
+ YY_BREAK
+case 47:
+YY_RULE_SETUP
+#line 140 "chat_lexer.lpp"
+{ return _T_ME; }
+ YY_BREAK
+case 48:
+YY_RULE_SETUP
+#line 141 "chat_lexer.lpp"
+{ return _T_MORE; }
+ YY_BREAK
+case 49:
+YY_RULE_SETUP
+#line 142 "chat_lexer.lpp"
+{ return _T_NEED; }
+ YY_BREAK
+case 50:
+YY_RULE_SETUP
+#line 143 "chat_lexer.lpp"
+{ return _T_NO; }
+ YY_BREAK
+case 51:
+YY_RULE_SETUP
+#line 144 "chat_lexer.lpp"
+{ return _T_NOW; }
+ YY_BREAK
+case 52:
+YY_RULE_SETUP
+#line 145 "chat_lexer.lpp"
+{ return _T_OFCOURSE; }
+ YY_BREAK
+case 53:
+YY_RULE_SETUP
+#line 146 "chat_lexer.lpp"
+{ return _T_OK; }
+ YY_BREAK
+case 54:
+YY_RULE_SETUP
+#line 147 "chat_lexer.lpp"
+{ return _T_ON; }
+ YY_BREAK
+case 55:
+YY_RULE_SETUP
+#line 148 "chat_lexer.lpp"
+{ return _T_PLACE; }
+ YY_BREAK
+case 56:
+YY_RULE_SETUP
+#line 149 "chat_lexer.lpp"
+{ return _T_POSSESSION; }
+ YY_BREAK
+case 57:
+YY_RULE_SETUP
+#line 150 "chat_lexer.lpp"
+{ return _T_POWER; }
+ YY_BREAK
+case 58:
+YY_RULE_SETUP
+#line 151 "chat_lexer.lpp"
+{ return _T_PUMPING; }
+ YY_BREAK
+case 59:
+YY_RULE_SETUP
+#line 152 "chat_lexer.lpp"
+{ return _T_PUT; }
+ YY_BREAK
+case 60:
+YY_RULE_SETUP
+#line 153 "chat_lexer.lpp"
+{ return _T_READY; }
+ YY_BREAK
+case 61:
+YY_RULE_SETUP
+#line 154 "chat_lexer.lpp"
+{ return _T_REQUIRE; }
+ YY_BREAK
+case 62:
+YY_RULE_SETUP
+#line 155 "chat_lexer.lpp"
+{ return _T_ROGER; }
+ YY_BREAK
+case 63:
+YY_RULE_SETUP
+#line 156 "chat_lexer.lpp"
+{ return _T_RUSH; }
+ YY_BREAK
+case 64:
+YY_RULE_SETUP
+#line 157 "chat_lexer.lpp"
+{ return _T_SEC; }
+ YY_BREAK
+case 65:
+YY_RULE_SETUP
+#line 158 "chat_lexer.lpp"
+{ return _T_SEE; }
+ YY_BREAK
+case 66:
+YY_RULE_SETUP
+#line 159 "chat_lexer.lpp"
+{ return _T_SOME; }
+ YY_BREAK
+case 67:
+YY_RULE_SETUP
+#line 160 "chat_lexer.lpp"
+{ return _T_STATUS; }
+ YY_BREAK
+case 68:
+YY_RULE_SETUP
+#line 161 "chat_lexer.lpp"
+{ return _T_STOP; }
+ YY_BREAK
+case 69:
+YY_RULE_SETUP
+#line 162 "chat_lexer.lpp"
+{ return _T_SURE; }
+ YY_BREAK
+case 70:
+YY_RULE_SETUP
+#line 163 "chat_lexer.lpp"
+{ return _T_THANK_YOU; }
+ YY_BREAK
+case 71:
+YY_RULE_SETUP
+#line 164 "chat_lexer.lpp"
+{ return _T_THANKS; }
+ YY_BREAK
+case 72:
+YY_RULE_SETUP
+#line 165 "chat_lexer.lpp"
+{ return _T_THE; }
+ YY_BREAK
+case 73:
+YY_RULE_SETUP
+#line 166 "chat_lexer.lpp"
+{ return _T_U; }
+ YY_BREAK
+case 74:
+YY_RULE_SETUP
+#line 167 "chat_lexer.lpp"
+{ return _T_UNITS; }
+ YY_BREAK
+case 75:
+YY_RULE_SETUP
+#line 168 "chat_lexer.lpp"
+{ return _T_VTOLS; }
+ YY_BREAK
+case 76:
+YY_RULE_SETUP
+#line 169 "chat_lexer.lpp"
+{ return _T_WAIT; }
+ YY_BREAK
+case 77:
+YY_RULE_SETUP
+#line 170 "chat_lexer.lpp"
+{ return _T_WHERE; }
+ YY_BREAK
+case 78:
+YY_RULE_SETUP
+#line 171 "chat_lexer.lpp"
+{ return _T_YES; }
+ YY_BREAK
+case 79:
+YY_RULE_SETUP
+#line 172 "chat_lexer.lpp"
+{ return _T_YES; }
+ YY_BREAK
+case 80:
+YY_RULE_SETUP
+#line 173 "chat_lexer.lpp"
+{ return _T_YES; }
+ YY_BREAK
+case 81:
+YY_RULE_SETUP
+#line 174 "chat_lexer.lpp"
+{ return _T_YES; }
+ YY_BREAK
+case 82:
+YY_RULE_SETUP
+#line 175 "chat_lexer.lpp"
+{ return _T_YOU; }
+ YY_BREAK
+/* <> { return _T_EOF; } */
+case 83:
+YY_RULE_SETUP
+#line 179 "chat_lexer.lpp"
+{
+ playerIndex = getPlayerFromString(chat_text);
+
+ if(playerIndex >= 0)
+ {
+ //console( "matched 'player'");
+ chat_lval.ival = playerIndex;
+
+ return R_PLAYER;
+ }
+
+ }
+ YY_BREAK
+/* [^ \t\n\<\>\[\]\(\)]+ { return T_WORD; } */
+/* [^ \t\n]+ { console( "matched 'T_WORD'"); return T_WORD; } */
+/* Skip white space */
+case 84:
+/* rule 84 can match eol */
+YY_RULE_SETUP
+#line 197 "chat_lexer.lpp"
+;
+ YY_BREAK
+/* Match anything that's been missed and pass it as a char */
+/* . {console( "matched 'anything else '%s'", chat_text[0]); return chat_text[0];} */
+case 85:
+YY_RULE_SETUP
+#line 203 "chat_lexer.lpp"
+ECHO;
+ YY_BREAK
+#line 1517 "chat_lexer.cpp"
+case YY_STATE_EOF(INITIAL):
+ yyterminate();
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = (yy_hold_char);
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed chat_in at a new source and called
+ * chat_lex(). If so, then we have to assure
+ * consistency between YY_CURRENT_BUFFER and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = chat_in;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++(yy_c_buf_p);
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ (yy_did_buffer_switch_on_eof) = 0;
+
+ if ( chat_wrap( ) )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * chat_text, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) =
+ (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ (yy_c_buf_p) =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+} /* end of chat_lex */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+static int yy_get_next_buffer (void)
+{
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ register char *source = (yytext_ptr);
+ register int number_to_move, i;
+ int ret_val;
+
+ if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
+
+ else
+ {
+ int num_to_read =
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+
+ int yy_c_buf_p_offset =
+ (int) ((yy_c_buf_p) - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ chat_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = 0;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+ number_to_move - 1;
+
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+ (yy_n_chars), (size_t) num_to_read );
+
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ if ( (yy_n_chars) == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ chat_restart(chat_in );
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) chat_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
+ (yy_n_chars) += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
+
+ (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+ return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+ static yy_state_type yy_get_previous_state (void)
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp;
+
+ yy_current_state = (yy_start);
+
+ for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
+ {
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 262 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ }
+
+ return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
+{
+ register int yy_is_jam;
+ register char *yy_cp = (yy_c_buf_p);
+
+ register YY_CHAR yy_c = 1;
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 262 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_is_jam = (yy_current_state == 261);
+
+ return yy_is_jam ? 0 : yy_current_state;
+}
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+ static int yyinput (void)
+#else
+ static int input (void)
+#endif
+
+{
+ int c;
+
+ *(yy_c_buf_p) = (yy_hold_char);
+
+ if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ /* This was really a NUL. */
+ *(yy_c_buf_p) = '\0';
+
+ else
+ { /* need more input */
+ int offset = (yy_c_buf_p) - (yytext_ptr);
+ ++(yy_c_buf_p);
+
+ switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ chat_restart(chat_in );
+
+ /*FALLTHROUGH*/
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( chat_wrap( ) )
+ return EOF;
+
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput();
+#else
+ return input();
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) = (yytext_ptr) + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
+ *(yy_c_buf_p) = '\0'; /* preserve chat_text */
+ (yy_hold_char) = *++(yy_c_buf_p);
+
+ if ( c == '\n' )
+
+ chat_lineno++;
+;
+
+ return c;
+}
+#endif /* ifndef YY_NO_INPUT */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ *
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+ void chat_restart (FILE * input_file )
+{
+
+ if ( ! YY_CURRENT_BUFFER ){
+ chat_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ chat__create_buffer(chat_in,YY_BUF_SIZE );
+ }
+
+ chat__init_buffer(YY_CURRENT_BUFFER,input_file );
+ chat__load_buffer_state( );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ *
+ */
+ void chat__switch_to_buffer (YY_BUFFER_STATE new_buffer )
+{
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * chat_pop_buffer_state();
+ * chat_push_buffer_state(new_buffer);
+ */
+ chat_ensure_buffer_stack ();
+ if ( YY_CURRENT_BUFFER == new_buffer )
+ return;
+
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ chat__load_buffer_state( );
+
+ /* We don't actually know whether we did this switch during
+ * EOF (chat_wrap()) processing, but the only time this flag
+ * is looked at is after chat_wrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+static void chat__load_buffer_state (void)
+{
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ chat_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ (yy_hold_char) = *(yy_c_buf_p);
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ *
+ * @return the allocated buffer state.
+ */
+ YY_BUFFER_STATE chat__create_buffer (FILE * file, int size )
+{
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) chat_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in chat__create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) chat_alloc(b->yy_buf_size + 2 );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in chat__create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ chat__init_buffer(b,file );
+
+ return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with chat__create_buffer()
+ *
+ */
+ void chat__delete_buffer (YY_BUFFER_STATE b )
+{
+
+ if ( ! b )
+ return;
+
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ chat_free((void *) b->yy_ch_buf );
+
+ chat_free((void *) b );
+}
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a chat_restart() or at EOF.
+ */
+ static void chat__init_buffer (YY_BUFFER_STATE b, FILE * file )
+
+{
+ int oerrno = errno;
+
+ chat__flush_buffer(b );
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+ /* If b is the current buffer, then chat__init_buffer was _probably_
+ * called from chat_restart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
+
+ b->yy_is_interactive = 0;
+
+ errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ *
+ */
+ void chat__flush_buffer (YY_BUFFER_STATE b )
+{
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == YY_CURRENT_BUFFER )
+ chat__load_buffer_state( );
+}
+
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ *
+ */
+void chat_push_buffer_state (YY_BUFFER_STATE new_buffer )
+{
+ if (new_buffer == NULL)
+ return;
+
+ chat_ensure_buffer_stack();
+
+ /* This block is copied from chat__switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ (yy_buffer_stack_top)++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from chat__switch_to_buffer. */
+ chat__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ *
+ */
+void chat_pop_buffer_state (void)
+{
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ chat__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if ((yy_buffer_stack_top) > 0)
+ --(yy_buffer_stack_top);
+
+ if (YY_CURRENT_BUFFER) {
+ chat__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+ }
+}
+
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+static void chat_ensure_buffer_stack (void)
+{
+ int num_to_alloc;
+
+ if (!(yy_buffer_stack)) {
+
+ /* First allocation is just for 2 elements, since we don't know if this
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
+ * immediate realloc on the next call.
+ */
+ num_to_alloc = 1;
+ (yy_buffer_stack) = (struct yy_buffer_state**)chat_alloc
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in chat_ensure_buffer_stack()" );
+
+ memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+
+ (yy_buffer_stack_max) = num_to_alloc;
+ (yy_buffer_stack_top) = 0;
+ return;
+ }
+
+ if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+
+ /* Increase the buffer to prepare for a possible push. */
+ int grow_size = 8 /* arbitrary grow size */;
+
+ num_to_alloc = (yy_buffer_stack_max) + grow_size;
+ (yy_buffer_stack) = (struct yy_buffer_state**)chat_realloc
+ ((yy_buffer_stack),
+ num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in chat_ensure_buffer_stack()" );
+
+ /* zero only the new slots.*/
+ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+ (yy_buffer_stack_max) = num_to_alloc;
+ }
+}
+
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE chat__scan_buffer (char * base, yy_size_t size )
+{
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return 0;
+
+ b = (YY_BUFFER_STATE) chat_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in chat__scan_buffer()" );
+
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = 0;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ chat__switch_to_buffer(b );
+
+ return b;
+}
+
+/** Setup the input buffer state to scan a string. The next call to chat_lex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ *
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * chat__scan_bytes() instead.
+ */
+YY_BUFFER_STATE chat__scan_string (yyconst char * yystr )
+{
+
+ return chat__scan_bytes(yystr,strlen(yystr) );
+}
+
+/** Setup the input buffer state to scan the given bytes. The next call to chat_lex() will
+ * scan from a @e copy of @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE chat__scan_bytes (yyconst char * yybytes, int _yybytes_len )
+{
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = _yybytes_len + 2;
+ buf = (char *) chat_alloc(n );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in chat__scan_bytes()" );
+
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
+
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = chat__scan_buffer(buf,n );
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in chat__scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+}
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+static void yy_fatal_error (yyconst char* msg )
+{
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+}
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up chat_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ chat_text[chat_leng] = (yy_hold_char); \
+ (yy_c_buf_p) = chat_text + yyless_macro_arg; \
+ (yy_hold_char) = *(yy_c_buf_p); \
+ *(yy_c_buf_p) = '\0'; \
+ chat_leng = yyless_macro_arg; \
+ } \
+ while ( 0 )
+
+/* Accessor methods (get/set functions) to struct members. */
+
+/** Get the current line number.
+ *
+ */
+int chat_get_lineno (void)
+{
+
+ return chat_lineno;
+}
+
+/** Get the input stream.
+ *
+ */
+FILE *chat_get_in (void)
+{
+ return chat_in;
+}
+
+/** Get the output stream.
+ *
+ */
+FILE *chat_get_out (void)
+{
+ return chat_out;
+}
+
+/** Get the length of the current token.
+ *
+ */
+int chat_get_leng (void)
+{
+ return chat_leng;
+}
+
+/** Get the current token.
+ *
+ */
+
+char *chat_get_text (void)
+{
+ return chat_text;
+}
+
+/** Set the current line number.
+ * @param line_number
+ *
+ */
+void chat_set_lineno (int line_number )
+{
+
+ chat_lineno = line_number;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ *
+ * @see chat__switch_to_buffer
+ */
+void chat_set_in (FILE * in_str )
+{
+ chat_in = in_str ;
+}
+
+void chat_set_out (FILE * out_str )
+{
+ chat_out = out_str ;
+}
+
+int chat_get_debug (void)
+{
+ return chat__flex_debug;
+}
+
+void chat_set_debug (int bdebug )
+{
+ chat__flex_debug = bdebug ;
+}
+
+static int yy_init_globals (void)
+{
+ /* Initialization is the same as for the non-reentrant scanner.
+ * This function is called from chat_lex_destroy(), so don't allocate here.
+ */
+
+ /* We do not touch chat_lineno unless the option is enabled. */
+ chat_lineno = 1;
+
+ (yy_buffer_stack) = 0;
+ (yy_buffer_stack_top) = 0;
+ (yy_buffer_stack_max) = 0;
+ (yy_c_buf_p) = (char *) 0;
+ (yy_init) = 0;
+ (yy_start) = 0;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ chat_in = stdin;
+ chat_out = stdout;
+#else
+ chat_in = (FILE *) 0;
+ chat_out = (FILE *) 0;
+#endif
+
+ /* For future reference: Set errno on error, since we are called by
+ * chat_lex_init()
+ */
+ return 0;
+}
+
+/* chat_lex_destroy is for both reentrant and non-reentrant scanners. */
+int chat_lex_destroy (void)
+{
+
+ /* Pop the buffer stack, destroying each element. */
+ while(YY_CURRENT_BUFFER){
+ chat__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ chat_pop_buffer_state();
+ }
+
+ /* Destroy the stack itself. */
+ chat_free((yy_buffer_stack) );
+ (yy_buffer_stack) = NULL;
+
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * chat_lex() is called, initialization will occur. */
+ yy_init_globals( );
+
+ return 0;
+}
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+{
+ register int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * s )
+{
+ register int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+}
+#endif
+
+void *chat_alloc (yy_size_t size )
+{
+ return (void *) malloc( size );
+}
+
+void *chat_realloc (void * ptr, yy_size_t size )
+{
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return (void *) realloc( (char *) ptr, size );
+}
+
+void chat_free (void * ptr )
+{
+ free( (char *) ptr ); /* see chat_realloc() for (char *) cast */
+}
+
+#define YYTABLES_NAME "yytables"
+
+#line 203 "chat_lexer.lpp"
+
+
+
+/* Set the current input buffer for the lexer */
+void chatSetInputBuffer(char *pBuffer, UDWORD size)
+{
+ pInputBuffer = pBuffer;
+ pEndBuffer = pBuffer + size;
+
+ /* Reset the lexer in case it's been used before */
+ chat__flush_buffer(YY_CURRENT_BUFFER);
+}
+
+void chatGetErrorData(int *pLine, char **ppText)
+{
+ *pLine = chat_lineno;
+ *ppText = chat_text;
+}
+
+int chat_wrap(void)
+{
+ return 1;
+}
+
+
+/* Older GNU Flex versions don't define chat_lex_destroy()
+ * (and neither define a subminor version)
+ */
+#if !defined(YY_FLEX_SUBMINOR_VERSION) || (YY_FLEX_SUBMINOR_VERSION < 9)
+int chat_lex_destroy(void)
+{
+ /* For non-reentrant C scanner only. */
+ chat__delete_buffer(YY_CURRENT_BUFFER);
+ yy_init = 1;
+ return 0;
+}
+#endif
+
diff --git a/lib/script/chat_parser.cpp b/lib/script/chat_parser.cpp
new file mode 100644
index 000000000..c4c40ea35
--- /dev/null
+++ b/lib/script/chat_parser.cpp
@@ -0,0 +1,2604 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "2.5"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 0
+
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+/* Substitute the variable and function names. */
+#define yyparse chat_parse
+#define yylex chat_lex
+#define yyerror chat_error
+#define yylval chat_lval
+#define yychar chat_char
+#define yydebug chat_debug
+#define yynerrs chat_nerrs
+
+
+/* Copy the first part of user declarations. */
+
+/* Line 268 of yacc.c */
+#line 21 "chat_parser.ypp"
+
+/*
+ * chat_parser.y
+ *
+ * yacc grammar for multiplayer chat messages
+ *
+ */
+#include "lib/framework/frame.h"
+#include "lib/framework/string_ext.h"
+
+#include "lib/framework/frameresource.h"
+#include "lib/script/chat_processing.h"
+
+#define MAX_CHAT_ARGUMENTS 10
+
+/* Holds information about a processed player chat message */
+CHAT_MSG chat_msg;
+
+// Parameter variable
+static INTERP_VAL scrParameter;
+
+extern int chat_lex(void);
+
+// Store extracted command for use in scripts
+static void chat_store_command(const char *command);
+
+/* Return value of the chat parsing - to be used in scripts */
+static bool chat_store_parameter(INTERP_VAL *parameter);
+
+// Store players that were addressed in a command
+static void chat_store_player(SDWORD cmdIndex, SDWORD playerIndex);
+
+// Reset a command
+static void chat_reset_command(SDWORD cmdIndex);
+
+// Information extracted from message and available for scripts
+//static int numMsgParams=0; //number of parameters currently extracted/stored
+//static INTERP_VAL msgParams[MAX_CHAT_ARGUMENTS];
+
+/* Store command parameter extracted from the message */
+static bool chat_store_parameter(INTERP_VAL *cmdParam)
+{
+ SDWORD numCmdParams, numCommands;
+
+ //console("chat_store_parameter: new parameter");
+
+ /* Make sure we have no overflow */
+ //if(numMsgParams >= MAX_CHAT_ARGUMENTS)
+ if(chat_msg.numCommands >= MAX_CHAT_COMMANDS)
+ {
+ ASSERT(false, "chat_store_parameter: too many commands in a message");
+ return false;
+ }
+
+ numCommands = chat_msg.numCommands;
+ numCmdParams = chat_msg.cmdData[numCommands].numCmdParams;
+
+ /* Make sure we still have room for more parameters */
+ if(numCmdParams >= MAX_CHAT_CMD_PARAMS)
+ {
+ ASSERT(false, "chat_store_parameter: out of parameters for command %d", numCommands);
+ return false;
+ }
+
+ /* Store parameter for command we are currently processing */
+ //memcpy(&(msgParams[numMsgParams]), parameter, sizeof(INTERP_VAL));
+ memcpy(&(chat_msg.cmdData[numCommands].parameter[numCmdParams]), cmdParam, sizeof(INTERP_VAL));
+
+ chat_msg.cmdData[numCommands].numCmdParams++;
+
+ return true;
+}
+
+// Store extracted command for use in scripts
+static void chat_store_command(const char *command)
+{
+ SDWORD numCmdParams, numCommands;
+
+ //console("chat_store_command: new command: %s", command);
+
+ /* Make sure we have no overflow */
+ if(chat_msg.numCommands >= MAX_CHAT_COMMANDS)
+ {
+ ASSERT(false, "chat_store_command: too many commands in a message");
+ return;
+ }
+
+ numCommands = chat_msg.numCommands;
+ numCmdParams = chat_msg.cmdData[numCommands].numCmdParams;
+
+ /* Make sure we still have room for more parameters */
+ if(numCmdParams >= MAX_CHAT_CMD_PARAMS)
+ {
+ ASSERT(false, "chat_store_command: out of parameters for command %d", numCommands);
+ return;
+ }
+
+ /* Store command */
+ chat_msg.cmdData[numCommands].pCmdDescription = command;
+
+ chat_msg.numCommands++;
+}
+
+// Store players that were addressed in a command
+static void chat_store_player(SDWORD cmdIndex, SDWORD playerIndex)
+{
+ SDWORD i;
+
+ //console("chat_store_player: player %d addressd in command %d", playerIndex, cmdIndex);
+
+ /* Make sure we have no overflow */
+ if(cmdIndex < 0 || cmdIndex >= MAX_CHAT_COMMANDS)
+ {
+ ASSERT(false, "chat_store_player: command message out of bounds: %d", cmdIndex);
+ return;
+ }
+
+ if(playerIndex == -1) //no player specified means all players addressed
+ {
+ /* Ally players addressed */
+ for(i=0; i= 0 && playerIndex < MAX_PLAYERS)
+ {
+ chat_msg.cmdData[cmdIndex].bPlayerAddressed[playerIndex] = true;
+ }
+ else /* Wrong player index */
+ {
+ ASSERT(false, "chat_store_player: wrong player index: %d", playerIndex);
+ return;
+ }
+}
+
+static void chat_reset_command(SDWORD cmdIndex)
+{
+ SDWORD i;
+
+ ASSERT(cmdIndex >= 0 && cmdIndex < MAX_CHAT_COMMANDS,
+ "chat_reset_command: command index out of bounds: %d", cmdIndex);
+
+ chat_msg.cmdData[cmdIndex].numCmdParams = 0;
+
+ for(i=0; i /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if defined YYENABLE_NLS && YYENABLE_NLS
+# if ENABLE_NLS
+# include /* INFRINGES ON USER NAME SPACE */
+# define YY_(msgid) dgettext ("bison-runtime", msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions. */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int yyi)
+#else
+static int
+YYID (yyi)
+ int yyi;
+#endif
+{
+ return yyi;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined EXIT_SUCCESS \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+};
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+# define YYCOPY_NEEDED 1
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (YYID (0))
+
+#endif
+
+#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (YYID (0))
+# endif
+# endif
+#endif /* !YYCOPY_NEEDED */
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 121
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 512
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 89
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 48
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 135
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 207
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 343
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const yytype_uint8 yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+ 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
+ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
+ 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
+ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
+ 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
+ 85, 86, 87, 88
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const yytype_uint16 yyprhs[] =
+{
+ 0, 0, 3, 5, 7, 10, 13, 15, 19, 23,
+ 27, 30, 32, 34, 36, 38, 40, 42, 44, 46,
+ 48, 50, 52, 54, 56, 58, 60, 62, 64, 66,
+ 68, 70, 72, 75, 79, 83, 86, 87, 89, 91,
+ 93, 95, 97, 100, 103, 104, 106, 108, 110, 112,
+ 114, 116, 118, 120, 122, 124, 127, 129, 131, 133,
+ 135, 137, 139, 141, 143, 145, 147, 149, 152, 154,
+ 156, 158, 160, 162, 164, 168, 171, 174, 176, 178,
+ 180, 182, 184, 186, 188, 190, 192, 194, 196, 198,
+ 200, 203, 207, 211, 214, 217, 220, 224, 227, 231,
+ 235, 238, 241, 244, 248, 253, 257, 260, 264, 268,
+ 271, 274, 278, 283, 285, 287, 291, 295, 299, 303,
+ 308, 312, 317, 321, 324, 328, 332, 336, 340, 344,
+ 349, 355, 359, 362, 365, 370
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yytype_int16 yyrhs[] =
+{
+ 90, 0, -1, 91, -1, 92, -1, 90, 91, -1,
+ 90, 92, -1, 1, -1, 93, 13, 92, -1, 93,
+ 14, 92, -1, 93, 15, 92, -1, 93, 92, -1,
+ 116, -1, 117, -1, 118, -1, 119, -1, 120, -1,
+ 121, -1, 123, -1, 124, -1, 125, -1, 126, -1,
+ 128, -1, 129, -1, 130, -1, 131, -1, 132, -1,
+ 133, -1, 134, -1, 135, -1, 136, -1, 115, -1,
+ 87, -1, 93, 87, -1, 93, 15, 87, -1, 93,
+ 22, 87, -1, 87, 9, -1, -1, 16, -1, 21,
+ -1, 79, -1, 10, -1, 11, -1, 96, 10, -1,
+ 96, 11, -1, -1, 0, -1, 12, -1, 11, -1,
+ 97, -1, 10, -1, 97, -1, 98, -1, 96, -1,
+ 25, -1, 41, -1, 41, 18, -1, 24, -1, 38,
+ -1, 66, -1, 34, -1, 62, -1, 65, -1, 39,
+ -1, 28, -1, 86, -1, 80, -1, 105, -1, 33,
+ 105, -1, 45, -1, 43, -1, 46, -1, 43, -1,
+ 23, -1, 73, -1, 106, 107, 109, -1, 106, 107,
+ -1, 107, 109, -1, 107, -1, 109, -1, 76, -1,
+ 59, -1, 85, -1, 35, -1, 60, -1, 112, -1,
+ 111, -1, 69, -1, 17, -1, 56, -1, 68, -1,
+ 70, 100, -1, 53, 70, 100, -1, 19, 54, 100,
+ -1, 19, 100, -1, 40, 10, -1, 67, 100, -1,
+ 50, 67, 100, -1, 40, 98, -1, 103, 95, 27,
+ -1, 40, 30, 100, -1, 74, 100, -1, 95, 37,
+ -1, 95, 26, -1, 104, 81, 98, -1, 104, 55,
+ 81, 98, -1, 104, 122, 98, -1, 75, 98, -1,
+ 110, 64, 99, -1, 47, 54, 100, -1, 47, 100,
+ -1, 49, 126, -1, 114, 47, 100, -1, 114, 109,
+ 47, 100, -1, 77, -1, 78, -1, 50, 60, 98,
+ -1, 50, 35, 98, -1, 128, 58, 98, -1, 128,
+ 127, 98, -1, 128, 15, 127, 98, -1, 127, 128,
+ 98, -1, 127, 15, 128, 98, -1, 127, 127, 98,
+ -1, 113, 98, -1, 129, 113, 98, -1, 19, 87,
+ 98, -1, 102, 87, 98, -1, 40, 87, 98, -1,
+ 101, 87, 98, -1, 87, 108, 82, 98, -1, 42,
+ 102, 94, 32, 98, -1, 52, 87, 98, -1, 83,
+ 98, -1, 71, 98, -1, 83, 36, 54, 98, -1,
+ 48, 61, 98, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const yytype_uint16 yyrline[] =
+{
+ 0, 288, 288, 289, 293, 294, 298, 309, 311, 313,
+ 315, 327, 331, 335, 339, 343, 347, 351, 355, 359,
+ 363, 367, 371, 375, 379, 383, 387, 391, 395, 399,
+ 403, 411, 415, 419, 423, 429, 437, 438, 439, 440,
+ 444, 445, 446, 447, 453, 454, 455, 461, 462, 468,
+ 469, 476, 477, 481, 482, 483, 487, 488, 491, 491,
+ 491, 493, 494, 495, 498, 499, 503, 504, 508, 509,
+ 512, 513, 517, 518, 521, 522, 523, 524, 525, 528,
+ 529, 532, 533, 534, 537, 538, 539, 540, 544, 545,
+ 548, 549, 558, 559, 566, 567, 568, 572, 575, 578,
+ 581, 584, 585, 589, 590, 591, 595, 598, 601, 602,
+ 603, 604, 605, 608, 609, 613, 614, 615, 616, 617,
+ 618, 619, 620, 625, 626, 631, 644, 654, 667, 680,
+ 692, 704, 716, 717, 718, 719
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "_T_EOF", "error", "$undefined", "BRACKET_OPEN", "BRACKET_CLOSE",
+ "SQ_BRACKET_OPEN", "SQ_BRACKET_CLOSE", "PIPE", "T_WORD", "R_POSSESSION",
+ "_T_QM", "_T_EM", "_T_FULLSTOP", "_T_COLON", "_T_SEMICOLON", "_T_COMMA",
+ "_T_A", "_T_AFFIRMATIVE", "_T_AFTER", "_T_ALLY", "_T_AM", "_T_AN",
+ "_T_AND", "_T_ANY", "_T_ATTACK", "_T_ATTACKING", "_T_ARMY", "_T_BEACON",
+ "_T_BUILDING", "_T_CANT", "_T_CENTER", "_T_DEAD", "_T_DERRICK", "_T_DO",
+ "_T_DROP", "_T_FINE", "_T_FOR", "_T_FORCE", "_T_GET", "_T_GETTING",
+ "_T_GO", "_T_GOING", "_T_GONNA", "_T_GOT", "_T_GREAT", "_T_HAVE",
+ "_T_HAS", "_T_HELP", "_T_HOLD", "_T_I", "_T_IM", "_T_IS", "_T_LASSAT",
+ "_T_LETS", "_T_ME", "_T_MORE", "_T_NEED", "_T_NO", "_T_NOW",
+ "_T_OFCOURSE", "_T_OK", "_T_ON", "_T_PLACE", "_T_POSSESSION", "_T_POWER",
+ "_T_PUMPING", "_T_PUT", "_T_READY", "_T_REQUIRE", "_T_ROGER", "_T_RUSH",
+ "_T_SEC", "_T_SEE", "_T_SOME", "_T_STATUS", "_T_STOP", "_T_SURE",
+ "_T_THANK_YOU", "_T_THANKS", "_T_THE", "_T_U", "_T_UNITS", "_T_VTOLS",
+ "_T_WAIT", "_T_WHERE", "_T_YES", "_T_YOU", "R_PLAYER", "R_INTEGER",
+ "$accept", "R_PHRASE", "R_ADDRESSED_COMMAND", "R_COMMAND",
+ "R_PLAYER_LIST", "R_PLAYER_POSSESSION", "R_A_OR_EMPTY",
+ "R_PUNCTUATION_MARK", "R_FULLSTOP_OR_EOF", "R_EOD", "R_EOQ", "R_EOS",
+ "R_ATTACKING", "R_INITIATE_ATTACK", "R_PUT_DOWN", "R_CONSTRUCTING",
+ "R_YOU", "R_DO_YOU", "R_POSSESSION_Q", "R_POSSESSES", "R_QUANTITY",
+ "R_DO_YOU_HAVE_ANY", "R_CONFIDENCE_EXPRESSION", "R_AGREEMENT_EXPRESSION",
+ "R_AFFIRMATIVE_FORMS", "R_NEED", "R_RUSH_INITIATION", "R_ALLY_OFFER",
+ "R_ASK_READINESS", "R_INITIATE_ACTION", "R_DEMAND_BEACON",
+ "R_MEET_CENTER", "R_ASK_STATUS", "R_UNIT_ARMY", "R_BUILDING_UNITS",
+ "R_STOP", "R_WONDER_IF_HAVE_POWER", "R_DEMAND_HELP", "R_GRATITUDE",
+ "R_REPORT_SAFETY", "R_AFFIRMATIVE", "R_ALLY_PLAYER", "R_ATTACK_PLAYER",
+ "R_ATTACKING_PLAYER", "R_PLAYER_HAS_VTOLS", "R_GETTING_ENEMY_DERRICK",
+ "R_LASSAT_PLAYER", "R_WAIT_FOR_ME", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const yytype_uint16 yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
+ 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
+ 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
+ 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
+ 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
+ 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
+ 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
+ 335, 336, 337, 338, 339, 340, 341, 342, 343
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const yytype_uint8 yyr1[] =
+{
+ 0, 89, 90, 90, 90, 90, 90, 91, 91, 91,
+ 91, 92, 92, 92, 92, 92, 92, 92, 92, 92,
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
+ 92, 93, 93, 93, 93, 94, 95, 95, 95, 95,
+ 96, 96, 96, 96, 97, 97, 97, 98, 98, 99,
+ 99, 100, 100, 101, 101, 101, 102, 102, 103, 103,
+ 103, 104, 104, 104, 105, 105, 106, 106, 107, 107,
+ 108, 108, 109, 109, 110, 110, 110, 110, 110, 111,
+ 111, 112, 112, 112, 113, 113, 113, 113, 114, 114,
+ 115, 115, 116, 116, 117, 117, 117, 118, 119, 120,
+ 121, 122, 122, 123, 123, 123, 124, 125, 126, 126,
+ 126, 126, 126, 127, 127, 128, 128, 128, 128, 128,
+ 128, 128, 128, 129, 129, 130, 131, 131, 132, 133,
+ 134, 135, 136, 136, 136, 136
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const yytype_uint8 yyr2[] =
+{
+ 0, 2, 1, 1, 2, 2, 1, 3, 3, 3,
+ 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 2, 3, 3, 2, 0, 1, 1, 1,
+ 1, 1, 2, 2, 0, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 2, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 2, 1, 1,
+ 1, 1, 1, 1, 3, 2, 2, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 3, 3, 2, 2, 2, 3, 2, 3, 3,
+ 2, 2, 2, 3, 4, 3, 2, 3, 3, 2,
+ 2, 3, 4, 1, 1, 3, 3, 3, 3, 4,
+ 3, 4, 3, 2, 3, 3, 3, 3, 3, 4,
+ 5, 3, 2, 2, 4, 3
+};
+
+/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
+ Performed when YYTABLE doesn't specify something else to do. Zero
+ means the default is an error. */
+static const yytype_uint8 yydefact[] =
+{
+ 0, 6, 87, 44, 72, 56, 53, 63, 0, 59,
+ 82, 57, 62, 44, 54, 0, 69, 68, 44, 0,
+ 0, 0, 0, 0, 88, 80, 83, 60, 61, 58,
+ 44, 89, 86, 44, 44, 73, 44, 44, 79, 113,
+ 114, 65, 44, 81, 64, 31, 0, 2, 3, 0,
+ 0, 0, 36, 36, 66, 0, 77, 78, 0, 85,
+ 84, 44, 0, 30, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 0, 21, 22, 23, 24, 25,
+ 26, 27, 28, 29, 45, 40, 41, 46, 44, 44,
+ 52, 48, 51, 93, 67, 94, 47, 44, 44, 97,
+ 55, 0, 44, 109, 44, 110, 44, 44, 44, 44,
+ 44, 95, 90, 133, 100, 106, 0, 132, 71, 70,
+ 0, 1, 4, 5, 0, 0, 0, 0, 32, 10,
+ 44, 44, 37, 38, 39, 0, 0, 44, 0, 44,
+ 75, 76, 44, 123, 44, 0, 0, 0, 44, 44,
+ 0, 44, 44, 44, 92, 125, 42, 43, 99, 127,
+ 0, 0, 108, 135, 116, 115, 96, 131, 91, 44,
+ 44, 0, 7, 8, 33, 9, 34, 128, 126, 98,
+ 44, 103, 102, 101, 105, 74, 49, 50, 107, 111,
+ 44, 44, 122, 120, 44, 117, 118, 124, 35, 44,
+ 134, 129, 104, 112, 121, 119, 130
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const yytype_int16 yydefgoto[] =
+{
+ -1, 46, 47, 48, 49, 161, 135, 90, 91, 92,
+ 188, 93, 50, 51, 52, 53, 54, 55, 56, 120,
+ 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
+ 67, 68, 69, 139, 70, 71, 72, 73, 74, 75,
+ 76, 77, 78, 79, 80, 81, 82, 83
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -70
+static const yytype_int16 yypact[] =
+{
+ 220, -70, -70, 1, -70, -70, -70, -70, -29, -70,
+ -70, -70, -70, 22, -1, -22, -70, -70, 35, -24,
+ 103, -4, -43, 20, -70, -70, -70, -70, -70, -70,
+ 151, -70, -70, 151, 99, -70, 151, 99, -70, -70,
+ -70, -70, 95, -70, -70, 28, 149, -70, -70, 295,
+ 10, 33, -7, -6, -70, -15, -20, -70, 57, -70,
+ -70, 99, 13, -70, -70, -70, -70, -70, -70, -70,
+ -70, -70, -70, -70, 52, 55, 84, -70, -70, -70,
+ -70, -70, -70, -70, -70, -70, -70, -70, 151, 99,
+ 48, -70, -70, -70, -70, -70, -70, 151, 99, -70,
+ -70, 36, 151, -70, 99, -70, 99, 99, 151, 99,
+ 151, -70, -70, -70, -70, -70, 71, -70, -70, -70,
+ 59, -70, -70, -70, 360, 360, 425, 58, 28, -70,
+ 99, 99, -70, -70, -70, 115, 65, 99, 111, 99,
+ -20, -70, 54, -70, 151, 100, -9, -17, 27, 50,
+ 38, 99, 99, 99, -70, -70, -70, -70, -70, -70,
+ 145, 123, -70, -70, -70, -70, -70, -70, -70, 99,
+ 99, 28, -70, -70, 28, -70, -70, -70, -70, -70,
+ 99, -70, -70, -70, -70, -70, -70, -70, -70, -70,
+ 151, 50, -70, -70, 99, -70, -70, -70, -70, 99,
+ -70, -70, -70, -70, -70, -70, -70
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const yytype_int16 yypgoto[] =
+{
+ -70, -70, 112, -42, -70, -70, 117, -70, 23, -13,
+ -70, -10, -70, 160, -70, -70, 156, -70, 121, -70,
+ -37, -70, -70, -70, 109, -70, -70, -70, -70, -70,
+ -70, -70, -70, -70, -70, -70, -70, 159, -69, -34,
+ -70, -70, -70, -70, -70, -70, -70, -70
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If YYTABLE_NINF, syntax error. */
+#define YYTABLE_NINF -1
+static const yytype_uint8 yytable[] =
+{
+ 99, 84, 5, 4, 123, 148, 152, 129, 103, 132,
+ 132, 85, 86, 87, 133, 133, 11, 100, 106, 141,
+ 111, 113, 84, 112, 115, 145, 114, 84, 16, 117,
+ 17, 106, 95, 96, 87, 84, 4, 104, 96, 87,
+ 149, 147, 146, 107, 109, 85, 86, 87, 143, 136,
+ 84, 41, 97, 35, 84, 88, 107, 44, 156, 157,
+ 144, 96, 87, 108, 186, 150, 87, 146, 39, 40,
+ 150, 118, 134, 134, 119, 137, 155, 147, 154, 148,
+ 152, 194, 172, 173, 175, 159, 35, 158, 89, 102,
+ 110, 163, 162, 164, 165, 84, 167, 130, 166, 84,
+ 168, 2, 147, 185, 39, 40, 96, 87, 151, 98,
+ 96, 87, 191, 151, 149, 39, 40, 177, 178, 10,
+ 131, 142, 152, 160, 181, 169, 184, 39, 40, 39,
+ 40, 116, 39, 40, 189, 192, 193, 182, 195, 196,
+ 197, 170, 179, 25, 26, 176, 180, 190, 183, 121,
+ 18, 84, 20, 32, 198, 199, 200, 201, 122, 24,
+ 38, 85, 86, 87, 94, 187, 2, 202, 3, 43,
+ 138, 31, 4, 5, 6, 101, 140, 7, 204, 105,
+ 203, 205, 8, 9, 10, 153, 206, 11, 12, 13,
+ 14, 15, 16, 0, 17, 0, 18, 19, 20, 21,
+ 0, 22, 23, 0, 0, 24, 0, 0, 25, 26,
+ 0, 27, 0, 0, 28, 29, 30, 31, 32, 33,
+ 34, 1, 35, 36, 37, 38, 39, 40, 0, 41,
+ 0, 0, 42, 0, 43, 44, 45, 2, 0, 3,
+ 0, 0, 0, 4, 5, 6, 0, 0, 7, 0,
+ 0, 0, 0, 8, 9, 10, 0, 0, 11, 12,
+ 13, 14, 15, 16, 0, 17, 0, 18, 19, 20,
+ 21, 0, 22, 23, 0, 0, 24, 0, 0, 25,
+ 26, 0, 27, 0, 0, 28, 29, 30, 31, 32,
+ 33, 34, 0, 35, 36, 37, 38, 39, 40, 0,
+ 41, 0, 0, 42, 0, 43, 44, 45, 124, 125,
+ 126, 0, 2, 0, 3, 0, 0, 127, 4, 5,
+ 6, 0, 0, 7, 0, 0, 0, 0, 8, 9,
+ 10, 0, 0, 11, 12, 13, 14, 15, 16, 0,
+ 17, 0, 18, 19, 20, 21, 0, 22, 23, 0,
+ 0, 24, 0, 0, 25, 26, 0, 27, 0, 0,
+ 28, 29, 30, 31, 32, 33, 34, 0, 35, 36,
+ 37, 38, 39, 40, 0, 41, 0, 2, 42, 3,
+ 43, 44, 128, 4, 5, 6, 0, 0, 7, 0,
+ 0, 0, 0, 8, 9, 10, 0, 0, 11, 12,
+ 13, 14, 15, 16, 0, 17, 0, 18, 19, 20,
+ 21, 0, 22, 23, 0, 0, 24, 0, 0, 25,
+ 26, 0, 27, 0, 0, 28, 29, 30, 31, 32,
+ 33, 34, 0, 35, 36, 37, 38, 39, 40, 0,
+ 41, 0, 2, 42, 3, 43, 44, 171, 4, 5,
+ 6, 0, 0, 7, 0, 0, 0, 0, 8, 9,
+ 10, 0, 0, 11, 12, 13, 14, 15, 16, 0,
+ 17, 0, 18, 19, 20, 21, 0, 22, 23, 0,
+ 0, 24, 0, 0, 25, 26, 0, 27, 0, 0,
+ 28, 29, 30, 31, 32, 33, 34, 0, 35, 36,
+ 37, 38, 39, 40, 0, 41, 0, 0, 42, 0,
+ 43, 44, 174
+};
+
+#define yypact_value_is_default(yystate) \
+ ((yystate) == (-70))
+
+#define yytable_value_is_error(yytable_value) \
+ YYID (0)
+
+static const yytype_int16 yycheck[] =
+{
+ 13, 0, 24, 23, 46, 74, 75, 49, 18, 16,
+ 16, 10, 11, 12, 21, 21, 38, 18, 35, 56,
+ 30, 34, 0, 33, 37, 62, 36, 0, 43, 42,
+ 45, 35, 10, 11, 12, 0, 23, 61, 11, 12,
+ 74, 50, 15, 60, 87, 10, 11, 12, 61, 55,
+ 0, 80, 30, 73, 0, 54, 60, 86, 10, 11,
+ 47, 11, 12, 67, 10, 15, 12, 15, 77, 78,
+ 15, 43, 79, 79, 46, 81, 89, 50, 88, 148,
+ 149, 150, 124, 125, 126, 98, 73, 97, 87, 54,
+ 70, 104, 102, 106, 107, 0, 109, 87, 108, 0,
+ 110, 17, 50, 140, 77, 78, 11, 12, 58, 87,
+ 11, 12, 146, 58, 148, 77, 78, 130, 131, 35,
+ 87, 64, 191, 87, 137, 54, 139, 77, 78, 77,
+ 78, 36, 77, 78, 144, 148, 149, 26, 151, 152,
+ 153, 82, 27, 59, 60, 87, 81, 47, 37, 0,
+ 47, 0, 49, 69, 9, 32, 169, 170, 46, 56,
+ 76, 10, 11, 12, 8, 142, 17, 180, 19, 85,
+ 53, 68, 23, 24, 25, 15, 55, 28, 191, 20,
+ 190, 194, 33, 34, 35, 76, 199, 38, 39, 40,
+ 41, 42, 43, -1, 45, -1, 47, 48, 49, 50,
+ -1, 52, 53, -1, -1, 56, -1, -1, 59, 60,
+ -1, 62, -1, -1, 65, 66, 67, 68, 69, 70,
+ 71, 1, 73, 74, 75, 76, 77, 78, -1, 80,
+ -1, -1, 83, -1, 85, 86, 87, 17, -1, 19,
+ -1, -1, -1, 23, 24, 25, -1, -1, 28, -1,
+ -1, -1, -1, 33, 34, 35, -1, -1, 38, 39,
+ 40, 41, 42, 43, -1, 45, -1, 47, 48, 49,
+ 50, -1, 52, 53, -1, -1, 56, -1, -1, 59,
+ 60, -1, 62, -1, -1, 65, 66, 67, 68, 69,
+ 70, 71, -1, 73, 74, 75, 76, 77, 78, -1,
+ 80, -1, -1, 83, -1, 85, 86, 87, 13, 14,
+ 15, -1, 17, -1, 19, -1, -1, 22, 23, 24,
+ 25, -1, -1, 28, -1, -1, -1, -1, 33, 34,
+ 35, -1, -1, 38, 39, 40, 41, 42, 43, -1,
+ 45, -1, 47, 48, 49, 50, -1, 52, 53, -1,
+ -1, 56, -1, -1, 59, 60, -1, 62, -1, -1,
+ 65, 66, 67, 68, 69, 70, 71, -1, 73, 74,
+ 75, 76, 77, 78, -1, 80, -1, 17, 83, 19,
+ 85, 86, 87, 23, 24, 25, -1, -1, 28, -1,
+ -1, -1, -1, 33, 34, 35, -1, -1, 38, 39,
+ 40, 41, 42, 43, -1, 45, -1, 47, 48, 49,
+ 50, -1, 52, 53, -1, -1, 56, -1, -1, 59,
+ 60, -1, 62, -1, -1, 65, 66, 67, 68, 69,
+ 70, 71, -1, 73, 74, 75, 76, 77, 78, -1,
+ 80, -1, 17, 83, 19, 85, 86, 87, 23, 24,
+ 25, -1, -1, 28, -1, -1, -1, -1, 33, 34,
+ 35, -1, -1, 38, 39, 40, 41, 42, 43, -1,
+ 45, -1, 47, 48, 49, 50, -1, 52, 53, -1,
+ -1, 56, -1, -1, 59, 60, -1, 62, -1, -1,
+ 65, 66, 67, 68, 69, 70, 71, -1, 73, 74,
+ 75, 76, 77, 78, -1, 80, -1, -1, 83, -1,
+ 85, 86, 87
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const yytype_uint8 yystos[] =
+{
+ 0, 1, 17, 19, 23, 24, 25, 28, 33, 34,
+ 35, 38, 39, 40, 41, 42, 43, 45, 47, 48,
+ 49, 50, 52, 53, 56, 59, 60, 62, 65, 66,
+ 67, 68, 69, 70, 71, 73, 74, 75, 76, 77,
+ 78, 80, 83, 85, 86, 87, 90, 91, 92, 93,
+ 101, 102, 103, 104, 105, 106, 107, 109, 110, 111,
+ 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
+ 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
+ 133, 134, 135, 136, 0, 10, 11, 12, 54, 87,
+ 96, 97, 98, 100, 105, 10, 11, 30, 87, 98,
+ 18, 102, 54, 100, 61, 126, 35, 60, 67, 87,
+ 70, 100, 100, 98, 100, 98, 36, 98, 43, 46,
+ 108, 0, 91, 92, 13, 14, 15, 22, 87, 92,
+ 87, 87, 16, 21, 79, 95, 55, 81, 95, 122,
+ 107, 109, 64, 98, 47, 109, 15, 50, 127, 128,
+ 15, 58, 127, 113, 100, 98, 10, 11, 100, 98,
+ 87, 94, 100, 98, 98, 98, 100, 98, 100, 54,
+ 82, 87, 92, 92, 87, 92, 87, 98, 98, 27,
+ 81, 98, 26, 37, 98, 109, 10, 97, 99, 100,
+ 47, 128, 98, 98, 127, 98, 98, 98, 9, 32,
+ 98, 98, 98, 100, 98, 98, 98
+};
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
+
+
+/* Like YYERROR except do call yyerror. This remains here temporarily
+ to ease the transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. However,
+ YYFAIL appears to be in use. Nevertheless, it is formally deprecated
+ in Bison 2.4.2's NEWS entry, where a plan to phase it out is
+ discussed. */
+
+#define YYFAIL goto yyerrlab
+#if defined YYFAIL
+ /* This is here to suppress warnings from the GCC cpp's
+ -Wunused-macros. Normally we don't worry about that warning, but
+ some users do, and we want to make it easy for users to remove
+ YYFAIL uses, which will produce warnings from Bison 2.5. */
+#endif
+
+#define YYRECOVERING() (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (1); \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+while (YYID (0))
+
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+ If N is 0, then set CURRENT to the empty location which ends
+ the previous symbol: RHS[0] (always defined). */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (YYID (N)) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ } \
+ while (YYID (0))
+#endif
+
+
+/* This macro is provided for backward compatibility. */
+
+#ifndef YY_LOCATION_PRINT
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+#endif
+
+
+/* YYLEX -- calling `yylex' with the right arguments. */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (YYLEX_PARAM)
+#else
+# define YYLEX yylex ()
+#endif
+
+/* Enable debugging if requested. */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+# include /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, \
+ Type, Value); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (YYID (0))
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (!yyvaluep)
+ return;
+# ifdef YYPRINT
+ if (yytype < YYNTOKENS)
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# else
+ YYUSE (yyoutput);
+# endif
+ switch (yytype)
+ {
+ default:
+ break;
+ }
+}
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (yytype < YYNTOKENS)
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+ else
+ YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+ yy_symbol_value_print (yyoutput, yytype, yyvaluep);
+ YYFPRINTF (yyoutput, ")");
+}
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included). |
+`------------------------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
+#else
+static void
+yy_stack_print (yybottom, yytop)
+ yytype_int16 *yybottom;
+ yytype_int16 *yytop;
+#endif
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
+ YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (YYID (0))
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
+#else
+static void
+yy_reduce_print (yyvsp, yyrule)
+ YYSTYPE *yyvsp;
+ int yyrule;
+#endif
+{
+ int yynrhs = yyr2[yyrule];
+ int yyi;
+ unsigned long int yylno = yyrline[yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+ yyrule - 1, yylno);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+ &(yyvsp[(yyi + 1) - (yynrhs)])
+ );
+ YYFPRINTF (stderr, "\n");
+ }
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyvsp, Rule); \
+} while (YYID (0))
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+# if defined __GLIBC__ && defined _STRING_H
+# define yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static YYSIZE_T
+yystrlen (const char *yystr)
+#else
+static YYSIZE_T
+yystrlen (yystr)
+ const char *yystr;
+#endif
+{
+ YYSIZE_T yylen;
+ for (yylen = 0; yystr[yylen]; yylen++)
+ continue;
+ return yylen;
+}
+# endif
+# endif
+
+# ifndef yystpcpy
+# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static char *
+yystpcpy (char *yydest, const char *yysrc)
+#else
+static char *
+yystpcpy (yydest, yysrc)
+ char *yydest;
+ const char *yysrc;
+#endif
+{
+ char *yyd = yydest;
+ const char *yys = yysrc;
+
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
+
+ return yyd - 1;
+}
+# endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+ if (*yystr == '"')
+ {
+ YYSIZE_T yyn = 0;
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
+ do_not_strip_quotes: ;
+ }
+
+ if (! yyres)
+ return yystrlen (yystr);
+
+ return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
+ about the unexpected token YYTOKEN for the state stack whose top is
+ YYSSP.
+
+ Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
+ not large enough to hold the message. In that case, also set
+ *YYMSG_ALLOC to the required number of bytes. Return 2 if the
+ required number of bytes is too large to store. */
+static int
+yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
+ yytype_int16 *yyssp, int yytoken)
+{
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
+ YYSIZE_T yysize = yysize0;
+ YYSIZE_T yysize1;
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ /* Internationalized format string. */
+ const char *yyformat = 0;
+ /* Arguments of yyformat. */
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ /* Number of reported tokens (one for the "unexpected", one per
+ "expected"). */
+ int yycount = 0;
+
+ /* There are many possibilities here to consider:
+ - Assume YYFAIL is not used. It's too flawed to consider. See
+
+ for details. YYERROR is fine as it does not invoke this
+ function.
+ - If this state is a consistent state with a default action, then
+ the only way this function was invoked is if the default action
+ is an error action. In that case, don't check for expected
+ tokens because there are none.
+ - The only way there can be no lookahead present (in yychar) is if
+ this state is a consistent state with a default action. Thus,
+ detecting the absence of a lookahead is sufficient to determine
+ that there is no unexpected or expected token to report. In that
+ case, just report a simple "syntax error".
+ - Don't assume there isn't a lookahead just because this state is a
+ consistent state with a default action. There might have been a
+ previous inconsistent state, consistent state with a non-default
+ action, or user semantic action that manipulated yychar.
+ - Of course, the expected token list depends on states to have
+ correct lookahead information, and it depends on the parser not
+ to perform extra reductions after fetching a lookahead from the
+ scanner and before detecting a syntax error. Thus, state merging
+ (from LALR or IELR) and default reductions corrupt the expected
+ token list. However, the list is correct for canonical LR with
+ one exception: it will still contain any token that will not be
+ accepted due to an error action in a later state.
+ */
+ if (yytoken != YYEMPTY)
+ {
+ int yyn = yypact[*yyssp];
+ yyarg[yycount++] = yytname[yytoken];
+ if (!yypact_value_is_default (yyn))
+ {
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. In other words, skip the first -YYN actions for
+ this state because they are default actions. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn + 1;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yyx;
+
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
+ && !yytable_value_is_error (yytable[yyx + yyn]))
+ {
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ yycount = 1;
+ yysize = yysize0;
+ break;
+ }
+ yyarg[yycount++] = yytname[yyx];
+ yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+ if (! (yysize <= yysize1
+ && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+ }
+ }
+ }
+
+ switch (yycount)
+ {
+# define YYCASE_(N, S) \
+ case N: \
+ yyformat = S; \
+ break
+ YYCASE_(0, YY_("syntax error"));
+ YYCASE_(1, YY_("syntax error, unexpected %s"));
+ YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
+ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
+ YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
+ YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
+# undef YYCASE_
+ }
+
+ yysize1 = yysize + yystrlen (yyformat);
+ if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+
+ if (*yymsg_alloc < yysize)
+ {
+ *yymsg_alloc = 2 * yysize;
+ if (! (yysize <= *yymsg_alloc
+ && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
+ *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
+ return 1;
+ }
+
+ /* Avoid sprintf, as that infringes on the user's name space.
+ Don't have undefined behavior even if the translation
+ produced a string with the wrong number of "%s"s. */
+ {
+ char *yyp = *yymsg;
+ int yyi = 0;
+ while ((*yyp = *yyformat) != '\0')
+ if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyformat += 2;
+ }
+ else
+ {
+ yyp++;
+ yyformat++;
+ }
+ }
+ return 0;
+}
+#endif /* YYERROR_VERBOSE */
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol. |
+`-----------------------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
+#else
+static void
+yydestruct (yymsg, yytype, yyvaluep)
+ const char *yymsg;
+ int yytype;
+ YYSTYPE *yyvaluep;
+#endif
+{
+ YYUSE (yyvaluep);
+
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+ switch (yytype)
+ {
+
+ default:
+ break;
+ }
+}
+
+
+/* Prevent warnings from -Wmissing-prototypes. */
+#ifdef YYPARSE_PARAM
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void *YYPARSE_PARAM);
+#else
+int yyparse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+/* The lookahead symbol. */
+int yychar;
+
+/* The semantic value of the lookahead symbol. */
+YYSTYPE yylval;
+
+/* Number of syntax errors so far. */
+int yynerrs;
+
+
+/*----------.
+| yyparse. |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *YYPARSE_PARAM)
+#else
+int
+yyparse (YYPARSE_PARAM)
+ void *YYPARSE_PARAM;
+#endif
+#else /* ! YYPARSE_PARAM */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void)
+#else
+int
+yyparse ()
+
+#endif
+#endif
+{
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
+
+ YYSIZE_T yystacksize;
+
+ int yyn;
+ int yyresult;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char yymsgbuf[128];
+ char *yymsg = yymsgbuf;
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+
+ /* The number of symbols on the RHS of the reduced rule.
+ Keep to zero when no symbol should be popped. */
+ int yylen = 0;
+
+ yytoken = 0;
+ yyss = yyssa;
+ yyvs = yyvsa;
+ yystacksize = YYINITDEPTH;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+ yyssp = yyss;
+ yyvsp = yyvs;
+
+ goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate. |
+`------------------------------------------------------------*/
+ yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. So pushing a state here evens the stacks. */
+ yyssp++;
+
+ yysetstate:
+ *yyssp = yystate;
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ {
+ /* Get the current used size of the three stacks, in elements. */
+ YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ {
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ yytype_int16 *yyss1 = yyss;
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
+ &yystacksize);
+
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+# else
+ /* Extend the stack our own way. */
+ if (YYMAXDEPTH <= yystacksize)
+ goto yyexhaustedlab;
+ yystacksize *= 2;
+ if (YYMAXDEPTH < yystacksize)
+ yystacksize = YYMAXDEPTH;
+
+ {
+ yytype_int16 *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyexhaustedlab;
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+# undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+ }
+# endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + yysize - 1;
+ yyvsp = yyvs + yysize - 1;
+
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ YYABORT;
+ }
+
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
+ goto yybackup;
+
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
+
+ /* Do appropriate processing given the current state. Read a
+ lookahead token if we need one and don't already have one. */
+
+ /* First try to decide what to do without reference to lookahead token. */
+ yyn = yypact[yystate];
+ if (yypact_value_is_default (yyn))
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
+ }
+
+ if (yychar <= YYEOF)
+ {
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ }
+
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
+ detect an error, take that action. */
+ yyn += yytoken;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+ goto yydefault;
+ yyn = yytable[yyn];
+ if (yyn <= 0)
+ {
+ if (yytable_value_is_error (yyn))
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
+
+ /* Shift the lookahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
+
+ yystate = yyn;
+ *++yyvsp = yylval;
+
+ goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+yydefault:
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction. |
+`-----------------------------*/
+yyreduce:
+ /* yyn is the number of a rule to reduce with. */
+ yylen = yyr2[yyn];
+
+ /* If YYLEN is nonzero, implement the default value of the action:
+ `$$ = $1'.
+
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ yyval = yyvsp[1-yylen];
+
+
+ YY_REDUCE_PRINT (yyn);
+ switch (yyn)
+ {
+ case 3:
+
+/* Line 1806 of yacc.c */
+#line 290 "chat_parser.ypp"
+ {
+ chat_store_player(chat_msg.numCommands - 1, -1); /* No player list means current command is addressed to everyone */
+ }
+ break;
+
+ case 5:
+
+/* Line 1806 of yacc.c */
+#line 295 "chat_parser.ypp"
+ {
+ chat_store_player(chat_msg.numCommands - 1, -1);
+ }
+ break;
+
+ case 6:
+
+/* Line 1806 of yacc.c */
+#line 299 "chat_parser.ypp"
+ {
+ //console("-unrecognized phrase");
+
+ /* Reset current command */
+ chat_reset_command(chat_msg.numCommands);
+ }
+ break;
+
+ case 11:
+
+/* Line 1806 of yacc.c */
+#line 328 "chat_parser.ypp"
+ {
+ chat_store_command("ally me"); /* Store current command */
+ }
+ break;
+
+ case 12:
+
+/* Line 1806 of yacc.c */
+#line 332 "chat_parser.ypp"
+ {
+ chat_store_command("go?");
+ }
+ break;
+
+ case 13:
+
+/* Line 1806 of yacc.c */
+#line 336 "chat_parser.ypp"
+ {
+ chat_store_command("go!");
+ }
+ break;
+
+ case 14:
+
+/* Line 1806 of yacc.c */
+#line 340 "chat_parser.ypp"
+ {
+ chat_store_command("drop a beacon");
+ }
+ break;
+
+ case 15:
+
+/* Line 1806 of yacc.c */
+#line 344 "chat_parser.ypp"
+ {
+ chat_store_command("go center");
+ }
+ break;
+
+ case 16:
+
+/* Line 1806 of yacc.c */
+#line 348 "chat_parser.ypp"
+ {
+ chat_store_command("status?");
+ }
+ break;
+
+ case 17:
+
+/* Line 1806 of yacc.c */
+#line 352 "chat_parser.ypp"
+ {
+ chat_store_command("pumping units");
+ }
+ break;
+
+ case 18:
+
+/* Line 1806 of yacc.c */
+#line 356 "chat_parser.ypp"
+ {
+ chat_store_command("stop");
+ }
+ break;
+
+ case 19:
+
+/* Line 1806 of yacc.c */
+#line 360 "chat_parser.ypp"
+ {
+ chat_store_command("got power?");
+ }
+ break;
+
+ case 20:
+
+/* Line 1806 of yacc.c */
+#line 364 "chat_parser.ypp"
+ {
+ chat_store_command("help me");
+ }
+ break;
+
+ case 21:
+
+/* Line 1806 of yacc.c */
+#line 368 "chat_parser.ypp"
+ {
+ chat_store_command("i'm ok");
+ }
+ break;
+
+ case 22:
+
+/* Line 1806 of yacc.c */
+#line 372 "chat_parser.ypp"
+ {
+ chat_store_command("roger");
+ }
+ break;
+
+ case 23:
+
+/* Line 1806 of yacc.c */
+#line 376 "chat_parser.ypp"
+ {
+ chat_store_command("ally player");
+ }
+ break;
+
+ case 24:
+
+/* Line 1806 of yacc.c */
+#line 380 "chat_parser.ypp"
+ {
+ chat_store_command("attack player");
+ }
+ break;
+
+ case 25:
+
+/* Line 1806 of yacc.c */
+#line 384 "chat_parser.ypp"
+ {
+ chat_store_command("attacking player?");
+ }
+ break;
+
+ case 26:
+
+/* Line 1806 of yacc.c */
+#line 388 "chat_parser.ypp"
+ {
+ chat_store_command("player has vtols");
+ }
+ break;
+
+ case 27:
+
+/* Line 1806 of yacc.c */
+#line 392 "chat_parser.ypp"
+ {
+ chat_store_command("getting player oil");
+ }
+ break;
+
+ case 28:
+
+/* Line 1806 of yacc.c */
+#line 396 "chat_parser.ypp"
+ {
+ chat_store_command("lassat player");
+ }
+ break;
+
+ case 29:
+
+/* Line 1806 of yacc.c */
+#line 400 "chat_parser.ypp"
+ {
+ chat_store_command("wait for me");
+ }
+ break;
+
+ case 30:
+
+/* Line 1806 of yacc.c */
+#line 404 "chat_parser.ypp"
+ {
+ chat_store_command("rush");
+ }
+ break;
+
+ case 31:
+
+/* Line 1806 of yacc.c */
+#line 412 "chat_parser.ypp"
+ {
+ chat_store_player(chat_msg.numCommands, (yyvsp[(1) - (1)].ival)); /* Remember this player was addressed in current command */
+ }
+ break;
+
+ case 32:
+
+/* Line 1806 of yacc.c */
+#line 416 "chat_parser.ypp"
+ {
+ chat_store_player(chat_msg.numCommands, (yyvsp[(2) - (2)].ival));
+ }
+ break;
+
+ case 33:
+
+/* Line 1806 of yacc.c */
+#line 420 "chat_parser.ypp"
+ {
+ chat_store_player(chat_msg.numCommands, (yyvsp[(3) - (3)].ival));
+ }
+ break;
+
+ case 34:
+
+/* Line 1806 of yacc.c */
+#line 424 "chat_parser.ypp"
+ {
+ chat_store_player(chat_msg.numCommands, (yyvsp[(3) - (3)].ival));
+ }
+ break;
+
+ case 35:
+
+/* Line 1806 of yacc.c */
+#line 430 "chat_parser.ypp"
+ {
+ (yyval.ival) = (yyvsp[(1) - (2)].ival); // just pass player index
+ }
+ break;
+
+ case 125:
+
+/* Line 1806 of yacc.c */
+#line 632 "chat_parser.ypp"
+ {
+ /* Store for scripts */
+ scrParameter.type = VAL_INT;
+ scrParameter.v.ival = (yyvsp[(2) - (3)].ival);
+ if(!chat_store_parameter(&scrParameter))
+ {
+ yyerror("chat command: Too many parameters in the message");
+ }
+ }
+ break;
+
+ case 126:
+
+/* Line 1806 of yacc.c */
+#line 645 "chat_parser.ypp"
+ {
+ /* Store for scripts */
+ scrParameter.type = VAL_INT;
+ scrParameter.v.ival = (yyvsp[(2) - (3)].ival);
+ if(!chat_store_parameter(&scrParameter))
+ {
+ yyerror("chat command: Too many parameters in the message");
+ }
+ }
+ break;
+
+ case 127:
+
+/* Line 1806 of yacc.c */
+#line 655 "chat_parser.ypp"
+ {
+ /* Store for scripts */
+ scrParameter.type = VAL_INT;
+ scrParameter.v.ival = (yyvsp[(2) - (3)].ival);
+ if(!chat_store_parameter(&scrParameter))
+ {
+ yyerror("chat command: Too many parameters in the message");
+ }
+ }
+ break;
+
+ case 128:
+
+/* Line 1806 of yacc.c */
+#line 668 "chat_parser.ypp"
+ {
+ /* Store for scripts */
+ scrParameter.type = VAL_INT;
+ scrParameter.v.ival = (yyvsp[(2) - (3)].ival);
+ if(!chat_store_parameter(&scrParameter))
+ {
+ yyerror("chat command: Too many parameters in the message");
+ }
+ }
+ break;
+
+ case 129:
+
+/* Line 1806 of yacc.c */
+#line 681 "chat_parser.ypp"
+ {
+ /* Store for scripts */
+ scrParameter.type = VAL_INT;
+ scrParameter.v.ival = (yyvsp[(1) - (4)].ival);
+ if(!chat_store_parameter(&scrParameter))
+ {
+ yyerror("chat command: Too many parameters in the message");
+ }
+ }
+ break;
+
+ case 130:
+
+/* Line 1806 of yacc.c */
+#line 693 "chat_parser.ypp"
+ {
+ /* Store for scripts */
+ scrParameter.type = VAL_INT;
+ scrParameter.v.ival = (yyvsp[(3) - (5)].ival);
+ if(!chat_store_parameter(&scrParameter))
+ {
+ yyerror("chat command: Too many parameters in the message");
+ }
+ }
+ break;
+
+ case 131:
+
+/* Line 1806 of yacc.c */
+#line 705 "chat_parser.ypp"
+ {
+ /* Store for scripts */
+ scrParameter.type = VAL_INT;
+ scrParameter.v.ival = (yyvsp[(2) - (3)].ival);
+ if(!chat_store_parameter(&scrParameter))
+ {
+ yyerror("chat command: Too many parameters in the message");
+ }
+ }
+ break;
+
+
+
+/* Line 1806 of yacc.c */
+#line 2339 "chat_parser.cpp"
+ default: break;
+ }
+ /* User semantic actions sometimes alter yychar, and that requires
+ that yytoken be updated with the new translation. We take the
+ approach of translating immediately before every use of yytoken.
+ One alternative is translating here after every semantic action,
+ but that translation would be missed if the semantic action invokes
+ YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
+ if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
+ incorrect destructor might then be invoked immediately. In the
+ case of YYERROR or YYBACKUP, subsequent parser actions might lead
+ to an incorrect destructor call or verbose syntax error message
+ before the lookahead is translated. */
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
+
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+
+ *++yyvsp = yyval;
+
+ /* Now `shift' the result of the reduction. Determine what state
+ that goes to, based on the state we popped back to and the rule
+ number reduced by. */
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTOKENS];
+
+ goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
+
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus)
+ {
+ ++yynerrs;
+#if ! YYERROR_VERBOSE
+ yyerror (YY_("syntax error"));
+#else
+# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
+ yyssp, yytoken)
+ {
+ char const *yymsgp = YY_("syntax error");
+ int yysyntax_error_status;
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ if (yysyntax_error_status == 0)
+ yymsgp = yymsg;
+ else if (yysyntax_error_status == 1)
+ {
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+ yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
+ if (!yymsg)
+ {
+ yymsg = yymsgbuf;
+ yymsg_alloc = sizeof yymsgbuf;
+ yysyntax_error_status = 2;
+ }
+ else
+ {
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ yymsgp = yymsg;
+ }
+ }
+ yyerror (yymsgp);
+ if (yysyntax_error_status == 2)
+ goto yyexhaustedlab;
+ }
+# undef YYSYNTAX_ERROR
+#endif
+ }
+
+
+
+ if (yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ if (yychar <= YYEOF)
+ {
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ YYABORT;
+ }
+ else
+ {
+ yydestruct ("Error: discarding",
+ yytoken, &yylval);
+ yychar = YYEMPTY;
+ }
+ }
+
+ /* Else will try to reuse lookahead token after shifting the error
+ token. */
+ goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR. |
+`---------------------------------------------------*/
+yyerrorlab:
+
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label yyerrorlab therefore never appears in user
+ code. */
+ if (/*CONSTCOND*/ 0)
+ goto yyerrorlab;
+
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYERROR. */
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+ yystate = *yyssp;
+ goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR. |
+`-------------------------------------------------------------*/
+yyerrlab1:
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
+
+ for (;;)
+ {
+ yyn = yypact[yystate];
+ if (!yypact_value_is_default (yyn))
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yyssp == yyss)
+ YYABORT;
+
+
+ yydestruct ("Error: popping",
+ yystos[yystate], yyvsp);
+ YYPOPSTACK (1);
+ yystate = *yyssp;
+ YY_STACK_PRINT (yyss, yyssp);
+ }
+
+ *++yyvsp = yylval;
+
+
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+#if !defined(yyoverflow) || YYERROR_VERBOSE
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here. |
+`-------------------------------------------------*/
+yyexhaustedlab:
+ yyerror (YY_("memory exhausted"));
+ yyresult = 2;
+ /* Fall through. */
+#endif
+
+yyreturn:
+ if (yychar != YYEMPTY)
+ {
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = YYTRANSLATE (yychar);
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval);
+ }
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYABORT or YYACCEPT. */
+ YYPOPSTACK (yylen);
+ YY_STACK_PRINT (yyss, yyssp);
+ while (yyssp != yyss)
+ {
+ yydestruct ("Cleanup: popping",
+ yystos[*yyssp], yyvsp);
+ YYPOPSTACK (1);
+ }
+#ifndef yyoverflow
+ if (yyss != yyssa)
+ YYSTACK_FREE (yyss);
+#endif
+#if YYERROR_VERBOSE
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+#endif
+ /* Make sure YYID is used. */
+ return YYID (yyresult);
+}
+
+
+
+/* Line 2067 of yacc.c */
+#line 721 "chat_parser.ypp"
+
+
+/* Initialize Bison and start chat processing */
+bool chatLoad(char *pData, UDWORD size)
+{
+ SDWORD cmdIndex,parseResult;
+
+ /* Don't parse the same message again for a different player */
+ if(strcmp(pData, &(chat_msg.lastMessage[0])) == 0) //just parsed this message for some other player
+ {
+ return true; //keep all the parsed data unmodified
+ }
+
+ /* Tell bison what to parse */
+ chatSetInputBuffer(pData, size);
+
+ /* Reset previous chat processing */
+ chat_msg.numCommands = 0;
+
+ /* Initialize command data */
+ for(cmdIndex=0; cmdIndexUnicode
-
-
-
+
@@ -237,7 +235,7 @@
-
+
@@ -245,25 +243,9 @@
-
+
-
-
- Document
-
-
- Document
-
-
- Document
-
-
- Document
-
-
-
-
-
+
\ No newline at end of file
diff --git a/lib/script/script.vcxproj.filters b/lib/script/script.vcxproj.filters
index c25dec29b..fe3536548 100644
--- a/lib/script/script.vcxproj.filters
+++ b/lib/script/script.vcxproj.filters
@@ -9,9 +9,6 @@
{93995380-89BD-4b04-88EB-625FBE52EBFB}
h;hpp;hxx;hm;inl;inc;xsd
-
- {30be94dd-96c4-473b-a323-e6bf6f278b9d}
-
@@ -70,27 +67,11 @@
Header Files
-
+
Header Files
-
+
Header Files
-
-
- FlexBison
-
-
- FlexBison
-
-
-
-
- FlexBison
-
-
- FlexBison
-
-
\ No newline at end of file
diff --git a/lib/script/script_lexer.cpp b/lib/script/script_lexer.cpp
new file mode 100644
index 000000000..d5d61a1eb
--- /dev/null
+++ b/lib/script/script_lexer.cpp
@@ -0,0 +1,3053 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+#line 2 "script_lexer.cpp"
+
+#line 4 "script_lexer.cpp"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define yy_create_buffer scr__create_buffer
+#define yy_delete_buffer scr__delete_buffer
+#define yy_flex_debug scr__flex_debug
+#define yy_init_buffer scr__init_buffer
+#define yy_flush_buffer scr__flush_buffer
+#define yy_load_buffer_state scr__load_buffer_state
+#define yy_switch_to_buffer scr__switch_to_buffer
+#define yyin scr_in
+#define yyleng scr_leng
+#define yylex scr_lex
+#define yylineno scr_lineno
+#define yyout scr_out
+#define yyrestart scr_restart
+#define yytext scr_text
+#define yywrap scr_wrap
+#define yyalloc scr_alloc
+#define yyrealloc scr_realloc
+#define yyfree scr_free
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 35
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+#include "lib/framework/frame.h"
+/* begin standard C headers. */
+#include
+#include
+#include
+#include
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have . Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#endif /* ! C99 */
+
+#endif /* ! FLEXINT_H */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
+
+#define YY_USE_CONST
+
+#endif /* defined (__STDC__) */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index. If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN (yy_start) = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START (((yy_start) - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE scr_restart(scr_in )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
+#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
+#endif
+
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+extern int scr_leng;
+
+extern FILE *scr_in, *scr_out;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+ /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
+ * access to the local variable yy_act. Since yyless() is a macro, it would break
+ * existing scanners that call yyless() from OUTSIDE scr_lex.
+ * One obvious solution it to make yy_act a global. I tried that, and saw
+ * a 5% performance hit in a non-scr_lineno scanner, because yy_act is
+ * normally declared as a register variable-- so it is not worth it.
+ */
+ #define YY_LESS_LINENO(n) \
+ do { \
+ int yyl;\
+ for ( yyl = n; yyl < scr_leng; ++yyl )\
+ if ( scr_text[yyl] == '\n' )\
+ --scr_lineno;\
+ }while(0)
+
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up scr_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ *yy_cp = (yy_hold_char); \
+ YY_RESTORE_YY_MORE_OFFSET \
+ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up scr_text again */ \
+ } \
+ while ( 0 )
+
+#define unput(c) yyunput( c, (yytext_ptr) )
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via scr_restart()), so that the user can continue scanning by
+ * just pointing scr_in at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+ : NULL)
+
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+
+/* yy_hold_char holds the character lost when scr_text is formed. */
+static char yy_hold_char;
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+int scr_leng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 0; /* whether we need to initialize */
+static int yy_start = 0; /* start state number */
+
+/* Flag which is used to allow scr_wrap()'s to do buffer switches
+ * instead of setting up a fresh scr_in. A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void scr_restart (FILE *input_file );
+void scr__switch_to_buffer (YY_BUFFER_STATE new_buffer );
+YY_BUFFER_STATE scr__create_buffer (FILE *file,int size );
+void scr__delete_buffer (YY_BUFFER_STATE b );
+void scr__flush_buffer (YY_BUFFER_STATE b );
+void scr_push_buffer_state (YY_BUFFER_STATE new_buffer );
+void scr_pop_buffer_state (void );
+
+static void scr_ensure_buffer_stack (void );
+static void scr__load_buffer_state (void );
+static void scr__init_buffer (YY_BUFFER_STATE b,FILE *file );
+
+#define YY_FLUSH_BUFFER scr__flush_buffer(YY_CURRENT_BUFFER )
+
+YY_BUFFER_STATE scr__scan_buffer (char *base,yy_size_t size );
+YY_BUFFER_STATE scr__scan_string (yyconst char *yy_str );
+YY_BUFFER_STATE scr__scan_bytes (yyconst char *bytes,int len );
+
+void *scr_alloc (yy_size_t );
+void *scr_realloc (void *,yy_size_t );
+void scr_free (void * );
+
+#define yy_new_buffer scr__create_buffer
+
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ scr_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ scr__create_buffer(scr_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+ }
+
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){\
+ scr_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ scr__create_buffer(scr_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+ }
+
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* Begin user sect3 */
+
+typedef unsigned char YY_CHAR;
+
+FILE *scr_in = (FILE *) 0, *scr_out = (FILE *) 0;
+
+typedef int yy_state_type;
+
+extern int scr_lineno;
+
+int scr_lineno = 1;
+
+extern char *scr_text;
+#define yytext_ptr scr_text
+
+static yy_state_type yy_get_previous_state (void );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
+static int yy_get_next_buffer (void );
+static void yy_fatal_error (yyconst char msg[] );
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up scr_text.
+ */
+#define YY_DO_BEFORE_ACTION \
+ (yytext_ptr) = yy_bp; \
+ scr_leng = (size_t) (yy_cp - yy_bp); \
+ (yy_hold_char) = *yy_cp; \
+ *yy_cp = '\0'; \
+ (yy_c_buf_p) = yy_cp;
+
+#define YY_NUM_RULES 65
+#define YY_END_OF_BUFFER 66
+/* This struct is not used in this scanner,
+ but its presence is necessary. */
+struct yy_trans_info
+ {
+ flex_int32_t yy_verify;
+ flex_int32_t yy_nxt;
+ };
+static yyconst flex_int16_t yy_accept[251] =
+ { 0,
+ 0, 0, 0, 0, 63, 63, 54, 54, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 42, 42,
+ 66, 64, 55, 55, 38, 52, 49, 64, 64, 64,
+ 64, 64, 64, 47, 35, 64, 34, 48, 48, 48,
+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
+ 48, 64, 59, 60, 59, 63, 62, 54, 65, 53,
+ 51, 50, 44, 45, 40, 41, 42, 31, 0, 0,
+ 36, 0, 0, 0, 0, 28, 29, 0, 47, 46,
+ 56, 61, 33, 30, 32, 48, 48, 48, 48, 48,
+
+ 48, 48, 37, 48, 48, 48, 48, 48, 48, 48,
+ 48, 48, 48, 48, 17, 48, 48, 48, 48, 48,
+ 48, 48, 48, 48, 48, 48, 48, 48, 37, 57,
+ 63, 54, 44, 40, 41, 42, 0, 0, 0, 0,
+ 0, 0, 36, 48, 48, 48, 24, 38, 48, 48,
+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
+ 48, 48, 48, 48, 48, 8, 48, 48, 48, 48,
+ 48, 48, 48, 58, 0, 0, 0, 0, 0, 0,
+ 23, 48, 48, 48, 26, 21, 18, 48, 48, 19,
+ 48, 48, 48, 48, 6, 7, 48, 48, 48, 48,
+
+ 48, 48, 48, 1, 48, 0, 0, 0, 11, 0,
+ 27, 25, 48, 4, 2, 48, 48, 15, 20, 48,
+ 48, 48, 48, 48, 16, 0, 0, 0, 0, 22,
+ 48, 48, 48, 13, 9, 48, 0, 0, 12, 48,
+ 48, 14, 3, 39, 0, 10, 5, 0, 43, 0
+ } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 5, 6, 7, 1, 1, 8, 1, 9,
+ 10, 11, 12, 1, 13, 14, 15, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 1, 1, 17,
+ 18, 19, 1, 1, 20, 21, 22, 23, 24, 25,
+ 26, 22, 27, 22, 22, 28, 22, 29, 30, 22,
+ 22, 31, 32, 33, 34, 35, 22, 22, 22, 22,
+ 1, 1, 1, 1, 22, 1, 36, 37, 38, 39,
+
+ 40, 41, 42, 43, 44, 22, 45, 46, 22, 47,
+ 48, 49, 22, 50, 51, 52, 53, 54, 55, 56,
+ 57, 22, 1, 58, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1
+ } ;
+
+static yyconst flex_int32_t yy_meta[59] =
+ { 0,
+ 1, 2, 3, 4, 1, 5, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 6, 1, 1, 1, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 1
+ } ;
+
+static yyconst flex_int16_t yy_base[265] =
+ { 0,
+ 0, 0, 56, 57, 375, 374, 58, 59, 373, 372,
+ 67, 69, 368, 367, 75, 133, 370, 369, 92, 94,
+ 370, 379, 379, 379, 351, 379, 60, 360, 75, 355,
+ 92, 350, 92, 95, 347, 346, 345, 333, 331, 0,
+ 46, 331, 329, 327, 324, 325, 325, 307, 305, 64,
+ 76, 74, 69, 304, 301, 78, 310, 297, 298, 299,
+ 87, 288, 379, 379, 330, 0, 379, 0, 379, 379,
+ 379, 379, 0, 379, 0, 342, 0, 379, 303, 295,
+ 379, 313, 311, 293, 291, 379, 379, 321, 110, 320,
+ 379, 379, 379, 379, 379, 0, 312, 304, 305, 302,
+
+ 298, 297, 0, 298, 294, 300, 287, 277, 273, 283,
+ 278, 275, 272, 272, 0, 117, 271, 279, 264, 262,
+ 270, 276, 113, 262, 111, 267, 266, 265, 379, 305,
+ 0, 0, 0, 0, 305, 0, 265, 267, 274, 270,
+ 254, 249, 0, 272, 267, 278, 0, 0, 270, 272,
+ 272, 248, 253, 109, 240, 240, 254, 251, 250, 235,
+ 241, 249, 233, 229, 236, 0, 228, 236, 237, 238,
+ 238, 224, 229, 379, 230, 227, 252, 261, 234, 259,
+ 0, 244, 234, 237, 0, 0, 0, 213, 207, 0,
+ 221, 208, 204, 202, 0, 0, 207, 210, 212, 198,
+
+ 140, 142, 146, 0, 147, 139, 132, 151, 379, 131,
+ 0, 0, 156, 0, 0, 137, 136, 0, 0, 127,
+ 140, 130, 134, 135, 0, 134, 134, 162, 161, 0,
+ 122, 114, 127, 0, 0, 116, 161, 120, 379, 110,
+ 92, 0, 0, 125, 123, 0, 0, 156, 379, 379,
+ 191, 197, 203, 209, 215, 221, 227, 233, 95, 239,
+ 245, 251, 57, 257
+ } ;
+
+static yyconst flex_int16_t yy_def[265] =
+ { 0,
+ 250, 1, 251, 251, 252, 252, 253, 253, 254, 254,
+ 255, 255, 256, 256, 257, 257, 256, 256, 258, 258,
+ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
+ 250, 250, 250, 250, 250, 250, 250, 259, 259, 259,
+ 259, 259, 259, 259, 259, 259, 259, 259, 259, 259,
+ 259, 259, 259, 259, 259, 259, 259, 259, 259, 259,
+ 259, 250, 250, 250, 250, 260, 250, 261, 250, 250,
+ 250, 250, 262, 250, 263, 250, 264, 250, 250, 250,
+ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
+ 250, 250, 250, 250, 250, 259, 259, 259, 259, 259,
+
+ 259, 259, 259, 259, 259, 259, 259, 259, 259, 259,
+ 259, 259, 259, 259, 259, 259, 259, 259, 259, 259,
+ 259, 259, 259, 259, 259, 259, 259, 259, 250, 250,
+ 260, 261, 262, 263, 250, 264, 250, 250, 250, 250,
+ 250, 250, 259, 259, 259, 259, 259, 259, 259, 259,
+ 259, 259, 259, 259, 259, 259, 259, 259, 259, 259,
+ 259, 259, 259, 259, 259, 259, 259, 259, 259, 259,
+ 259, 259, 259, 250, 250, 250, 250, 250, 250, 250,
+ 259, 259, 259, 259, 259, 259, 259, 259, 259, 259,
+ 259, 259, 259, 259, 259, 259, 259, 259, 259, 259,
+
+ 259, 259, 259, 259, 259, 250, 250, 250, 250, 250,
+ 259, 259, 259, 259, 259, 259, 259, 259, 259, 259,
+ 259, 259, 259, 259, 259, 250, 250, 250, 250, 259,
+ 259, 259, 259, 259, 259, 259, 250, 250, 250, 259,
+ 259, 259, 259, 250, 250, 259, 259, 250, 250, 0,
+ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
+ 250, 250, 250, 250
+ } ;
+
+static yyconst flex_int16_t yy_nxt[438] =
+ { 0,
+ 22, 23, 24, 23, 25, 26, 27, 28, 29, 22,
+ 22, 30, 31, 32, 33, 34, 35, 36, 37, 38,
+ 39, 40, 40, 40, 41, 40, 42, 40, 43, 44,
+ 40, 45, 46, 40, 47, 48, 49, 40, 40, 50,
+ 51, 40, 40, 52, 40, 53, 54, 55, 56, 57,
+ 58, 59, 40, 60, 61, 40, 40, 62, 64, 64,
+ 69, 69, 134, 70, 70, 99, 65, 65, 69, 69,
+ 69, 69, 69, 100, 69, 69, 69, 69, 69, 69,
+ 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
+ 69, 69, 69, 69, 69, 69, 69, 69, 79, 82,
+
+ 96, 83, 91, 80, 87, 88, 92, 89, 88, 109,
+ 89, 112, 117, 120, 115, 84, 118, 110, 85, 111,
+ 116, 113, 127, 88, 248, 89, 244, 121, 114, 128,
+ 122, 247, 69, 69, 69, 69, 69, 69, 69, 69,
+ 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
+ 69, 69, 159, 166, 169, 188, 246, 248, 189, 245,
+ 160, 249, 244, 170, 167, 243, 242, 241, 147, 240,
+ 239, 239, 238, 237, 236, 230, 235, 234, 233, 232,
+ 231, 230, 229, 228, 227, 226, 225, 224, 223, 222,
+ 69, 63, 63, 63, 63, 63, 63, 66, 66, 66,
+
+ 66, 66, 66, 68, 68, 68, 68, 68, 68, 71,
+ 71, 71, 71, 71, 71, 73, 73, 73, 73, 73,
+ 73, 69, 69, 69, 69, 69, 69, 75, 75, 75,
+ 75, 75, 75, 77, 77, 77, 77, 77, 77, 131,
+ 131, 221, 131, 131, 131, 132, 132, 220, 132, 219,
+ 132, 133, 218, 217, 133, 216, 133, 136, 136, 212,
+ 211, 136, 136, 215, 214, 213, 212, 211, 209, 210,
+ 209, 208, 207, 206, 205, 204, 186, 185, 203, 202,
+ 201, 200, 199, 198, 197, 196, 195, 194, 193, 192,
+ 191, 190, 187, 181, 186, 185, 184, 183, 182, 181,
+
+ 180, 179, 178, 177, 176, 175, 135, 174, 173, 172,
+ 171, 168, 165, 164, 163, 148, 162, 161, 158, 157,
+ 156, 155, 154, 153, 152, 143, 151, 150, 149, 148,
+ 147, 146, 145, 144, 143, 90, 90, 142, 141, 140,
+ 139, 138, 137, 135, 130, 129, 126, 125, 124, 123,
+ 103, 119, 108, 107, 106, 105, 104, 103, 102, 101,
+ 98, 97, 95, 94, 93, 90, 86, 81, 78, 250,
+ 76, 76, 74, 74, 72, 72, 67, 67, 21, 250,
+ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
+ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
+
+ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
+ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
+ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
+ 250, 250, 250, 250, 250, 250, 250
+ } ;
+
+static yyconst flex_int16_t yy_chk[438] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 3, 4,
+ 7, 8, 263, 7, 8, 41, 3, 4, 11, 11,
+ 12, 12, 11, 41, 12, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 19, 19, 20, 20, 27, 29,
+
+ 259, 29, 33, 27, 31, 31, 33, 31, 34, 50,
+ 34, 51, 53, 56, 52, 29, 53, 50, 29, 50,
+ 52, 51, 61, 89, 245, 89, 244, 56, 51, 61,
+ 56, 241, 15, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 116, 123, 125, 154, 240, 248, 154, 238,
+ 116, 248, 237, 125, 123, 236, 233, 232, 116, 231,
+ 229, 228, 227, 226, 224, 223, 222, 221, 220, 217,
+ 216, 213, 210, 208, 207, 206, 205, 203, 202, 201,
+ 16, 251, 251, 251, 251, 251, 251, 252, 252, 252,
+
+ 252, 252, 252, 253, 253, 253, 253, 253, 253, 254,
+ 254, 254, 254, 254, 254, 255, 255, 255, 255, 255,
+ 255, 256, 256, 256, 256, 256, 256, 257, 257, 257,
+ 257, 257, 257, 258, 258, 258, 258, 258, 258, 260,
+ 260, 200, 260, 260, 260, 261, 261, 199, 261, 198,
+ 261, 262, 197, 194, 262, 193, 262, 264, 264, 192,
+ 191, 264, 264, 189, 188, 184, 183, 182, 180, 179,
+ 178, 177, 176, 175, 173, 172, 171, 170, 169, 168,
+ 167, 165, 164, 163, 162, 161, 160, 159, 158, 157,
+ 156, 155, 153, 152, 151, 150, 149, 146, 145, 144,
+
+ 142, 141, 140, 139, 138, 137, 135, 130, 128, 127,
+ 126, 124, 122, 121, 120, 119, 118, 117, 114, 113,
+ 112, 111, 110, 109, 108, 107, 106, 105, 104, 102,
+ 101, 100, 99, 98, 97, 90, 88, 85, 84, 83,
+ 82, 80, 79, 76, 65, 62, 60, 59, 58, 57,
+ 55, 54, 49, 48, 47, 46, 45, 44, 43, 42,
+ 39, 38, 37, 36, 35, 32, 30, 28, 25, 21,
+ 18, 17, 14, 13, 10, 9, 6, 5, 250, 250,
+ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
+ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
+
+ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
+ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
+ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
+ 250, 250, 250, 250, 250, 250, 250
+ } ;
+
+/* Table of booleans, true if rule could match eol. */
+static yyconst flex_int32_t yy_rule_can_match_eol[66] =
+ { 0,
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0,
+ 1, 0, 1, 0, 0, 0, };
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+extern int scr__flex_debug;
+int scr__flex_debug = 0;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *scr_text;
+#line 1 "script_lexer.lpp"
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 1999-2004 Eidos Interactive
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+#line 21 "script_lexer.lpp"
+/*
+ * script.l
+ *
+ * Script file lexer.
+ */
+#include
+#include "lib/framework/frame.h"
+#include "lib/framework/string_ext.h"
+#include "lib/script/interpreter.h"
+#include "lib/script/parse.h"
+#include "lib/script/script.h"
+
+/* Get the Yacc definitions */
+#include "script_parser.h"
+
+// fwrite declared with warn_unused_result, resulting in mysterious errors in "%%" on some distros.
+static inline bool no_warn_unused_result(int ignore) { if (ignore) {} return true; }
+#define fwrite(a, b, c, d) no_warn_unused_result(fwrite(a, b, c, d))
+
+/* Maximum length for any TEXT value */
+#ifndef YYLMAX
+#define YYLMAX 255
+#endif
+
+#if defined(YY_FLEX_SUBMINOR_VERSION) && YY_FLEX_SUBMINOR_VERSION == 33
+extern int scr_get_lineno(void);
+extern FILE *scr_get_in(void);
+extern FILE *scr_get_out(void);
+extern int scr_get_leng(void);
+extern char *scr_get_text(void);
+extern void scr_set_lineno(int line_number);
+extern void scr_set_in(FILE* in_str);
+extern void scr_set_out(FILE* out_str);
+extern int scr_get_debug(void);
+extern void scr_set_debug(int bdebug);
+extern int scr_lex_destroy(void);
+#endif
+
+/* Store for any string values */
+static char aText[TEXT_BUFFERS][YYLMAX];
+static UDWORD currText=0;
+
+// Note if we are in a comment
+static bool inComment = false;
+
+/* FLEX include buffer stack */
+static YY_BUFFER_STATE include_stack[MAX_SCR_INCLUDE_DEPTH];
+
+/* FLEX define buffer stack */
+static YY_BUFFER_STATE macro_stack[MAX_SCR_MACRO_DEPTH];
+static SCR_MACRO scr_macro[MAX_SCR_MACROS];
+
+/* Script include files stack */
+static unsigned int scr_include_stack_ptr = 0;
+static PHYSFS_file* pScrInputFiles[MAX_SCR_INCLUDE_DEPTH];
+
+/* Line count stack used with script includes */
+static unsigned int scrInclLine[MAX_SCR_INCLUDE_DEPTH];
+
+/* Script defines stack */
+static unsigned int scr_num_macros; /* Number of macros defined so far */
+static int scr_macro_stack_ptr; /* Pointer to the current flex macro input buffer */
+static char *pScrMacroBuffer[MAX_SCR_MACRO_DEPTH];
+
+#undef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ { \
+ if (PHYSFS_eof(pScrInputFiles[scr_include_stack_ptr])) \
+ { \
+ buf[0] = EOF; \
+ result = YY_NULL; \
+ } \
+ else \
+ { \
+ result = PHYSFS_read(pScrInputFiles[scr_include_stack_ptr], buf, 1, max_size); \
+ if (result == -1) \
+ { \
+ buf[0] = EOF; \
+ result = YY_NULL; \
+ } \
+ } \
+ }
+
+static YYSTYPE dummy;
+
+/* Get the token type for a variable symbol */
+static SDWORD scriptGetVarToken(VAR_SYMBOL *psVar)
+{
+ bool object;
+
+ // See if this is an object pointer
+ if (!asScrTypeTab || psVar->type < VAL_USERTYPESTART)
+ {
+ object = false;
+ }
+ else
+ {
+ object = asScrTypeTab[psVar->type - VAL_USERTYPESTART].accessType == AT_OBJECT;
+ }
+
+ if (psVar->storage == ST_OBJECT)
+ {
+ /* This is an object member variable */
+ if (object)
+ {
+
+ RULE("current variable is OBJ_OBJVAR");
+
+ return OBJ_OBJVAR;
+ }
+ else
+ {
+ switch (psVar->type)
+ {
+ case VAL_BOOL:
+ return BOOL_OBJVAR;
+ break;
+ case VAL_INT:
+// case VAL_FLOAT:
+
+ RULE( "current variable is NUM_OBJVAR");
+
+ return NUM_OBJVAR;
+ break;
+ default:
+
+ RULE( "current variable is USER_OBJVAR");
+
+ return USER_OBJVAR;
+ break;
+ }
+ }
+ }
+ else if (psVar->dimensions > 0)
+ {
+ /* This is an array variable */
+ if (object)
+ {
+ return OBJ_ARRAY;
+ }
+ else
+ {
+ switch (psVar->type)
+ {
+ case VAL_BOOL:
+ return BOOL_ARRAY;
+ break;
+ case VAL_FLOAT:
+ return FLOAT_ARRAY;
+ break;
+ case VAL_INT:
+ return NUM_ARRAY;
+ break;
+ default:
+ return VAR_ARRAY;
+ break;
+ }
+ }
+ }
+ else
+ {
+ /* This is a standard variable */
+ if (object)
+ {
+
+ RULE( "current variable is OBJ_VAR");
+
+ return OBJ_VAR;
+ }
+ else
+ {
+
+ RULE( "ordinary var");
+
+ switch (psVar->type)
+ {
+ case VAL_BOOL:
+ return BOOL_VAR;
+ break;
+ case VAL_FLOAT:
+
+ RULE( "VAL_FLOAT");
+
+ return FLOAT_VAR;
+ break;
+ case VAL_INT:
+ return NUM_VAR;
+ break;
+ case VAL_STRING:
+ return STRING_VAR;
+ break;
+ default:
+ return VAR;
+ break;
+ }
+ }
+ }
+}
+
+/* Get the token type for a constant symbol */
+static SDWORD scriptGetConstToken(CONST_SYMBOL *psConst)
+{
+ bool object;
+
+ // See if this is an object constant
+ if (!asScrTypeTab || psConst->type < VAL_USERTYPESTART)
+ {
+ object = false;
+ }
+ else
+ {
+ object = asScrTypeTab[psConst->type - VAL_USERTYPESTART].accessType == AT_OBJECT;
+ }
+
+ switch (psConst->type)
+ {
+ case VAL_BOOL:
+ return BOOL_CONSTANT;
+ break;
+// case VAL_FLOAT:
+ case VAL_INT:
+ return NUM_CONSTANT;
+ break;
+ case VAL_STRING:
+ return STRING_CONSTANT;
+ break;
+ default:
+ if (object)
+ {
+ //debug(LOG_SCRIPT, "scriptGetConstToken: OBJ_CONSTANT");
+ return OBJ_CONSTANT;
+ }
+ else
+ {
+ return USER_CONSTANT;
+ }
+ break;
+ }
+}
+
+/* Get the token type for a function symbol */
+static SDWORD scriptGetFuncToken(FUNC_SYMBOL *psFunc)
+{
+ bool object;
+
+ // See if this is an object pointer
+ if(psFunc->type >= VAL_USERTYPESTART)
+ {
+ object = asScrTypeTab[psFunc->type - VAL_USERTYPESTART].accessType == AT_OBJECT;
+
+ if (object)
+ {
+ return OBJ_FUNC;
+ }
+ }
+ switch (psFunc->type)
+ {
+ case VAL_BOOL:
+ return BOOL_FUNC;
+ break;
+ case VAL_FLOAT:
+ return FLOAT_FUNC;
+ break;
+ case VAL_INT:
+ return NUM_FUNC;
+ break;
+ case VAL_STRING:
+ return STRING_FUNC;
+ break;
+ case VAL_VOID:
+ return FUNC;
+ break;
+ default:
+ return USER_FUNC;
+ break;
+ }
+}
+
+/* Get the token type for a custom function symbol */
+static SDWORD scriptGetCustomFuncToken(EVENT_SYMBOL *psFunc)
+{
+ bool object;
+
+ // See if this is an object pointer
+ if (!asScrTypeTab || psFunc->retType < VAL_USERTYPESTART)
+ {
+ object = false;
+ }
+ else
+ {
+ object = asScrTypeTab[psFunc->retType - VAL_USERTYPESTART].accessType == AT_OBJECT;
+ }
+
+ if (object)
+ {
+ return OBJ_FUNC_CUST;
+ }
+ else
+ {
+ switch (psFunc->retType)
+ {
+ case VAL_BOOL:
+ return BOOL_FUNC_CUST;
+ break;
+ case VAL_FLOAT:
+
+ RULE( "current function is FLOAT_FUNC_CUST");
+
+ return FLOAT_FUNC_CUST;
+ break;
+ case VAL_INT:
+
+ RULE( "current function is NUM_FUNC_CUST");
+
+ return NUM_FUNC_CUST;
+ break;
+ case VAL_STRING:
+ return STRING_FUNC_CUST;
+ break;
+ case VAL_VOID:
+ return VOID_FUNC_CUST;
+ break;
+ default:
+ return USER_FUNC_CUST;
+ break;
+ }
+ }
+}
+
+/* Look up defined macro and return new define buffer */
+static bool scriptLoopUpMacro(const char *pMacro, char **ppMacroBody)
+{
+ unsigned int i;
+
+ for (i = 0; i < scr_num_macros; ++i)
+ {
+ if(strcmp(pMacro, &(scr_macro[i].scr_define_macro[0]) ) == 0)
+ {
+ *ppMacroBody = (char *)malloc(MAXSTRLEN);
+ strcpy( *ppMacroBody, &(scr_macro[i].scr_define_body[0]) ); //copy macro body into buffer so we can process it
+ //*pMacroBody = &(scr_macro[i].scr_define_body[0]); //return macro body
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/* Return to the previous macto buffer */
+static void popMacroStack(void)
+{
+ ASSERT(scr_macro_stack_ptr <= MAX_SCR_MACRO_DEPTH,
+ "FLEX: macro stack pointer out of bounds: %d", scr_macro_stack_ptr);
+
+ /* Free current macro buffer */
+ free(pScrMacroBuffer[scr_macro_stack_ptr]);
+ pScrMacroBuffer[scr_macro_stack_ptr] = NULL;
+
+ /* Delete flex buffer */
+ scr__delete_buffer(YY_CURRENT_BUFFER );
+
+ /* Switch one level lower in the macro stack */
+ scr__switch_to_buffer(macro_stack[scr_macro_stack_ptr - 1] );
+
+ scr_macro_stack_ptr--;
+}
+
+/* Store macro name */
+static void storeMacroName(const char *pMacroName)
+{
+ ASSERT(scr_num_macros < MAX_SCR_MACROS,
+ "FLEX: macro count out of bounds: %u", scr_num_macros);
+
+ /* Make sure this name isn't already reserved */
+ if((scriptLookUpType(pMacroName, &dummy.tval)) ||
+ (scriptLookUpVariable(pMacroName, &dummy.vSymbol)) ||
+ (scriptLookUpConstant(pMacroName, &dummy.cSymbol)) ||
+ (scriptLookUpFunction(pMacroName, &dummy.fSymbol)) ||
+ (scriptLookUpCustomFunction(pMacroName, &dummy.eSymbol)) ||
+ (scriptLookUpTrigger(pMacroName, &dummy.tSymbol)) ||
+ (scriptLookUpEvent(pMacroName, &dummy.eSymbol)) ||
+ (scriptLookUpCallback(pMacroName, &dummy.cbSymbol)))
+ {
+ scr_error("FLEX: macro name '%s' is already reserved", pMacroName);
+ }
+
+ /* Store define macro */
+ sstrcpy(scr_macro[scr_num_macros].scr_define_macro, pMacroName);
+}
+
+/* Store macro body */
+static void storeMacroBody(const char *pMacroBody)
+{
+ ASSERT(scr_num_macros < MAX_SCR_MACROS,
+ "FLEX: macro count out of bounds: %u", scr_num_macros);
+
+ /* Store macro body */
+ sstrcpy(scr_macro[scr_num_macros].scr_define_body, pMacroBody);
+
+ scr_num_macros++;
+}
+
+/* include directive encountered - push current buffer, set up new one */
+static void pushInclude(const char *pIncludePath)
+{
+ PHYSFS_file* newInput;
+
+ if ( scr_include_stack_ptr >= MAX_SCR_INCLUDE_DEPTH ){
+ scr_error("FLEX: Includes nested too deeply" );
+ }
+
+ if(!PHYSFS_exists(pIncludePath)){
+ scr_error("FLEX: '%s' include doesn't exist", pIncludePath );
+ }
+
+ /* Open include */
+ newInput = PHYSFS_openRead(pIncludePath);
+
+ if(!newInput){
+ scr_error("FLEX: Couldn't open include: '%s'\n%s",
+ pIncludePath, PHYSFS_getLastError() );
+ }
+
+ /* Push current flex buffer */
+ include_stack[scr_include_stack_ptr] = YY_CURRENT_BUFFER;
+ scr_include_stack_ptr++;
+
+ ASSERT(scr_include_stack_ptr < MAX_SCR_INCLUDE_DEPTH,
+ "FLEX: scr_include_stack_ptr out of bounds: %u", scr_include_stack_ptr);
+
+ pScrInputFiles[scr_include_stack_ptr] = newInput;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+#line 1147 "script_lexer.cpp"
+
+#define INITIAL 0
+#define COMMENT 1
+#define SLCOMMENT 2
+#define QUOTE 3
+#define _MACRO 4
+#define _INCL 5
+#define _INCL_END_QUOTE 6
+#define _DEF_MACRO 7
+#define _DEF_BODY_START 8
+#define _DEF_BODY 9
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#include
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+static int yy_init_globals (void );
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int scr_lex_destroy (void );
+
+int scr_get_debug (void );
+
+void scr_set_debug (int debug_flag );
+
+YY_EXTRA_TYPE scr_get_extra (void );
+
+void scr_set_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *scr_get_in (void );
+
+void scr_set_in (FILE * in_str );
+
+FILE *scr_get_out (void );
+
+void scr_set_out (FILE * out_str );
+
+int scr_get_leng (void );
+
+char *scr_get_text (void );
+
+int scr_get_lineno (void );
+
+void scr_set_lineno (int line_number );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int scr_wrap (void );
+#else
+extern int scr_wrap (void );
+#endif
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int );
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * );
+#endif
+
+#ifndef YY_NO_INPUT
+
+#ifdef __cplusplus
+static int yyinput (void );
+#else
+static int input (void );
+#endif
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
+#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO do { if (fwrite( scr_text, scr_leng, 1, scr_out )) {} } while (0)
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ { \
+ int c = '*'; \
+ size_t n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( scr_in )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( scr_in ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else \
+ { \
+ errno=0; \
+ while ( (result = fread(buf, 1, max_size, scr_in))==0 && ferror(scr_in)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(scr_in); \
+ } \
+ }\
+\
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* end tables serialization structures and prototypes */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int scr_lex (void);
+
+#define YY_DECL int scr_lex (void)
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after scr_text and scr_leng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+ YY_USER_ACTION
+
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp, *yy_bp;
+ register int yy_act;
+
+#line 478 "script_lexer.lpp"
+
+
+ /* Match keywords */
+#line 1345 "script_lexer.cpp"
+
+ if ( !(yy_init) )
+ {
+ (yy_init) = 1;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! (yy_start) )
+ (yy_start) = 1; /* first start state */
+
+ if ( ! scr_in )
+ scr_in = stdin;
+
+ if ( ! scr_out )
+ scr_out = stdout;
+
+ if ( ! YY_CURRENT_BUFFER ) {
+ scr_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ scr__create_buffer(scr_in,YY_BUF_SIZE );
+ }
+
+ scr__load_buffer_state( );
+ }
+
+ while ( 1 ) /* loops until end-of-file is reached */
+ {
+ yy_cp = (yy_c_buf_p);
+
+ /* Support of scr_text. */
+ *yy_cp = (yy_hold_char);
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+ yy_current_state = (yy_start);
+yy_match:
+ do
+ {
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 251 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ ++yy_cp;
+ }
+ while ( yy_current_state != 250 );
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+
+yy_find_action:
+ yy_act = yy_accept[yy_current_state];
+
+ YY_DO_BEFORE_ACTION;
+
+ if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
+ {
+ int yyl;
+ for ( yyl = 0; yyl < scr_leng; ++yyl )
+ if ( scr_text[yyl] == '\n' )
+
+ scr_lineno++;
+;
+ }
+
+do_action: /* This label is used only to access EOF actions. */
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = (yy_hold_char);
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 481 "script_lexer.lpp"
+return WAIT;
+ YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 482 "script_lexer.lpp"
+return EVERY;
+ YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 483 "script_lexer.lpp"
+return TRIGGER;
+ YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 484 "script_lexer.lpp"
+return EVENT;
+ YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 485 "script_lexer.lpp"
+return INACTIVE;
+ YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 486 "script_lexer.lpp"
+return INITIALISE;
+ YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 487 "script_lexer.lpp"
+return LINK;
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 488 "script_lexer.lpp"
+return REF;
+ YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 489 "script_lexer.lpp"
+return RET;
+ YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 490 "script_lexer.lpp"
+return lexFUNCTION;
+ YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 491 "script_lexer.lpp"
+{ RULE(scr_text); return TO_INT_CAST; }
+ YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 492 "script_lexer.lpp"
+{ RULE(scr_text); return TO_FLOAT_CAST; }
+ YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 493 "script_lexer.lpp"
+{ scr_lval.stype = ST_PUBLIC; return STORAGE; }
+ YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 494 "script_lexer.lpp"
+{ scr_lval.stype = ST_PRIVATE; return STORAGE; }
+ YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 495 "script_lexer.lpp"
+{ scr_lval.stype = ST_LOCAL; return STORAGE; }
+ YY_BREAK
+case 16:
+YY_RULE_SETUP
+#line 496 "script_lexer.lpp"
+return WHILE;
+ YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 497 "script_lexer.lpp"
+return IF;
+ YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 498 "script_lexer.lpp"
+return ELSE;
+ YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 499 "script_lexer.lpp"
+return EXIT;
+ YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 500 "script_lexer.lpp"
+return PAUSE;
+ YY_BREAK
+/* Match type keywords */
+case 21:
+YY_RULE_SETUP
+#line 503 "script_lexer.lpp"
+{ scr_lval.tval = VAL_VOID; return _VOID; }
+ YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 504 "script_lexer.lpp"
+{ scr_lval.tval = VAL_STRING; return TYPE; }
+ YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 505 "script_lexer.lpp"
+{ scr_lval.tval = VAL_BOOL; return TYPE; }
+ YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 506 "script_lexer.lpp"
+{ scr_lval.tval = VAL_INT; return TYPE; }
+ YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 507 "script_lexer.lpp"
+{ scr_lval.tval = VAL_FLOAT; return TYPE; }
+ YY_BREAK
+/* Match boolean values */
+case 26:
+YY_RULE_SETUP
+#line 510 "script_lexer.lpp"
+{ scr_lval.bval = true; return BOOLEAN_T; }
+ YY_BREAK
+case 27:
+YY_RULE_SETUP
+#line 511 "script_lexer.lpp"
+{ scr_lval.bval = false; return BOOLEAN_T; }
+ YY_BREAK
+/* Match increment/decrement operators */
+case 28:
+YY_RULE_SETUP
+#line 514 "script_lexer.lpp"
+{RULE("++"); return _INC; }
+ YY_BREAK
+case 29:
+YY_RULE_SETUP
+#line 515 "script_lexer.lpp"
+{RULE("++"); return _DEC; }
+ YY_BREAK
+/* Match boolean operators */
+case 30:
+YY_RULE_SETUP
+#line 518 "script_lexer.lpp"
+return BOOLEQUAL;
+ YY_BREAK
+case 31:
+YY_RULE_SETUP
+#line 519 "script_lexer.lpp"
+return NOTEQUAL;
+ YY_BREAK
+case 32:
+YY_RULE_SETUP
+#line 520 "script_lexer.lpp"
+return GREATEQUAL;
+ YY_BREAK
+case 33:
+YY_RULE_SETUP
+#line 521 "script_lexer.lpp"
+return LESSEQUAL;
+ YY_BREAK
+case 34:
+YY_RULE_SETUP
+#line 522 "script_lexer.lpp"
+return GREATER;
+ YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 523 "script_lexer.lpp"
+return LESS;
+ YY_BREAK
+case 36:
+YY_RULE_SETUP
+#line 524 "script_lexer.lpp"
+return _AND;
+ YY_BREAK
+case 37:
+YY_RULE_SETUP
+#line 525 "script_lexer.lpp"
+return _OR;
+ YY_BREAK
+case 38:
+YY_RULE_SETUP
+#line 526 "script_lexer.lpp"
+return _NOT;
+ YY_BREAK
+/* Start of a #define */
+case 39:
+YY_RULE_SETUP
+#line 529 "script_lexer.lpp"
+{ BEGIN (_DEF_MACRO); }
+ YY_BREAK
+/* Start of the #define macro name */
+case 40:
+YY_RULE_SETUP
+#line 532 "script_lexer.lpp"
+{
+ RULE("FLEX: matched define macro: '#define %s'", scr_text);
+
+ /* Store macro name */
+ storeMacroName(scr_text);
+
+ BEGIN (_DEF_BODY_START);
+ }
+ YY_BREAK
+case 41:
+YY_RULE_SETUP
+#line 541 "script_lexer.lpp"
+{ BEGIN (_DEF_BODY); } /* Eat space between macro and body */
+ YY_BREAK
+case 42:
+YY_RULE_SETUP
+#line 543 "script_lexer.lpp"
+{ /* Anything until the end of the line is macro body */
+
+ RULE("FLEX: matched define body: '#define %s %s' (%d)",
+ scr_macro[scr_num_macros].scr_define_macro, scr_text, scr_num_macros + 1);
+
+ /* Store macro body */
+ storeMacroBody(scr_text);
+
+ BEGIN (INITIAL);
+ }
+ YY_BREAK
+/* Handle Includes */
+case 43:
+YY_RULE_SETUP
+#line 555 "script_lexer.lpp"
+{ BEGIN (_INCL); } /* Match '#include' and skip whitespace until quotation */
+ YY_BREAK
+case 44:
+YY_RULE_SETUP
+#line 557 "script_lexer.lpp"
+{ /* got the include file name */
+ RULE("FLEX: Opening include '%s' (scr_include_stack_ptr: %u)", scr_text, scr_include_stack_ptr);
+
+ /* Set up new input buffer, push current one to stack */
+ pushInclude(scr_text);
+
+ /* Match the ending quote */
+ BEGIN(_INCL_END_QUOTE);
+ }
+ YY_BREAK
+case 45:
+YY_RULE_SETUP
+#line 567 "script_lexer.lpp"
+{
+ int line;
+ char *text;
+ YY_BUFFER_STATE includeBuffer;
+
+ ASSERT(scr_include_stack_ptr < MAX_SCR_INCLUDE_DEPTH,
+ "FLEX: scr_include_stack_ptr out of bounds: %u", scr_include_stack_ptr);
+
+ ASSERT(pScrInputFiles[scr_include_stack_ptr] != NULL, "FLEX: failed to load include");
+
+ RULE("FLEX: storing line number for include %u: ",
+ scr_include_stack_ptr - 1, scr_lineno);
+
+ /* Store the current line number in the current input buffer */
+ scriptGetErrorData(&line, &text);
+ scrInclLine[scr_include_stack_ptr - 1] = line;
+ scr_lineno = 1; //we are at the beginning of the first line in a new input now
+
+ /* Create a new YY_BUFFER_STATE for this file */
+ includeBuffer = scr__create_buffer(NULL,YY_BUF_SIZE);
+
+ /* Switch to the new buffer */
+ scr__switch_to_buffer(includeBuffer);
+
+ BEGIN (INITIAL);
+ }
+ YY_BREAK
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(COMMENT):
+case YY_STATE_EOF(SLCOMMENT):
+case YY_STATE_EOF(QUOTE):
+case YY_STATE_EOF(_MACRO):
+case YY_STATE_EOF(_INCL):
+case YY_STATE_EOF(_INCL_END_QUOTE):
+case YY_STATE_EOF(_DEF_MACRO):
+case YY_STATE_EOF(_DEF_BODY_START):
+case YY_STATE_EOF(_DEF_BODY):
+#line 594 "script_lexer.lpp"
+{
+ RULE("FLEX: EOF: scr_include_stack_ptr: %u; scr_macro_stack_ptr: %d",
+ scr_include_stack_ptr, scr_macro_stack_ptr);
+
+ ASSERT(pScrInputFiles[scr_include_stack_ptr] != NULL, "FLEX: can't unload, buffer is NULL");
+
+ if ( scr_include_stack_ptr == 0 )
+ {
+ /* We finished scanning top level script or macro */
+ if(scr_macro_stack_ptr > 0)
+ {
+ RULE("FLEX: Finished parsing macro %d", scr_macro_stack_ptr);
+
+ popMacroStack();
+ }
+ else //both stacks are empty
+ {
+ RULE("FLEX: Finished parsing all input");
+ yyterminate();
+ }
+ }
+ else
+ {
+ /* First finish scanning all macros */
+ if(scr_macro_stack_ptr > 0)
+ {
+ RULE("FLEX: Finished parsing macro %d in include %d",
+ scr_macro_stack_ptr, scr_include_stack_ptr);
+
+ popMacroStack();
+ }
+ else //no macros, return to previous include
+ {
+ RULE("FLEX: returning from parsing include %u", scr_include_stack_ptr);
+
+ /* Free include buffer */
+ PHYSFS_close(pScrInputFiles[scr_include_stack_ptr]);
+ pScrInputFiles[scr_include_stack_ptr] = NULL;
+
+ /* Delete flex buffer */
+ scr__delete_buffer(YY_CURRENT_BUFFER );
+
+ /* Pop previous script file */
+ scr__switch_to_buffer(include_stack[scr_include_stack_ptr - 1] );
+
+ ASSERT(scr_include_stack_ptr != 0,
+ "Can't restore line number of theprevious flex input");
+
+ /* Restore line count of the previous buffer from the line count stack */
+ scr_lineno = scrInclLine[scr_include_stack_ptr - 1];
+ RULE("FLEX: restoring line number for include %u: ",
+ scr_include_stack_ptr, scr_lineno);
+
+ /* Go to the previous flex input buffer */
+ scr_include_stack_ptr--;
+ }
+ }
+ }
+ YY_BREAK
+/* Match floating point numbers */
+case 46:
+YY_RULE_SETUP
+#line 655 "script_lexer.lpp"
+{
+ RULE( "float matched '%s'", scr_text);
+
+ scr_lval.fval = (float)atof(scr_text);
+
+ return FLOAT_T;
+ }
+ YY_BREAK
+/* Match integer numbers */
+case 47:
+YY_RULE_SETUP
+#line 664 "script_lexer.lpp"
+{ scr_lval.ival = atol(scr_text); return INTEGER; }
+ YY_BREAK
+/* Match identifiers */
+case 48:
+YY_RULE_SETUP
+#line 667 "script_lexer.lpp"
+{
+ char* tmpMacroBuffer;
+ RULE( "looking up '%s'", scr_text);
+
+ /* See if this identifier has been defined as a type */
+ if (scriptLookUpType(scr_text, &scr_lval.tval)) //STRUCTURESTAT etc
+ {
+
+ RULE( "'%s' is a user type", scr_text);
+
+ return TYPE;
+ }
+ /* See if this identifier has been defined as a variable */
+ else if (scriptLookUpVariable(scr_text, &scr_lval.vSymbol))
+ {
+
+ RULE( "'%s' is a var", scr_text);
+
+ return scriptGetVarToken(scr_lval.vSymbol);
+ }
+ /* See if this identifier has been defined as a constant */
+ else if (scriptLookUpConstant(scr_text, &scr_lval.cSymbol))
+ {
+
+ RULE( "'%s' is a constant", scr_text);
+
+ return scriptGetConstToken(scr_lval.cSymbol);
+ }
+ /* See if this identifier has been defined as a function */
+ else if (scriptLookUpFunction(scr_text, &scr_lval.fSymbol))
+ {
+
+ RULE( "'%s' is a function", scr_text);
+
+ return scriptGetFuncToken(scr_lval.fSymbol);
+ }
+
+ /* See if this identifier has been defined as a custom function */
+ else if (scriptLookUpCustomFunction(scr_text, &scr_lval.eSymbol))
+ {
+
+ RULE( "'%s' is a cust func", scr_text);
+
+ return scriptGetCustomFuncToken(scr_lval.eSymbol);
+ }
+
+ else if (scriptLookUpTrigger(scr_text, &scr_lval.tSymbol))
+ {
+
+ RULE( "'%s' is a trigger", scr_text);
+
+ return TRIG_SYM;
+ }
+ else if (scriptLookUpEvent(scr_text, &scr_lval.eSymbol))
+ {
+
+ RULE( "'%s' is an event", scr_text);
+
+ return EVENT_SYM;
+ }
+ else if (scriptLookUpCallback(scr_text, &scr_lval.cbSymbol))
+ {
+
+ RULE( "'%s' is a callback", scr_text);
+
+ return CALLBACK_SYM;
+ }
+ else if(scriptLoopUpMacro(scr_text, &tmpMacroBuffer))
+ {
+ RULE( "'%s' is a macro", scr_text);
+
+ ASSERT(tmpMacroBuffer != NULL,
+ "FLEX: failed to allocate memory for macro buffer %d", scr_macro_stack_ptr);
+
+ ASSERT(scr_macro_stack_ptr >= 0 && scr_macro_stack_ptr < MAX_SCR_MACRO_DEPTH,
+ "FLEX: flex macro buffer pointer out of bounds: %d", scr_macro_stack_ptr );
+
+ /* Push current buffer we are processing;
+ * can be either macro buffer, include buffer or top level script
+ */
+ macro_stack[scr_macro_stack_ptr] = YY_CURRENT_BUFFER;
+ scr_macro_stack_ptr++;
+
+ pScrMacroBuffer[scr_macro_stack_ptr] = tmpMacroBuffer; // Assign to the new input buffer
+
+ /* Feed flex with the new macro buffer */
+ scr__switch_to_buffer(scr__scan_string(pScrMacroBuffer[scr_macro_stack_ptr] ) );
+ }
+ else
+ {
+ RULE( "'%s' is an ident", scr_text);
+
+ sstrcpy(aText[currText], scr_text);
+ scr_lval.sval = aText[currText];
+ currText = (currText + 1) % TEXT_BUFFERS;
+ return IDENT;
+ }
+ }
+ YY_BREAK
+/* Strip macros */
+case 49:
+YY_RULE_SETUP
+#line 766 "script_lexer.lpp"
+{ BEGIN (_MACRO); }
+ YY_BREAK
+case 50:
+/* rule 50 can match eol */
+YY_RULE_SETUP
+#line 767 "script_lexer.lpp"
+{ BEGIN (INITIAL); }
+ YY_BREAK
+case 51:
+YY_RULE_SETUP
+#line 768 "script_lexer.lpp"
+;
+ YY_BREAK
+/* Match quoted text */
+case 52:
+YY_RULE_SETUP
+#line 771 "script_lexer.lpp"
+{ BEGIN (QUOTE); }
+ YY_BREAK
+case 53:
+YY_RULE_SETUP
+#line 772 "script_lexer.lpp"
+{ BEGIN (INITIAL); }
+ YY_BREAK
+case 54:
+YY_RULE_SETUP
+#line 773 "script_lexer.lpp"
+{
+ sstrcpy(aText[currText], scr_text);
+ scr_lval.sval = aText[currText];
+ currText = (currText + 1) % TEXT_BUFFERS;
+ //debug(LOG_SCRIPT, "%s is QTEXT", scr_text);
+ return QTEXT;
+ }
+ YY_BREAK
+/* Skip white space */
+case 55:
+/* rule 55 can match eol */
+YY_RULE_SETUP
+#line 782 "script_lexer.lpp"
+;
+ YY_BREAK
+/* Strip comments */
+case 56:
+YY_RULE_SETUP
+#line 785 "script_lexer.lpp"
+{ inComment=true; BEGIN (COMMENT); }
+ YY_BREAK
+case 57:
+#line 787 "script_lexer.lpp"
+case 58:
+/* rule 58 can match eol */
+YY_RULE_SETUP
+#line 787 "script_lexer.lpp"
+{ inComment=false; BEGIN (INITIAL); }
+ YY_BREAK
+case 59:
+#line 789 "script_lexer.lpp"
+case 60:
+/* rule 60 can match eol */
+YY_RULE_SETUP
+#line 789 "script_lexer.lpp"
+;
+ YY_BREAK
+/* Strip single line comments */
+case 61:
+YY_RULE_SETUP
+#line 792 "script_lexer.lpp"
+{ BEGIN (SLCOMMENT); }
+ YY_BREAK
+case 62:
+/* rule 62 can match eol */
+YY_RULE_SETUP
+#line 793 "script_lexer.lpp"
+{ BEGIN (INITIAL); }
+ YY_BREAK
+case 63:
+YY_RULE_SETUP
+#line 794 "script_lexer.lpp"
+;
+ YY_BREAK
+/* Match anything that's been missed and pass it as a char */
+case 64:
+YY_RULE_SETUP
+#line 797 "script_lexer.lpp"
+return scr_text[0];
+ YY_BREAK
+case 65:
+YY_RULE_SETUP
+#line 799 "script_lexer.lpp"
+ECHO;
+ YY_BREAK
+#line 2002 "script_lexer.cpp"
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = (yy_hold_char);
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed scr_in at a new source and called
+ * scr_lex(). If so, then we have to assure
+ * consistency between YY_CURRENT_BUFFER and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = scr_in;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++(yy_c_buf_p);
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ (yy_did_buffer_switch_on_eof) = 0;
+
+ if ( scr_wrap( ) )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * scr_text, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) =
+ (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ (yy_c_buf_p) =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+} /* end of scr_lex */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+static int yy_get_next_buffer (void)
+{
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ register char *source = (yytext_ptr);
+ register int number_to_move, i;
+ int ret_val;
+
+ if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
+
+ else
+ {
+ int num_to_read =
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+
+ int yy_c_buf_p_offset =
+ (int) ((yy_c_buf_p) - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ scr_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = 0;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+ number_to_move - 1;
+
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+ (yy_n_chars), (size_t) num_to_read );
+
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ if ( (yy_n_chars) == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ scr_restart(scr_in );
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) scr_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
+ (yy_n_chars) += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
+
+ (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+ return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+ static yy_state_type yy_get_previous_state (void)
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp;
+
+ yy_current_state = (yy_start);
+
+ for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
+ {
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 251 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ }
+
+ return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
+{
+ register int yy_is_jam;
+ register char *yy_cp = (yy_c_buf_p);
+
+ register YY_CHAR yy_c = 1;
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 251 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_is_jam = (yy_current_state == 250);
+
+ return yy_is_jam ? 0 : yy_current_state;
+}
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+ static int yyinput (void)
+#else
+ static int input (void)
+#endif
+
+{
+ int c;
+
+ *(yy_c_buf_p) = (yy_hold_char);
+
+ if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ /* This was really a NUL. */
+ *(yy_c_buf_p) = '\0';
+
+ else
+ { /* need more input */
+ int offset = (yy_c_buf_p) - (yytext_ptr);
+ ++(yy_c_buf_p);
+
+ switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ scr_restart(scr_in );
+
+ /*FALLTHROUGH*/
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( scr_wrap( ) )
+ return EOF;
+
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput();
+#else
+ return input();
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) = (yytext_ptr) + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
+ *(yy_c_buf_p) = '\0'; /* preserve scr_text */
+ (yy_hold_char) = *++(yy_c_buf_p);
+
+ if ( c == '\n' )
+
+ scr_lineno++;
+;
+
+ return c;
+}
+#endif /* ifndef YY_NO_INPUT */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ *
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+ void scr_restart (FILE * input_file )
+{
+
+ if ( ! YY_CURRENT_BUFFER ){
+ scr_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ scr__create_buffer(scr_in,YY_BUF_SIZE );
+ }
+
+ scr__init_buffer(YY_CURRENT_BUFFER,input_file );
+ scr__load_buffer_state( );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ *
+ */
+ void scr__switch_to_buffer (YY_BUFFER_STATE new_buffer )
+{
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * scr_pop_buffer_state();
+ * scr_push_buffer_state(new_buffer);
+ */
+ scr_ensure_buffer_stack ();
+ if ( YY_CURRENT_BUFFER == new_buffer )
+ return;
+
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ scr__load_buffer_state( );
+
+ /* We don't actually know whether we did this switch during
+ * EOF (scr_wrap()) processing, but the only time this flag
+ * is looked at is after scr_wrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+static void scr__load_buffer_state (void)
+{
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ scr_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ (yy_hold_char) = *(yy_c_buf_p);
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ *
+ * @return the allocated buffer state.
+ */
+ YY_BUFFER_STATE scr__create_buffer (FILE * file, int size )
+{
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) scr_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in scr__create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) scr_alloc(b->yy_buf_size + 2 );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in scr__create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ scr__init_buffer(b,file );
+
+ return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with scr__create_buffer()
+ *
+ */
+ void scr__delete_buffer (YY_BUFFER_STATE b )
+{
+
+ if ( ! b )
+ return;
+
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ scr_free((void *) b->yy_ch_buf );
+
+ scr_free((void *) b );
+}
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a scr_restart() or at EOF.
+ */
+ static void scr__init_buffer (YY_BUFFER_STATE b, FILE * file )
+
+{
+ int oerrno = errno;
+
+ scr__flush_buffer(b );
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+ /* If b is the current buffer, then scr__init_buffer was _probably_
+ * called from scr_restart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
+
+ b->yy_is_interactive = 0;
+
+ errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ *
+ */
+ void scr__flush_buffer (YY_BUFFER_STATE b )
+{
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == YY_CURRENT_BUFFER )
+ scr__load_buffer_state( );
+}
+
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ *
+ */
+void scr_push_buffer_state (YY_BUFFER_STATE new_buffer )
+{
+ if (new_buffer == NULL)
+ return;
+
+ scr_ensure_buffer_stack();
+
+ /* This block is copied from scr__switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ (yy_buffer_stack_top)++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from scr__switch_to_buffer. */
+ scr__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ *
+ */
+void scr_pop_buffer_state (void)
+{
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ scr__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if ((yy_buffer_stack_top) > 0)
+ --(yy_buffer_stack_top);
+
+ if (YY_CURRENT_BUFFER) {
+ scr__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+ }
+}
+
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+static void scr_ensure_buffer_stack (void)
+{
+ int num_to_alloc;
+
+ if (!(yy_buffer_stack)) {
+
+ /* First allocation is just for 2 elements, since we don't know if this
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
+ * immediate realloc on the next call.
+ */
+ num_to_alloc = 1;
+ (yy_buffer_stack) = (struct yy_buffer_state**)scr_alloc
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in scr_ensure_buffer_stack()" );
+
+ memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+
+ (yy_buffer_stack_max) = num_to_alloc;
+ (yy_buffer_stack_top) = 0;
+ return;
+ }
+
+ if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+
+ /* Increase the buffer to prepare for a possible push. */
+ int grow_size = 8 /* arbitrary grow size */;
+
+ num_to_alloc = (yy_buffer_stack_max) + grow_size;
+ (yy_buffer_stack) = (struct yy_buffer_state**)scr_realloc
+ ((yy_buffer_stack),
+ num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in scr_ensure_buffer_stack()" );
+
+ /* zero only the new slots.*/
+ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+ (yy_buffer_stack_max) = num_to_alloc;
+ }
+}
+
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE scr__scan_buffer (char * base, yy_size_t size )
+{
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return 0;
+
+ b = (YY_BUFFER_STATE) scr_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in scr__scan_buffer()" );
+
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = 0;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ scr__switch_to_buffer(b );
+
+ return b;
+}
+
+/** Setup the input buffer state to scan a string. The next call to scr_lex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ *
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * scr__scan_bytes() instead.
+ */
+YY_BUFFER_STATE scr__scan_string (yyconst char * yystr )
+{
+
+ return scr__scan_bytes(yystr,strlen(yystr) );
+}
+
+/** Setup the input buffer state to scan the given bytes. The next call to scr_lex() will
+ * scan from a @e copy of @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE scr__scan_bytes (yyconst char * yybytes, int _yybytes_len )
+{
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = _yybytes_len + 2;
+ buf = (char *) scr_alloc(n );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in scr__scan_bytes()" );
+
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
+
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = scr__scan_buffer(buf,n );
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in scr__scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+}
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+static void yy_fatal_error (yyconst char* msg )
+{
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+}
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up scr_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ scr_text[scr_leng] = (yy_hold_char); \
+ (yy_c_buf_p) = scr_text + yyless_macro_arg; \
+ (yy_hold_char) = *(yy_c_buf_p); \
+ *(yy_c_buf_p) = '\0'; \
+ scr_leng = yyless_macro_arg; \
+ } \
+ while ( 0 )
+
+/* Accessor methods (get/set functions) to struct members. */
+
+/** Get the current line number.
+ *
+ */
+int scr_get_lineno (void)
+{
+
+ return scr_lineno;
+}
+
+/** Get the input stream.
+ *
+ */
+FILE *scr_get_in (void)
+{
+ return scr_in;
+}
+
+/** Get the output stream.
+ *
+ */
+FILE *scr_get_out (void)
+{
+ return scr_out;
+}
+
+/** Get the length of the current token.
+ *
+ */
+int scr_get_leng (void)
+{
+ return scr_leng;
+}
+
+/** Get the current token.
+ *
+ */
+
+char *scr_get_text (void)
+{
+ return scr_text;
+}
+
+/** Set the current line number.
+ * @param line_number
+ *
+ */
+void scr_set_lineno (int line_number )
+{
+
+ scr_lineno = line_number;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ *
+ * @see scr__switch_to_buffer
+ */
+void scr_set_in (FILE * in_str )
+{
+ scr_in = in_str ;
+}
+
+void scr_set_out (FILE * out_str )
+{
+ scr_out = out_str ;
+}
+
+int scr_get_debug (void)
+{
+ return scr__flex_debug;
+}
+
+void scr_set_debug (int bdebug )
+{
+ scr__flex_debug = bdebug ;
+}
+
+static int yy_init_globals (void)
+{
+ /* Initialization is the same as for the non-reentrant scanner.
+ * This function is called from scr_lex_destroy(), so don't allocate here.
+ */
+
+ /* We do not touch scr_lineno unless the option is enabled. */
+ scr_lineno = 1;
+
+ (yy_buffer_stack) = 0;
+ (yy_buffer_stack_top) = 0;
+ (yy_buffer_stack_max) = 0;
+ (yy_c_buf_p) = (char *) 0;
+ (yy_init) = 0;
+ (yy_start) = 0;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ scr_in = stdin;
+ scr_out = stdout;
+#else
+ scr_in = (FILE *) 0;
+ scr_out = (FILE *) 0;
+#endif
+
+ /* For future reference: Set errno on error, since we are called by
+ * scr_lex_init()
+ */
+ return 0;
+}
+
+/* scr_lex_destroy is for both reentrant and non-reentrant scanners. */
+int scr_lex_destroy (void)
+{
+
+ /* Pop the buffer stack, destroying each element. */
+ while(YY_CURRENT_BUFFER){
+ scr__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ scr_pop_buffer_state();
+ }
+
+ /* Destroy the stack itself. */
+ scr_free((yy_buffer_stack) );
+ (yy_buffer_stack) = NULL;
+
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * scr_lex() is called, initialization will occur. */
+ yy_init_globals( );
+
+ return 0;
+}
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+{
+ register int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * s )
+{
+ register int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+}
+#endif
+
+void *scr_alloc (yy_size_t size )
+{
+ return (void *) malloc( size );
+}
+
+void *scr_realloc (void * ptr, yy_size_t size )
+{
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return (void *) realloc( (char *) ptr, size );
+}
+
+void scr_free (void * ptr )
+{
+ free( (char *) ptr ); /* see scr_realloc() for (char *) cast */
+}
+
+#define YYTABLES_NAME "yytables"
+
+#line 799 "script_lexer.lpp"
+
+
+
+/* Set the current input file for the lexer */
+void scriptSetInputFile(PHYSFS_file* fileHandle)
+{
+ YY_BUFFER_STATE inputScript;
+ unsigned int i;
+
+ /* Reset the lexer in case it's been used before */
+ scr__flush_buffer( YY_CURRENT_BUFFER );
+
+ /* Reset include stack */
+ scr_include_stack_ptr = 0;
+
+ /* Initialize include input files */
+ for(i = 0; i < MAX_SCR_INCLUDE_DEPTH; ++i)
+ {
+ pScrInputFiles[i] = NULL;
+ scrInclLine[i] = 0;
+ }
+
+ /* Set the initial input buffer */
+ pScrInputFiles[0] = fileHandle;
+
+ inputScript = scr__create_buffer(NULL,YY_BUF_SIZE);
+
+ scr__switch_to_buffer(inputScript);
+
+ /* Reset number of macros */
+ scr_num_macros = 0;
+
+ /* Reset macro stack */
+ scr_macro_stack_ptr = 0;
+
+ /* Initialize macro input buffers */
+ for(i = 0; i < MAX_SCR_MACRO_DEPTH; ++i)
+ {
+ pScrMacroBuffer[i] = NULL;
+ }
+}
+
+void scriptGetErrorData(int *pLine, char **ppText)
+{
+ *pLine = scr_lineno;
+ *ppText = scr_text;
+}
+
+int scr_wrap(void)
+{
+ if (inComment)
+ {
+ debug( LOG_ERROR, "Warning: reached end of file in a comment" );
+ abort();
+ }
+ return 1;
+}
+
+
+/* Older GNU Flex versions don't define scr_lex_destroy()
+ * (and neither define a subminor version)
+ */
+#if !defined(YY_FLEX_SUBMINOR_VERSION) || (YY_FLEX_SUBMINOR_VERSION < 9)
+int scr_lex_destroy(void)
+{
+ /* For non-reentrant C scanner only. */
+ scr__delete_buffer(YY_CURRENT_BUFFER);
+ yy_init = 1;
+ return 0;
+}
+#endif
+
diff --git a/lib/script/script_parser.cpp b/lib/script/script_parser.cpp
new file mode 100644
index 000000000..4464892a0
--- /dev/null
+++ b/lib/script/script_parser.cpp
@@ -0,0 +1,9583 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "2.5"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 0
+
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+/* Substitute the variable and function names. */
+#define yyparse scr_parse
+#define yylex scr_lex
+#define yyerror scr_error
+#define yylval scr_lval
+#define yychar scr_char
+#define yydebug scr_debug
+#define yynerrs scr_nerrs
+
+
+/* Copy the first part of user declarations. */
+
+/* Line 268 of yacc.c */
+#line 21 "script_parser.ypp"
+
+/*
+ * script.y
+ *
+ * The yacc grammar for the scipt files.
+ */
+
+#include "lib/framework/frame.h"
+#include "lib/framework/frameresource.h"
+#include "lib/framework/string_ext.h"
+#include "lib/script/interpreter.h"
+#include "lib/script/parse.h"
+#include "lib/script/script.h"
+
+#include
+
+/* this will give us a more detailed error output */
+#define YYERROR_VERBOSE true
+
+/* Script defines stack */
+
+extern int scr_lex(void);
+extern int scr_lex_destroy(void);
+
+/* Error return codes for code generation functions */
+enum CODE_ERROR
+{
+ CE_OK, // No error
+ CE_MEMORY, // Out of memory
+ CE_PARSE // A parse error occured
+};
+
+/* Turn off a couple of warnings that the yacc generated code gives */
+
+/* Pointer to the compiled code */
+static SCRIPT_CODE *psFinalProg=NULL;
+
+/* Pointer to current block of compiled code */
+static CODE_BLOCK *psCurrBlock=NULL;
+
+/* Pointer to current block of conditional code */
+static COND_BLOCK *psCondBlock=NULL;
+
+/* Pointer to current block of object variable code */
+static OBJVAR_BLOCK *psObjVarBlock=NULL;
+
+/* Pointer to current block of compiled parameter code */
+static PARAM_BLOCK *psCurrPBlock=NULL;
+
+/* Any errors occured? */
+static bool bError=false;
+
+//String support
+//-----------------------------
+char msg[MAXSTRLEN];
+extern char STRSTACK[MAXSTACKLEN][MAXSTRLEN]; // just a simple string "stack"
+extern UDWORD CURSTACKSTR; //Current string index
+
+/* Pointer into the current code block */
+static INTERP_VAL *ip;
+
+/* Pointer to current parameter declaration block */
+//static PARAM_DECL *psCurrParamDecl=NULL;
+
+/* Pointer to current trigger subdeclaration */
+static TRIGGER_DECL *psCurrTDecl=NULL;
+
+/* Pointer to current variable subdeclaration */
+static VAR_DECL *psCurrVDecl=NULL;
+
+/* Pointer to the current variable identifier declaration */
+static VAR_IDENT_DECL *psCurrVIdentDecl=NULL;
+
+/* Pointer to the current array access block */
+static ARRAY_BLOCK *psCurrArrayBlock=NULL;
+
+/* Return code from code generation functions */
+static CODE_ERROR codeRet;
+
+/* The list of global variables */
+static VAR_SYMBOL *psGlobalVars=NULL;
+
+/* The list of global arrays */
+static VAR_SYMBOL *psGlobalArrays=NULL;
+
+#define maxEventsLocalVars 1200
+static VAR_SYMBOL *psLocalVarsB[maxEventsLocalVars]; /* local var storage */
+static UDWORD numEventLocalVars[maxEventsLocalVars]; /* number of declard local vars for each event */
+EVENT_SYMBOL *psCurEvent = NULL; /* stores current event: for local var declaration */
+
+/* The current object variable context */
+static INTERP_TYPE objVarContext = (INTERP_TYPE)0;
+
+/* Control whether debug info is generated */
+static bool genDebugInfo = true;
+
+/* Currently defined triggers */
+static TRIGGER_SYMBOL *psTriggers;
+static UDWORD numTriggers;
+
+/* Currently defined events */
+static EVENT_SYMBOL *psEvents;
+static UDWORD numEvents;
+
+/* This is true when local variables are being defined.
+ * (So local variables can have the same name as global ones)
+ */
+static bool localVariableDef=false;
+
+/* The identifier for the current script function being defined */
+//static char *pCurrFuncIdent=NULL;
+
+/* A temporary store for a line number - used when
+ * generating debugging info for functions, conditionals and loops.
+ */
+static UDWORD debugLine;
+
+/* The table of user types */
+TYPE_SYMBOL *asScrTypeTab;
+
+/* The table of instinct function type definitions */
+FUNC_SYMBOL *asScrInstinctTab;
+
+/* The table of external variables and their access functions */
+VAR_SYMBOL *asScrExternalTab;
+
+/* The table of object variables and their access functions. */
+VAR_SYMBOL *asScrObjectVarTab;
+
+/* The table of constant variables */
+CONST_SYMBOL *asScrConstantTab;
+
+/* The table of callback triggers */
+CALLBACK_SYMBOL *asScrCallbackTab;
+
+/* Used for additional debug output */
+void script_debug(const char *pFormat, ...);
+
+/****************************************************************************************
+ *
+ * Code Block Macros
+ *
+ * These macros are used to allocate and free the different types of code
+ * block used within the compiler
+ */
+
+
+/* What the macro should do if it has an allocation error.
+ * This is different depending on whether the macro is used
+ * in a function, or in a rule body.
+ *
+ * This definition is used within the code generation functions
+ * and is then changed for use within a rule body.
+ */
+#define ALLOC_ERROR_ACTION return CE_MEMORY
+
+/* Macro to allocate a program structure, size is in _bytes_ */
+#define ALLOC_PROG(psProg, codeSize, pAICode, numGlobs, numArys, numTrigs, numEvnts) \
+ (psProg) = (SCRIPT_CODE *)malloc(sizeof(SCRIPT_CODE)); \
+ if ((psProg) == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psProg)->pCode = (INTERP_VAL *)malloc((codeSize) * sizeof(INTERP_VAL)); \
+ if ((psProg)->pCode == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ if (numGlobs > 0) \
+ { \
+ (psProg)->pGlobals = (INTERP_TYPE *)malloc(sizeof(INTERP_TYPE) * (numGlobs)); \
+ if ((psProg)->pGlobals == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ } \
+ else \
+ { \
+ (psProg)->pGlobals = NULL; \
+ } \
+ if (numArys > 0) \
+ { \
+ (psProg)->psArrayInfo = (ARRAY_DATA *)malloc(sizeof(ARRAY_DATA) * (numArys)); \
+ if ((psProg)->psArrayInfo == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ } \
+ else \
+ { \
+ (psProg)->psArrayInfo = NULL; \
+ } \
+ (psProg)->numArrays = (UWORD)(numArys); \
+ if ((numTrigs) > 0) \
+ { \
+ (psProg)->pTriggerTab = (uint16_t *)malloc(sizeof(uint16_t) * ((numTrigs) + 1)); \
+ if ((psProg)->pTriggerTab == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psProg)->psTriggerData = (TRIGGER_DATA *)malloc(sizeof(TRIGGER_DATA) * (numTrigs)); \
+ if ((psProg)->psTriggerData == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ } \
+ else \
+ { \
+ (psProg)->pTriggerTab = NULL; \
+ (psProg)->psTriggerData = NULL; \
+ } \
+ (psProg)->pEventTab = (uint16_t *)malloc(sizeof(uint16_t) * ((numEvnts) + 1)); \
+ if ((psProg)->pEventTab == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psProg)->pEventLinks = (int16_t *)malloc(sizeof(int16_t) * (numEvnts)); \
+ if ((psProg)->pEventLinks == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psProg)->numGlobals = (UWORD)(numGlobs); \
+ (psProg)->numTriggers = (UWORD)(numTriggers); \
+ (psProg)->numEvents = (UWORD)(numEvnts); \
+ (psProg)->size = (codeSize) * sizeof(INTERP_VAL);
+
+/* Macro to allocate a code block, blockSize - number of INTERP_VALs we need*/
+#define ALLOC_BLOCK(psBlock, num) \
+ (psBlock) = (CODE_BLOCK *)malloc(sizeof(CODE_BLOCK)); \
+ if ((psBlock) == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psBlock)->pCode = (INTERP_VAL *)malloc((num) * sizeof(INTERP_VAL)); \
+ if ((psBlock)->pCode == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ free((psBlock)); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psBlock)->size = (num); \
+ (psBlock)->debugEntries = 0
+
+/* Macro to free a code block */
+#define FREE_BLOCK(psBlock) \
+ free((psBlock)->pCode); \
+ free((psBlock))
+
+/* Macro to allocate a parameter block */
+#define ALLOC_PBLOCK(psBlock, num, paramSize) \
+ (psBlock) = (PARAM_BLOCK *)malloc(sizeof(PARAM_BLOCK)); \
+ if ((psBlock) == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psBlock)->pCode = (INTERP_VAL *)malloc((num) * sizeof(INTERP_VAL)); \
+ if ((psBlock)->pCode == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ free((psBlock)); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psBlock)->aParams = (INTERP_TYPE *)malloc(sizeof(INTERP_TYPE) * (paramSize)); \
+ if ((psBlock)->aParams == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ free((psBlock)->pCode); \
+ free((psBlock)); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psBlock)->size = (num); \
+ (psBlock)->numParams = (paramSize)
+
+/* Macro to free a parameter block */
+#define FREE_PBLOCK(psBlock) \
+ free((psBlock)->pCode); \
+ free((psBlock)->aParams); \
+ free((psBlock))
+
+/* Macro to allocate a parameter declaration block */
+#define ALLOC_PARAMDECL(psPDecl, num) \
+ (psPDecl) = (PARAM_DECL *)malloc(sizeof(PARAM_DECL)); \
+ if ((psPDecl) == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psPDecl)->aParams = (INTERP_TYPE *)malloc(sizeof(INTERP_TYPE) * (num)); \
+ if ((psPDecl)->aParams == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psPDecl)->numParams = (num)
+
+/* Macro to free a parameter declaration block */
+#define FREE_PARAMDECL(psPDecl) \
+ free((psPDecl)->aParams); \
+ free((psPDecl))
+
+/* Macro to allocate a conditional block */
+#define ALLOC_CONDBLOCK(psCB, num, numBlocks) \
+ (psCB) = (COND_BLOCK *)malloc(sizeof(COND_BLOCK)); \
+ if ((psCB) == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psCB)->aOffsets = (UDWORD *)malloc(sizeof(SDWORD) * (num)); \
+ if ((psCB)->aOffsets == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psCB)->pCode = (INTERP_VAL *)malloc((numBlocks) * sizeof(INTERP_VAL)); \
+ if ((psCB)->pCode == NULL) \
+ { \
+ debug(LOG_ERROR, "Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psCB)->size = (numBlocks); \
+ (psCB)->numOffsets = (num)
+
+/* Macro to free a conditional block */
+#define FREE_CONDBLOCK(psCB) \
+ free((psCB)->aOffsets); \
+ free((psCB)->pCode); \
+ free(psCB)
+
+/* Macro to free a code block */
+#define FREE_USERBLOCK(psBlock) \
+ free((psBlock)->pCode); \
+ free((psBlock))
+
+/* Macro to allocate an object variable block */
+#define ALLOC_OBJVARBLOCK(psOV, blockSize, psVar) \
+ (psOV) = (OBJVAR_BLOCK *)malloc(sizeof(OBJVAR_BLOCK)); \
+ if ((psOV) == NULL) \
+ { \
+ scr_error("Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psOV)->pCode = (INTERP_VAL *)malloc((blockSize) * sizeof(INTERP_VAL)); \
+ if ((psOV)->pCode == NULL) \
+ { \
+ scr_error("Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psOV)->size = (blockSize); \
+ (psOV)->psObjVar = (psVar)
+
+/* Macro to free an object variable block */
+#define FREE_OBJVARBLOCK(psOV) \
+ free((psOV)->pCode); \
+ free(psOV)
+
+/* Macro to allocate an array variable block */
+#define ALLOC_ARRAYBLOCK(psAV, blockSize, psVar) \
+ (psAV) = (ARRAY_BLOCK *)malloc(sizeof(ARRAY_BLOCK)); \
+ if ((psAV) == NULL) \
+ { \
+ scr_error("Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psAV)->pCode = (INTERP_VAL *)malloc((blockSize) * sizeof(INTERP_VAL)); \
+ if ((psAV)->pCode == NULL) \
+ { \
+ scr_error("Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psAV)->size = (blockSize); \
+ (psAV)->dimensions = 1; \
+ (psAV)->psArrayVar = (psVar)
+
+/* Macro to free an object variable block */
+#define FREE_ARRAYBLOCK(psAV) \
+ free((psAV)->pCode); \
+ free((psAV))
+
+/* Allocate a trigger subdecl */
+#define ALLOC_TSUBDECL(psTSub, blockType, blockSize, blockTime) \
+ (psTSub) = (TRIGGER_DECL *)malloc(sizeof(TRIGGER_DECL)); \
+ if ((psTSub) == NULL) \
+ { \
+ scr_error("Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psTSub)->type = (blockType); \
+ (psTSub)->time = (blockTime); \
+ if ((blockSize) > 0) \
+ { \
+ (psTSub)->pCode = (INTERP_VAL *)malloc((blockSize) * sizeof(INTERP_VAL)); \
+ if ((psTSub)->pCode == NULL) \
+ { \
+ scr_error("Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ (psTSub)->size = (blockSize); \
+ } \
+ else \
+ { \
+ (psTSub)->pCode = NULL; \
+ (psTSub)->size = 0; \
+ }
+
+/* Free a trigger subdecl */
+#define FREE_TSUBDECL(psTSub) \
+ if ((psTSub)->pCode) \
+ { \
+ free((psTSub)->pCode); \
+ } \
+ free(psTSub)
+
+/* Allocate a variable declaration block */
+#define ALLOC_VARDECL(psDcl) \
+ (psDcl) = (VAR_DECL *)malloc(sizeof(VAR_DECL)); \
+ if ((psDcl) == NULL) \
+ { \
+ scr_error("Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ }
+
+/* Free a variable declaration block */
+#define FREE_VARDECL(psDcl) \
+ free(psDcl)
+
+/* Allocate a variable declaration block */
+static inline CODE_ERROR do_ALLOC_VARIDENTDECL(VAR_IDENT_DECL** psDcl, const char* ident, unsigned int dim)
+{
+ // Allocate memory
+ *psDcl = (VAR_IDENT_DECL *)malloc(sizeof(VAR_IDENT_DECL));
+ if (*psDcl == NULL)
+ {
+ scr_error("Out of memory");
+ ALLOC_ERROR_ACTION;
+ }
+
+ // Copy over the "ident" string (if it's there)
+ if (ident != NULL)
+ {
+ (*psDcl)->pIdent = strdup(ident);
+ if ((*psDcl)->pIdent == NULL)
+ {
+ scr_error("Out of memory");
+ ALLOC_ERROR_ACTION;
+ }
+ }
+ else
+ {
+ (*psDcl)->pIdent = NULL;
+ }
+
+ (*psDcl)->dimensions = dim;
+
+ return CE_OK;
+}
+
+#define ALLOC_VARIDENTDECL(psDcl, ident, dim) \
+{ \
+ CODE_ERROR err = do_ALLOC_VARIDENTDECL(&psDcl, ident, dim); \
+ if (err != CE_OK) \
+ return err; \
+}
+
+/* Free a variable declaration block */
+static void freeVARIDENTDECL(VAR_IDENT_DECL* psDcl)
+{
+ free(psDcl->pIdent);
+ free(psDcl);
+}
+
+/****************************************************************************************
+ *
+ * Code block manipulation macros.
+ *
+ * These are used to copy chunks of code from one block to another
+ * or to insert opcodes or other values into a code block.
+ * All the macros use the ip parameter. This is a pointer into the code
+ * block that is incremented by the macro. This ensures that it always points
+ * to the next free space in the code block.
+ */
+
+/* Macro to store an opcode in a code block, opcode type is '-1' */
+#define PUT_OPCODE(ip, opcode) \
+ (ip)->type = VAL_OPCODE; \
+ (ip)->v.ival = (opcode) << OPCODE_SHIFT; \
+ (ip)++
+
+/* Macro to put a packed opcode in a code block */
+#define PUT_PKOPCODE(ip, opcode, data) \
+ (ip)->type = VAL_PKOPCODE; \
+ (ip)->v.ival = ((SDWORD)(data)) & OPCODE_DATAMASK; \
+ (ip)->v.ival = (((SDWORD)(opcode)) << OPCODE_SHIFT) | ((ip)->v.ival); \
+ (ip)++
+
+/* Special macro for floats, could be a bit tricky */
+#define PUT_DATA_FLOAT(ip, data) \
+ ip->type = VAL_FLOAT; \
+ ip->v.fval = (float)(data); \
+ ip++
+
+/* Macros to store a value in a code block */
+#define PUT_DATA_BOOL(ip, value) \
+ (ip)->type = VAL_BOOL; \
+ (ip)->v.bval = (int32_t)(value); \
+ (ip)++
+
+#define PUT_DATA_INT(ip, value) \
+ (ip)->type = VAL_INT; \
+ (ip)->v.ival = (SDWORD)(value); \
+ (ip)++
+
+#define PUT_DATA_STRING(ip, value) \
+ (ip)->type = VAL_STRING; \
+ (ip)->v.sval = (char *)(value); \
+ (ip)++
+
+#define PUT_OBJECT_CONST(ip, value, constType) \
+ (ip)->type = (constType); \
+ (ip)->v.oval = (value); \
+ (ip)++
+
+#define PUT_STRING(ip, value) \
+ ((INTERP_VAL *)(ip))->type = VAL_STRING; \
+ ((INTERP_VAL *)(ip))->v.sval = (value); \
+ ((INTERP_VAL *)(ip)) += 1
+
+/* Macro to store an external function index in a code block */
+#define PUT_FUNC_EXTERN(ip, func) \
+ (ip)->type = VAL_FUNC_EXTERN; \
+ (ip)->v.pFuncExtern = (SCRIPT_FUNC)func; \
+ (ip)++
+
+/* Macro to store an internal (in-script, actually an event) function index in a code block */
+#define PUT_EVENT(ip, func) \
+ (ip)->type = VAL_EVENT; \
+ (ip)->v.ival = (SDWORD)func; \
+ (ip)++
+
+/* Macro to store trigger */
+#define PUT_TRIGGER(ip, func) \
+ (ip)->type = VAL_TRIGGER; \
+ (ip)->v.ival = (SDWORD)func; \
+ (ip)++
+
+/* Macro to store a function pointer in a code block */
+#define PUT_VARFUNC(ip, func) \
+ (ip)->type = VAL_OBJ_GETSET; \
+ (ip)->v.pObjGetSet = (SCRIPT_VARFUNC)func; \
+ (ip)++
+
+/* Macro to store a variable index number in a code block - NOT USED */
+#define PUT_INDEX(ip, index) \
+ (ip)->type = -1; \
+ (ip)->v.ival = (SDWORD)(index); \
+ (ip)++
+
+/* Macro to copy a code block into another code block */
+#define PUT_BLOCK(ip, psOldBlock) \
+ memcpy(ip, (psOldBlock)->pCode, (psOldBlock)->size * sizeof(INTERP_VAL)); \
+ (ip) = (INTERP_VAL *)( (ip) + (psOldBlock)->size)
+
+/***********************************************************************************
+ *
+ * Debugging information macros
+ *
+ * These macros are only used to generate debugging information for scripts.
+ */
+
+/* Macro to allocate debugging info for a CODE_BLOCK or a COND_BLOCK */
+#define ALLOC_DEBUG(psBlock, num) \
+ if (genDebugInfo) \
+ { \
+ (psBlock)->psDebug = (SCRIPT_DEBUG *)malloc(sizeof(SCRIPT_DEBUG) * (num)); \
+ if ((psBlock)->psDebug == NULL) \
+ { \
+ scr_error("Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ memset((psBlock)->psDebug, 0, sizeof(SCRIPT_DEBUG) * (num));\
+ (psBlock)->debugEntries = (UWORD)(num); \
+ } \
+ else \
+ { \
+ (psBlock)->psDebug = NULL; \
+ (psBlock)->debugEntries = 0; \
+ }
+
+/* Macro to free debugging info */
+#define FREE_DEBUG(psBlock) \
+ if (genDebugInfo) \
+ free((psBlock)->psDebug)
+
+
+/* Macro to copy the debugging information from one block to another */
+#define PUT_DEBUG(psFinal, psBlock) \
+ if (genDebugInfo) \
+ { \
+ memcpy((psFinal)->psDebug, (psBlock)->psDebug, \
+ sizeof(SCRIPT_DEBUG) * (psBlock)->debugEntries); \
+ (psFinal)->debugEntries = (psBlock)->debugEntries; \
+ }
+
+/* Macro to combine the debugging information in two blocks into a third block */
+static UDWORD _dbEntry;
+static SCRIPT_DEBUG *_psCurr;
+#define COMBINE_DEBUG(psFinal, psBlock1, psBlock2) \
+ if (genDebugInfo) \
+ { \
+ memcpy((psFinal)->psDebug, (psBlock1)->psDebug, \
+ sizeof(SCRIPT_DEBUG) * (psBlock1)->debugEntries); \
+ _baseOffset = (psBlock1)->size / sizeof(UDWORD); \
+ for(_dbEntry = 0; _dbEntry < (psBlock2)->debugEntries; _dbEntry++) \
+ { \
+ _psCurr = (psFinal)->psDebug + (psBlock1)->debugEntries + _dbEntry; \
+ _psCurr->line = (psBlock2)->psDebug[_dbEntry].line; \
+ _psCurr->offset = (psBlock2)->psDebug[_dbEntry].offset + _baseOffset; \
+ } \
+ (psFinal)->debugEntries = (psBlock1)->debugEntries + (psBlock2)->debugEntries; \
+ }
+
+/* Macro to append some debugging information onto a block, given the instruction
+ offset of the debugging information already in the destination block */
+#define APPEND_DEBUG(psFinal, baseOffset, psBlock) \
+ if (genDebugInfo) \
+ { \
+ for(_dbEntry = 0; _dbEntry < (psBlock)->debugEntries; _dbEntry++) \
+ { \
+ _psCurr = (psFinal)->psDebug + (psFinal)->debugEntries + _dbEntry; \
+ _psCurr->line = (psBlock)->psDebug[_dbEntry].line; \
+ _psCurr->offset = (psBlock)->psDebug[_dbEntry].offset + (baseOffset); \
+ } \
+ (psFinal)->debugEntries = (UWORD)((psFinal)->debugEntries + (psBlock)->debugEntries); \
+ }
+
+
+/* Macro to store a label in the debug info */
+#define DEBUG_LABEL(psBlock, offset, pString) \
+ if (genDebugInfo) \
+ { \
+ (psBlock)->psDebug[offset].pLabel = (char *)malloc(strlen(pString)+1); \
+ if (!(psBlock)->psDebug[offset].pLabel) \
+ { \
+ scr_error("Out of memory"); \
+ ALLOC_ERROR_ACTION; \
+ } \
+ strcpy((psBlock)->psDebug[offset].pLabel, pString); \
+ }
+
+
+/***************************************************************************************
+ *
+ * Code generation functions
+ *
+ * These functions are used within rule bodies to generate code.
+ */
+
+/* Macro to deal with the errors returned by code generation functions.
+ * Used within the rule body.
+ */
+#define CHECK_CODE_ERROR(error) \
+ if ((error) == CE_MEMORY) \
+ { \
+ YYABORT; \
+ } \
+ else if ((error) == CE_PARSE) \
+ { \
+ YYERROR; \
+ }
+
+void script_debug(const char *pFormat, ...)
+{
+ char buffer[500];
+ va_list pArgs;
+
+ va_start(pArgs, pFormat);
+ vsnprintf(buffer, sizeof(buffer), pFormat, pArgs);
+ va_end(pArgs);
+
+ debug(LOG_SCRIPT, "%s", buffer);
+}
+
+/* Generate the code for a function call, checking the parameter
+ * types match.
+ */
+static CODE_ERROR scriptCodeFunction(FUNC_SYMBOL *psFSymbol, // The function being called
+ PARAM_BLOCK *psPBlock, // The functions parameters
+ int32_t expContext, // Whether the function is being
+ // called in an expression context
+ CODE_BLOCK **ppsCBlock) // The generated code block
+{
+ UDWORD size, i;
+ INTERP_VAL *ip;
+ bool typeError = false;
+ char aErrorString[255];
+ INTERP_TYPE type1,type2;
+
+ ASSERT( psFSymbol != NULL, "ais_CodeFunction: Invalid function symbol pointer" );
+ ASSERT( psPBlock != NULL,
+ "scriptCodeFunction: Invalid param block pointer" );
+ ASSERT( (psPBlock->size == 0) || psPBlock->pCode != NULL,
+ "scriptCodeFunction: Invalid parameter code pointer" );
+ ASSERT( ppsCBlock != NULL,
+ "scriptCodeFunction: Invalid generated code block pointer" );
+
+ /* Check the parameter types match what the function needs */
+ for(i=0; (inumParams) && (inumParams); i++)
+ {
+/* if (psFSymbol->aParams[i] != VAL_VOID &&
+ psFSymbol->aParams[i] != psPBlock->aParams[i])*/
+ //TODO: string support
+ if(psFSymbol->aParams[i] != VAL_STRING) // string - allow mixed types if string is parameter type //TODO: tweak this
+ {
+ type1 = (INTERP_TYPE)psFSymbol->aParams[i];
+ type2 = (INTERP_TYPE)psPBlock->aParams[i];
+ if (!interpCheckEquiv(type1, type2))
+ {
+ debug(LOG_ERROR, "scriptCodeFunction: Type mismatch for parameter %d (%d/%d)", i, psFSymbol->aParams[i], psPBlock->aParams[i]);
+ snprintf(aErrorString, sizeof(aErrorString), "Type mismatch for parameter %d", i);
+ scr_error("%s", aErrorString);
+ typeError = true;
+ }
+ }
+ //else
+ //{
+ // debug(LOG_SCRIPT, "scriptCodeFunction: %s takes string as parameter %d (provided: %d)", psFSymbol->pIdent, i, psPBlock->aParams[i]);
+ //}
+ }
+
+ /* Check the number of parameters matches that expected */
+ if (psFSymbol->numParams != psPBlock->numParams)
+ {
+ snprintf(aErrorString, sizeof(aErrorString), "Expected %d parameters", psFSymbol->numParams);
+ scr_error("%s", aErrorString);
+ *ppsCBlock = NULL;
+ return CE_PARSE;
+ }
+
+ if (typeError)
+ {
+ /* Report the error here so all the */
+ /* type mismatches are reported */
+ *ppsCBlock = NULL;
+ return CE_PARSE;
+ }
+
+ //size = psPBlock->size + sizeof(OPCODE) + sizeof(SCRIPT_FUNC);
+ size = psPBlock->size + 1 + 1; //size + opcode + sizeof(SCRIPT_FUNC)
+
+ if (!expContext && (psFSymbol->type != VAL_VOID))
+ {
+ //size += sizeof(OPCODE);
+ size += 1; //+ 1 additional opcode to pop value if needed
+ }
+
+ ALLOC_BLOCK(*ppsCBlock, size);
+ ip = (*ppsCBlock)->pCode;
+ (*ppsCBlock)->type = psFSymbol->type;
+
+ /* Copy in the code for the parameters */
+ PUT_BLOCK(ip, psPBlock);
+ FREE_PBLOCK(psPBlock);
+
+ /* Make the function call */
+ if (psFSymbol->script)
+ {
+ /* function defined in this script */
+// PUT_OPCODE(ip, OP_FUNC);
+// PUT_SCRIPTFUNC(ip, psFSymbol);
+ ASSERT(false, "wrong function type call");
+ }
+ else
+ {
+ /* call an instinct function */
+ PUT_OPCODE(ip, OP_CALL);
+ PUT_FUNC_EXTERN(ip, psFSymbol->pFunc);
+ }
+
+ if (!expContext && (psFSymbol->type != VAL_VOID))
+ {
+ /* Clear the return value from the stack */
+ PUT_OPCODE(ip, OP_POP);
+ }
+
+ return CE_OK;
+}
+
+
+/* Function call: Check the parameter types match, assumes param count matched */
+static UDWORD checkFuncParamTypes(EVENT_SYMBOL *psFSymbol, // The function being called
+ PARAM_BLOCK *psPBlock) // The generated code block
+{
+ UDWORD i;
+
+ //debug(LOG_SCRIPT,"checkFuncParamTypes");
+
+ /* Check the parameter types match what the function needs */
+ for(i=0; (inumParams) && (inumParams); i++)
+ {
+ //TODO: string support
+ //if(psFSymbol->aParams[i] != VAL_STRING) // string - allow mixed types if string is parameter type
+ //{
+ if (!interpCheckEquiv(psFSymbol->aParams[i], psPBlock->aParams[i]))
+ {
+ debug(LOG_ERROR, "checkFuncParamTypes: Type mismatch for parameter %d ('1' based) in Function '%s' (provided type: %d, expected: %d)", (i+1), psFSymbol->pIdent, psPBlock->aParams[i], psFSymbol->aParams[i]);
+ scr_error("Parameter type mismatch");
+ return i+1;
+ }
+ //}
+ }
+
+ //debug(LOG_SCRIPT,"END checkFuncParamTypes");
+
+ return 0; //all ok
+}
+
+/* Generate the code for a parameter callback, checking the parameter
+ * types match.
+ */
+static CODE_ERROR scriptCodeCallbackParams(
+ CALLBACK_SYMBOL *psCBSymbol, // The callback being called
+ PARAM_BLOCK *psPBlock, // The callbacks parameters
+ TRIGGER_DECL **ppsTDecl) // The generated code block
+{
+ UDWORD size, i;
+ INTERP_VAL *ip;
+ bool typeError = false;
+ char aErrorString[255];
+
+ ASSERT( psPBlock != NULL,
+ "scriptCodeCallbackParams: Invalid param block pointer" );
+ ASSERT( (psPBlock->size == 0) || psPBlock->pCode != NULL,
+ "scriptCodeCallbackParams: Invalid parameter code pointer" );
+ ASSERT( ppsTDecl != NULL,
+ "scriptCodeCallbackParams: Invalid generated code block pointer" );
+ ASSERT( psCBSymbol->pFunc != NULL,
+ "scriptCodeCallbackParams: Expected function pointer for callback symbol" );
+
+ /* Check the parameter types match what the function needs */
+ for(i=0; (inumParams) && (inumParams); i++)
+ {
+ if (!interpCheckEquiv((INTERP_TYPE)psCBSymbol->aParams[i], psPBlock->aParams[i]))
+ {
+ snprintf(aErrorString, sizeof(aErrorString), "Type mismatch for parameter %d", i);
+ scr_error("%s", aErrorString);
+ typeError = true;
+ }
+ }
+
+ /* Check the number of parameters matches that expected */
+ if (psPBlock->numParams == 0)
+ {
+ scr_error("Expected parameters to callback");
+ *ppsTDecl = NULL;
+ return CE_PARSE;
+ }
+ else if (psCBSymbol->numParams != psPBlock->numParams)
+ {
+ snprintf(aErrorString, sizeof(aErrorString), "Expected %d parameters", psCBSymbol->numParams);
+ scr_error("%s", aErrorString);
+ *ppsTDecl = NULL;
+ return CE_PARSE;
+ }
+ if (typeError)
+ {
+ /* Return the error here so all the */
+ /* type mismatches are reported */
+ *ppsTDecl = NULL;
+ return CE_PARSE;
+ }
+
+ //size = psPBlock->size + sizeof(OPCODE) + sizeof(SCRIPT_FUNC);
+ size = psPBlock->size + 1 + 1; //size + opcode + SCRIPT_FUNC
+
+ ALLOC_TSUBDECL(*ppsTDecl, psCBSymbol->type, size, 0);
+ ip = (*ppsTDecl)->pCode;
+
+ /* Copy in the code for the parameters */
+ PUT_BLOCK(ip, psPBlock);
+ FREE_PBLOCK(psPBlock);
+
+ /* call the instinct function */
+ PUT_OPCODE(ip, OP_CALL);
+ PUT_FUNC_EXTERN(ip, psCBSymbol->pFunc);
+
+ return CE_OK;
+}
+
+
+/* Generate code for assigning a value to a variable */
+static CODE_ERROR scriptCodeAssignment(VAR_SYMBOL *psVariable, // The variable to assign to
+ CODE_BLOCK *psValue, // The code for the value to
+ // assign
+ CODE_BLOCK **ppsBlock) // Generated code
+{
+ SDWORD size;
+
+ ASSERT( psVariable != NULL,
+ "scriptCodeAssignment: Invalid variable symbol pointer" );
+ ASSERT( psValue != NULL,
+ "scriptCodeAssignment: Invalid value code block pointer" );
+ ASSERT( psValue->pCode != NULL,
+ "scriptCodeAssignment: Invalid value code pointer" );
+ ASSERT( ppsBlock != NULL,
+ "scriptCodeAssignment: Invalid generated code block pointer" );
+
+ //size = psValue->size + sizeof(OPCODE);
+ size = psValue->size + 1; //1 - for assignment opcode
+
+ if (psVariable->storage == ST_EXTERN)
+ {
+ // Check there is a set function
+ if (psVariable->set == NULL)
+ {
+ scr_error("No set function for external variable");
+ return CE_PARSE;
+ }
+
+ //size += sizeof(SCRIPT_VARFUNC);
+ size += 1; //1 - for set func pointer
+ }
+ ALLOC_BLOCK(*ppsBlock, size);
+ ip = (*ppsBlock)->pCode;
+
+ /* Copy in the code for the expression */
+ PUT_BLOCK(ip, psValue);
+ FREE_BLOCK(psValue);
+
+ /* Code to get the value from the stack into the variable */
+ switch (psVariable->storage)
+ {
+ case ST_PUBLIC:
+ case ST_PRIVATE:
+ PUT_PKOPCODE(ip, OP_POPGLOBAL, psVariable->index);
+ break;
+ case ST_LOCAL:
+ PUT_PKOPCODE(ip, OP_POPLOCAL, psVariable->index);
+ break;
+ case ST_EXTERN:
+ PUT_PKOPCODE(ip, OP_VARCALL, psVariable->index);
+ PUT_VARFUNC(ip, psVariable->set);
+ break;
+ case ST_OBJECT:
+ scr_error("Cannot use member variables in this context");
+ return CE_PARSE;
+ break;
+ default:
+ scr_error("Unknown storage type");
+ return CE_PARSE;
+ break;
+ }
+
+ return CE_OK;
+}
+
+
+/* Generate code for assigning a value to an object variable */
+static CODE_ERROR scriptCodeObjAssignment(OBJVAR_BLOCK *psVariable,// The variable to assign to
+ CODE_BLOCK *psValue, // The code for the value to
+ // assign
+ CODE_BLOCK **ppsBlock) // Generated code
+{
+ ASSERT( psVariable != NULL,
+ "scriptCodeObjAssignment: Invalid object variable block pointer" );
+ ASSERT( psVariable->pCode != NULL,
+ "scriptCodeObjAssignment: Invalid object variable code pointer" );
+ ASSERT( psVariable->psObjVar != NULL,
+ "scriptCodeObjAssignment: Invalid object variable symbol pointer" );
+ ASSERT( psValue != NULL,
+ "scriptCodeObjAssignment: Invalid value code block pointer" );
+ ASSERT( psValue->pCode != NULL,
+ "scriptCodeObjAssignment: Invalid value code pointer" );
+ ASSERT( ppsBlock != NULL,
+ "scriptCodeObjAssignment: Invalid generated code block pointer" );
+
+ // Check there is an access function for the variable
+ if (psVariable->psObjVar->set == NULL)
+ {
+ scr_error("No set function for object variable");
+ return CE_PARSE;
+ }
+
+ //ALLOC_BLOCK(*ppsBlock, psVariable->size + psValue->size + sizeof(OPCODE) + sizeof(SCRIPT_VARFUNC));
+ ALLOC_BLOCK(*ppsBlock, psVariable->size + psValue->size + 1 + 1); //size + size + opcode + 'sizeof(SCRIPT_VARFUNC)'
+
+ ip = (*ppsBlock)->pCode;
+
+ /* Copy in the code for the value */
+ PUT_BLOCK(ip, psValue);
+ FREE_BLOCK(psValue);
+
+ /* Copy in the code for the object */
+ PUT_BLOCK(ip, psVariable);
+
+ /* Code to get the value from the stack into the variable */
+ PUT_PKOPCODE(ip, OP_VARCALL, psVariable->psObjVar->index);
+ PUT_VARFUNC(ip, (psVariable->psObjVar->set));
+
+ /* Free the variable block */
+ FREE_OBJVARBLOCK(psVariable);
+
+ return CE_OK;
+}
+
+
+/* Generate code for getting a value from an object variable */
+static CODE_ERROR scriptCodeObjGet(OBJVAR_BLOCK *psVariable,// The variable to get from
+ CODE_BLOCK **ppsBlock) // Generated code
+{
+ ASSERT( psVariable != NULL,
+ "scriptCodeObjAssignment: Invalid object variable block pointer" );
+ ASSERT( psVariable->pCode != NULL,
+ "scriptCodeObjAssignment: Invalid object variable code pointer" );
+ ASSERT( psVariable->psObjVar != NULL,
+ "scriptCodeObjAssignment: Invalid object variable symbol pointer" );
+ ASSERT( ppsBlock != NULL,
+ "scriptCodeObjAssignment: Invalid generated code block pointer" );
+
+ // Check there is an access function for the variable
+ if (psVariable->psObjVar->get == NULL)
+ {
+ scr_error("No get function for object variable");
+ return CE_PARSE;
+ }
+
+ //ALLOC_BLOCK(*ppsBlock, psVariable->size + sizeof(OPCODE) + sizeof(SCRIPT_VARFUNC));
+ ALLOC_BLOCK(*ppsBlock, psVariable->size + 1 + 1); //size + opcode + SCRIPT_VARFUNC
+
+ ip = (*ppsBlock)->pCode;
+
+ /* Copy in the code for the object */
+ PUT_BLOCK(ip, psVariable);
+ (*ppsBlock)->type = psVariable->psObjVar->type;
+
+ /* Code to get the value from the object onto the stack */
+ PUT_PKOPCODE(ip, OP_VARCALL, psVariable->psObjVar->index);
+ PUT_VARFUNC(ip, psVariable->psObjVar->get);
+
+ /* Free the variable block */
+ FREE_OBJVARBLOCK(psVariable);
+
+ return CE_OK;
+}
+
+
+/* Generate code for assigning a value to an array variable */
+static CODE_ERROR scriptCodeArrayAssignment(ARRAY_BLOCK *psVariable,// The variable to assign to
+ CODE_BLOCK *psValue, // The code for the value to
+ // assign
+ CODE_BLOCK **ppsBlock) // Generated code
+{
+ ASSERT( psVariable != NULL,
+ "scriptCodeObjAssignment: Invalid object variable block pointer" );
+ ASSERT( psVariable->pCode != NULL,
+ "scriptCodeObjAssignment: Invalid object variable code pointer" );
+ ASSERT( psVariable->psArrayVar != NULL,
+ "scriptCodeObjAssignment: Invalid object variable symbol pointer" );
+ ASSERT( psValue != NULL,
+ "scriptCodeObjAssignment: Invalid value code block pointer" );
+ ASSERT( psValue->pCode != NULL,
+ "scriptCodeObjAssignment: Invalid value code pointer" );
+ ASSERT( ppsBlock != NULL,
+ "scriptCodeObjAssignment: Invalid generated code block pointer" );
+
+ // Check this is an array
+ if (psVariable->psArrayVar->dimensions == 0)
+ {
+ scr_error("Not an array variable");
+ return CE_PARSE;
+ }
+
+ ALLOC_BLOCK(*ppsBlock, psVariable->size + psValue->size + 1); //size + size + opcode
+
+ ip = (*ppsBlock)->pCode;
+
+ /* Copy in the code for the value */
+ PUT_BLOCK(ip, psValue);
+ FREE_BLOCK(psValue);
+
+ /* Copy in the code for the array index */
+ PUT_BLOCK(ip, psVariable);
+
+ /* Code to get the value from the stack into the variable */
+ PUT_PKOPCODE(ip, OP_POPARRAYGLOBAL,
+ ((psVariable->psArrayVar->dimensions << ARRAY_DIMENSION_SHIFT) & ARRAY_DIMENSION_MASK) |
+ (psVariable->psArrayVar->index & ARRAY_BASE_MASK) );
+
+ /* Free the variable block */
+ FREE_ARRAYBLOCK(psVariable);
+
+ return CE_OK;
+}
+
+
+/* Generate code for getting a value from an array variable */
+static CODE_ERROR scriptCodeArrayGet(ARRAY_BLOCK *psVariable,// The variable to get from
+ CODE_BLOCK **ppsBlock) // Generated code
+{
+ ASSERT( psVariable != NULL,
+ "scriptCodeObjAssignment: Invalid object variable block pointer" );
+ ASSERT( psVariable->pCode != NULL,
+ "scriptCodeObjAssignment: Invalid object variable code pointer" );
+ ASSERT( psVariable->psArrayVar != NULL,
+ "scriptCodeObjAssignment: Invalid object variable symbol pointer" );
+ ASSERT( ppsBlock != NULL,
+ "scriptCodeObjAssignment: Invalid generated code block pointer" );
+
+ // Check this is an array
+ if (psVariable->psArrayVar->dimensions == 0)
+ {
+ scr_error("Not an array variable");
+ return CE_PARSE;
+ }
+
+ ALLOC_BLOCK(*ppsBlock, psVariable->size + 1); //size + opcode
+
+ ip = (*ppsBlock)->pCode;
+
+ /* Copy in the code for the array index */
+ PUT_BLOCK(ip, psVariable);
+ (*ppsBlock)->type = psVariable->psArrayVar->type;
+
+ /* Code to get the value from the array onto the stack */
+ PUT_PKOPCODE(ip, OP_PUSHARRAYGLOBAL,
+ ((psVariable->psArrayVar->dimensions << ARRAY_DIMENSION_SHIFT) & ARRAY_DIMENSION_MASK) |
+ (psVariable->psArrayVar->index & ARRAY_BASE_MASK) );
+
+ /* Free the variable block */
+ FREE_ARRAYBLOCK(psVariable);
+
+ return CE_OK;
+}
+
+
+/* Generate the final code block for conditional statements */
+static CODE_ERROR scriptCodeConditional(
+ COND_BLOCK *psCondBlock, // The intermediate conditional code
+ CODE_BLOCK **ppsBlock) // The final conditional code
+{
+ UDWORD i;
+
+ ASSERT( psCondBlock != NULL,
+ "scriptCodeConditional: Invalid conditional code block pointer" );
+ ASSERT( psCondBlock->pCode != NULL,
+ "scriptCodeConditional: Invalid conditional code pointer" );
+ ASSERT( ppsBlock != NULL,
+ "scriptCodeConditional: Invalid generated code block pointer" );
+
+ /* Allocate the final block */
+ ALLOC_BLOCK(*ppsBlock, psCondBlock->size);
+ ALLOC_DEBUG(*ppsBlock, psCondBlock->debugEntries);
+ ip = (*ppsBlock)->pCode;
+
+ /* Copy the code over */
+ PUT_BLOCK(ip, psCondBlock);
+
+ /* Copy the debugging information */
+ PUT_DEBUG(*ppsBlock, psCondBlock);
+
+ /* Now set the offsets of jumps in the conditional to the correct value */
+ for(i = 0; i < psCondBlock->numOffsets; i++)
+ {
+ ip = (*ppsBlock)->pCode + psCondBlock->aOffsets[i];
+ // *ip = ((*ppsBlock)->size / sizeof(UDWORD)) - (ip - (*ppsBlock)->pCode);
+
+ ip->type = VAL_PKOPCODE;
+ ip->v.ival = (*ppsBlock)->size - (ip - (*ppsBlock)->pCode);
+ ip->v.ival = (OP_JUMP << OPCODE_SHIFT) | ( (ip->v.ival) & OPCODE_DATAMASK );
+ }
+
+ /* Free the original code */
+ FREE_DEBUG(psCondBlock);
+ FREE_CONDBLOCK(psCondBlock);
+
+ return CE_OK;
+}
+
+/* Generate code for function parameters */
+static CODE_ERROR scriptCodeParameter(CODE_BLOCK *psParam, // Code for the parameter
+ INTERP_TYPE type, // Parameter type
+ PARAM_BLOCK **ppsBlock) // Generated code
+{
+ ASSERT( psParam != NULL,
+ "scriptCodeParameter: Invalid parameter code block pointer" );
+ ASSERT( psParam->pCode != NULL,
+ "scriptCodeParameter: Invalid parameter code pointer" );
+ ASSERT( ppsBlock != NULL,
+ "scriptCodeParameter: Invalid generated code block pointer" );
+
+ RULE(" scriptCodeParameter(): type: %d", type);
+
+ ALLOC_PBLOCK(*ppsBlock, psParam->size, 1);
+ ip = (*ppsBlock)->pCode;
+
+ /* Copy in the code for the parameter */
+ PUT_BLOCK(ip, psParam);
+ FREE_BLOCK(psParam);
+
+ (*ppsBlock)->aParams[0] = type;
+
+ return CE_OK;
+}
+
+
+/* Generate code for binary operators (e.g. 2 + 2) */
+static CODE_ERROR scriptCodeBinaryOperator(CODE_BLOCK *psFirst, // Code for first parameter
+ CODE_BLOCK *psSecond, // Code for second parameter
+ OPCODE opcode, // Operator function
+ CODE_BLOCK **ppsBlock) // Generated code
+{
+ ALLOC_BLOCK(*ppsBlock, psFirst->size + psSecond->size + 1); //size + size + binary opcode
+ ip = (*ppsBlock)->pCode;
+
+ /* Copy the already generated bits of code into the code block */
+ PUT_BLOCK(ip, psFirst);
+ PUT_BLOCK(ip, psSecond);
+
+ /* Now put an add operator into the code */
+ PUT_PKOPCODE(ip, OP_BINARYOP, opcode);
+
+ /* Free the two code blocks that have been copied */
+ FREE_BLOCK(psFirst);
+ FREE_BLOCK(psSecond);
+
+ return CE_OK;
+}
+
+/* check if the arguments in the function definition body match the argument types
+and names from function declaration (if there was any) */
+static bool checkFuncParamType(UDWORD argIndex, UDWORD argType)
+{
+ VAR_SYMBOL *psCurr;
+ SDWORD i,j;
+
+ if(psCurEvent == NULL)
+ {
+ debug(LOG_ERROR, "checkFuncParamType() - psCurEvent == NULL");
+ return false;
+ }
+
+ if(argIndex < psCurEvent->numParams)
+ {
+ /* find the argument by the index */
+ i=psCurEvent->index;
+ j=0;
+ for(psCurr = psLocalVarsB[i]; psCurr != NULL; psCurr = psCurr->psNext)
+ {
+ if((psCurEvent->numParams - j - 1)==argIndex) /* got to the right argument */
+ {
+ if(argType != psCurr->type)
+ {
+ debug(LOG_ERROR, "Argument type with index %d in event '%s' doesn't match function declaration (%d/%d)",argIndex,psCurEvent->pIdent,argType,psCurr->type);
+ return false;
+ }
+ else
+ {
+ //debug(LOG_SCRIPT, "arg matched ");
+ return true;
+ }
+ }
+ j++;
+ }
+ }
+ else
+ {
+ debug(LOG_ERROR, "checkFuncParamType() - argument %d has wrong argument index, event: '%s'", argIndex, psCurEvent->pIdent);
+ return false;
+ }
+
+ return false;
+}
+
+
+/* Generate code for accessing an object variable. The variable symbol is
+ * stored with the code for the object value so that this block can be used for
+ * both setting and retrieving an object value.
+ */
+static CODE_ERROR scriptCodeObjectVariable(CODE_BLOCK *psObjCode, // Code for the object value
+ VAR_SYMBOL *psVar, // The object variable symbol
+ OBJVAR_BLOCK **ppsBlock) // Generated code
+{
+ ASSERT( psObjCode != NULL,
+ "scriptCodeObjectVariable: Invalid object code block pointer" );
+ ASSERT( psObjCode->pCode != NULL,
+ "scriptCodeObjectVariable: Invalid object code pointer" );
+ ASSERT( psVar != NULL,
+ "scriptCodeObjectVariable: Invalid variable symbol pointer" );
+ ASSERT( ppsBlock != NULL,
+ "scriptCodeObjectVariable: Invalid generated code block pointer" );
+
+ ALLOC_OBJVARBLOCK(*ppsBlock, psObjCode->size, psVar);
+ ip = (*ppsBlock)->pCode;
+
+ /* Copy the already generated bit of code into the code block */
+ PUT_BLOCK(ip, psObjCode);
+ FREE_BLOCK(psObjCode);
+
+ /* Check the variable is the correct type */
+ if (psVar->storage != ST_OBJECT)
+ {
+ scr_error("Only object variables are valid in this context");
+ return CE_PARSE;
+ }
+
+ return CE_OK;
+}
+
+
+/* Generate code for accessing an array variable. The variable symbol is
+ * stored with the code for the object value so that this block can be used for
+ * both setting and retrieving an array value.
+ */
+static CODE_ERROR scriptCodeArrayVariable(ARRAY_BLOCK *psArrayCode, // Code for the array index
+ VAR_SYMBOL *psVar, // The array variable symbol
+ ARRAY_BLOCK **ppsBlock) // Generated code
+{
+ ASSERT( psArrayCode != NULL,
+ "scriptCodeObjectVariable: Invalid object code block pointer" );
+ ASSERT( psArrayCode->pCode != NULL,
+ "scriptCodeObjectVariable: Invalid object code pointer" );
+ ASSERT( psVar != NULL,
+ "scriptCodeObjectVariable: Invalid variable symbol pointer" );
+ ASSERT( ppsBlock != NULL,
+ "scriptCodeObjectVariable: Invalid generated code block pointer" );
+
+ // Check the variable is the correct type
+ if (psVar->dimensions != psArrayCode->dimensions)
+ {
+ scr_error("Invalid number of array dimensions for this variable");
+ return CE_PARSE;
+ }
+
+ psArrayCode->psArrayVar = psVar;
+ *ppsBlock = psArrayCode;
+
+ return CE_OK;
+}
+
+
+/* Generate code for a constant */
+static CODE_ERROR scriptCodeConstant(CONST_SYMBOL *psConst, // The object variable symbol
+ CODE_BLOCK **ppsBlock) // Generated code
+{
+ ASSERT( psConst != NULL,
+ "scriptCodeConstant: Invalid constant symbol pointer" );
+ ASSERT( ppsBlock != NULL,
+ "scriptCodeConstant: Invalid generated code block pointer" );
+
+ ALLOC_BLOCK(*ppsBlock, 1 + 1); //OP_PUSH opcode + variable value
+
+ ip = (*ppsBlock)->pCode;
+ (*ppsBlock)->type = psConst->type;
+
+ /* Put the value onto the stack */
+ switch (psConst->type)
+ {
+ case VAL_FLOAT:
+ RULE(" scriptCodeConstant: pushing float");
+ PUT_PKOPCODE(ip, OP_PUSH, VAL_FLOAT);
+ PUT_DATA_FLOAT(ip, psConst->fval);
+ break;
+ case VAL_BOOL:
+ RULE(" scriptCodeConstant: pushing bool");
+ PUT_PKOPCODE(ip, OP_PUSH, VAL_BOOL);
+ PUT_DATA_BOOL(ip, psConst->bval);
+ break;
+ case VAL_INT:
+ RULE(" scriptCodeConstant: pushing int");
+ PUT_PKOPCODE(ip, OP_PUSH, VAL_INT);
+ PUT_DATA_INT(ip, psConst->ival);
+ break;
+ case VAL_STRING:
+ RULE(" scriptCodeConstant: pushing string");
+ PUT_PKOPCODE(ip, OP_PUSH, VAL_STRING);
+ PUT_DATA_STRING(ip, psConst->sval);
+ break;
+ default: /* Object/user constants */
+ RULE(" scriptCodeConstant: pushing object/ user var (type: %d)", psConst->type);
+ PUT_PKOPCODE(ip, OP_PUSH, psConst->type);
+ PUT_OBJECT_CONST(ip, psConst->oval, psConst->type); //TODO: differentiate types
+ break;
+ }
+
+ return CE_OK;
+}
+
+
+/* Generate code for getting a variables value */
+static CODE_ERROR scriptCodeVarGet(VAR_SYMBOL *psVariable, // The object variable symbol
+ CODE_BLOCK **ppsBlock) // Generated code
+{
+ SDWORD size = 1; //1 - for opcode
+
+ if (psVariable->storage == ST_EXTERN)
+ {
+ // Check there is a set function
+ if (psVariable->get == NULL)
+ {
+ scr_error("No get function for external variable");
+ return CE_PARSE;
+ }
+
+ size++;
+ }
+
+ ALLOC_BLOCK(*ppsBlock, size);
+ ip = (*ppsBlock)->pCode;
+ (*ppsBlock)->type = psVariable->type;
+
+ /* Code to get the value onto the stack */
+ switch (psVariable->storage)
+ {
+ case ST_PUBLIC:
+ case ST_PRIVATE:
+ PUT_PKOPCODE(ip, OP_PUSHGLOBAL, psVariable->index);
+ break;
+ case ST_LOCAL:
+ PUT_PKOPCODE(ip, OP_PUSHLOCAL, psVariable->index); //opcode + event index
+ break;
+ case ST_EXTERN:
+ PUT_PKOPCODE(ip, OP_VARCALL, psVariable->index);
+ PUT_VARFUNC(ip, psVariable->get);
+ break;
+ case ST_OBJECT:
+ scr_error("Cannot use member variables in this context");
+ return CE_PARSE;
+ break;
+ default:
+ scr_error("Unknown storage type");
+ return CE_PARSE;
+ break;
+ }
+
+ return CE_OK;
+}
+
+/* Code Increment/Decrement operators */
+static CODE_ERROR scriptCodeIncDec(VAR_SYMBOL *psVariable, // The object variable symbol
+ CODE_BLOCK **ppsBlock, OPCODE op_dec_inc)
+{
+
+ ALLOC_BLOCK(*ppsBlock, 1 + 1 + 1); //OP_PUSHREF opcode + variable index + inc opcode
+ ip = (*ppsBlock)->pCode;
+ (*ppsBlock)->type = psVariable->type;
+
+ /* Put variable index */
+ switch (psVariable->storage)
+ {
+ case ST_PRIVATE:
+ PUT_PKOPCODE(ip, OP_PUSHREF, psVariable->type | VAL_REF);
+ PUT_DATA_INT(ip, psVariable->index);
+ break;
+ case ST_LOCAL:
+ PUT_PKOPCODE(ip, OP_PUSHLOCALREF, psVariable->type | VAL_REF);
+ PUT_DATA_INT(ip, psVariable->index);
+ break;
+ default:
+ scr_error("Wrong variable storage type for increment/decrement operator");
+ break;
+ }
+
+ /* Put inc/dec opcode */
+ PUT_PKOPCODE(ip, OP_UNARYOP, op_dec_inc);
+
+ return CE_OK;
+}
+
+
+/* Generate code for getting a variables value */
+static CODE_ERROR scriptCodeVarRef(VAR_SYMBOL *psVariable, // The object variable symbol
+ PARAM_BLOCK **ppsBlock) // Generated code
+{
+ SDWORD size;
+
+ //size = sizeof(OPCODE) + sizeof(SDWORD);
+ size = 1 + 1; //OP_PUSHREF opcode + variable index
+
+ ALLOC_PBLOCK(*ppsBlock, size, 1);
+ ip = (*ppsBlock)->pCode;
+
+ (*ppsBlock)->aParams[0] = (INTERP_TYPE)(psVariable->type | VAL_REF);
+
+ /* Code to get the value onto the stack */
+ switch (psVariable->storage)
+ {
+ case ST_PUBLIC:
+ case ST_PRIVATE:
+
+ PUT_PKOPCODE(ip, OP_PUSHREF, (*ppsBlock)->aParams[0]);
+ PUT_DATA_INT(ip, psVariable->index); //TODO: add new macro
+ break;
+
+ case ST_LOCAL:
+ PUT_PKOPCODE(ip, OP_PUSHLOCALREF, (*ppsBlock)->aParams[0]);
+ PUT_DATA_INT(ip, psVariable->index);
+ break;
+ case ST_EXTERN:
+ scr_error("Cannot use external variables in this context");
+ return CE_PARSE;
+ break;
+ case ST_OBJECT:
+ scr_error("Cannot use member variables in this context");
+ return CE_PARSE;
+ break;
+ default:
+ scr_error("Unknown storage type: %d", psVariable->storage);
+ return CE_PARSE;
+ break;
+ }
+
+ return CE_OK;
+}
+
+/* Change the error action for the ALLOC macro's to what it
+ * should be inside a rule body.
+ *
+ * NOTE: DO NOT USE THE ALLOC MACRO'S INSIDE ANY FUNCTIONS
+ * ONCE ALLOC_ERROR_ACTION IS SET TO THIS VALUE.
+ * ALL FUNCTIONS THAT USE THESE MACROS MUST BE PLACED
+ * BEFORE THIS #define.
+ */
+#undef ALLOC_ERROR_ACTION
+#define ALLOC_ERROR_ACTION YYABORT
+
+
+
+/* Line 268 of yacc.c */
+#line 1616 "script_parser.cpp"
+
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
+#endif
+
+/* Enabling the token table. */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ lexFUNCTION = 258,
+ TRIGGER = 259,
+ EVENT = 260,
+ WAIT = 261,
+ EVERY = 262,
+ INACTIVE = 263,
+ INITIALISE = 264,
+ LINK = 265,
+ REF = 266,
+ RET = 267,
+ _VOID = 268,
+ WHILE = 269,
+ IF = 270,
+ ELSE = 271,
+ EXIT = 272,
+ PAUSE = 273,
+ BOOLEQUAL = 274,
+ NOTEQUAL = 275,
+ GREATEQUAL = 276,
+ LESSEQUAL = 277,
+ GREATER = 278,
+ LESS = 279,
+ _AND = 280,
+ _OR = 281,
+ _NOT = 282,
+ _INC = 283,
+ _DEC = 284,
+ TO_INT_CAST = 285,
+ TO_FLOAT_CAST = 286,
+ UMINUS = 287,
+ BOOLEAN_T = 288,
+ FLOAT_T = 289,
+ INTEGER = 290,
+ QTEXT = 291,
+ TYPE = 292,
+ STORAGE = 293,
+ IDENT = 294,
+ VAR = 295,
+ BOOL_VAR = 296,
+ NUM_VAR = 297,
+ FLOAT_VAR = 298,
+ OBJ_VAR = 299,
+ STRING_VAR = 300,
+ VAR_ARRAY = 301,
+ BOOL_ARRAY = 302,
+ NUM_ARRAY = 303,
+ FLOAT_ARRAY = 304,
+ OBJ_ARRAY = 305,
+ BOOL_OBJVAR = 306,
+ NUM_OBJVAR = 307,
+ USER_OBJVAR = 308,
+ OBJ_OBJVAR = 309,
+ BOOL_CONSTANT = 310,
+ NUM_CONSTANT = 311,
+ USER_CONSTANT = 312,
+ OBJ_CONSTANT = 313,
+ STRING_CONSTANT = 314,
+ FUNC = 315,
+ BOOL_FUNC = 316,
+ NUM_FUNC = 317,
+ FLOAT_FUNC = 318,
+ USER_FUNC = 319,
+ OBJ_FUNC = 320,
+ STRING_FUNC = 321,
+ VOID_FUNC_CUST = 322,
+ BOOL_FUNC_CUST = 323,
+ NUM_FUNC_CUST = 324,
+ FLOAT_FUNC_CUST = 325,
+ USER_FUNC_CUST = 326,
+ OBJ_FUNC_CUST = 327,
+ STRING_FUNC_CUST = 328,
+ TRIG_SYM = 329,
+ EVENT_SYM = 330,
+ CALLBACK_SYM = 331
+ };
+#endif
+/* Tokens. */
+#define lexFUNCTION 258
+#define TRIGGER 259
+#define EVENT 260
+#define WAIT 261
+#define EVERY 262
+#define INACTIVE 263
+#define INITIALISE 264
+#define LINK 265
+#define REF 266
+#define RET 267
+#define _VOID 268
+#define WHILE 269
+#define IF 270
+#define ELSE 271
+#define EXIT 272
+#define PAUSE 273
+#define BOOLEQUAL 274
+#define NOTEQUAL 275
+#define GREATEQUAL 276
+#define LESSEQUAL 277
+#define GREATER 278
+#define LESS 279
+#define _AND 280
+#define _OR 281
+#define _NOT 282
+#define _INC 283
+#define _DEC 284
+#define TO_INT_CAST 285
+#define TO_FLOAT_CAST 286
+#define UMINUS 287
+#define BOOLEAN_T 288
+#define FLOAT_T 289
+#define INTEGER 290
+#define QTEXT 291
+#define TYPE 292
+#define STORAGE 293
+#define IDENT 294
+#define VAR 295
+#define BOOL_VAR 296
+#define NUM_VAR 297
+#define FLOAT_VAR 298
+#define OBJ_VAR 299
+#define STRING_VAR 300
+#define VAR_ARRAY 301
+#define BOOL_ARRAY 302
+#define NUM_ARRAY 303
+#define FLOAT_ARRAY 304
+#define OBJ_ARRAY 305
+#define BOOL_OBJVAR 306
+#define NUM_OBJVAR 307
+#define USER_OBJVAR 308
+#define OBJ_OBJVAR 309
+#define BOOL_CONSTANT 310
+#define NUM_CONSTANT 311
+#define USER_CONSTANT 312
+#define OBJ_CONSTANT 313
+#define STRING_CONSTANT 314
+#define FUNC 315
+#define BOOL_FUNC 316
+#define NUM_FUNC 317
+#define FLOAT_FUNC 318
+#define USER_FUNC 319
+#define OBJ_FUNC 320
+#define STRING_FUNC 321
+#define VOID_FUNC_CUST 322
+#define BOOL_FUNC_CUST 323
+#define NUM_FUNC_CUST 324
+#define FLOAT_FUNC_CUST 325
+#define USER_FUNC_CUST 326
+#define OBJ_FUNC_CUST 327
+#define STRING_FUNC_CUST 328
+#define TRIG_SYM 329
+#define EVENT_SYM 330
+#define CALLBACK_SYM 331
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 293 of yacc.c */
+#line 1559 "script_parser.ypp"
+
+ /* Types returned by the lexer */
+ int32_t bval;
+ float fval;
+ SDWORD ival;
+ char *sval;
+ INTERP_TYPE tval;
+ STORAGE_TYPE stype;
+ VAR_SYMBOL *vSymbol;
+ CONST_SYMBOL *cSymbol;
+ FUNC_SYMBOL *fSymbol;
+ TRIGGER_SYMBOL *tSymbol;
+ EVENT_SYMBOL *eSymbol;
+ CALLBACK_SYMBOL *cbSymbol;
+
+ /* Types only returned by rules */
+ CODE_BLOCK *cblock;
+ COND_BLOCK *condBlock;
+ OBJVAR_BLOCK *objVarBlock;
+ ARRAY_BLOCK *arrayBlock;
+ PARAM_BLOCK *pblock;
+ PARAM_DECL *pdecl;
+ TRIGGER_DECL *tdecl;
+ UDWORD integer_val;
+ VAR_DECL *vdecl;
+ VAR_IDENT_DECL *videcl;
+
+
+
+/* Line 293 of yacc.c */
+#line 1834 "script_parser.cpp"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+
+/* Copy the second part of user declarations. */
+
+
+/* Line 343 of yacc.c */
+#line 1846 "script_parser.cpp"
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if defined YYENABLE_NLS && YYENABLE_NLS
+# if ENABLE_NLS
+# include /* INFRINGES ON USER NAME SPACE */
+# define YY_(msgid) dgettext ("bison-runtime", msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions. */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int yyi)
+#else
+static int
+YYID (yyi)
+ int yyi;
+#endif
+{
+ return yyi;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined EXIT_SUCCESS \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+};
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+# define YYCOPY_NEEDED 1
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (YYID (0))
+
+#endif
+
+#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (YYID (0))
+# endif
+# endif
+#endif /* !YYCOPY_NEEDED */
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 11
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 2212
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 92
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 66
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 249
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 514
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 331
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const yytype_uint8 yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 32, 2,
+ 86, 87, 33, 31, 85, 30, 91, 34, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 82,
+ 2, 90, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 83, 2, 84, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 88, 2, 89, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
+ 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
+ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
+ 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const yytype_uint16 yyprhs[] =
+{
+ 0, 0, 3, 5, 8, 11, 14, 17, 18, 20,
+ 23, 26, 29, 32, 35, 39, 41, 46, 48, 51,
+ 54, 58, 59, 61, 64, 68, 72, 76, 78, 80,
+ 84, 91, 93, 96, 99, 102, 106, 108, 110, 112,
+ 114, 116, 118, 120, 124, 128, 132, 135, 138, 141,
+ 144, 147, 150, 153, 156, 158, 162, 167, 171, 176,
+ 180, 183, 188, 191, 195, 200, 204, 209, 213, 216,
+ 218, 222, 223, 225, 228, 231, 235, 239, 248, 249,
+ 259, 268, 274, 280, 287, 294, 300, 306, 309, 312,
+ 315, 321, 327, 329, 331, 334, 336, 342, 344, 346,
+ 348, 350, 352, 354, 358, 362, 366, 370, 374, 378,
+ 382, 386, 390, 394, 398, 402, 406, 410, 415, 420,
+ 425, 430, 435, 440, 445, 446, 448, 452, 454, 456,
+ 458, 460, 462, 464, 466, 469, 472, 475, 478, 481,
+ 484, 486, 490, 492, 496, 500, 501, 510, 511, 518,
+ 519, 528, 531, 534, 538, 542, 546, 550, 553, 557,
+ 560, 565, 570, 572, 574, 576, 578, 580, 584, 588,
+ 592, 596, 599, 602, 606, 611, 616, 618, 620, 624,
+ 628, 632, 636, 640, 644, 648, 652, 657, 662, 664,
+ 666, 668, 672, 676, 680, 684, 687, 691, 696, 701,
+ 703, 705, 707, 709, 711, 715, 719, 723, 727, 731,
+ 735, 739, 743, 747, 751, 755, 759, 763, 767, 771,
+ 775, 779, 783, 785, 787, 789, 791, 796, 801, 803,
+ 805, 807, 809, 811, 816, 821, 823, 825, 828, 831,
+ 834, 837, 840, 843, 847, 849, 854, 857, 860, 863
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yytype_int16 yyrhs[] =
+{
+ 93, 0, -1, 94, -1, 95, 102, -1, 94, 105,
+ -1, 94, 95, -1, 94, 102, -1, -1, 96, -1,
+ 95, 96, -1, 101, 82, -1, 43, 42, -1, 43,
+ 4, -1, 43, 5, -1, 83, 40, 84, -1, 98,
+ -1, 99, 83, 40, 84, -1, 44, -1, 44, 99,
+ -1, 97, 100, -1, 101, 85, 100, -1, -1, 104,
+ -1, 102, 104, -1, 144, 85, 40, -1, 6, 85,
+ 40, -1, 7, 85, 40, -1, 9, -1, 81, -1,
+ 81, 85, 129, -1, 4, 44, 86, 103, 87, 82,
+ -1, 123, -1, 105, 123, -1, 5, 44, -1, 5,
+ 80, -1, 3, 42, 108, -1, 72, -1, 73, -1,
+ 74, -1, 76, -1, 77, -1, 78, -1, 75, -1,
+ 3, 42, 44, -1, 3, 13, 44, -1, 3, 13,
+ 108, -1, 42, 47, -1, 42, 48, -1, 42, 46,
+ -1, 42, 50, -1, 42, 49, -1, 42, 59, -1,
+ 42, 55, -1, 42, 45, -1, 112, -1, 113, 85,
+ 112, -1, 107, 86, 113, 87, -1, 107, 86, 87,
+ -1, 111, 86, 113, 87, -1, 111, 86, 87, -1,
+ 42, 100, -1, 116, 85, 42, 100, -1, 86, 87,
+ -1, 86, 116, 87, -1, 109, 86, 116, 87, -1,
+ 109, 86, 87, -1, 110, 86, 116, 87, -1, 110,
+ 86, 87, -1, 12, 82, -1, 120, -1, 12, 126,
+ 82, -1, -1, 125, -1, 122, 125, -1, 106, 82,
+ -1, 109, 117, 82, -1, 110, 117, 82, -1, 106,
+ 86, 79, 87, 88, 95, 122, 89, -1, -1, 106,
+ 86, 103, 87, 124, 88, 95, 122, 89, -1, 106,
+ 86, 8, 87, 88, 95, 122, 89, -1, 119, 88,
+ 95, 122, 89, -1, 115, 88, 95, 122, 89, -1,
+ 118, 88, 95, 122, 121, 89, -1, 114, 88, 95,
+ 122, 121, 89, -1, 114, 88, 95, 121, 89, -1,
+ 118, 88, 95, 121, 89, -1, 127, 82, -1, 140,
+ 82, -1, 128, 82, -1, 72, 86, 129, 87, 82,
+ -1, 80, 86, 129, 87, 82, -1, 132, -1, 138,
+ -1, 17, 82, -1, 121, -1, 18, 86, 40, 87,
+ 82, -1, 141, -1, 142, -1, 143, -1, 144, -1,
+ 146, -1, 145, -1, 47, 90, 141, -1, 46, 90,
+ 144, -1, 48, 90, 142, -1, 50, 90, 143, -1,
+ 49, 90, 146, -1, 45, 90, 145, -1, 148, 90,
+ 141, -1, 149, 90, 144, -1, 150, 90, 145, -1,
+ 151, 90, 146, -1, 154, 90, 141, -1, 155, 90,
+ 144, -1, 157, 90, 145, -1, 156, 90, 146, -1,
+ 67, 86, 129, 87, -1, 66, 86, 129, 87, -1,
+ 69, 86, 129, 87, -1, 70, 86, 129, 87, -1,
+ 65, 86, 129, 87, -1, 71, 86, 129, 87, -1,
+ 68, 86, 129, 87, -1, -1, 130, -1, 129, 85,
+ 130, -1, 141, -1, 144, -1, 142, -1, 143, -1,
+ 145, -1, 146, -1, 131, -1, 11, 47, -1, 11,
+ 48, -1, 11, 46, -1, 11, 50, -1, 11, 45,
+ -1, 11, 49, -1, 133, -1, 133, 16, 134, -1,
+ 135, -1, 133, 16, 135, -1, 88, 122, 89, -1,
+ -1, 15, 86, 144, 87, 136, 88, 122, 89, -1,
+ -1, 15, 86, 144, 87, 137, 125, -1, -1, 14,
+ 86, 144, 87, 139, 88, 122, 89, -1, 47, 28,
+ -1, 47, 29, -1, 141, 31, 141, -1, 141, 30,
+ 141, -1, 141, 33, 141, -1, 141, 34, 141, -1,
+ 30, 141, -1, 86, 141, 87, -1, 35, 142, -1,
+ 67, 86, 129, 87, -1, 74, 86, 129, 87, -1,
+ 47, -1, 61, -1, 148, -1, 154, -1, 40, -1,
+ 142, 31, 142, -1, 142, 30, 142, -1, 142, 33,
+ 142, -1, 142, 34, 142, -1, 36, 141, -1, 30,
+ 142, -1, 86, 142, 87, -1, 68, 86, 129, 87,
+ -1, 75, 86, 129, 87, -1, 48, -1, 39, -1,
+ 143, 32, 143, -1, 143, 32, 141, -1, 141, 32,
+ 143, -1, 143, 32, 144, -1, 144, 32, 143, -1,
+ 143, 32, 142, -1, 142, 32, 143, -1, 86, 143,
+ 87, -1, 71, 86, 129, 87, -1, 78, 86, 129,
+ 87, -1, 50, -1, 41, -1, 141, -1, 144, 25,
+ 144, -1, 144, 26, 144, -1, 144, 19, 144, -1,
+ 144, 20, 144, -1, 27, 144, -1, 86, 144, 87,
+ -1, 66, 86, 129, 87, -1, 73, 86, 129, 87,
+ -1, 46, -1, 60, -1, 149, -1, 155, -1, 38,
+ -1, 141, 19, 141, -1, 142, 19, 142, -1, 143,
+ 19, 143, -1, 145, 19, 145, -1, 146, 19, 146,
+ -1, 141, 20, 141, -1, 142, 20, 142, -1, 143,
+ 20, 143, -1, 145, 20, 145, -1, 146, 20, 146,
+ -1, 141, 22, 141, -1, 142, 22, 142, -1, 141,
+ 21, 141, -1, 142, 21, 142, -1, 141, 23, 141,
+ -1, 142, 23, 142, -1, 141, 24, 141, -1, 142,
+ 24, 142, -1, 45, -1, 62, -1, 150, -1, 157,
+ -1, 69, 86, 129, 87, -1, 76, 86, 129, 87,
+ -1, 79, -1, 8, -1, 80, -1, 49, -1, 63,
+ -1, 70, 86, 129, 87, -1, 77, 86, 129, 87,
+ -1, 151, -1, 156, -1, 146, 91, -1, 145, 91,
+ -1, 147, 57, -1, 147, 56, -1, 147, 58, -1,
+ 147, 59, -1, 83, 141, 84, -1, 152, -1, 153,
+ 83, 141, 84, -1, 53, 153, -1, 52, 153, -1,
+ 55, 153, -1, 51, 153, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const yytype_uint16 yyrline[] =
+{
+ 0, 1754, 1754, 1982, 1986, 1990, 1994, 2001, 2004, 2009,
+ 2020, 2030, 2048, 2057, 2067, 2082, 2087, 2107, 2114, 2127,
+ 2140, 2160, 2161, 2162, 2165, 2174, 2180, 2186, 2192, 2204,
+ 2214, 2233, 2234, 2237, 2254, 2267, 2286, 2287, 2288, 2289,
+ 2290, 2291, 2292, 2296, 2323, 2348, 2371, 2375, 2379, 2383,
+ 2387, 2391, 2395, 2399, 2406, 2417, 2431, 2461, 2496, 2526,
+ 2561, 2595, 2627, 2628, 2636, 2652, 2673, 2687, 2708, 2711,
+ 2743, 2792, 2801, 2806, 2836, 2842, 2848, 2856, 2887, 2886,
+ 2930, 2957, 2994, 3031, 3074, 3115, 3142, 3175, 3193, 3211,
+ 3229, 3284, 3332, 3336, 3340, 3363, 3408, 3441, 3449, 3457,
+ 3465, 3473, 3481, 3495, 3505, 3515, 3525, 3535, 3550, 3565,
+ 3575, 3585, 3600, 3615, 3625, 3635, 3650, 3673, 3684, 3695,
+ 3706, 3717, 3729, 3740, 3763, 3772, 3777, 3803, 3814, 3825,
+ 3836, 3847, 3858, 3869, 3876, 3884, 3892, 3900, 3908, 3916,
+ 3931, 3940, 3976, 3982, 4018, 4040, 4039, 4096, 4095, 4163,
+ 4162, 4210, 4219, 4235, 4243, 4251, 4259, 4268, 4287, 4292,
+ 4310, 4323, 4379, 4389, 4399, 4410, 4418, 4436, 4444, 4452,
+ 4460, 4468, 4485, 4503, 4508, 4519, 4584, 4594, 4618, 4630,
+ 4640, 4650, 4660, 4670, 4680, 4690, 4696, 4707, 4753, 4763,
+ 4791, 4806, 4814, 4822, 4830, 4838, 4857, 4862, 4873, 4928,
+ 4938, 4948, 4956, 4964, 4979, 4987, 4995, 5003, 5016, 5029,
+ 5037, 5045, 5053, 5066, 5079, 5087, 5095, 5103, 5111, 5119,
+ 5127, 5135, 5150, 5158, 5168, 5175, 5185, 5194, 5251, 5267,
+ 5283, 5306, 5314, 5324, 5333, 5389, 5397, 5411, 5419, 5432,
+ 5448, 5461, 5473, 5492, 5505, 5510, 5527, 5537, 5547, 5557
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "$end", "error", "$undefined", "lexFUNCTION", "TRIGGER", "EVENT",
+ "WAIT", "EVERY", "INACTIVE", "INITIALISE", "LINK", "REF", "RET", "_VOID",
+ "WHILE", "IF", "ELSE", "EXIT", "PAUSE", "BOOLEQUAL", "NOTEQUAL",
+ "GREATEQUAL", "LESSEQUAL", "GREATER", "LESS", "_AND", "_OR", "_NOT",
+ "_INC", "_DEC", "'-'", "'+'", "'&'", "'*'", "'/'", "TO_INT_CAST",
+ "TO_FLOAT_CAST", "UMINUS", "BOOLEAN_T", "FLOAT_T", "INTEGER", "QTEXT",
+ "TYPE", "STORAGE", "IDENT", "VAR", "BOOL_VAR", "NUM_VAR", "FLOAT_VAR",
+ "OBJ_VAR", "STRING_VAR", "VAR_ARRAY", "BOOL_ARRAY", "NUM_ARRAY",
+ "FLOAT_ARRAY", "OBJ_ARRAY", "BOOL_OBJVAR", "NUM_OBJVAR", "USER_OBJVAR",
+ "OBJ_OBJVAR", "BOOL_CONSTANT", "NUM_CONSTANT", "USER_CONSTANT",
+ "OBJ_CONSTANT", "STRING_CONSTANT", "FUNC", "BOOL_FUNC", "NUM_FUNC",
+ "FLOAT_FUNC", "USER_FUNC", "OBJ_FUNC", "STRING_FUNC", "VOID_FUNC_CUST",
+ "BOOL_FUNC_CUST", "NUM_FUNC_CUST", "FLOAT_FUNC_CUST", "USER_FUNC_CUST",
+ "OBJ_FUNC_CUST", "STRING_FUNC_CUST", "TRIG_SYM", "EVENT_SYM",
+ "CALLBACK_SYM", "';'", "'['", "']'", "','", "'('", "')'", "'{'", "'}'",
+ "'='", "'.'", "$accept", "accept_script", "script", "var_list",
+ "var_line", "variable_decl_head", "array_sub_decl",
+ "array_sub_decl_list", "variable_ident", "variable_decl", "trigger_list",
+ "trigger_subdecl", "trigger_decl", "event_list", "event_subdecl",
+ "function_def", "function_type", "func_subdecl", "void_func_subdecl",
+ "void_function_def", "funcvar_decl_types", "funcbody_var_def_body",
+ "funcbody_var_def", "void_funcbody_var_def", "argument_decl_head",
+ "argument_decl", "function_declaration", "void_function_declaration",
+ "return_statement_void", "return_statement", "statement_list",
+ "event_decl", "$@1", "statement", "return_exp", "assignment",
+ "func_call", "param_list", "parameter", "var_ref", "conditional",
+ "cond_clause_list", "terminal_cond", "cond_clause", "$@2", "$@3", "loop",
+ "$@4", "inc_dec_exp", "expression", "floatexp", "stringexp", "boolexp",
+ "userexp", "objexp", "objexp_dot", "num_objvar", "bool_objvar",
+ "user_objvar", "obj_objvar", "array_index", "array_index_list",
+ "num_array_var", "bool_array_var", "obj_array_var", "user_array_var", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const yytype_uint16 yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
+ 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
+ 45, 43, 38, 42, 47, 285, 286, 287, 288, 289,
+ 290, 291, 292, 293, 294, 295, 296, 297, 298, 299,
+ 300, 301, 302, 303, 304, 305, 306, 307, 308, 309,
+ 310, 311, 312, 313, 314, 315, 316, 317, 318, 319,
+ 320, 321, 322, 323, 324, 325, 326, 327, 328, 329,
+ 330, 331, 59, 91, 93, 44, 40, 41, 123, 125,
+ 61, 46
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const yytype_uint8 yyr1[] =
+{
+ 0, 92, 93, 94, 94, 94, 94, 95, 95, 95,
+ 96, 97, 97, 97, 98, 99, 99, 100, 100, 101,
+ 101, 102, 102, 102, 103, 103, 103, 103, 103, 103,
+ 104, 105, 105, 106, 106, 107, 108, 108, 108, 108,
+ 108, 108, 108, 109, 110, 111, 112, 112, 112, 112,
+ 112, 112, 112, 112, 113, 113, 114, 114, 115, 115,
+ 116, 116, 117, 117, 118, 118, 119, 119, 120, 121,
+ 121, 122, 122, 122, 123, 123, 123, 123, 124, 123,
+ 123, 123, 123, 123, 123, 123, 123, 125, 125, 125,
+ 125, 125, 125, 125, 125, 125, 125, 126, 126, 126,
+ 126, 126, 126, 127, 127, 127, 127, 127, 127, 127,
+ 127, 127, 127, 127, 127, 127, 127, 128, 128, 128,
+ 128, 128, 128, 128, 129, 129, 129, 130, 130, 130,
+ 130, 130, 130, 130, 131, 131, 131, 131, 131, 131,
+ 132, 132, 133, 133, 134, 136, 135, 137, 135, 139,
+ 138, 140, 140, 141, 141, 141, 141, 141, 141, 141,
+ 141, 141, 141, 141, 141, 141, 141, 142, 142, 142,
+ 142, 142, 142, 142, 142, 142, 142, 142, 143, 143,
+ 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
+ 143, 144, 144, 144, 144, 144, 144, 144, 144, 144,
+ 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
+ 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
+ 144, 144, 145, 145, 145, 145, 145, 145, 145, 145,
+ 145, 146, 146, 146, 146, 146, 146, 147, 147, 148,
+ 149, 150, 151, 152, 153, 153, 154, 155, 156, 157
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const yytype_uint8 yyr2[] =
+{
+ 0, 2, 1, 2, 2, 2, 2, 0, 1, 2,
+ 2, 2, 2, 2, 3, 1, 4, 1, 2, 2,
+ 3, 0, 1, 2, 3, 3, 3, 1, 1, 3,
+ 6, 1, 2, 2, 2, 3, 1, 1, 1, 1,
+ 1, 1, 1, 3, 3, 3, 2, 2, 2, 2,
+ 2, 2, 2, 2, 1, 3, 4, 3, 4, 3,
+ 2, 4, 2, 3, 4, 3, 4, 3, 2, 1,
+ 3, 0, 1, 2, 2, 3, 3, 8, 0, 9,
+ 8, 5, 5, 6, 6, 5, 5, 2, 2, 2,
+ 5, 5, 1, 1, 2, 1, 5, 1, 1, 1,
+ 1, 1, 1, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
+ 4, 4, 4, 4, 0, 1, 3, 1, 1, 1,
+ 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
+ 1, 3, 1, 3, 3, 0, 8, 0, 6, 0,
+ 8, 2, 2, 3, 3, 3, 3, 2, 3, 2,
+ 4, 4, 1, 1, 1, 1, 1, 3, 3, 3,
+ 3, 2, 2, 3, 4, 4, 1, 1, 3, 3,
+ 3, 3, 3, 3, 3, 3, 4, 4, 1, 1,
+ 1, 3, 3, 3, 3, 2, 3, 4, 4, 1,
+ 1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 1, 1, 1, 1, 4, 4, 1, 1,
+ 1, 1, 1, 4, 4, 1, 1, 2, 2, 2,
+ 2, 2, 2, 3, 1, 4, 2, 2, 2, 2
+};
+
+/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
+ Performed when YYTABLE doesn't specify something else to do. Zero
+ means the default is an error. */
+static const yytype_uint8 yydefact[] =
+{
+ 7, 0, 0, 2, 21, 8, 0, 0, 12, 13,
+ 11, 1, 0, 0, 0, 5, 6, 22, 4, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 31, 9,
+ 3, 17, 19, 10, 0, 0, 0, 0, 33, 34,
+ 23, 32, 74, 0, 0, 0, 0, 0, 0, 0,
+ 7, 7, 7, 7, 0, 15, 18, 20, 44, 36,
+ 37, 38, 42, 39, 40, 41, 45, 43, 35, 0,
+ 0, 0, 229, 27, 0, 0, 0, 0, 203, 177,
+ 166, 189, 222, 199, 162, 176, 231, 188, 0, 0,
+ 0, 0, 200, 163, 223, 232, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 228, 230,
+ 28, 0, 0, 190, 0, 0, 0, 0, 0, 0,
+ 164, 201, 224, 235, 165, 202, 236, 225, 0, 57,
+ 54, 0, 0, 62, 0, 75, 62, 0, 76, 59,
+ 0, 0, 71, 0, 71, 0, 0, 229, 228, 0,
+ 0, 0, 0, 195, 0, 157, 172, 0, 0, 0,
+ 0, 0, 159, 0, 0, 171, 0, 244, 249, 247,
+ 246, 248, 124, 124, 124, 124, 124, 124, 124, 124,
+ 124, 124, 124, 124, 0, 124, 0, 0, 0, 0,
+ 78, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 238, 0, 0, 237, 240, 239,
+ 241, 242, 53, 48, 46, 47, 50, 49, 52, 51,
+ 0, 56, 60, 0, 63, 63, 58, 0, 0, 0,
+ 0, 0, 222, 0, 0, 0, 231, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 230, 69, 95, 0,
+ 72, 0, 0, 92, 140, 142, 93, 0, 0, 0,
+ 224, 235, 0, 0, 236, 225, 95, 0, 95, 0,
+ 0, 14, 0, 0, 25, 26, 7, 0, 0, 0,
+ 0, 0, 0, 125, 133, 127, 129, 130, 128, 131,
+ 132, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 7, 29, 158, 173, 185, 196, 0, 204,
+ 209, 216, 214, 218, 220, 154, 153, 180, 0, 155,
+ 156, 205, 210, 217, 215, 219, 221, 168, 167, 184,
+ 169, 170, 206, 211, 179, 183, 178, 181, 193, 194,
+ 191, 192, 182, 24, 207, 0, 212, 208, 213, 55,
+ 0, 68, 0, 97, 98, 99, 100, 102, 101, 0,
+ 0, 94, 0, 0, 0, 151, 152, 0, 0, 0,
+ 0, 124, 124, 124, 124, 124, 124, 124, 124, 124,
+ 85, 95, 73, 87, 89, 0, 88, 0, 0, 0,
+ 0, 0, 0, 0, 0, 82, 86, 95, 81, 16,
+ 30, 71, 243, 0, 138, 136, 134, 135, 139, 137,
+ 0, 197, 160, 174, 226, 233, 186, 198, 161, 175,
+ 227, 234, 187, 71, 7, 61, 70, 0, 0, 0,
+ 108, 104, 103, 105, 107, 106, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 84, 71, 141, 143, 109,
+ 110, 111, 112, 113, 114, 116, 115, 83, 0, 245,
+ 126, 0, 71, 149, 147, 0, 121, 118, 117, 123,
+ 119, 120, 122, 0, 0, 0, 80, 77, 0, 0,
+ 0, 0, 96, 90, 91, 144, 79, 71, 71, 148,
+ 0, 0, 150, 146
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const yytype_int16 yydefgoto[] =
+{
+ -1, 2, 3, 4, 5, 6, 55, 56, 32, 7,
+ 16, 112, 17, 18, 19, 20, 66, 21, 22, 23,
+ 130, 131, 24, 25, 134, 46, 26, 27, 267, 286,
+ 269, 28, 328, 270, 372, 271, 272, 302, 303, 304,
+ 273, 274, 467, 275, 500, 501, 276, 499, 277, 305,
+ 306, 307, 308, 157, 158, 119, 120, 121, 122, 123,
+ 167, 168, 124, 125, 126, 127
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -236
+static const yytype_int16 yypact[] =
+{
+ -25, 19, 31, 131, -1, -236, -8, -45, -236, -236,
+ -236, -236, -7, 16, -14, -25, 78, -236, 172, -69,
+ 17, 24, 35, 39, 67, 72, 90, 93, -236, -236,
+ 78, 12, -236, -236, -8, 269, 601, 113, -236, -236,
+ -236, -236, -236, 38, -34, -23, 132, -20, 173, -17,
+ -25, -25, -25, -25, 214, -236, 179, -236, -236, -236,
+ -236, -236, -236, -236, -236, -236, -236, -236, -236, 1727,
+ 180, 192, 194, -236, 1915, 1972, 509, 2020, -236, -236,
+ -236, -236, -236, -236, -236, -236, -236, -236, 228, 228,
+ 228, 228, -236, -236, -236, -236, 206, 230, 236, 239,
+ 249, 250, 253, 264, 265, 270, 306, 307, 319, -236,
+ 330, 1915, 329, 719, 767, 181, 37, -10, 1, 161,
+ -236, -236, -236, -236, -236, -236, -236, -236, 341, -236,
+ -236, 153, -8, 347, 221, -236, 352, 227, -236, -236,
+ 234, 2062, 2062, 2062, 2062, 348, 416, -236, -236, 373,
+ 421, 425, 385, 444, 1972, -236, -236, 391, 396, 114,
+ 509, 509, -236, 2020, 2020, -236, 2020, -236, 408, 408,
+ 408, 408, 1801, 1801, 1801, 1801, 1801, 1801, 1801, 1801,
+ 1801, 1801, 1801, 1801, 411, 1801, 174, 568, 9, 7,
+ -236, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 1915,
+ 2020, 2020, 509, 509, 509, 509, 509, 509, 509, 509,
+ 1915, 509, 509, 1915, 1915, 1915, 1915, 1915, 1915, 1915,
+ 1915, 455, 657, 657, -236, 657, 657, -236, -236, -236,
+ -236, -236, -236, -236, -236, -236, -236, -236, -236, -236,
+ 458, -236, -236, 461, 420, 436, -236, 1858, 423, 434,
+ 447, 446, 443, 478, 30, 481, 482, 483, 451, 465,
+ 484, 488, 494, 496, 497, 499, 500, -236, 505, 2132,
+ -236, 521, 522, -236, 531, -236, -236, 523, 517, 518,
+ 519, 524, 525, 527, 528, 529, -236, 1113, 532, 2132,
+ 1232, -236, 536, 530, -236, -236, -25, 136, 191, 96,
+ 2020, 202, 286, -236, -236, 719, 767, 181, 271, -10,
+ 1, 287, 316, 326, 327, 344, 370, 383, 384, 398,
+ 403, 407, -25, 479, -236, -236, -236, -236, 539, 252,
+ 252, 252, 252, 252, 252, 98, 98, -236, 271, -236,
+ -236, 364, 364, 364, 364, 364, 364, 254, 254, -236,
+ -236, -236, 592, 592, 792, 885, -236, -236, 444, 444,
+ 183, 183, -236, -236, 391, 13, 391, 396, 396, -236,
+ -8, -236, 547, 719, 767, 181, 271, -10, 1, 1915,
+ 1915, -236, 590, 657, 1915, -236, -236, 2020, 509, 657,
+ 1915, 1801, 1801, 1801, 1801, 1801, 1801, 1801, 1801, 1801,
+ -236, 542, -236, -236, -236, -13, -236, 2020, 1915, 657,
+ 657, 2020, 1915, 657, 657, -236, -236, 545, -236, -236,
+ -236, 2062, -236, 211, -236, -236, -236, -236, -236, -236,
+ 1801, -236, -236, -236, -236, -236, -236, -236, -236, -236,
+ -236, -236, -236, 2062, -25, -236, -236, 298, 350, 548,
+ 391, 271, 252, 364, 396, 181, 427, 432, 453, 456,
+ 457, 467, 474, 475, 480, -236, 2132, -236, -236, 252,
+ 271, 391, 396, 252, 271, 396, 391, -236, 1302, -236,
+ -236, 1372, 2062, -236, 558, 565, -236, -236, -236, -236,
+ 557, 563, -236, 567, 575, 1442, -236, -236, 1512, 570,
+ 571, 2132, -236, -236, -236, -236, -236, 2132, 2132, -236,
+ 1582, 1652, -236, -236
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const yytype_int16 yypgoto[] =
+{
+ -236, -236, -236, -2, -4, -236, -236, -236, -30, -236,
+ 656, 593, 160, -236, -236, -236, 625, -236, -236, -236,
+ 424, 620, -236, -236, 623, 659, -236, -236, -236, -136,
+ -128, 664, -236, -235, -236, -236, -236, 245, 259, -236,
+ -236, -236, -236, 279, -236, -236, -236, -236, -236, 685,
+ 736, 761, 819, -31, 54, 856, 15, 20, 68, 115,
+ -236, 209, 185, 190, 266, 363
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If YYTABLE_NINF, syntax error. */
+#define YYTABLE_NINF -234
+static const yytype_int16 yytable[] =
+{
+ 29, 15, 249, 13, 57, 268, 35, 288, 128, 222,
+ 223, 29, 117, 42, 287, 289, 290, 43, 1, 132,
+ 225, 226, 132, 8, 9, 128, 216, 217, 213, 214,
+ 38, 11, 218, 219, 402, 36, 31, 33, 117, 220,
+ 34, 215, 1, 117, 70, 71, 72, 73, 141, 142,
+ 143, 144, 402, 129, 402, 402, 216, 217, 385, 386,
+ 37, 10, 218, 219, 133, 74, 39, 136, 75, 220,
+ 139, 230, 231, 76, 77, 466, 78, 79, 80, 81,
+ 117, 224, 13, 82, 83, 84, 85, 86, 87, 88,
+ 89, 90, 227, 91, 327, 54, 326, 118, 92, 93,
+ 94, 95, 242, 44, 96, 97, 98, 99, 100, 101,
+ 45, 102, 103, 104, 105, 106, 107, 108, 109, 110,
+ 387, 47, 221, 118, 111, 49, 197, 198, 118, 200,
+ 201, 200, 201, 401, 12, 13, 14, 29, 29, 29,
+ 29, 309, 309, 309, 309, 309, 309, 309, 309, 309,
+ 309, 309, 309, 417, 309, 50, 278, 278, 278, 278,
+ 51, 279, 279, 279, 279, 118, 197, 198, 117, 200,
+ 201, 229, 230, 231, 1, 12, 40, 14, 52, 117,
+ 422, 53, 117, 117, 117, 117, 117, 117, 117, 117,
+ 40, 364, 366, 191, 192, 193, 194, 195, 196, 69,
+ 213, 214, 216, 217, 197, 198, 199, 200, 201, 280,
+ 280, 280, 280, 215, 135, 220, 377, 228, 229, 230,
+ 231, 208, 209, 324, 211, 212, 310, 310, 310, 310,
+ 310, 310, 310, 310, 310, 310, 310, 310, 240, 310,
+ 241, 197, 198, 402, 200, 201, 402, 424, 425, 426,
+ 427, 428, 429, 118, 145, 138, 281, 281, 281, 281,
+ 402, 324, 146, 402, 118, 150, 509, 118, 118, 118,
+ 118, 118, 118, 118, 118, 402, 402, 151, 325, 367,
+ 368, 152, 197, 198, 278, 200, 201, 211, 212, 279,
+ 216, 217, 172, 478, 421, 479, 218, 219, 169, 170,
+ 171, 378, 278, 220, 278, 278, 243, 279, 244, 279,
+ 279, 166, 243, 58, 245, 481, 173, 216, 217, 240,
+ 443, 246, 174, 218, 219, 175, 282, 282, 282, 282,
+ 220, 283, 283, 283, 283, 176, 177, 280, 495, 178,
+ 445, 59, 60, 61, 62, 63, 64, 65, 117, 117,
+ 179, 180, 450, 117, 498, 280, 181, 280, 280, 117,
+ 309, 309, 309, 309, 309, 309, 309, 309, 309, 216,
+ 217, 430, 430, 431, 432, 218, 219, 117, 471, 510,
+ 511, 117, 220, 476, 281, 483, 232, 233, 234, 235,
+ 236, 237, 182, 183, 208, 209, 238, 211, 212, 309,
+ 239, 430, 281, 433, 281, 281, 184, 284, 284, 284,
+ 284, 430, 430, 434, 435, 185, 190, 29, 311, 312,
+ 313, 314, 315, 316, 317, 318, 319, 320, 321, 430,
+ 323, 436, 291, 118, 118, -65, 278, 484, 118, 29,
+ -67, 279, 482, 454, 118, 310, 310, 310, 310, 310,
+ 310, 310, 310, 310, 282, 430, 292, 437, 278, 283,
+ 293, 294, 118, 279, 472, 295, 118, 475, 430, 430,
+ 438, 439, 282, 296, 282, 282, 220, 283, 29, 283,
+ 283, 278, 224, 430, 310, 440, 279, 227, 430, 280,
+ 441, 300, 430, 278, 442, 363, 278, 278, 279, 322,
+ 128, 279, 279, 370, 285, 285, 285, 285, -64, 379,
+ 278, 280, 430, 278, 486, 279, 278, 430, 279, 487,
+ 380, 279, 278, 278, -66, 278, 278, 279, 279, 381,
+ 279, 279, 382, 383, 280, 284, 281, 391, 430, 160,
+ 488, 430, 430, 489, 490, 77, 280, 405, 79, 280,
+ 280, 392, 430, 284, 491, 284, 284, 85, 281, 430,
+ 430, 492, 493, 280, 430, 430, 280, 494, 384, 280,
+ 393, 388, 389, 390, 394, 280, 280, 98, 280, 280,
+ 395, 281, 396, 397, 104, 398, 399, 202, 203, 204,
+ 205, 206, 207, 281, 400, 161, 281, 281, 208, 209,
+ 210, 211, 212, 403, 404, 406, 282, 407, 408, 409,
+ 281, 283, 420, 281, 410, 411, 281, 412, 413, 414,
+ 419, 416, 281, 281, 215, 281, 281, 444, 282, 446,
+ 449, 465, 285, 283, 477, 485, 456, 457, 458, 459,
+ 460, 461, 462, 463, 464, 67, -145, 502, -226, 503,
+ 285, 282, 285, 285, -233, 325, 283, 504, 507, 508,
+ 30, 68, 149, 282, 369, 147, 282, 282, 283, 140,
+ 137, 283, 283, 59, 60, 61, 62, 63, 64, 65,
+ 282, 48, 41, 282, 468, 283, 282, 284, 283, 480,
+ 0, 283, 282, 282, 0, 282, 282, 283, 283, 0,
+ 283, 283, 82, 0, 0, 0, 86, 0, 88, 284,
+ 0, 0, 91, 0, 0, 0, 0, 0, 0, 94,
+ 95, 0, 0, 0, 0, 0, 99, 100, 113, 0,
+ 0, 0, 284, 105, 106, 0, 148, 109, 191, 192,
+ 193, 194, 195, 196, 284, 0, 0, 284, 284, 197,
+ 198, 199, 200, 201, 113, 0, 0, 0, 0, 113,
+ 155, 284, 165, 0, 284, 0, 0, 284, 0, 0,
+ 0, 0, 0, 284, 284, 0, 284, 284, 0, 114,
+ 0, 0, 0, 0, 285, 0, 202, 203, 204, 205,
+ 206, 207, 0, 0, 0, 0, 186, 208, 209, 210,
+ 211, 212, 0, 0, 115, 114, 285, 0, 0, 0,
+ 114, 156, 162, 193, 194, 195, 196, 0, 0, 0,
+ 0, 0, 197, 198, 0, 200, 201, 0, 0, 285,
+ 115, 0, 0, 0, 0, 115, 0, 0, 0, 297,
+ 0, 285, 0, 0, 285, 285, 0, 187, 155, 297,
+ 0, 299, 0, 0, 0, 0, 0, 0, 285, 0,
+ 0, 285, 116, 0, 285, 0, 0, 0, 0, 0,
+ 285, 285, 188, 285, 285, 0, 329, 330, 331, 332,
+ 333, 334, 335, 336, 113, 339, 340, 0, 116, 0,
+ 298, 0, 0, 153, 0, 113, 156, 298, 113, 113,
+ 354, 113, 113, 113, 113, 113, 204, 205, 206, 207,
+ 0, 0, 0, 0, 0, 208, 209, 0, 211, 212,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 189, 159, 373, 159, 0, 114, 0, 0, 341, 342,
+ 343, 344, 345, 346, 347, 348, 114, 350, 351, 114,
+ 114, 355, 114, 114, 114, 114, 114, 0, 0, 0,
+ 337, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 349, 0, 0, 352, 353, 356, 115, 115, 115,
+ 115, 362, 0, 374, 0, 423, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 375, 0,
+ 159, 0, 0, 0, 0, 0, 0, 0, 338, 159,
+ 159, 0, 159, 0, 0, 0, 0, 0, 0, 338,
+ 0, 0, 338, 338, 357, 358, 359, 360, 361, 338,
+ 0, 0, 0, 0, 0, 0, 0, 159, 159, 159,
+ 159, 159, 159, 159, 159, 0, 159, 159, 0, 0,
+ 0, 0, 0, 0, 113, 113, 376, 0, 0, 113,
+ 0, 0, 452, 0, 0, 113, 0, 0, 365, 365,
+ 0, 365, 365, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 469, 113, 0, 0, 473, 113, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 114, 114, 0, 0, 0,
+ 114, 147, 0, 0, 453, 247, 114, 248, 249, 0,
+ 250, 251, 0, 0, 0, 0, 0, 0, 0, 0,
+ 115, 115, 0, 0, 114, 115, 0, 0, 114, 0,
+ 0, 455, 0, 0, 0, 0, 159, 0, 252, 253,
+ 254, 255, 256, 257, 88, 89, 90, 0, 91, 115,
+ 0, 0, 0, 115, 0, 94, 95, 0, 258, 259,
+ 260, 261, 262, 263, 264, 265, 0, 0, 0, 105,
+ 106, 0, 148, 266, 0, 0, 0, 0, 447, 448,
+ 0, 0, 415, 451, 0, 0, 0, 0, 0, 338,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 470, 0, 0,
+ 0, 474, 0, 0, 0, 0, 0, 0, 0, 365,
+ 147, 0, 0, 159, 247, 365, 248, 249, 0, 250,
+ 251, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 159, 0, 365, 365, 159, 0, 365,
+ 365, 0, 0, 0, 0, 0, 0, 252, 253, 254,
+ 255, 256, 257, 88, 89, 90, 0, 91, 0, 0,
+ 0, 0, 0, 0, 94, 95, 0, 258, 259, 260,
+ 261, 262, 263, 264, 265, 0, 0, 0, 105, 106,
+ 147, 148, 266, 0, 247, 0, 248, 249, 0, 250,
+ 251, 418, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 252, 253, 254,
+ 255, 256, 257, 88, 89, 90, 0, 91, 0, 0,
+ 0, 0, 0, 0, 94, 95, 0, 258, 259, 260,
+ 261, 262, 263, 264, 265, 0, 0, 0, 105, 106,
+ 147, 148, 266, 0, 247, 0, 248, 249, 0, 250,
+ 251, 496, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 252, 253, 254,
+ 255, 256, 257, 88, 89, 90, 0, 91, 0, 0,
+ 0, 0, 0, 0, 94, 95, 0, 258, 259, 260,
+ 261, 262, 263, 264, 265, 0, 0, 0, 105, 106,
+ 147, 148, 266, 0, 247, 0, 248, 249, 0, 250,
+ 251, 497, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 252, 253, 254,
+ 255, 256, 257, 88, 89, 90, 0, 91, 0, 0,
+ 0, 0, 0, 0, 94, 95, 0, 258, 259, 260,
+ 261, 262, 263, 264, 265, 0, 0, 0, 105, 106,
+ 147, 148, 266, 0, 247, 0, 248, 249, 0, 250,
+ 251, 505, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 252, 253, 254,
+ 255, 256, 257, 88, 89, 90, 0, 91, 0, 0,
+ 0, 0, 0, 0, 94, 95, 0, 258, 259, 260,
+ 261, 262, 263, 264, 265, 0, 0, 0, 105, 106,
+ 147, 148, 266, 0, 247, 0, 248, 249, 0, 250,
+ 251, 506, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 252, 253, 254,
+ 255, 256, 257, 88, 89, 90, 0, 91, 0, 0,
+ 0, 0, 0, 0, 94, 95, 0, 258, 259, 260,
+ 261, 262, 263, 264, 265, 0, 0, 0, 105, 106,
+ 147, 148, 266, 0, 247, 0, 248, 249, 0, 250,
+ 251, 512, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 252, 253, 254,
+ 255, 256, 257, 88, 89, 90, 0, 91, 0, 0,
+ 0, 0, 0, 0, 94, 95, 0, 258, 259, 260,
+ 261, 262, 263, 264, 265, 0, 0, 0, 105, 106,
+ 0, 148, 266, 70, 71, 147, 73, 0, 0, 0,
+ 0, 513, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 74, 0, 0, 75, 0, 0,
+ 0, 0, 76, 77, 0, 78, 79, 80, 81, 0,
+ 0, 0, 82, 83, 84, 85, 86, 87, 88, 89,
+ 90, 0, 91, 0, 0, 0, 0, 92, 93, 94,
+ 95, 0, 0, 96, 97, 98, 99, 100, 101, 0,
+ 102, 103, 104, 105, 106, 107, 148, 109, 110, 147,
+ 0, 0, 301, 111, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 74, 0,
+ 0, 75, 0, 0, 0, 0, 76, 77, 0, 78,
+ 79, 80, 81, 0, 0, 0, 82, 83, 84, 85,
+ 86, 87, 88, 89, 90, 0, 91, 0, 0, 0,
+ 0, 92, 93, 94, 95, 0, 147, 96, 97, 98,
+ 99, 100, 101, 0, 102, 103, 104, 105, 106, 107,
+ 148, 109, 0, 0, 0, 74, 0, 111, 75, 0,
+ 0, 0, 0, 76, 77, 0, 78, 79, 80, 81,
+ 0, 0, 0, 82, 83, 84, 85, 86, 87, 88,
+ 89, 90, 0, 91, 0, 0, 0, 0, 92, 93,
+ 94, 95, 0, 147, 96, 97, 98, 99, 100, 101,
+ 0, 102, 103, 104, 105, 106, 107, 148, 109, 0,
+ 371, 0, 74, 0, 111, 75, 0, 0, 0, 0,
+ 76, 77, 0, 78, 79, 80, 81, 0, 0, 0,
+ 82, 83, 84, 85, 86, 87, 88, 89, 90, 0,
+ 91, 0, 0, 0, 0, 92, 93, 94, 95, 0,
+ 147, 96, 97, 98, 99, 100, 101, 0, 102, 103,
+ 104, 105, 106, 107, 148, 109, 0, 0, 0, 0,
+ 0, 111, 75, 0, 0, 0, 0, 76, 77, 0,
+ 0, 79, 80, 0, 0, 0, 0, 82, 0, 84,
+ 85, 86, 0, 88, 0, 90, 0, 91, 147, 0,
+ 0, 0, 0, 93, 94, 95, 0, 0, 0, 97,
+ 98, 99, 100, 0, 0, 0, 103, 104, 105, 106,
+ 163, 148, 109, 0, 0, 76, 0, 0, 154, 0,
+ 80, 0, 0, 0, 0, 82, 0, 84, 0, 86,
+ 147, 88, 0, 90, 247, 91, 248, 249, 0, 250,
+ 251, 93, 94, 95, 0, 0, 0, 97, 0, 99,
+ 100, 0, 0, 0, 103, 0, 105, 106, 0, 148,
+ 109, 0, 0, 0, 0, 1, 164, 252, 253, 254,
+ 255, 256, 257, 88, 89, 90, 0, 91, 0, 0,
+ 0, 0, 0, 0, 94, 95, 0, 258, 259, 260,
+ 261, 262, 263, 264, 265, 0, 0, 0, 105, 106,
+ 147, 148, 266, 0, 247, 0, 248, 249, 0, 250,
+ 251, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 252, 253, 254,
+ 255, 256, 257, 88, 89, 90, 0, 91, 0, 0,
+ 0, 0, 0, 0, 94, 95, 0, 258, 259, 260,
+ 261, 262, 263, 264, 265, 0, 0, 0, 105, 106,
+ 0, 148, 266
+};
+
+#define yypact_value_is_default(yystate) \
+ ((yystate) == (-236))
+
+#define yytable_value_is_error(yytable_value) \
+ YYID (0)
+
+static const yytype_int16 yycheck[] =
+{
+ 4, 3, 15, 4, 34, 141, 13, 143, 42, 19,
+ 20, 15, 43, 82, 142, 143, 144, 86, 43, 42,
+ 19, 20, 42, 4, 5, 42, 19, 20, 19, 20,
+ 44, 0, 25, 26, 269, 42, 44, 82, 69, 32,
+ 85, 32, 43, 74, 6, 7, 8, 9, 50, 51,
+ 52, 53, 287, 87, 289, 290, 19, 20, 28, 29,
+ 44, 42, 25, 26, 87, 27, 80, 87, 30, 32,
+ 87, 58, 59, 35, 36, 88, 38, 39, 40, 41,
+ 111, 91, 4, 45, 46, 47, 48, 49, 50, 51,
+ 52, 53, 91, 55, 87, 83, 87, 43, 60, 61,
+ 62, 63, 132, 86, 66, 67, 68, 69, 70, 71,
+ 86, 73, 74, 75, 76, 77, 78, 79, 80, 81,
+ 90, 86, 85, 69, 86, 86, 30, 31, 74, 33,
+ 34, 33, 34, 269, 3, 4, 5, 141, 142, 143,
+ 144, 172, 173, 174, 175, 176, 177, 178, 179, 180,
+ 181, 182, 183, 289, 185, 88, 141, 142, 143, 144,
+ 88, 141, 142, 143, 144, 111, 30, 31, 199, 33,
+ 34, 57, 58, 59, 43, 3, 16, 5, 88, 210,
+ 84, 88, 213, 214, 215, 216, 217, 218, 219, 220,
+ 30, 222, 223, 19, 20, 21, 22, 23, 24, 86,
+ 19, 20, 19, 20, 30, 31, 32, 33, 34, 141,
+ 142, 143, 144, 32, 82, 32, 247, 56, 57, 58,
+ 59, 30, 31, 87, 33, 34, 172, 173, 174, 175,
+ 176, 177, 178, 179, 180, 181, 182, 183, 85, 185,
+ 87, 30, 31, 478, 33, 34, 481, 45, 46, 47,
+ 48, 49, 50, 199, 40, 82, 141, 142, 143, 144,
+ 495, 87, 83, 498, 210, 85, 501, 213, 214, 215,
+ 216, 217, 218, 219, 220, 510, 511, 85, 87, 225,
+ 226, 87, 30, 31, 269, 33, 34, 33, 34, 269,
+ 19, 20, 86, 421, 296, 84, 25, 26, 89, 90,
+ 91, 247, 287, 32, 289, 290, 85, 287, 87, 289,
+ 290, 83, 85, 44, 87, 443, 86, 19, 20, 85,
+ 322, 87, 86, 25, 26, 86, 141, 142, 143, 144,
+ 32, 141, 142, 143, 144, 86, 86, 269, 466, 86,
+ 370, 72, 73, 74, 75, 76, 77, 78, 379, 380,
+ 86, 86, 383, 384, 482, 287, 86, 289, 290, 390,
+ 391, 392, 393, 394, 395, 396, 397, 398, 399, 19,
+ 20, 85, 85, 87, 87, 25, 26, 408, 409, 507,
+ 508, 412, 32, 414, 269, 87, 45, 46, 47, 48,
+ 49, 50, 86, 86, 30, 31, 55, 33, 34, 430,
+ 59, 85, 287, 87, 289, 290, 87, 141, 142, 143,
+ 144, 85, 85, 87, 87, 85, 87, 421, 173, 174,
+ 175, 176, 177, 178, 179, 180, 181, 182, 183, 85,
+ 185, 87, 84, 379, 380, 88, 421, 87, 384, 443,
+ 88, 421, 444, 389, 390, 391, 392, 393, 394, 395,
+ 396, 397, 398, 399, 269, 85, 40, 87, 443, 269,
+ 87, 40, 408, 443, 410, 40, 412, 413, 85, 85,
+ 87, 87, 287, 88, 289, 290, 32, 287, 482, 289,
+ 290, 466, 91, 85, 430, 87, 466, 91, 85, 421,
+ 87, 83, 85, 478, 87, 40, 481, 482, 478, 88,
+ 42, 481, 482, 42, 141, 142, 143, 144, 88, 86,
+ 495, 443, 85, 498, 87, 495, 501, 85, 498, 87,
+ 86, 501, 507, 508, 88, 510, 511, 507, 508, 82,
+ 510, 511, 86, 90, 466, 269, 421, 86, 85, 30,
+ 87, 85, 85, 87, 87, 36, 478, 16, 39, 481,
+ 482, 86, 85, 287, 87, 289, 290, 48, 443, 85,
+ 85, 87, 87, 495, 85, 85, 498, 87, 90, 501,
+ 86, 90, 90, 90, 86, 507, 508, 68, 510, 511,
+ 86, 466, 86, 86, 75, 86, 86, 19, 20, 21,
+ 22, 23, 24, 478, 89, 86, 481, 482, 30, 31,
+ 32, 33, 34, 82, 82, 82, 421, 90, 90, 90,
+ 495, 421, 82, 498, 90, 90, 501, 90, 90, 90,
+ 84, 89, 507, 508, 32, 510, 511, 88, 443, 82,
+ 40, 89, 269, 443, 89, 87, 391, 392, 393, 394,
+ 395, 396, 397, 398, 399, 44, 88, 82, 91, 82,
+ 287, 466, 289, 290, 91, 87, 466, 82, 88, 88,
+ 4, 36, 69, 478, 240, 8, 481, 482, 478, 49,
+ 47, 481, 482, 72, 73, 74, 75, 76, 77, 78,
+ 495, 22, 18, 498, 405, 495, 501, 421, 498, 430,
+ -1, 501, 507, 508, -1, 510, 511, 507, 508, -1,
+ 510, 511, 45, -1, -1, -1, 49, -1, 51, 443,
+ -1, -1, 55, -1, -1, -1, -1, -1, -1, 62,
+ 63, -1, -1, -1, -1, -1, 69, 70, 43, -1,
+ -1, -1, 466, 76, 77, -1, 79, 80, 19, 20,
+ 21, 22, 23, 24, 478, -1, -1, 481, 482, 30,
+ 31, 32, 33, 34, 69, -1, -1, -1, -1, 74,
+ 75, 495, 77, -1, 498, -1, -1, 501, -1, -1,
+ -1, -1, -1, 507, 508, -1, 510, 511, -1, 43,
+ -1, -1, -1, -1, 421, -1, 19, 20, 21, 22,
+ 23, 24, -1, -1, -1, -1, 111, 30, 31, 32,
+ 33, 34, -1, -1, 43, 69, 443, -1, -1, -1,
+ 74, 75, 76, 21, 22, 23, 24, -1, -1, -1,
+ -1, -1, 30, 31, -1, 33, 34, -1, -1, 466,
+ 69, -1, -1, -1, -1, 74, -1, -1, -1, 154,
+ -1, 478, -1, -1, 481, 482, -1, 111, 163, 164,
+ -1, 166, -1, -1, -1, -1, -1, -1, 495, -1,
+ -1, 498, 43, -1, 501, -1, -1, -1, -1, -1,
+ 507, 508, 111, 510, 511, -1, 191, 192, 193, 194,
+ 195, 196, 197, 198, 199, 200, 201, -1, 69, -1,
+ 154, -1, -1, 74, -1, 210, 160, 161, 213, 214,
+ 215, 216, 217, 218, 219, 220, 21, 22, 23, 24,
+ -1, -1, -1, -1, -1, 30, 31, -1, 33, 34,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 111, 75, 247, 77, -1, 199, -1, -1, 202, 203,
+ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213,
+ 214, 215, 216, 217, 218, 219, 220, -1, -1, -1,
+ 199, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 210, -1, -1, 213, 214, 215, 216, 217, 218,
+ 219, 220, -1, 247, -1, 300, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, 247, -1,
+ 154, -1, -1, -1, -1, -1, -1, -1, 199, 163,
+ 164, -1, 166, -1, -1, -1, -1, -1, -1, 210,
+ -1, -1, 213, 214, 215, 216, 217, 218, 219, 220,
+ -1, -1, -1, -1, -1, -1, -1, 191, 192, 193,
+ 194, 195, 196, 197, 198, -1, 200, 201, -1, -1,
+ -1, -1, -1, -1, 379, 380, 247, -1, -1, 384,
+ -1, -1, 387, -1, -1, 390, -1, -1, 222, 223,
+ -1, 225, 226, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 407, 408, -1, -1, 411, 412, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 379, 380, -1, -1, -1,
+ 384, 8, -1, -1, 388, 12, 390, 14, 15, -1,
+ 17, 18, -1, -1, -1, -1, -1, -1, -1, -1,
+ 379, 380, -1, -1, 408, 384, -1, -1, 412, -1,
+ -1, 390, -1, -1, -1, -1, 300, -1, 45, 46,
+ 47, 48, 49, 50, 51, 52, 53, -1, 55, 408,
+ -1, -1, -1, 412, -1, 62, 63, -1, 65, 66,
+ 67, 68, 69, 70, 71, 72, -1, -1, -1, 76,
+ 77, -1, 79, 80, -1, -1, -1, -1, 379, 380,
+ -1, -1, 89, 384, -1, -1, -1, -1, -1, 390,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 408, -1, -1,
+ -1, 412, -1, -1, -1, -1, -1, -1, -1, 383,
+ 8, -1, -1, 387, 12, 389, 14, 15, -1, 17,
+ 18, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 407, -1, 409, 410, 411, -1, 413,
+ 414, -1, -1, -1, -1, -1, -1, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, -1, 55, -1, -1,
+ -1, -1, -1, -1, 62, 63, -1, 65, 66, 67,
+ 68, 69, 70, 71, 72, -1, -1, -1, 76, 77,
+ 8, 79, 80, -1, 12, -1, 14, 15, -1, 17,
+ 18, 89, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, -1, 55, -1, -1,
+ -1, -1, -1, -1, 62, 63, -1, 65, 66, 67,
+ 68, 69, 70, 71, 72, -1, -1, -1, 76, 77,
+ 8, 79, 80, -1, 12, -1, 14, 15, -1, 17,
+ 18, 89, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, -1, 55, -1, -1,
+ -1, -1, -1, -1, 62, 63, -1, 65, 66, 67,
+ 68, 69, 70, 71, 72, -1, -1, -1, 76, 77,
+ 8, 79, 80, -1, 12, -1, 14, 15, -1, 17,
+ 18, 89, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, -1, 55, -1, -1,
+ -1, -1, -1, -1, 62, 63, -1, 65, 66, 67,
+ 68, 69, 70, 71, 72, -1, -1, -1, 76, 77,
+ 8, 79, 80, -1, 12, -1, 14, 15, -1, 17,
+ 18, 89, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, -1, 55, -1, -1,
+ -1, -1, -1, -1, 62, 63, -1, 65, 66, 67,
+ 68, 69, 70, 71, 72, -1, -1, -1, 76, 77,
+ 8, 79, 80, -1, 12, -1, 14, 15, -1, 17,
+ 18, 89, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, -1, 55, -1, -1,
+ -1, -1, -1, -1, 62, 63, -1, 65, 66, 67,
+ 68, 69, 70, 71, 72, -1, -1, -1, 76, 77,
+ 8, 79, 80, -1, 12, -1, 14, 15, -1, 17,
+ 18, 89, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, -1, 55, -1, -1,
+ -1, -1, -1, -1, 62, 63, -1, 65, 66, 67,
+ 68, 69, 70, 71, 72, -1, -1, -1, 76, 77,
+ -1, 79, 80, 6, 7, 8, 9, -1, -1, -1,
+ -1, 89, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 27, -1, -1, 30, -1, -1,
+ -1, -1, 35, 36, -1, 38, 39, 40, 41, -1,
+ -1, -1, 45, 46, 47, 48, 49, 50, 51, 52,
+ 53, -1, 55, -1, -1, -1, -1, 60, 61, 62,
+ 63, -1, -1, 66, 67, 68, 69, 70, 71, -1,
+ 73, 74, 75, 76, 77, 78, 79, 80, 81, 8,
+ -1, -1, 11, 86, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, 27, -1,
+ -1, 30, -1, -1, -1, -1, 35, 36, -1, 38,
+ 39, 40, 41, -1, -1, -1, 45, 46, 47, 48,
+ 49, 50, 51, 52, 53, -1, 55, -1, -1, -1,
+ -1, 60, 61, 62, 63, -1, 8, 66, 67, 68,
+ 69, 70, 71, -1, 73, 74, 75, 76, 77, 78,
+ 79, 80, -1, -1, -1, 27, -1, 86, 30, -1,
+ -1, -1, -1, 35, 36, -1, 38, 39, 40, 41,
+ -1, -1, -1, 45, 46, 47, 48, 49, 50, 51,
+ 52, 53, -1, 55, -1, -1, -1, -1, 60, 61,
+ 62, 63, -1, 8, 66, 67, 68, 69, 70, 71,
+ -1, 73, 74, 75, 76, 77, 78, 79, 80, -1,
+ 82, -1, 27, -1, 86, 30, -1, -1, -1, -1,
+ 35, 36, -1, 38, 39, 40, 41, -1, -1, -1,
+ 45, 46, 47, 48, 49, 50, 51, 52, 53, -1,
+ 55, -1, -1, -1, -1, 60, 61, 62, 63, -1,
+ 8, 66, 67, 68, 69, 70, 71, -1, 73, 74,
+ 75, 76, 77, 78, 79, 80, -1, -1, -1, -1,
+ -1, 86, 30, -1, -1, -1, -1, 35, 36, -1,
+ -1, 39, 40, -1, -1, -1, -1, 45, -1, 47,
+ 48, 49, -1, 51, -1, 53, -1, 55, 8, -1,
+ -1, -1, -1, 61, 62, 63, -1, -1, -1, 67,
+ 68, 69, 70, -1, -1, -1, 74, 75, 76, 77,
+ 30, 79, 80, -1, -1, 35, -1, -1, 86, -1,
+ 40, -1, -1, -1, -1, 45, -1, 47, -1, 49,
+ 8, 51, -1, 53, 12, 55, 14, 15, -1, 17,
+ 18, 61, 62, 63, -1, -1, -1, 67, -1, 69,
+ 70, -1, -1, -1, 74, -1, 76, 77, -1, 79,
+ 80, -1, -1, -1, -1, 43, 86, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, -1, 55, -1, -1,
+ -1, -1, -1, -1, 62, 63, -1, 65, 66, 67,
+ 68, 69, 70, 71, 72, -1, -1, -1, 76, 77,
+ 8, 79, 80, -1, 12, -1, 14, 15, -1, 17,
+ 18, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, -1, 55, -1, -1,
+ -1, -1, -1, -1, 62, 63, -1, 65, 66, 67,
+ 68, 69, 70, 71, 72, -1, -1, -1, 76, 77,
+ -1, 79, 80
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const yytype_uint8 yystos[] =
+{
+ 0, 43, 93, 94, 95, 96, 97, 101, 4, 5,
+ 42, 0, 3, 4, 5, 95, 102, 104, 105, 106,
+ 107, 109, 110, 111, 114, 115, 118, 119, 123, 96,
+ 102, 44, 100, 82, 85, 13, 42, 44, 44, 80,
+ 104, 123, 82, 86, 86, 86, 117, 86, 117, 86,
+ 88, 88, 88, 88, 83, 98, 99, 100, 44, 72,
+ 73, 74, 75, 76, 77, 78, 108, 44, 108, 86,
+ 6, 7, 8, 9, 27, 30, 35, 36, 38, 39,
+ 40, 41, 45, 46, 47, 48, 49, 50, 51, 52,
+ 53, 55, 60, 61, 62, 63, 66, 67, 68, 69,
+ 70, 71, 73, 74, 75, 76, 77, 78, 79, 80,
+ 81, 86, 103, 141, 142, 143, 144, 145, 146, 147,
+ 148, 149, 150, 151, 154, 155, 156, 157, 42, 87,
+ 112, 113, 42, 87, 116, 82, 87, 116, 82, 87,
+ 113, 95, 95, 95, 95, 40, 83, 8, 79, 103,
+ 85, 85, 87, 144, 86, 141, 142, 145, 146, 147,
+ 30, 86, 142, 30, 86, 141, 83, 152, 153, 153,
+ 153, 153, 86, 86, 86, 86, 86, 86, 86, 86,
+ 86, 86, 86, 86, 87, 85, 141, 142, 143, 144,
+ 87, 19, 20, 21, 22, 23, 24, 30, 31, 32,
+ 33, 34, 19, 20, 21, 22, 23, 24, 30, 31,
+ 32, 33, 34, 19, 20, 32, 19, 20, 25, 26,
+ 32, 85, 19, 20, 91, 19, 20, 91, 56, 57,
+ 58, 59, 45, 46, 47, 48, 49, 50, 55, 59,
+ 85, 87, 100, 85, 87, 87, 87, 12, 14, 15,
+ 17, 18, 45, 46, 47, 48, 49, 50, 65, 66,
+ 67, 68, 69, 70, 71, 72, 80, 120, 121, 122,
+ 125, 127, 128, 132, 133, 135, 138, 140, 148, 149,
+ 150, 151, 154, 155, 156, 157, 121, 122, 121, 122,
+ 122, 84, 40, 87, 40, 40, 88, 141, 142, 141,
+ 83, 11, 129, 130, 131, 141, 142, 143, 144, 145,
+ 146, 129, 129, 129, 129, 129, 129, 129, 129, 129,
+ 129, 129, 88, 129, 87, 87, 87, 87, 124, 141,
+ 141, 141, 141, 141, 141, 141, 141, 143, 144, 141,
+ 141, 142, 142, 142, 142, 142, 142, 142, 142, 143,
+ 142, 142, 143, 143, 141, 142, 143, 144, 144, 144,
+ 144, 144, 143, 40, 145, 147, 145, 146, 146, 112,
+ 42, 82, 126, 141, 142, 143, 144, 145, 146, 86,
+ 86, 82, 86, 90, 90, 28, 29, 90, 90, 90,
+ 90, 86, 86, 86, 86, 86, 86, 86, 86, 86,
+ 89, 121, 125, 82, 82, 16, 82, 90, 90, 90,
+ 90, 90, 90, 90, 90, 89, 89, 121, 89, 84,
+ 82, 95, 84, 141, 45, 46, 47, 48, 49, 50,
+ 85, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 95, 88, 100, 82, 144, 144, 40,
+ 145, 144, 141, 142, 146, 143, 129, 129, 129, 129,
+ 129, 129, 129, 129, 129, 89, 88, 134, 135, 141,
+ 144, 145, 146, 141, 144, 146, 145, 89, 122, 84,
+ 130, 122, 95, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 122, 89, 89, 122, 139,
+ 136, 137, 82, 82, 82, 89, 89, 88, 88, 125,
+ 122, 122, 89, 89
+};
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
+
+
+/* Like YYERROR except do call yyerror. This remains here temporarily
+ to ease the transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. However,
+ YYFAIL appears to be in use. Nevertheless, it is formally deprecated
+ in Bison 2.4.2's NEWS entry, where a plan to phase it out is
+ discussed. */
+
+#define YYFAIL goto yyerrlab
+#if defined YYFAIL
+ /* This is here to suppress warnings from the GCC cpp's
+ -Wunused-macros. Normally we don't worry about that warning, but
+ some users do, and we want to make it easy for users to remove
+ YYFAIL uses, which will produce warnings from Bison 2.5. */
+#endif
+
+#define YYRECOVERING() (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (1); \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+while (YYID (0))
+
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+ If N is 0, then set CURRENT to the empty location which ends
+ the previous symbol: RHS[0] (always defined). */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (YYID (N)) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ } \
+ while (YYID (0))
+#endif
+
+
+/* This macro is provided for backward compatibility. */
+
+#ifndef YY_LOCATION_PRINT
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+#endif
+
+
+/* YYLEX -- calling `yylex' with the right arguments. */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (YYLEX_PARAM)
+#else
+# define YYLEX yylex ()
+#endif
+
+/* Enable debugging if requested. */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+# include /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, \
+ Type, Value); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (YYID (0))
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (!yyvaluep)
+ return;
+# ifdef YYPRINT
+ if (yytype < YYNTOKENS)
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# else
+ YYUSE (yyoutput);
+# endif
+ switch (yytype)
+ {
+ default:
+ break;
+ }
+}
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (yytype < YYNTOKENS)
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+ else
+ YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+ yy_symbol_value_print (yyoutput, yytype, yyvaluep);
+ YYFPRINTF (yyoutput, ")");
+}
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included). |
+`------------------------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
+#else
+static void
+yy_stack_print (yybottom, yytop)
+ yytype_int16 *yybottom;
+ yytype_int16 *yytop;
+#endif
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
+ YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (YYID (0))
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
+#else
+static void
+yy_reduce_print (yyvsp, yyrule)
+ YYSTYPE *yyvsp;
+ int yyrule;
+#endif
+{
+ int yynrhs = yyr2[yyrule];
+ int yyi;
+ unsigned long int yylno = yyrline[yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+ yyrule - 1, yylno);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+ &(yyvsp[(yyi + 1) - (yynrhs)])
+ );
+ YYFPRINTF (stderr, "\n");
+ }
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyvsp, Rule); \
+} while (YYID (0))
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+# if defined __GLIBC__ && defined _STRING_H
+# define yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static YYSIZE_T
+yystrlen (const char *yystr)
+#else
+static YYSIZE_T
+yystrlen (yystr)
+ const char *yystr;
+#endif
+{
+ YYSIZE_T yylen;
+ for (yylen = 0; yystr[yylen]; yylen++)
+ continue;
+ return yylen;
+}
+# endif
+# endif
+
+# ifndef yystpcpy
+# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static char *
+yystpcpy (char *yydest, const char *yysrc)
+#else
+static char *
+yystpcpy (yydest, yysrc)
+ char *yydest;
+ const char *yysrc;
+#endif
+{
+ char *yyd = yydest;
+ const char *yys = yysrc;
+
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
+
+ return yyd - 1;
+}
+# endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+ if (*yystr == '"')
+ {
+ YYSIZE_T yyn = 0;
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
+ do_not_strip_quotes: ;
+ }
+
+ if (! yyres)
+ return yystrlen (yystr);
+
+ return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
+ about the unexpected token YYTOKEN for the state stack whose top is
+ YYSSP.
+
+ Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
+ not large enough to hold the message. In that case, also set
+ *YYMSG_ALLOC to the required number of bytes. Return 2 if the
+ required number of bytes is too large to store. */
+static int
+yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
+ yytype_int16 *yyssp, int yytoken)
+{
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
+ YYSIZE_T yysize = yysize0;
+ YYSIZE_T yysize1;
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ /* Internationalized format string. */
+ const char *yyformat = 0;
+ /* Arguments of yyformat. */
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ /* Number of reported tokens (one for the "unexpected", one per
+ "expected"). */
+ int yycount = 0;
+
+ /* There are many possibilities here to consider:
+ - Assume YYFAIL is not used. It's too flawed to consider. See
+
+ for details. YYERROR is fine as it does not invoke this
+ function.
+ - If this state is a consistent state with a default action, then
+ the only way this function was invoked is if the default action
+ is an error action. In that case, don't check for expected
+ tokens because there are none.
+ - The only way there can be no lookahead present (in yychar) is if
+ this state is a consistent state with a default action. Thus,
+ detecting the absence of a lookahead is sufficient to determine
+ that there is no unexpected or expected token to report. In that
+ case, just report a simple "syntax error".
+ - Don't assume there isn't a lookahead just because this state is a
+ consistent state with a default action. There might have been a
+ previous inconsistent state, consistent state with a non-default
+ action, or user semantic action that manipulated yychar.
+ - Of course, the expected token list depends on states to have
+ correct lookahead information, and it depends on the parser not
+ to perform extra reductions after fetching a lookahead from the
+ scanner and before detecting a syntax error. Thus, state merging
+ (from LALR or IELR) and default reductions corrupt the expected
+ token list. However, the list is correct for canonical LR with
+ one exception: it will still contain any token that will not be
+ accepted due to an error action in a later state.
+ */
+ if (yytoken != YYEMPTY)
+ {
+ int yyn = yypact[*yyssp];
+ yyarg[yycount++] = yytname[yytoken];
+ if (!yypact_value_is_default (yyn))
+ {
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. In other words, skip the first -YYN actions for
+ this state because they are default actions. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn + 1;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yyx;
+
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
+ && !yytable_value_is_error (yytable[yyx + yyn]))
+ {
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ yycount = 1;
+ yysize = yysize0;
+ break;
+ }
+ yyarg[yycount++] = yytname[yyx];
+ yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+ if (! (yysize <= yysize1
+ && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+ }
+ }
+ }
+
+ switch (yycount)
+ {
+# define YYCASE_(N, S) \
+ case N: \
+ yyformat = S; \
+ break
+ YYCASE_(0, YY_("syntax error"));
+ YYCASE_(1, YY_("syntax error, unexpected %s"));
+ YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
+ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
+ YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
+ YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
+# undef YYCASE_
+ }
+
+ yysize1 = yysize + yystrlen (yyformat);
+ if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+
+ if (*yymsg_alloc < yysize)
+ {
+ *yymsg_alloc = 2 * yysize;
+ if (! (yysize <= *yymsg_alloc
+ && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
+ *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
+ return 1;
+ }
+
+ /* Avoid sprintf, as that infringes on the user's name space.
+ Don't have undefined behavior even if the translation
+ produced a string with the wrong number of "%s"s. */
+ {
+ char *yyp = *yymsg;
+ int yyi = 0;
+ while ((*yyp = *yyformat) != '\0')
+ if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyformat += 2;
+ }
+ else
+ {
+ yyp++;
+ yyformat++;
+ }
+ }
+ return 0;
+}
+#endif /* YYERROR_VERBOSE */
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol. |
+`-----------------------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
+#else
+static void
+yydestruct (yymsg, yytype, yyvaluep)
+ const char *yymsg;
+ int yytype;
+ YYSTYPE *yyvaluep;
+#endif
+{
+ YYUSE (yyvaluep);
+
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+ switch (yytype)
+ {
+
+ default:
+ break;
+ }
+}
+
+
+/* Prevent warnings from -Wmissing-prototypes. */
+#ifdef YYPARSE_PARAM
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void *YYPARSE_PARAM);
+#else
+int yyparse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+/* The lookahead symbol. */
+int yychar;
+
+/* The semantic value of the lookahead symbol. */
+YYSTYPE yylval;
+
+/* Number of syntax errors so far. */
+int yynerrs;
+
+
+/*----------.
+| yyparse. |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *YYPARSE_PARAM)
+#else
+int
+yyparse (YYPARSE_PARAM)
+ void *YYPARSE_PARAM;
+#endif
+#else /* ! YYPARSE_PARAM */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void)
+#else
+int
+yyparse ()
+
+#endif
+#endif
+{
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
+
+ YYSIZE_T yystacksize;
+
+ int yyn;
+ int yyresult;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char yymsgbuf[128];
+ char *yymsg = yymsgbuf;
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+
+ /* The number of symbols on the RHS of the reduced rule.
+ Keep to zero when no symbol should be popped. */
+ int yylen = 0;
+
+ yytoken = 0;
+ yyss = yyssa;
+ yyvs = yyvsa;
+ yystacksize = YYINITDEPTH;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+ yyssp = yyss;
+ yyvsp = yyvs;
+
+ goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate. |
+`------------------------------------------------------------*/
+ yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. So pushing a state here evens the stacks. */
+ yyssp++;
+
+ yysetstate:
+ *yyssp = yystate;
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ {
+ /* Get the current used size of the three stacks, in elements. */
+ YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ {
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ yytype_int16 *yyss1 = yyss;
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
+ &yystacksize);
+
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+# else
+ /* Extend the stack our own way. */
+ if (YYMAXDEPTH <= yystacksize)
+ goto yyexhaustedlab;
+ yystacksize *= 2;
+ if (YYMAXDEPTH < yystacksize)
+ yystacksize = YYMAXDEPTH;
+
+ {
+ yytype_int16 *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyexhaustedlab;
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+# undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+ }
+# endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + yysize - 1;
+ yyvsp = yyvs + yysize - 1;
+
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ YYABORT;
+ }
+
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
+ goto yybackup;
+
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
+
+ /* Do appropriate processing given the current state. Read a
+ lookahead token if we need one and don't already have one. */
+
+ /* First try to decide what to do without reference to lookahead token. */
+ yyn = yypact[yystate];
+ if (yypact_value_is_default (yyn))
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
+ }
+
+ if (yychar <= YYEOF)
+ {
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ }
+
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
+ detect an error, take that action. */
+ yyn += yytoken;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+ goto yydefault;
+ yyn = yytable[yyn];
+ if (yyn <= 0)
+ {
+ if (yytable_value_is_error (yyn))
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
+
+ /* Shift the lookahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
+
+ yystate = yyn;
+ *++yyvsp = yylval;
+
+ goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+yydefault:
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction. |
+`-----------------------------*/
+yyreduce:
+ /* yyn is the number of a rule to reduce with. */
+ yylen = yyr2[yyn];
+
+ /* If YYLEN is nonzero, implement the default value of the action:
+ `$$ = $1'.
+
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ yyval = yyvsp[1-yylen];
+
+
+ YY_REDUCE_PRINT (yyn);
+ switch (yyn)
+ {
+ case 2:
+
+/* Line 1806 of yacc.c */
+#line 1755 "script_parser.ypp"
+ {
+ unsigned int i, numArrays;
+ SDWORD size = 0, debug_i = 0, totalArraySize = 0;
+ UDWORD base;
+ VAR_SYMBOL *psCurr;
+ TRIGGER_SYMBOL *psTrig;
+ EVENT_SYMBOL *psEvent;
+ UDWORD numVars;
+
+ RULE("script: var_list");
+
+ // Calculate the code size
+ for(psTrig = psTriggers; psTrig; psTrig = psTrig->psNext)
+ {
+ // Add the trigger code size
+ size += psTrig->size;
+ debug_i += psTrig->debugEntries;
+ }
+
+ for(psEvent = psEvents; psEvent; psEvent = psEvent->psNext)
+ {
+ // Add the trigger code size
+ size += psEvent->size;
+ debug_i += psEvent->debugEntries;
+ }
+
+ // Allocate the program
+ numVars = psGlobalVars ? psGlobalVars->index+1 : 0;
+ numArrays = psGlobalArrays ? psGlobalArrays->index+1 : 0;
+ for(psCurr=psGlobalArrays; psCurr; psCurr=psCurr->psNext)
+ {
+ unsigned int arraySize = 1, dimension;
+ for(dimension = 0; dimension < psCurr->dimensions; dimension++)
+ {
+ arraySize *= psCurr->elements[dimension];
+ }
+ totalArraySize += arraySize;
+ }
+ ALLOC_PROG(psFinalProg, size, psCurrBlock->pCode,
+ numVars, numArrays, numTriggers, numEvents);
+
+ //store local vars
+ //allocate array for holding an array of local vars for each event
+ psFinalProg->ppsLocalVars = (INTERP_TYPE **)malloc(sizeof(INTERP_TYPE*) * numEvents);
+ psFinalProg->ppsLocalVarVal = NULL;
+ psFinalProg->numLocalVars = (UDWORD *)malloc(sizeof(UDWORD) * numEvents); //how many local vars each event has
+ psFinalProg->numParams = (UDWORD *)malloc(sizeof(UDWORD) * numEvents); //how many arguments each event has
+
+ for(psEvent = psEvents, i = 0; psEvent; psEvent = psEvent->psNext, i++)
+ {
+ psEvent->numLocalVars = numEventLocalVars[i];
+
+ psFinalProg->numLocalVars[i] = numEventLocalVars[i]; //remember how many local vars this event has
+ psFinalProg->numParams[i] = psEvent->numParams; //remember how many parameters this event has
+
+ if(numEventLocalVars[i] > 0)
+ {
+ unsigned int j;
+ INTERP_TYPE * pCurEvLocalVars = (INTERP_TYPE*)malloc(sizeof(INTERP_TYPE) * numEventLocalVars[i]);
+
+ for(psCurr = psLocalVarsB[i], j = 0; psCurr != NULL; psCurr = psCurr->psNext, j++)
+ {
+ pCurEvLocalVars[numEventLocalVars[i] - j - 1] = psCurr->type; //save type, order is reversed
+ }
+
+ psFinalProg->ppsLocalVars[i] = pCurEvLocalVars;
+ }
+ else
+ {
+ psFinalProg->ppsLocalVars[i] = NULL; //this event has no local vars
+ }
+ }
+
+ ALLOC_DEBUG(psFinalProg, debug_i);
+ psFinalProg->debugEntries = 0;
+ ip = psFinalProg->pCode;
+
+ // Add the trigger code
+ for(psTrig = psTriggers, i = 0; psTrig; psTrig = psTrig->psNext, i++)
+ {
+ // Store the trigger offset
+ psFinalProg->pTriggerTab[i] = (UWORD)(ip - psFinalProg->pCode);
+ if (psTrig->pCode != NULL)
+ {
+ // Store the label
+ DEBUG_LABEL(psFinalProg, psFinalProg->debugEntries,
+ psTrig->pIdent);
+ // Store debug info
+ APPEND_DEBUG(psFinalProg, ip - psFinalProg->pCode, psTrig);
+ // Store the code
+ PUT_BLOCK(ip, psTrig);
+ psFinalProg->psTriggerData[i].code = true;
+ }
+ else
+ {
+ psFinalProg->psTriggerData[i].code = false;
+ }
+ // Store the data
+ psFinalProg->psTriggerData[i].type = psTrig->type;
+ psFinalProg->psTriggerData[i].time = psTrig->time;
+ }
+ // Note the end of the final trigger
+ psFinalProg->pTriggerTab[i] = (UWORD)(ip - psFinalProg->pCode);
+
+ // Add the event code
+ for(psEvent = psEvents, i = 0; psEvent; psEvent = psEvent->psNext, i++)
+ {
+ // Check the event was declared and has a code body
+ if (psEvent->pCode == NULL)
+ {
+ scr_error("Event %s declared without being defined",
+ psEvent->pIdent);
+ YYABORT;
+ }
+
+ // Store the event offset
+ psFinalProg->pEventTab[i] = (UWORD)(ip - psFinalProg->pCode);
+ // Store the trigger link
+ psFinalProg->pEventLinks[i] = (SWORD)(psEvent->trigger);
+ // Store the label
+ DEBUG_LABEL(psFinalProg, psFinalProg->debugEntries,
+ psEvent->pIdent);
+ // Store debug info
+ APPEND_DEBUG(psFinalProg, ip - psFinalProg->pCode, psEvent);
+ // Store the code
+ PUT_BLOCK(ip, psEvent);
+ }
+ // Note the end of the final event
+ psFinalProg->pEventTab[i] = (UWORD)(ip - psFinalProg->pCode);
+
+ // Allocate debug info for the variables if necessary
+ if (genDebugInfo)
+ {
+ if (numVars > 0)
+ {
+ psFinalProg->psVarDebug = (VAR_DEBUG *)malloc(sizeof(VAR_DEBUG) * numVars);
+ if (psFinalProg->psVarDebug == NULL)
+ {
+ scr_error("Out of memory");
+ YYABORT;
+ }
+ }
+ else
+ {
+ psFinalProg->psVarDebug = NULL;
+ }
+ if (numArrays > 0)
+ {
+ psFinalProg->psArrayDebug = (ARRAY_DEBUG *)malloc(sizeof(ARRAY_DEBUG) * numArrays);
+ if (psFinalProg->psArrayDebug == NULL)
+ {
+ scr_error("Out of memory");
+ YYABORT;
+ }
+ }
+ else
+ {
+ psFinalProg->psArrayDebug = NULL;
+ }
+ }
+ else
+ {
+ psFinalProg->psVarDebug = NULL;
+ psFinalProg->psArrayDebug = NULL;
+ }
+
+ /* Now set the types for the global variables */
+ for(psCurr = psGlobalVars; psCurr != NULL; psCurr = psCurr->psNext)
+ {
+ unsigned int i = psCurr->index;
+ psFinalProg->pGlobals[i] = psCurr->type;
+
+ if (genDebugInfo)
+ {
+ psFinalProg->psVarDebug[i].pIdent = strdup(psCurr->pIdent);
+ if (psFinalProg->psVarDebug[i].pIdent == NULL)
+ {
+ scr_error("Out of memory");
+ YYABORT;
+ }
+ psFinalProg->psVarDebug[i].storage = psCurr->storage;
+ }
+ }
+
+ /* Now store the array info */
+ psFinalProg->arraySize = totalArraySize;
+ for(psCurr = psGlobalArrays; psCurr != NULL; psCurr = psCurr->psNext)
+ {
+ unsigned int i = psCurr->index, dimension;
+
+ psFinalProg->psArrayInfo[i].type = psCurr->type;
+ psFinalProg->psArrayInfo[i].dimensions = (UBYTE)psCurr->dimensions;
+ for(dimension = 0; dimension < psCurr->dimensions; dimension++)
+ {
+ psFinalProg->psArrayInfo[i].elements[dimension] = (UBYTE)psCurr->elements[dimension];
+ }
+
+ if (genDebugInfo)
+ {
+ psFinalProg->psArrayDebug[i].pIdent = strdup(psCurr->pIdent);
+ if (psFinalProg->psArrayDebug[i].pIdent == NULL)
+ {
+ scr_error("Out of memory");
+ YYABORT;
+ }
+ psFinalProg->psArrayDebug[i].storage = psCurr->storage;
+ }
+ }
+ // calculate the base index of each array
+ base = psFinalProg->numGlobals;
+ for(i=0; ipsArrayInfo[i].base = base;
+ for(dimension = 0; dimension < psFinalProg->psArrayInfo[i].dimensions; dimension++)
+ {
+ arraySize *= psFinalProg->psArrayInfo[i].elements[dimension];
+ }
+
+ base += arraySize;
+ }
+
+ RULE("END script: var_list");
+ }
+ break;
+
+ case 3:
+
+/* Line 1806 of yacc.c */
+#line 1983 "script_parser.ypp"
+ {
+ RULE("script:var_list trigger_list");
+ }
+ break;
+
+ case 4:
+
+/* Line 1806 of yacc.c */
+#line 1987 "script_parser.ypp"
+ {
+ RULE("script:script event_list");
+ }
+ break;
+
+ case 5:
+
+/* Line 1806 of yacc.c */
+#line 1991 "script_parser.ypp"
+ {
+ RULE("script:script var_list");
+ }
+ break;
+
+ case 6:
+
+/* Line 1806 of yacc.c */
+#line 1995 "script_parser.ypp"
+ {
+ RULE("script:script trigger_list");
+ }
+ break;
+
+ case 7:
+
+/* Line 1806 of yacc.c */
+#line 2001 "script_parser.ypp"
+ {
+ RULE("var_list: NULL");
+ }
+ break;
+
+ case 8:
+
+/* Line 1806 of yacc.c */
+#line 2005 "script_parser.ypp"
+ {
+ RULE("var_list: var_line");
+ FREE_VARDECL((yyvsp[(1) - (1)].vdecl));
+ }
+ break;
+
+ case 9:
+
+/* Line 1806 of yacc.c */
+#line 2010 "script_parser.ypp"
+ {
+ FREE_VARDECL((yyvsp[(2) - (2)].vdecl));
+ }
+ break;
+
+ case 10:
+
+/* Line 1806 of yacc.c */
+#line 2021 "script_parser.ypp"
+ {
+ /* remember that local var declaration is over */
+ localVariableDef = false;
+ //debug(LOG_SCRIPT, "localVariableDef = false 0");
+ (yyval.vdecl) = (yyvsp[(1) - (2)].vdecl);
+ }
+ break;
+
+ case 11:
+
+/* Line 1806 of yacc.c */
+#line 2031 "script_parser.ypp"
+ {
+ //debug(LOG_SCRIPT, "variable_decl_head: STORAGE TYPE");
+
+ ALLOC_VARDECL(psCurrVDecl);
+ psCurrVDecl->storage = (yyvsp[(1) - (2)].stype);
+ psCurrVDecl->type = (yyvsp[(2) - (2)].tval);
+
+ /* allow local vars to have the same names as global vars (don't check global vars) */
+ if((yyvsp[(1) - (2)].stype) == ST_LOCAL)
+ {
+ localVariableDef = true;
+ //debug(LOG_SCRIPT, "localVariableDef = true 0");
+ }
+
+ (yyval.vdecl) = psCurrVDecl;
+ //debug(LOG_SCRIPT, "END variable_decl_head: STORAGE TYPE (TYPE=%d)", $2);
+ }
+ break;
+
+ case 12:
+
+/* Line 1806 of yacc.c */
+#line 2049 "script_parser.ypp"
+ {
+
+ ALLOC_VARDECL(psCurrVDecl);
+ psCurrVDecl->storage = (yyvsp[(1) - (2)].stype);
+ psCurrVDecl->type = VAL_TRIGGER;
+
+ (yyval.vdecl) = psCurrVDecl;
+ }
+ break;
+
+ case 13:
+
+/* Line 1806 of yacc.c */
+#line 2058 "script_parser.ypp"
+ {
+ ALLOC_VARDECL(psCurrVDecl);
+ psCurrVDecl->storage = (yyvsp[(1) - (2)].stype);
+ psCurrVDecl->type = VAL_EVENT;
+
+ (yyval.vdecl) = psCurrVDecl;
+ }
+ break;
+
+ case 14:
+
+/* Line 1806 of yacc.c */
+#line 2068 "script_parser.ypp"
+ {
+ if ((yyvsp[(2) - (3)].ival) <= 0 || (yyvsp[(2) - (3)].ival) >= VAR_MAX_ELEMENTS)
+ {
+ scr_error("Invalid array size %d", (yyvsp[(2) - (3)].ival));
+ YYABORT;
+ }
+
+ ALLOC_VARIDENTDECL(psCurrVIdentDecl, NULL, 1);
+ psCurrVIdentDecl->elements[0] = (yyvsp[(2) - (3)].ival);
+
+ (yyval.videcl) = psCurrVIdentDecl;
+ }
+ break;
+
+ case 15:
+
+/* Line 1806 of yacc.c */
+#line 2083 "script_parser.ypp"
+ {
+ (yyval.videcl) = (yyvsp[(1) - (1)].videcl);
+ }
+ break;
+
+ case 16:
+
+/* Line 1806 of yacc.c */
+#line 2088 "script_parser.ypp"
+ {
+ if ((yyvsp[(1) - (4)].videcl)->dimensions >= VAR_MAX_DIMENSIONS)
+ {
+ scr_error("Too many dimensions for array");
+ YYABORT;
+ }
+ if ((yyvsp[(3) - (4)].ival) <= 0 || (yyvsp[(3) - (4)].ival) >= VAR_MAX_ELEMENTS)
+ {
+ scr_error("Invalid array size %d", (yyvsp[(3) - (4)].ival));
+ YYABORT;
+ }
+
+ (yyvsp[(1) - (4)].videcl)->elements[(yyvsp[(1) - (4)].videcl)->dimensions] = (yyvsp[(3) - (4)].ival);
+ (yyvsp[(1) - (4)].videcl)->dimensions += 1;
+
+ (yyval.videcl) = (yyvsp[(1) - (4)].videcl);
+ }
+ break;
+
+ case 17:
+
+/* Line 1806 of yacc.c */
+#line 2108 "script_parser.ypp"
+ {
+ ALLOC_VARIDENTDECL(psCurrVIdentDecl, (yyvsp[(1) - (1)].sval), 0);
+
+ (yyval.videcl) = psCurrVIdentDecl;
+ }
+ break;
+
+ case 18:
+
+/* Line 1806 of yacc.c */
+#line 2115 "script_parser.ypp"
+ {
+ (yyvsp[(2) - (2)].videcl)->pIdent = strdup((yyvsp[(1) - (2)].sval));
+ if ((yyvsp[(2) - (2)].videcl)->pIdent == NULL)
+ {
+ scr_error("Out of memory");
+ YYABORT;
+ }
+
+ (yyval.videcl) = (yyvsp[(2) - (2)].videcl);
+ }
+ break;
+
+ case 19:
+
+/* Line 1806 of yacc.c */
+#line 2128 "script_parser.ypp"
+ {
+ if (!scriptAddVariable((yyvsp[(1) - (2)].vdecl), (yyvsp[(2) - (2)].videcl)))
+ {
+ /* Out of memory - error already given */
+ YYABORT;
+ }
+
+ freeVARIDENTDECL((yyvsp[(2) - (2)].videcl));
+
+ /* return the variable type */
+ (yyval.vdecl) = (yyvsp[(1) - (2)].vdecl);
+ }
+ break;
+
+ case 20:
+
+/* Line 1806 of yacc.c */
+#line 2141 "script_parser.ypp"
+ {
+ if (!scriptAddVariable((yyvsp[(1) - (3)].vdecl), (yyvsp[(3) - (3)].videcl)))
+ {
+ /* Out of memory - error already given */
+ YYABORT;
+ }
+
+ freeVARIDENTDECL((yyvsp[(3) - (3)].videcl));
+
+ /* return the variable type */
+ (yyval.vdecl) = (yyvsp[(1) - (3)].vdecl);
+ }
+ break;
+
+ case 24:
+
+/* Line 1806 of yacc.c */
+#line 2166 "script_parser.ypp"
+ {
+ ALLOC_TSUBDECL(psCurrTDecl, TR_CODE, (yyvsp[(1) - (3)].cblock)->size, (yyvsp[(3) - (3)].ival));
+ ip = psCurrTDecl->pCode;
+ PUT_BLOCK(ip, (yyvsp[(1) - (3)].cblock));
+ FREE_BLOCK((yyvsp[(1) - (3)].cblock));
+
+ (yyval.tdecl) = psCurrTDecl;
+ }
+ break;
+
+ case 25:
+
+/* Line 1806 of yacc.c */
+#line 2175 "script_parser.ypp"
+ {
+ ALLOC_TSUBDECL(psCurrTDecl, TR_WAIT, 0, (yyvsp[(3) - (3)].ival));
+
+ (yyval.tdecl) = psCurrTDecl;
+ }
+ break;
+
+ case 26:
+
+/* Line 1806 of yacc.c */
+#line 2181 "script_parser.ypp"
+ {
+ ALLOC_TSUBDECL(psCurrTDecl, TR_EVERY, 0, (yyvsp[(3) - (3)].ival));
+
+ (yyval.tdecl) = psCurrTDecl;
+ }
+ break;
+
+ case 27:
+
+/* Line 1806 of yacc.c */
+#line 2187 "script_parser.ypp"
+ {
+ ALLOC_TSUBDECL(psCurrTDecl, TR_INIT, 0, 0);
+
+ (yyval.tdecl) = psCurrTDecl;
+ }
+ break;
+
+ case 28:
+
+/* Line 1806 of yacc.c */
+#line 2193 "script_parser.ypp"
+ {
+ if ((yyvsp[(1) - (1)].cbSymbol)->numParams != 0)
+ {
+ scr_error("Expected parameters for callback trigger");
+ YYABORT;
+ }
+
+ ALLOC_TSUBDECL(psCurrTDecl, (yyvsp[(1) - (1)].cbSymbol)->type, 0, 0);
+
+ (yyval.tdecl) = psCurrTDecl;
+ }
+ break;
+
+ case 29:
+
+/* Line 1806 of yacc.c */
+#line 2205 "script_parser.ypp"
+ {
+ RULE("trigger_subdecl: CALLBACK_SYM ',' param_list");
+ codeRet = scriptCodeCallbackParams((yyvsp[(1) - (3)].cbSymbol), (yyvsp[(3) - (3)].pblock), &psCurrTDecl);
+ CHECK_CODE_ERROR(codeRet);
+
+ (yyval.tdecl) = psCurrTDecl;
+ }
+ break;
+
+ case 30:
+
+/* Line 1806 of yacc.c */
+#line 2215 "script_parser.ypp"
+ {
+ SDWORD line;
+ char *pDummy;
+
+ scriptGetErrorData(&line, &pDummy);
+ if (!scriptAddTrigger((yyvsp[(2) - (6)].sval), (yyvsp[(4) - (6)].tdecl), (UDWORD)line))
+ {
+ YYABORT;
+ }
+ FREE_TSUBDECL((yyvsp[(4) - (6)].tdecl));
+ }
+ break;
+
+ case 33:
+
+/* Line 1806 of yacc.c */
+#line 2238 "script_parser.ypp"
+ {
+ EVENT_SYMBOL *psEvent;
+
+ RULE("event_subdecl: EVENT IDENT");
+
+ if (!scriptDeclareEvent((yyvsp[(2) - (2)].sval), &psEvent,0))
+ {
+ YYABORT;
+ }
+
+ psCurEvent = psEvent;
+
+ (yyval.eSymbol) = psEvent;
+
+ //debug(LOG_SCRIPT, "END event_subdecl: EVENT IDENT");
+ }
+ break;
+
+ case 34:
+
+/* Line 1806 of yacc.c */
+#line 2255 "script_parser.ypp"
+ {
+
+ RULE("EVENT EVENT_SYM");
+
+ psCurEvent = (yyvsp[(2) - (2)].eSymbol);
+ (yyval.eSymbol) = (yyvsp[(2) - (2)].eSymbol);
+
+ //debug(LOG_SCRIPT, "END EVENT EVENT_SYM");
+ }
+ break;
+
+ case 35:
+
+/* Line 1806 of yacc.c */
+#line 2268 "script_parser.ypp"
+ {
+
+ RULE("function_def: lexFUNCTION TYPE function_type");
+
+ psCurEvent = (yyvsp[(3) - (3)].eSymbol);
+
+ /* check if this event was declared as function before */
+ if(!(yyvsp[(3) - (3)].eSymbol)->bFunction)
+ {
+ debug(LOG_ERROR, "'%s' was declared as event before and can't be redefined to function", (yyvsp[(3) - (3)].eSymbol)->pIdent);
+ scr_error("Wrong event definition");
+ YYABORT;
+ }
+
+ (yyval.eSymbol) = (yyvsp[(3) - (3)].eSymbol);
+ }
+ break;
+
+ case 43:
+
+/* Line 1806 of yacc.c */
+#line 2297 "script_parser.ypp"
+ {
+ EVENT_SYMBOL *psEvent;
+
+ RULE("func_subdecl: lexFUNCTION TYPE IDENT");
+
+ /* allow local vars to have the same names as global vars (don't check global vars) */
+ localVariableDef = true;
+ //debug(LOG_SCRIPT, "localVariableDef = true 1");
+
+ if (!scriptDeclareEvent((yyvsp[(3) - (3)].sval), &psEvent,0))
+ {
+ YYABORT;
+ }
+
+ psEvent->retType = (yyvsp[(2) - (3)].tval);
+ psCurEvent = psEvent;
+ psCurEvent->bFunction = true;
+
+ (yyval.eSymbol) = psEvent;
+
+ //debug(LOG_SCRIPT, "END func_subdecl:lexFUNCTION TYPE IDENT. ");
+ }
+ break;
+
+ case 44:
+
+/* Line 1806 of yacc.c */
+#line 2324 "script_parser.ypp"
+ {
+ EVENT_SYMBOL *psEvent;
+
+ RULE("void_func_subdecl: lexFUNCTION _VOID IDENT");
+
+ /* allow local vars to have the same names as global vars (don't check global vars) */
+ localVariableDef = true;
+ //debug(LOG_SCRIPT, "localVariableDef = true 1");
+
+ if (!scriptDeclareEvent((yyvsp[(3) - (3)].sval), &psEvent,0))
+ {
+ YYABORT;
+ }
+
+ psEvent->retType = VAL_VOID;
+ psCurEvent = psEvent;
+ psCurEvent->bFunction = true;
+
+ (yyval.eSymbol) = psEvent;
+
+ //debug(LOG_SCRIPT, "END func_subdecl:lexFUNCTION TYPE IDENT. ");
+ }
+ break;
+
+ case 45:
+
+/* Line 1806 of yacc.c */
+#line 2349 "script_parser.ypp"
+ {
+ //debug(LOG_SCRIPT, "func_subdecl:lexFUNCTION EVENT_SYM ");
+ psCurEvent = (yyvsp[(3) - (3)].eSymbol);
+
+
+ /* check if this event was declared as function before */
+ if(!(yyvsp[(3) - (3)].eSymbol)->bFunction)
+ {
+ debug(LOG_ERROR, "'%s' was declared as event before and can't be redefined to function", (yyvsp[(3) - (3)].eSymbol)->pIdent);
+ scr_error("Wrong event definition");
+ YYABORT;
+ }
+
+ /* psCurEvent->bFunction = true; */
+ /* psEvent->retType = $2; */
+ (yyval.eSymbol) = (yyvsp[(3) - (3)].eSymbol);
+ //debug(LOG_SCRIPT, "func_subdecl:lexFUNCTION EVENT_SYM. ");
+ }
+ break;
+
+ case 46:
+
+/* Line 1806 of yacc.c */
+#line 2372 "script_parser.ypp"
+ {
+ (yyval.integer_val)=(yyvsp[(1) - (2)].tval);
+ }
+ break;
+
+ case 47:
+
+/* Line 1806 of yacc.c */
+#line 2376 "script_parser.ypp"
+ {
+ (yyval.integer_val)=(yyvsp[(1) - (2)].tval);
+ }
+ break;
+
+ case 48:
+
+/* Line 1806 of yacc.c */
+#line 2380 "script_parser.ypp"
+ {
+ (yyval.integer_val)=(yyvsp[(1) - (2)].tval);
+ }
+ break;
+
+ case 49:
+
+/* Line 1806 of yacc.c */
+#line 2384 "script_parser.ypp"
+ {
+ (yyval.integer_val)=(yyvsp[(1) - (2)].tval);
+ }
+ break;
+
+ case 50:
+
+/* Line 1806 of yacc.c */
+#line 2388 "script_parser.ypp"
+ {
+ (yyval.integer_val)=(yyvsp[(1) - (2)].tval);
+ }
+ break;
+
+ case 51:
+
+/* Line 1806 of yacc.c */
+#line 2392 "script_parser.ypp"
+ {
+ (yyval.integer_val)=(yyvsp[(1) - (2)].tval);
+ }
+ break;
+
+ case 52:
+
+/* Line 1806 of yacc.c */
+#line 2396 "script_parser.ypp"
+ {
+ (yyval.integer_val)=(yyvsp[(1) - (2)].tval);
+ }
+ break;
+
+ case 53:
+
+/* Line 1806 of yacc.c */
+#line 2400 "script_parser.ypp"
+ {
+ (yyval.integer_val)=(yyvsp[(1) - (2)].tval);
+ }
+ break;
+
+ case 54:
+
+/* Line 1806 of yacc.c */
+#line 2407 "script_parser.ypp"
+ {
+ if(!checkFuncParamType(0, (yyvsp[(1) - (1)].integer_val)))
+ {
+ scr_error("Wrong event argument definition in '%s'", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ //debug(LOG_SCRIPT, "funcbody_var_def_body=%d \n", $1);
+ (yyval.integer_val)=1;
+ }
+ break;
+
+ case 55:
+
+/* Line 1806 of yacc.c */
+#line 2418 "script_parser.ypp"
+ {
+ if(!checkFuncParamType((yyvsp[(1) - (3)].integer_val), (yyvsp[(3) - (3)].integer_val)))
+ {
+ scr_error("Wrong event argument definition");
+ YYABORT;
+ }
+
+ //debug(LOG_SCRIPT, "funcbody_var_def_body2=%d \n", $3);
+ (yyval.integer_val)=(yyvsp[(1) - (3)].integer_val)+1;
+ }
+ break;
+
+ case 56:
+
+/* Line 1806 of yacc.c */
+#line 2432 "script_parser.ypp"
+ {
+
+ RULE("funcbody_var_def: '(' funcvar_decl_types ')'");
+
+ /* remember that local var declaration is over */
+ localVariableDef = false;
+
+ if(psCurEvent == NULL)
+ {
+ scr_error("psCurEvent == NULL");
+ YYABORT;
+ }
+
+ if(!psCurEvent->bDeclared)
+ {
+ debug(LOG_ERROR, "Event %s's definition doesn't match with declaration.", psCurEvent->pIdent);
+ scr_error("Wrong event definition:\n event %s's definition doesn't match with declaration", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ /* check if number of parameter in body defenition match number of params in the declaration */
+ if((yyvsp[(3) - (4)].integer_val) != psCurEvent->numParams)
+ {
+ scr_error("Wrong number of arguments in function definition (or declaration-definition argument type/names mismatch) \n in event: '%s'", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ (yyval.eSymbol) = (yyvsp[(1) - (4)].eSymbol);
+ }
+ break;
+
+ case 57:
+
+/* Line 1806 of yacc.c */
+#line 2462 "script_parser.ypp"
+ {
+
+ RULE( "funcbody_var_def: funcbody_var_def_body '(' ')'");
+
+ /* remember that local var declaration is over */
+ localVariableDef = false;
+
+ if(psCurEvent == NULL)
+ {
+ scr_error("psCurEvent == NULL");
+ YYABORT;
+ }
+
+ if(!psCurEvent->bDeclared)
+ {
+ debug(LOG_ERROR, "Event %s's definition doesn't match with declaration.", psCurEvent->pIdent);
+ scr_error("Wrong event definition:\n event %s's definition doesn't match with declaration", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ /* check if number of parameter in body defenition match number of params in the declaration */
+ if(0 != psCurEvent->numParams)
+ {
+ scr_error("Wrong number of arguments in function definition (or declaration-definition argument type/names mismatch) \n in event: '%s'", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ (yyval.eSymbol) = (yyvsp[(1) - (3)].eSymbol);
+ }
+ break;
+
+ case 58:
+
+/* Line 1806 of yacc.c */
+#line 2497 "script_parser.ypp"
+ {
+
+ RULE( "funcbody_var_def: '(' funcvar_decl_types ')'");
+
+ /* remember that local var declaration is over */
+ localVariableDef = false;
+
+ if(psCurEvent == NULL)
+ {
+ scr_error("psCurEvent == NULL");
+ YYABORT;
+ }
+
+ if(!psCurEvent->bDeclared)
+ {
+ debug(LOG_ERROR, "Event %s's definition doesn't match with declaration.", psCurEvent->pIdent);
+ scr_error("Wrong event definition:\n event %s's definition doesn't match with declaration", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ /* check if number of parameter in body defenition match number of params in the declaration */
+ if((yyvsp[(3) - (4)].integer_val) != psCurEvent->numParams)
+ {
+ scr_error("Wrong number of arguments in function definition (or declaration-definition argument type/names mismatch) \n in event: '%s'", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ (yyval.eSymbol) = (yyvsp[(1) - (4)].eSymbol);
+ }
+ break;
+
+ case 59:
+
+/* Line 1806 of yacc.c */
+#line 2527 "script_parser.ypp"
+ {
+
+ RULE( "funcbody_var_def: funcbody_var_def_body '(' ')'");
+
+ /* remember that local var declaration is over */
+ localVariableDef = false;
+
+ if(psCurEvent == NULL)
+ {
+ scr_error("psCurEvent == NULL");
+ YYABORT;
+ }
+
+ if(!psCurEvent->bDeclared)
+ {
+ debug(LOG_ERROR, "Event %s's definition doesn't match with declaration.", psCurEvent->pIdent);
+ scr_error("Wrong event definition:\n event %s's definition doesn't match with declaration", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ /* check if number of parameter in body defenition match number of params in the declaration */
+ if(0 != psCurEvent->numParams)
+ {
+ scr_error("Wrong number of arguments in function definition (or declaration-definition argument type/names mismatch) \n in event: '%s'", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ (yyval.eSymbol) = (yyvsp[(1) - (3)].eSymbol);
+ }
+ break;
+
+ case 60:
+
+/* Line 1806 of yacc.c */
+#line 2562 "script_parser.ypp"
+ {
+
+ RULE( "argument_decl_head: TYPE variable_ident");
+
+
+ /* handle type part */
+ ALLOC_VARDECL(psCurrVDecl);
+ psCurrVDecl->storage =ST_LOCAL; /* can only be local */
+ psCurrVDecl->type = (yyvsp[(1) - (2)].tval);
+
+ /* handle ident part */
+ if (!scriptAddVariable(psCurrVDecl, (yyvsp[(2) - (2)].videcl)))
+ {
+ YYABORT;
+ }
+
+ freeVARIDENTDECL((yyvsp[(2) - (2)].videcl));
+
+ FREE_VARDECL(psCurrVDecl);
+
+ /* return the variable type */
+ /* $$ = psCurrVDecl; */ /* not needed? */
+
+ if(psCurEvent == NULL)
+ debug(LOG_ERROR, "argument_decl_head 0: - psCurEvent == NULL");
+
+ psCurEvent->numParams = psCurEvent->numParams + 1; /* remember a parameter was declared */
+
+ /* remember parameter type */
+ psCurEvent->aParams[0] = (yyvsp[(1) - (2)].tval);
+
+ //debug(LOG_SCRIPT, "argument_decl_head 0. ");
+ }
+ break;
+
+ case 61:
+
+/* Line 1806 of yacc.c */
+#line 2596 "script_parser.ypp"
+ {
+ //debug(LOG_SCRIPT, "argument_decl_head 1 ");
+
+ /* handle type part */
+ ALLOC_VARDECL(psCurrVDecl);
+ psCurrVDecl->storage =ST_LOCAL; /* can only be local */
+ psCurrVDecl->type = (yyvsp[(3) - (4)].tval);
+
+ /* remember parameter type */
+ psCurEvent->aParams[psCurEvent->numParams] = (yyvsp[(3) - (4)].tval);
+ //debug(LOG_SCRIPT, "argument_decl_head 10 ");
+
+ /* handle ident part */
+ if (!scriptAddVariable(psCurrVDecl, (yyvsp[(4) - (4)].videcl)))
+ {
+ YYABORT;
+ }
+ //debug(LOG_SCRIPT, "argument_decl_head 11 ");
+ freeVARIDENTDECL((yyvsp[(4) - (4)].videcl));
+ FREE_VARDECL(psCurrVDecl);
+
+ /* return the variable type */
+ /* $$ = psCurrVDecl; */ /* not needed? */
+
+ if(psCurEvent == NULL)
+ debug(LOG_ERROR, "argument_decl_head 0: - psCurEvent == NULL");
+ psCurEvent->numParams = psCurEvent->numParams + 1; /* remember a parameter was declared */
+
+ //debug(LOG_SCRIPT, "argument_decl_head 1. ");
+ }
+ break;
+
+ case 63:
+
+/* Line 1806 of yacc.c */
+#line 2629 "script_parser.ypp"
+ {
+ /* remember that local var declaration is over */
+ localVariableDef = false;
+ //debug(LOG_SCRIPT, "localVariableDef = false 1");
+ }
+ break;
+
+ case 64:
+
+/* Line 1806 of yacc.c */
+#line 2637 "script_parser.ypp"
+ {
+ RULE( "function_declaration: func_subdecl '(' argument_decl_head ')'");
+
+ /* remember that local var declaration is over */
+ localVariableDef = false;
+ //debug(LOG_SCRIPT, "localVariableDef = false 2");
+
+ if(psCurEvent->bDeclared) /* can only occur if different (new) var names are used in the event definition that don't match with declaration*/
+ {
+ scr_error("Wrong event definition: \nEvent %s's definition doesn't match with declaration", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ (yyval.eSymbol) = (yyvsp[(1) - (4)].eSymbol);
+ }
+ break;
+
+ case 65:
+
+/* Line 1806 of yacc.c */
+#line 2653 "script_parser.ypp"
+ {
+ RULE( "function_declaration: func_subdecl '(' ')'");
+
+ /* remember that local var declaration is over */
+ localVariableDef = false;
+ //debug(LOG_SCRIPT, "localVariableDef = false 3");
+
+ if((yyvsp[(1) - (3)].eSymbol)->numParams > 0 && psCurEvent->bDeclared) /* can only occur if no parameters or different (new) var names are used in the event definition that don't match with declaration */
+ {
+ scr_error("Wrong event definition: \nEvent %s's definition doesn't match with declaration", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ (yyval.eSymbol) = (yyvsp[(1) - (3)].eSymbol);
+ }
+ break;
+
+ case 66:
+
+/* Line 1806 of yacc.c */
+#line 2674 "script_parser.ypp"
+ {
+ /* remember that local var declaration is over */
+ localVariableDef = false;
+ //debug(LOG_SCRIPT, "localVariableDef = false 2");
+
+ if(psCurEvent->bDeclared) /* can only occur if different (new) var names are used in the event definition that don't match with declaration*/
+ {
+ scr_error("Wrong event definition: \nEvent %s's definition doesn't match with declaration", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ (yyval.eSymbol) = (yyvsp[(1) - (4)].eSymbol);
+ }
+ break;
+
+ case 67:
+
+/* Line 1806 of yacc.c */
+#line 2688 "script_parser.ypp"
+ {
+
+ RULE( "void_function_declaration: void_func_subdecl '(' ')'");
+
+ /* remember that local var declaration is over */
+ localVariableDef = false;
+ //debug(LOG_SCRIPT, "localVariableDef = false 3");
+
+ if((yyvsp[(1) - (3)].eSymbol)->numParams > 0 && psCurEvent->bDeclared) /* can only occur if no parameters or different (new) var names are used in the event definition that don't match with declaration */
+ {
+ scr_error("Wrong event definition: \nEvent %s's definition doesn't match with declaration", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ (yyval.eSymbol) = (yyvsp[(1) - (3)].eSymbol);
+ }
+ break;
+
+ case 69:
+
+/* Line 1806 of yacc.c */
+#line 2712 "script_parser.ypp"
+ {
+
+ RULE( "return_statement: return_statement_void");
+
+ if(psCurEvent == NULL) /* no events declared or defined yet */
+ {
+ scr_error("return statement outside of function");
+ YYABORT;
+ }
+
+ if(!psCurEvent->bFunction)
+ {
+ scr_error("return statement inside of an event '%s'", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ if(psCurEvent->retType != VAL_VOID)
+ {
+ scr_error("wrong return statement syntax for a non-void function '%s'", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ /* Allocate code block for exit instruction */
+ ALLOC_BLOCK(psCurrBlock, 1); //1 for opcode
+ ip = psCurrBlock->pCode;
+ PUT_OPCODE(ip, OP_EXIT);
+
+ psCurrBlock->type = VAL_VOID; /* make return statement of type VOID manually */
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 70:
+
+/* Line 1806 of yacc.c */
+#line 2744 "script_parser.ypp"
+ {
+
+ RULE( "return_statement: RET return_exp ';'");
+
+ if(psCurEvent == NULL) /* no events declared or defined yet */
+ {
+ debug(LOG_ERROR, "return statement outside of function");
+ YYABORT;
+ }
+
+ if(!psCurEvent->bFunction)
+ {
+ debug(LOG_ERROR, "return statement inside of an event '%s'", psCurEvent->pIdent);
+ YYABORT;
+ }
+
+ if(psCurEvent->retType != (yyvsp[(2) - (3)].cblock)->type)
+ {
+ if(!interpCheckEquiv(psCurEvent->retType, (yyvsp[(2) - (3)].cblock)->type))
+ {
+ debug(LOG_ERROR, "return type mismatch");
+ debug(LOG_ERROR, "wrong return statement syntax for function '%s' (%d - %d)", psCurEvent->pIdent, psCurEvent->retType, (yyvsp[(2) - (3)].cblock)->type);
+ YYABORT;
+ }
+ }
+
+ /* Allocate code block for exit instruction */
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(2) - (3)].cblock)->size + 1); //+1 for OPCODE
+
+ ip = psCurrBlock->pCode;
+
+ PUT_BLOCK(ip, (yyvsp[(2) - (3)].cblock));
+
+ PUT_OPCODE(ip, OP_EXIT);
+
+ /* store the type of the exp */
+ psCurrBlock->type = (yyvsp[(2) - (3)].cblock)->type;
+
+ FREE_BLOCK((yyvsp[(2) - (3)].cblock));
+
+ (yyval.cblock) = psCurrBlock;
+
+ //debug(LOG_SCRIPT, "END RET return_exp ';'");
+ }
+ break;
+
+ case 71:
+
+/* Line 1806 of yacc.c */
+#line 2792 "script_parser.ypp"
+ {
+ RULE( "statement_list: NULL");
+
+ // Allocate a dummy code block
+ ALLOC_BLOCK(psCurrBlock, 1);
+ psCurrBlock->size = 0;
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 72:
+
+/* Line 1806 of yacc.c */
+#line 2802 "script_parser.ypp"
+ {
+ RULE("statement_list: statement");
+ (yyval.cblock) = (yyvsp[(1) - (1)].cblock);
+ }
+ break;
+
+ case 73:
+
+/* Line 1806 of yacc.c */
+#line 2807 "script_parser.ypp"
+ {
+ RULE("statement_list: statement_list statement");
+
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(1) - (2)].cblock)->size + (yyvsp[(2) - (2)].cblock)->size);
+
+ ALLOC_DEBUG(psCurrBlock, (yyvsp[(1) - (2)].cblock)->debugEntries +
+ (yyvsp[(2) - (2)].cblock)->debugEntries);
+ ip = psCurrBlock->pCode;
+
+ /* Copy the two code blocks */
+ PUT_BLOCK(ip, (yyvsp[(1) - (2)].cblock));
+ PUT_BLOCK(ip, (yyvsp[(2) - (2)].cblock));
+ PUT_DEBUG(psCurrBlock, (yyvsp[(1) - (2)].cblock));
+ APPEND_DEBUG(psCurrBlock, (yyvsp[(1) - (2)].cblock)->size / sizeof(INTERP_VAL), (yyvsp[(2) - (2)].cblock));
+
+ ASSERT((yyvsp[(1) - (2)].cblock) != NULL, "$1 == NULL");
+ ASSERT((yyvsp[(1) - (2)].cblock)->psDebug != NULL, "psDebug == NULL");
+
+ FREE_DEBUG((yyvsp[(1) - (2)].cblock));
+ FREE_DEBUG((yyvsp[(2) - (2)].cblock));
+ FREE_BLOCK((yyvsp[(1) - (2)].cblock));
+ FREE_BLOCK((yyvsp[(2) - (2)].cblock));
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 74:
+
+/* Line 1806 of yacc.c */
+#line 2837 "script_parser.ypp"
+ {
+ RULE( "event_decl: event_subdecl ';'");
+
+ psCurEvent->bDeclared = true;
+ }
+ break;
+
+ case 75:
+
+/* Line 1806 of yacc.c */
+#line 2843 "script_parser.ypp"
+ {
+ //debug(LOG_SCRIPT, "localVariableDef = false new ");
+ localVariableDef = false;
+ psCurEvent->bDeclared = true;
+ }
+ break;
+
+ case 76:
+
+/* Line 1806 of yacc.c */
+#line 2849 "script_parser.ypp"
+ {
+ RULE( "event_decl: void_func_subdecl argument_decl ';'");
+
+ //debug(LOG_SCRIPT, "localVariableDef = false new ");
+ localVariableDef = false;
+ psCurEvent->bDeclared = true;
+ }
+ break;
+
+ case 77:
+
+/* Line 1806 of yacc.c */
+#line 2857 "script_parser.ypp"
+ {
+ RULE( "event_decl: event_subdecl '(' TRIG_SYM ')'");
+
+ /* make sure this event is not declared as function */
+ if(psCurEvent->bFunction)
+ {
+ debug(LOG_ERROR, "Event '%s' is declared as function and can't have a trigger assigned", psCurEvent->pIdent);
+ scr_error("Wrong event definition");
+ YYABORT;
+ }
+
+ /* pop required number of paramerets passed to this event (if any) */
+ /* popArguments($1, $7, &psCurrBlock); */
+
+ /* if (!scriptDefineEvent($1, $6, $3->index)) */
+ if (!scriptDefineEvent((yyvsp[(1) - (8)].eSymbol), (yyvsp[(7) - (8)].cblock), (yyvsp[(3) - (8)].tSymbol)->index))
+ {
+ YYABORT;
+ }
+
+ /* end of event */
+ psCurEvent = NULL;
+
+ FREE_DEBUG((yyvsp[(7) - (8)].cblock));
+ FREE_BLOCK((yyvsp[(7) - (8)].cblock));
+
+ RULE( "END event_decl: event_subdecl '(' TRIG_SYM ')'");
+
+ }
+ break;
+
+ case 78:
+
+/* Line 1806 of yacc.c */
+#line 2887 "script_parser.ypp"
+ {
+ // Get the line for the implicit trigger declaration
+ char *pDummy;
+
+ RULE( "event_decl:event_subdecl '(' trigger_subdecl ')' ");
+
+ /* make sure this event is not declared as function */
+ if(psCurEvent->bFunction)
+ {
+ debug(LOG_ERROR, "Event '%s' is declared as function and can't have a trigger assigned", psCurEvent->pIdent);
+ scr_error("Wrong event definition");
+ YYABORT;
+ }
+
+ scriptGetErrorData((SDWORD *)&debugLine, &pDummy);
+ }
+ break;
+
+ case 79:
+
+/* Line 1806 of yacc.c */
+#line 2904 "script_parser.ypp"
+ {
+ RULE("event_decl: '{' var_list statement_list '}'");
+
+ // Create a trigger for this event
+ if (!scriptAddTrigger("", (yyvsp[(3) - (9)].tdecl), debugLine))
+ {
+ YYABORT;
+ }
+ FREE_TSUBDECL((yyvsp[(3) - (9)].tdecl));
+
+ /* if (!scriptDefineEvent($1, $7, numTriggers - 1)) */
+ if (!scriptDefineEvent((yyvsp[(1) - (9)].eSymbol), (yyvsp[(8) - (9)].cblock), numTriggers - 1))
+ {
+ YYABORT;
+ }
+
+ /* end of event */
+ psCurEvent = NULL;
+
+ FREE_DEBUG((yyvsp[(8) - (9)].cblock));
+ FREE_BLOCK((yyvsp[(8) - (9)].cblock));
+
+ RULE( "END event_decl:event_subdecl '(' trigger_subdecl ')' .");
+ }
+ break;
+
+ case 80:
+
+/* Line 1806 of yacc.c */
+#line 2931 "script_parser.ypp"
+ {
+ RULE( "event_subdecl '(' INACTIVE ')' '{' var_list statement_list '}'");
+
+ /* make sure this event is not declared as function */
+ if(psCurEvent->bFunction)
+ {
+ debug(LOG_ERROR, "Event '%s' is declared as function and can't have a trigger assigned", psCurEvent->pIdent);
+ scr_error("Wrong event definition");
+ YYABORT;
+ }
+
+ if (!scriptDefineEvent((yyvsp[(1) - (8)].eSymbol), (yyvsp[(7) - (8)].cblock), -1))
+ {
+ YYABORT;
+ }
+
+ /* end of event */
+ psCurEvent = NULL;
+
+ FREE_DEBUG((yyvsp[(7) - (8)].cblock));
+ FREE_BLOCK((yyvsp[(7) - (8)].cblock));
+
+ RULE( "END event_subdecl '(' INACTIVE ')' '{' var_list statement_list '}'");
+ }
+ break;
+
+ case 81:
+
+/* Line 1806 of yacc.c */
+#line 2958 "script_parser.ypp"
+ {
+ RULE( "void_function_declaration '{' var_list statement_list '}'");
+
+ /* stays the same if no params (just gets copied) */
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(4) - (5)].cblock)->size + 1 + (yyvsp[(1) - (5)].eSymbol)->numParams); /* statement_list + opcode + numParams */
+ ip = psCurrBlock->pCode;
+
+ /* pop required number of paramerets passed to this event (if any) */
+ popArguments(&ip, (yyvsp[(1) - (5)].eSymbol)->numParams);
+
+ /* Copy the two code blocks */
+ PUT_BLOCK(ip, (yyvsp[(4) - (5)].cblock));
+ PUT_OPCODE(ip, OP_EXIT); /* must exit after return */
+
+ ALLOC_DEBUG(psCurrBlock, (yyvsp[(4) - (5)].cblock)->debugEntries);
+ PUT_DEBUG(psCurrBlock, (yyvsp[(4) - (5)].cblock));
+
+ if (!scriptDefineEvent((yyvsp[(1) - (5)].eSymbol), psCurrBlock, -1))
+ {
+ YYABORT;
+ }
+
+ FREE_DEBUG((yyvsp[(4) - (5)].cblock));
+ FREE_BLOCK((yyvsp[(4) - (5)].cblock));
+
+ /* end of event */
+ psCurEvent = NULL;
+
+ /* free block since code was copied in scriptDefineEvent() */
+ FREE_DEBUG(psCurrBlock);
+ FREE_BLOCK(psCurrBlock);
+
+ RULE( "END void_function_declaration '{' var_list statement_list '}'");
+ }
+ break;
+
+ case 82:
+
+/* Line 1806 of yacc.c */
+#line 2995 "script_parser.ypp"
+ {
+
+ RULE( "void_funcbody_var_def '{' var_list statement_list '}'");
+
+ /* stays the same if no params (just gets copied) */
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(4) - (5)].cblock)->size + 1 + (yyvsp[(1) - (5)].eSymbol)->numParams); /* statements + opcode + numparams */
+ ip = psCurrBlock->pCode;
+
+ /* pop required number of paramerets passed to this event (if any) */
+ popArguments(&ip, (yyvsp[(1) - (5)].eSymbol)->numParams);
+
+ /* Copy the old (main) code and free it */
+ PUT_BLOCK(ip, (yyvsp[(4) - (5)].cblock));
+ PUT_OPCODE(ip, OP_EXIT); /* must exit after return */
+
+ /* copy debug info */
+ ALLOC_DEBUG(psCurrBlock, (yyvsp[(4) - (5)].cblock)->debugEntries);
+ PUT_DEBUG(psCurrBlock, (yyvsp[(4) - (5)].cblock));
+
+ if (!scriptDefineEvent((yyvsp[(1) - (5)].eSymbol), psCurrBlock, -1))
+ {
+ YYABORT;
+ }
+
+ FREE_DEBUG((yyvsp[(4) - (5)].cblock));
+ FREE_BLOCK((yyvsp[(4) - (5)].cblock));
+ FREE_DEBUG(psCurrBlock);
+ FREE_BLOCK(psCurrBlock);
+
+ /* end of event */
+ psCurEvent = NULL;
+
+ RULE( "END void_func_subdecl '(' funcbody_var_def_body ')' '{' var_list statement_list '}'");
+ }
+ break;
+
+ case 83:
+
+/* Line 1806 of yacc.c */
+#line 3032 "script_parser.ypp"
+ {
+ RULE( "function_declaration '{' var_list statement_list return_statement '}'");
+
+ /* stays the same if no params (just gets copied) */
+ //ALLOC_BLOCK(psCurrBlock, $4->size + $5->size + sizeof(OPCODE) + (sizeof(OPCODE) * $1->numParams)); /* statement_list + expression + EXIT + numParams */
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(4) - (6)].cblock)->size + (yyvsp[(5) - (6)].cblock)->size + 1 + (yyvsp[(1) - (6)].eSymbol)->numParams); /* statement_list + return_expr + EXIT opcode + numParams */
+ ip = psCurrBlock->pCode;
+
+ /* pop required number of paramerets passed to this event (if any) */
+ popArguments(&ip, (yyvsp[(1) - (6)].eSymbol)->numParams);
+
+ /* Copy the two code blocks */
+ PUT_BLOCK(ip, (yyvsp[(4) - (6)].cblock));
+
+ PUT_BLOCK(ip, (yyvsp[(5) - (6)].cblock));
+
+ PUT_OPCODE(ip, OP_EXIT); /* must exit after return */
+
+ ALLOC_DEBUG(psCurrBlock, (yyvsp[(4) - (6)].cblock)->debugEntries);
+
+ PUT_DEBUG(psCurrBlock, (yyvsp[(4) - (6)].cblock));
+
+ if (!scriptDefineEvent((yyvsp[(1) - (6)].eSymbol), psCurrBlock, -1))
+ {
+ YYABORT;
+ }
+
+ FREE_DEBUG((yyvsp[(4) - (6)].cblock));
+ FREE_BLOCK((yyvsp[(4) - (6)].cblock));
+ FREE_BLOCK((yyvsp[(5) - (6)].cblock));
+
+ /* end of event */
+ psCurEvent = NULL;
+
+ /* free block since code was copied in scriptDefineEvent() */
+ FREE_DEBUG(psCurrBlock);
+ FREE_BLOCK(psCurrBlock);
+
+ RULE( "END function_declaration '{' var_list statement_list return_statement '}'");
+ }
+ break;
+
+ case 84:
+
+/* Line 1806 of yacc.c */
+#line 3075 "script_parser.ypp"
+ {
+ RULE( "func_subdecl '(' funcbody_var_def_body ')' '{' var_list statement_list return_statement '}'");
+
+ /* stays the same if no params (just gets copied) */
+ //ALLOC_BLOCK(psCurrBlock, $4->size + $5->size + sizeof(OPCODE) + (sizeof(OPCODE) * $1->numParams));
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(4) - (6)].cblock)->size + (yyvsp[(5) - (6)].cblock)->size + 1 + (yyvsp[(1) - (6)].eSymbol)->numParams); /* statements + return expr + opcode + numParams */
+ ip = psCurrBlock->pCode;
+
+ /* pop required number of paramerets passed to this event (if any) */
+ popArguments(&ip, (yyvsp[(1) - (6)].eSymbol)->numParams);
+
+ /* Copy the old (main) code and free it */
+ PUT_BLOCK(ip, (yyvsp[(4) - (6)].cblock));
+ PUT_BLOCK(ip, (yyvsp[(5) - (6)].cblock));
+ PUT_OPCODE(ip, OP_EXIT); /* must exit after return */
+
+ /* copy debug info */
+ ALLOC_DEBUG(psCurrBlock, (yyvsp[(4) - (6)].cblock)->debugEntries);
+ PUT_DEBUG(psCurrBlock, (yyvsp[(4) - (6)].cblock));
+
+ RULE( "debug entries %d", (yyvsp[(4) - (6)].cblock)->debugEntries);
+
+ if (!scriptDefineEvent((yyvsp[(1) - (6)].eSymbol), psCurrBlock, -1))
+ {
+ YYABORT;
+ }
+
+ FREE_DEBUG((yyvsp[(4) - (6)].cblock));
+ FREE_BLOCK((yyvsp[(4) - (6)].cblock));
+ FREE_BLOCK((yyvsp[(5) - (6)].cblock));
+ FREE_DEBUG(psCurrBlock);
+ FREE_BLOCK(psCurrBlock);
+
+ /* end of event */
+ psCurEvent = NULL;
+
+ RULE( "END func_subdecl '(' funcbody_var_def_body ')' '{' var_list statement_list return_statement '}'");
+ }
+ break;
+
+ case 85:
+
+/* Line 1806 of yacc.c */
+#line 3116 "script_parser.ypp"
+ {
+ RULE( "funcbody_var_def '{' var_list return_statement '}'");
+
+ /* stays the same if no params (just gets copied) */
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(4) - (5)].cblock)->size + 1 + (yyvsp[(1) - (5)].eSymbol)->numParams); /* return expr + opcode + numParams */
+ ip = psCurrBlock->pCode;
+
+ /* pop required number of paramerets passed to this event (if any) */
+ popArguments(&ip, (yyvsp[(1) - (5)].eSymbol)->numParams);
+
+ /* Copy the old (main) code and free it */
+ PUT_BLOCK(ip, (yyvsp[(4) - (5)].cblock));
+ PUT_OPCODE(ip, OP_EXIT); /* must exit after return */
+
+ if (!scriptDefineEvent((yyvsp[(1) - (5)].eSymbol), psCurrBlock, -1))
+ {
+ YYABORT;
+ }
+
+ FREE_BLOCK((yyvsp[(4) - (5)].cblock));
+ FREE_BLOCK(psCurrBlock);
+ psCurEvent = NULL;
+
+ RULE( "END funcbody_var_def '{' var_list return_statement '}'");
+ }
+ break;
+
+ case 86:
+
+/* Line 1806 of yacc.c */
+#line 3143 "script_parser.ypp"
+ {
+ RULE( "function_declaration '{' var_list statement_list return_statement '}'");
+
+ /* stays the same if no params (just gets copied) */
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(4) - (5)].cblock)->size + 1 + (yyvsp[(1) - (5)].eSymbol)->numParams); /* return_expr + EXIT opcode + numParams */
+ ip = psCurrBlock->pCode;
+
+ /* pop required number of paramerets passed to this event (if any) */
+ popArguments(&ip, (yyvsp[(1) - (5)].eSymbol)->numParams);
+
+ /* Copy code block */
+ PUT_BLOCK(ip, (yyvsp[(4) - (5)].cblock));
+ PUT_OPCODE(ip, OP_EXIT); /* must exit after return */
+
+ if (!scriptDefineEvent((yyvsp[(1) - (5)].eSymbol), psCurrBlock, -1))
+ {
+ YYABORT;
+ }
+
+ FREE_BLOCK((yyvsp[(4) - (5)].cblock));
+ psCurEvent = NULL;
+ FREE_BLOCK(psCurrBlock);
+
+ RULE( "END function_declaration '{' var_list statement_list return_statement '}'");
+ }
+ break;
+
+ case 87:
+
+/* Line 1806 of yacc.c */
+#line 3176 "script_parser.ypp"
+ {
+ UDWORD line;
+ char *pDummy;
+
+ RULE("statement: assignment");
+
+ /* Put in debugging info */
+ if (genDebugInfo)
+ {
+ ALLOC_DEBUG((yyvsp[(1) - (2)].cblock), 1);
+ (yyvsp[(1) - (2)].cblock)->psDebug[0].offset = 0;
+ scriptGetErrorData((SDWORD *)&line, &pDummy);
+ (yyvsp[(1) - (2)].cblock)->psDebug[0].line = line;
+ }
+
+ (yyval.cblock) = (yyvsp[(1) - (2)].cblock);
+ }
+ break;
+
+ case 88:
+
+/* Line 1806 of yacc.c */
+#line 3194 "script_parser.ypp"
+ {
+ UDWORD line;
+ char *pDummy;
+
+ RULE("statement: inc_dec_exp");
+
+ /* Put in debugging info */
+ if (genDebugInfo)
+ {
+ ALLOC_DEBUG((yyvsp[(1) - (2)].cblock), 1);
+ (yyvsp[(1) - (2)].cblock)->psDebug[0].offset = 0;
+ scriptGetErrorData((SDWORD *)&line, &pDummy);
+ (yyvsp[(1) - (2)].cblock)->psDebug[0].line = line;
+ }
+
+ (yyval.cblock) = (yyvsp[(1) - (2)].cblock);
+ }
+ break;
+
+ case 89:
+
+/* Line 1806 of yacc.c */
+#line 3212 "script_parser.ypp"
+ {
+ UDWORD line;
+ char *pDummy;
+
+ RULE("statement: func_call ';'");
+
+ /* Put in debugging info */
+ if (genDebugInfo)
+ {
+ ALLOC_DEBUG((yyvsp[(1) - (2)].cblock), 1);
+ (yyvsp[(1) - (2)].cblock)->psDebug[0].offset = 0;
+ scriptGetErrorData((SDWORD *)&line, &pDummy);
+ (yyvsp[(1) - (2)].cblock)->psDebug[0].line = line;
+ }
+
+ (yyval.cblock) = (yyvsp[(1) - (2)].cblock);
+ }
+ break;
+
+ case 90:
+
+/* Line 1806 of yacc.c */
+#line 3230 "script_parser.ypp"
+ {
+ UDWORD line,paramNumber;
+ char *pDummy;
+
+ RULE( "statement: VOID_FUNC_CUST '(' param_list ')' ';'");
+
+ /* allow to call EVENTs to reuse the code only if no actual parameters are specified in function call, like "myEvent();" */
+ if(!(yyvsp[(1) - (5)].eSymbol)->bFunction && (yyvsp[(3) - (5)].pblock)->numParams > 0)
+ {
+ scr_error("Can't pass any parameters in an event call:\nEvent: '%s'", (yyvsp[(1) - (5)].eSymbol)->pIdent);
+ return CE_PARSE;
+ }
+
+ if((yyvsp[(3) - (5)].pblock)->numParams != (yyvsp[(1) - (5)].eSymbol)->numParams)
+ {
+ scr_error("Wrong number of arguments for function call: '%s'. Expected %d parameters instead of %d.", (yyvsp[(1) - (5)].eSymbol)->pIdent, (yyvsp[(1) - (5)].eSymbol)->numParams, (yyvsp[(3) - (5)].pblock)->numParams);
+ return CE_PARSE;
+ }
+
+ /* check if right parameters were passed */
+ paramNumber = checkFuncParamTypes((yyvsp[(1) - (5)].eSymbol), (yyvsp[(3) - (5)].pblock));
+ if(paramNumber > 0)
+ {
+ debug(LOG_ERROR, "Parameter mismatch in function call: '%s'. Mismatch in parameter %d.", (yyvsp[(1) - (5)].eSymbol)->pIdent, paramNumber);
+ YYABORT;
+ }
+
+ /* Allocate the code block */
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(3) - (5)].pblock)->size + 1 + 1); //paramList + opcode + event index
+ ALLOC_DEBUG(psCurrBlock, 1);
+ ip = psCurrBlock->pCode;
+
+ if((yyvsp[(3) - (5)].pblock)->numParams > 0) /* if any parameters declared */
+ {
+ /* Copy in the code for the parameters */
+ PUT_BLOCK(ip, (yyvsp[(3) - (5)].pblock));
+ }
+
+ FREE_PBLOCK((yyvsp[(3) - (5)].pblock));
+
+ /* Store the instruction */
+ PUT_OPCODE(ip, OP_FUNC);
+ PUT_EVENT(ip,(yyvsp[(1) - (5)].eSymbol)->index); //Put event index
+
+ /* Add the debugging information */
+ if (genDebugInfo)
+ {
+ psCurrBlock->psDebug[0].offset = 0;
+ scriptGetErrorData((SDWORD *)&line, &pDummy);
+ psCurrBlock->psDebug[0].line = line;
+ }
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 91:
+
+/* Line 1806 of yacc.c */
+#line 3285 "script_parser.ypp"
+ {
+ UDWORD line;
+ char *pDummy;
+
+ RULE( "statement: EVENT_SYM '(' param_list ')' ';'");
+
+ /* allow to call EVENTs to reuse the code only if no actual parameters are specified in function call, like "myEvent();" */
+ if(!(yyvsp[(1) - (5)].eSymbol)->bFunction && (yyvsp[(3) - (5)].pblock)->numParams > 0)
+ {
+ scr_error("Can't pass any parameters in an event call:\nEvent: '%s'", (yyvsp[(1) - (5)].eSymbol)->pIdent);
+ return CE_PARSE;
+ }
+
+ if((yyvsp[(3) - (5)].pblock)->numParams != (yyvsp[(1) - (5)].eSymbol)->numParams)
+ {
+ scr_error("Wrong number of arguments for function call: '%s'. Expected %d parameters instead of %d.", (yyvsp[(1) - (5)].eSymbol)->pIdent, (yyvsp[(1) - (5)].eSymbol)->numParams, (yyvsp[(3) - (5)].pblock)->numParams);
+ return CE_PARSE;
+ }
+
+ /* Allocate the code block */
+ //ALLOC_BLOCK(psCurrBlock, $3->size + sizeof(OPCODE) + sizeof(UDWORD)); //Params + Opcode + event index
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(3) - (5)].pblock)->size + 1 + 1); //Params + Opcode + event index
+ ALLOC_DEBUG(psCurrBlock, 1);
+ ip = psCurrBlock->pCode;
+
+ if((yyvsp[(3) - (5)].pblock)->numParams > 0) /* if any parameters declared */
+ {
+ /* Copy in the code for the parameters */
+ PUT_BLOCK(ip, (yyvsp[(3) - (5)].pblock));
+ }
+
+ FREE_PBLOCK((yyvsp[(3) - (5)].pblock));
+
+ /* Store the instruction */
+ PUT_OPCODE(ip, OP_FUNC);
+ PUT_EVENT(ip,(yyvsp[(1) - (5)].eSymbol)->index); //Put event index as VAL_EVENT
+
+ /* Add the debugging information */
+ if (genDebugInfo)
+ {
+ psCurrBlock->psDebug[0].offset = 0;
+ scriptGetErrorData((SDWORD *)&line, &pDummy);
+ psCurrBlock->psDebug[0].line = line;
+ }
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 92:
+
+/* Line 1806 of yacc.c */
+#line 3333 "script_parser.ypp"
+ {
+ (yyval.cblock) = (yyvsp[(1) - (1)].cblock);
+ }
+ break;
+
+ case 93:
+
+/* Line 1806 of yacc.c */
+#line 3337 "script_parser.ypp"
+ {
+ (yyval.cblock) = (yyvsp[(1) - (1)].cblock);
+ }
+ break;
+
+ case 94:
+
+/* Line 1806 of yacc.c */
+#line 3341 "script_parser.ypp"
+ {
+ UDWORD line;
+ char *pDummy;
+
+ /* Allocate the code block */
+ ALLOC_BLOCK(psCurrBlock, 1); //1 - Exit opcode
+ ALLOC_DEBUG(psCurrBlock, 1);
+ ip = psCurrBlock->pCode;
+
+ /* Store the instruction */
+ PUT_OPCODE(ip, OP_EXIT);
+
+ /* Add the debugging information */
+ if (genDebugInfo)
+ {
+ psCurrBlock->psDebug[0].offset = 0;
+ scriptGetErrorData((SDWORD *)&line, &pDummy);
+ psCurrBlock->psDebug[0].line = line;
+ }
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 95:
+
+/* Line 1806 of yacc.c */
+#line 3364 "script_parser.ypp"
+ {
+ UDWORD line;
+ char *pDummy;
+
+ RULE( "statement: return_statement");
+
+ if(psCurEvent == NULL)
+ {
+ scr_error("'return' outside of function body");
+ YYABORT;
+ }
+
+ if(!psCurEvent->bFunction)
+ {
+ debug(LOG_ERROR, "'return' can only be used in functions, not in events, event: '%s'", psCurEvent->pIdent);
+ scr_error("'return' in event");
+ YYABORT;
+ }
+
+ if((yyvsp[(1) - (1)].cblock)->type != psCurEvent->retType)
+ {
+ debug(LOG_ERROR, "'return' type doesn't match with function return type, function: '%s' (%d / %d)", psCurEvent->pIdent, (yyvsp[(1) - (1)].cblock)->type, psCurEvent->retType);
+ scr_error("'return' type mismatch 0");
+ YYABORT;
+ }
+
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(1) - (1)].cblock)->size + 1); //return statement + EXIT opcode
+ ALLOC_DEBUG(psCurrBlock, 1);
+ ip = psCurrBlock->pCode;
+
+ PUT_BLOCK(ip, (yyvsp[(1) - (1)].cblock));
+ PUT_OPCODE(ip, OP_EXIT);
+
+ FREE_BLOCK((yyvsp[(1) - (1)].cblock));
+
+ if (genDebugInfo)
+ {
+ psCurrBlock->psDebug[0].offset = 0;
+ scriptGetErrorData((SDWORD *)&line, &pDummy);
+ psCurrBlock->psDebug[0].line = line;
+ }
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 96:
+
+/* Line 1806 of yacc.c */
+#line 3409 "script_parser.ypp"
+ {
+ UDWORD line;
+ char *pDummy;
+
+ // can only have a positive pause
+ if ((yyvsp[(3) - (5)].ival) < 0)
+ {
+ scr_error("Invalid pause time");
+ YYABORT;
+ }
+
+ /* Allocate the code block */
+ ALLOC_BLOCK(psCurrBlock, 1); //1 - for OP_PAUSE
+ ALLOC_DEBUG(psCurrBlock, 1);
+ ip = psCurrBlock->pCode;
+
+ /* Store the instruction */
+ PUT_PKOPCODE(ip, OP_PAUSE, (yyvsp[(3) - (5)].ival));
+
+ /* Add the debugging information */
+ if (genDebugInfo)
+ {
+ psCurrBlock->psDebug[0].offset = 0;
+ scriptGetErrorData((SDWORD *)&line, &pDummy);
+ psCurrBlock->psDebug[0].line = line;
+ }
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 97:
+
+/* Line 1806 of yacc.c */
+#line 3442 "script_parser.ypp"
+ {
+ RULE("return_exp: expression");
+
+ /* Just pass the code up the tree */
+ (yyvsp[(1) - (1)].cblock)->type = VAL_INT;
+ (yyval.cblock) = (yyvsp[(1) - (1)].cblock);
+ }
+ break;
+
+ case 98:
+
+/* Line 1806 of yacc.c */
+#line 3450 "script_parser.ypp"
+ {
+ RULE("return_exp: floatexp");
+
+ /* Just pass the code up the tree */
+ (yyvsp[(1) - (1)].cblock)->type = VAL_FLOAT;
+ (yyval.cblock) = (yyvsp[(1) - (1)].cblock);
+ }
+ break;
+
+ case 99:
+
+/* Line 1806 of yacc.c */
+#line 3458 "script_parser.ypp"
+ {
+ RULE( "return_exp: stringexp");
+
+ /* Just pass the code up the tree */
+ (yyvsp[(1) - (1)].cblock)->type = VAL_STRING;
+ (yyval.cblock) = (yyvsp[(1) - (1)].cblock);
+ }
+ break;
+
+ case 100:
+
+/* Line 1806 of yacc.c */
+#line 3466 "script_parser.ypp"
+ {
+ RULE( "return_exp: boolexp");
+
+ /* Just pass the code up the tree */
+ (yyvsp[(1) - (1)].cblock)->type = VAL_BOOL;
+ (yyval.cblock) = (yyvsp[(1) - (1)].cblock);
+ }
+ break;
+
+ case 101:
+
+/* Line 1806 of yacc.c */
+#line 3474 "script_parser.ypp"
+ {
+ RULE( "return_exp: objexp");
+
+ /* Just pass the code up the tree */
+ /* $1->type = */
+ (yyval.cblock) = (yyvsp[(1) - (1)].cblock);
+ }
+ break;
+
+ case 102:
+
+/* Line 1806 of yacc.c */
+#line 3482 "script_parser.ypp"
+ {
+ RULE( "return_exp: userexp");
+
+ /* Just pass the code up the tree */
+ /* $1->type = */
+ (yyval.cblock) = (yyvsp[(1) - (1)].cblock);
+ }
+ break;
+
+ case 103:
+
+/* Line 1806 of yacc.c */
+#line 3496 "script_parser.ypp"
+ {
+ RULE( "assignment: NUM_VAR '=' expression");
+
+ codeRet = scriptCodeAssignment((yyvsp[(1) - (3)].vSymbol), (yyvsp[(3) - (3)].cblock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 104:
+
+/* Line 1806 of yacc.c */
+#line 3506 "script_parser.ypp"
+ {
+ RULE( "assignment: BOOL_VAR '=' boolexp");
+
+ codeRet = scriptCodeAssignment((yyvsp[(1) - (3)].vSymbol), (yyvsp[(3) - (3)].cblock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 105:
+
+/* Line 1806 of yacc.c */
+#line 3516 "script_parser.ypp"
+ {
+ RULE( "assignment: FLOAT_VAR '=' floatexp");
+
+ codeRet = scriptCodeAssignment((yyvsp[(1) - (3)].vSymbol), (yyvsp[(3) - (3)].cblock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 106:
+
+/* Line 1806 of yacc.c */
+#line 3526 "script_parser.ypp"
+ {
+ RULE("assignment: STRING_VAR '=' stringexp");
+
+ codeRet = scriptCodeAssignment((yyvsp[(1) - (3)].vSymbol), (yyvsp[(3) - (3)].cblock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 107:
+
+/* Line 1806 of yacc.c */
+#line 3536 "script_parser.ypp"
+ {
+ RULE("assignment: OBJ_VAR '=' objexp");
+
+ if (!interpCheckEquiv((yyvsp[(1) - (3)].vSymbol)->type, (yyvsp[(3) - (3)].cblock)->type))
+ {
+ scr_error("User type mismatch for assignment (%d - %d) 4", (yyvsp[(1) - (3)].vSymbol)->type, (yyvsp[(3) - (3)].cblock)->type);
+ YYABORT;
+ }
+ codeRet = scriptCodeAssignment((yyvsp[(1) - (3)].vSymbol), (yyvsp[(3) - (3)].cblock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 108:
+
+/* Line 1806 of yacc.c */
+#line 3551 "script_parser.ypp"
+ {
+ RULE( "assignment: VAR '=' userexp");
+
+ if (!interpCheckEquiv((yyvsp[(1) - (3)].vSymbol)->type, (yyvsp[(3) - (3)].cblock)->type))
+ {
+ scr_error("User type mismatch for assignment (%d - %d) 3", (yyvsp[(1) - (3)].vSymbol)->type, (yyvsp[(3) - (3)].cblock)->type);
+ YYABORT;
+ }
+ codeRet = scriptCodeAssignment((yyvsp[(1) - (3)].vSymbol), (CODE_BLOCK *)(yyvsp[(3) - (3)].cblock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 109:
+
+/* Line 1806 of yacc.c */
+#line 3566 "script_parser.ypp"
+ {
+ RULE( "assignment: num_objvar '=' expression");
+
+ codeRet = scriptCodeObjAssignment((yyvsp[(1) - (3)].objVarBlock), (yyvsp[(3) - (3)].cblock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 110:
+
+/* Line 1806 of yacc.c */
+#line 3576 "script_parser.ypp"
+ {
+ RULE( "assignment: bool_objvar '=' boolexp");
+
+ codeRet = scriptCodeObjAssignment((yyvsp[(1) - (3)].objVarBlock), (yyvsp[(3) - (3)].cblock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 111:
+
+/* Line 1806 of yacc.c */
+#line 3586 "script_parser.ypp"
+ {
+ RULE( "assignment: user_objvar '=' userexp");
+
+ if (!interpCheckEquiv((yyvsp[(1) - (3)].objVarBlock)->psObjVar->type,(yyvsp[(3) - (3)].cblock)->type))
+ {
+ scr_error("User type mismatch for assignment (%d - %d) 2", (yyvsp[(1) - (3)].objVarBlock)->psObjVar->type, (yyvsp[(3) - (3)].cblock)->type);
+ YYABORT;
+ }
+ codeRet = scriptCodeObjAssignment((yyvsp[(1) - (3)].objVarBlock), (CODE_BLOCK *)(yyvsp[(3) - (3)].cblock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 112:
+
+/* Line 1806 of yacc.c */
+#line 3601 "script_parser.ypp"
+ {
+ RULE( "assignment: obj_objvar '=' objexp");
+
+ if (!interpCheckEquiv((yyvsp[(1) - (3)].objVarBlock)->psObjVar->type, (yyvsp[(3) - (3)].cblock)->type))
+ {
+ scr_error("User type mismatch for assignment (%d - %d) 1", (yyvsp[(1) - (3)].objVarBlock)->psObjVar->type, (yyvsp[(3) - (3)].cblock)->type);
+ YYABORT;
+ }
+ codeRet = scriptCodeObjAssignment((yyvsp[(1) - (3)].objVarBlock), (yyvsp[(3) - (3)].cblock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 113:
+
+/* Line 1806 of yacc.c */
+#line 3616 "script_parser.ypp"
+ {
+ RULE( "assignment: num_array_var '=' expression");
+
+ codeRet = scriptCodeArrayAssignment((yyvsp[(1) - (3)].arrayBlock), (yyvsp[(3) - (3)].cblock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 114:
+
+/* Line 1806 of yacc.c */
+#line 3626 "script_parser.ypp"
+ {
+ RULE( "assignment: bool_array_var '=' boolexp");
+
+ codeRet = scriptCodeArrayAssignment((yyvsp[(1) - (3)].arrayBlock), (yyvsp[(3) - (3)].cblock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 115:
+
+/* Line 1806 of yacc.c */
+#line 3636 "script_parser.ypp"
+ {
+ RULE( "assignment: user_array_var '=' userexp");
+
+ if (!interpCheckEquiv((yyvsp[(1) - (3)].arrayBlock)->psArrayVar->type,(yyvsp[(3) - (3)].cblock)->type))
+ {
+ scr_error("User type mismatch for assignment (%d - %d) 0", (yyvsp[(1) - (3)].arrayBlock)->psArrayVar->type, (yyvsp[(3) - (3)].cblock)->type);
+ YYABORT;
+ }
+ codeRet = scriptCodeArrayAssignment((yyvsp[(1) - (3)].arrayBlock), (CODE_BLOCK *)(yyvsp[(3) - (3)].cblock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 116:
+
+/* Line 1806 of yacc.c */
+#line 3651 "script_parser.ypp"
+ {
+ RULE( "assignment: obj_array_var '=' objexp");
+
+ if (!interpCheckEquiv((yyvsp[(1) - (3)].arrayBlock)->psArrayVar->type, (yyvsp[(3) - (3)].cblock)->type))
+ {
+ scr_error("User type mismatch for assignment");
+ YYABORT;
+ }
+ codeRet = scriptCodeArrayAssignment((yyvsp[(1) - (3)].arrayBlock), (yyvsp[(3) - (3)].cblock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 117:
+
+/* Line 1806 of yacc.c */
+#line 3674 "script_parser.ypp"
+ {
+ RULE( "func_call: NUM_FUNC '(' param_list ')'");
+
+ /* Generate the code for the function call */
+ codeRet = scriptCodeFunction((yyvsp[(1) - (4)].fSymbol), (yyvsp[(3) - (4)].pblock), false, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 118:
+
+/* Line 1806 of yacc.c */
+#line 3685 "script_parser.ypp"
+ {
+ RULE( "func_call: BOOL_FUNC '(' param_list ')'");
+
+ /* Generate the code for the function call */
+ codeRet = scriptCodeFunction((yyvsp[(1) - (4)].fSymbol), (yyvsp[(3) - (4)].pblock), false, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 119:
+
+/* Line 1806 of yacc.c */
+#line 3696 "script_parser.ypp"
+ {
+ RULE( "func_call: USER_FUNC '(' param_list ')'");
+
+ /* Generate the code for the function call */
+ codeRet = scriptCodeFunction((yyvsp[(1) - (4)].fSymbol), (yyvsp[(3) - (4)].pblock), false, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 120:
+
+/* Line 1806 of yacc.c */
+#line 3707 "script_parser.ypp"
+ {
+ RULE( "func_call: OBJ_FUNC '(' param_list ')'");
+
+ /* Generate the code for the function call */
+ codeRet = scriptCodeFunction((yyvsp[(1) - (4)].fSymbol), (yyvsp[(3) - (4)].pblock), false, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 121:
+
+/* Line 1806 of yacc.c */
+#line 3718 "script_parser.ypp"
+ {
+ RULE("func_call: FUNC '(' param_list ')'");
+
+ /* Generate the code for the function call */
+ codeRet = scriptCodeFunction((yyvsp[(1) - (4)].fSymbol), (yyvsp[(3) - (4)].pblock), false, &psCurrBlock);
+
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 122:
+
+/* Line 1806 of yacc.c */
+#line 3730 "script_parser.ypp"
+ {
+ RULE( "func_call: STRING_FUNC '(' param_list ')'");
+
+ /* Generate the code for the function call */
+ codeRet = scriptCodeFunction((yyvsp[(1) - (4)].fSymbol), (yyvsp[(3) - (4)].pblock), false, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 123:
+
+/* Line 1806 of yacc.c */
+#line 3741 "script_parser.ypp"
+ {
+ RULE( "func_call: FLOAT_FUNC '(' param_list ')'");
+
+ /* Generate the code for the function call */
+ codeRet = scriptCodeFunction((yyvsp[(1) - (4)].fSymbol), (yyvsp[(3) - (4)].pblock), false, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 124:
+
+/* Line 1806 of yacc.c */
+#line 3763 "script_parser.ypp"
+ {
+ /* create a dummy pblock containing nothing */
+ //ALLOC_PBLOCK(psCurrPBlock, sizeof(UDWORD), 1);
+ ALLOC_PBLOCK(psCurrPBlock, 1, 1); //1 is enough
+ psCurrPBlock->size = 0;
+ psCurrPBlock->numParams = 0;
+
+ (yyval.pblock) = psCurrPBlock;
+ }
+ break;
+
+ case 125:
+
+/* Line 1806 of yacc.c */
+#line 3773 "script_parser.ypp"
+ {
+ RULE("param_list: parameter");
+ (yyval.pblock) = (yyvsp[(1) - (1)].pblock);
+ }
+ break;
+
+ case 126:
+
+/* Line 1806 of yacc.c */
+#line 3778 "script_parser.ypp"
+ {
+ RULE("param_list: param_list ',' parameter");
+
+ ALLOC_PBLOCK(psCurrPBlock, (yyvsp[(1) - (3)].pblock)->size + (yyvsp[(3) - (3)].pblock)->size, (yyvsp[(1) - (3)].pblock)->numParams + (yyvsp[(3) - (3)].pblock)->numParams);
+ ip = psCurrPBlock->pCode;
+
+ /* Copy in the code for the parameters */
+ PUT_BLOCK(ip, (yyvsp[(1) - (3)].pblock));
+ PUT_BLOCK(ip, (yyvsp[(3) - (3)].pblock));
+
+ /* Copy the parameter types */
+ memcpy(psCurrPBlock->aParams, (yyvsp[(1) - (3)].pblock)->aParams,
+ (yyvsp[(1) - (3)].pblock)->numParams * sizeof(INTERP_TYPE));
+ memcpy(psCurrPBlock->aParams + (yyvsp[(1) - (3)].pblock)->numParams,
+ (yyvsp[(3) - (3)].pblock)->aParams,
+ (yyvsp[(3) - (3)].pblock)->numParams * sizeof(INTERP_TYPE));
+
+ /* Free the old pblocks */
+ FREE_PBLOCK((yyvsp[(1) - (3)].pblock));
+ FREE_PBLOCK((yyvsp[(3) - (3)].pblock));
+
+ /* return the pblock */
+ (yyval.pblock) = psCurrPBlock;
+ }
+ break;
+
+ case 127:
+
+/* Line 1806 of yacc.c */
+#line 3804 "script_parser.ypp"
+ {
+ RULE("parameter: expression");
+
+ /* Generate the code for the parameter */
+ codeRet = scriptCodeParameter((yyvsp[(1) - (1)].cblock), VAL_INT, &psCurrPBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.pblock) = psCurrPBlock;
+ }
+ break;
+
+ case 128:
+
+/* Line 1806 of yacc.c */
+#line 3815 "script_parser.ypp"
+ {
+ RULE("parameter: boolexp (boolexp size: %d)", (yyvsp[(1) - (1)].cblock)->size);
+
+ /* Generate the code for the parameter */
+ codeRet = scriptCodeParameter((yyvsp[(1) - (1)].cblock), VAL_BOOL, &psCurrPBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.pblock) = psCurrPBlock;
+ }
+ break;
+
+ case 129:
+
+/* Line 1806 of yacc.c */
+#line 3826 "script_parser.ypp"
+ {
+ RULE("parameter: floatexp");
+
+ /* Generate the code for the parameter */
+ codeRet = scriptCodeParameter((yyvsp[(1) - (1)].cblock), VAL_FLOAT, &psCurrPBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.pblock) = psCurrPBlock;
+ }
+ break;
+
+ case 130:
+
+/* Line 1806 of yacc.c */
+#line 3837 "script_parser.ypp"
+ {
+ RULE("parameter: stringexp");
+
+ /* Generate the code for the parameter */
+ codeRet = scriptCodeParameter((yyvsp[(1) - (1)].cblock), VAL_STRING, &psCurrPBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.pblock) = psCurrPBlock;
+ }
+ break;
+
+ case 131:
+
+/* Line 1806 of yacc.c */
+#line 3848 "script_parser.ypp"
+ {
+ RULE("parameter: userexp");
+
+ /* Generate the code for the parameter */
+ codeRet = scriptCodeParameter((CODE_BLOCK *)(yyvsp[(1) - (1)].cblock), (yyvsp[(1) - (1)].cblock)->type, &psCurrPBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.pblock) = psCurrPBlock;
+ }
+ break;
+
+ case 132:
+
+/* Line 1806 of yacc.c */
+#line 3859 "script_parser.ypp"
+ {
+ RULE( "parameter: objexp");
+
+ /* Generate the code for the parameter */
+ codeRet = scriptCodeParameter((yyvsp[(1) - (1)].cblock), (yyvsp[(1) - (1)].cblock)->type, &psCurrPBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.pblock) = psCurrPBlock;
+ }
+ break;
+
+ case 133:
+
+/* Line 1806 of yacc.c */
+#line 3870 "script_parser.ypp"
+ {
+ /* just pass the variable reference up the tree */
+ (yyval.pblock) = (yyvsp[(1) - (1)].pblock);
+ }
+ break;
+
+ case 134:
+
+/* Line 1806 of yacc.c */
+#line 3877 "script_parser.ypp"
+ {
+ codeRet = scriptCodeVarRef((yyvsp[(2) - (2)].vSymbol), &psCurrPBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.pblock) = psCurrPBlock;
+ }
+ break;
+
+ case 135:
+
+/* Line 1806 of yacc.c */
+#line 3885 "script_parser.ypp"
+ {
+ codeRet = scriptCodeVarRef((yyvsp[(2) - (2)].vSymbol), &psCurrPBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.pblock) = psCurrPBlock;
+ }
+ break;
+
+ case 136:
+
+/* Line 1806 of yacc.c */
+#line 3893 "script_parser.ypp"
+ {
+ codeRet = scriptCodeVarRef((yyvsp[(2) - (2)].vSymbol), &psCurrPBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.pblock) = psCurrPBlock;
+ }
+ break;
+
+ case 137:
+
+/* Line 1806 of yacc.c */
+#line 3901 "script_parser.ypp"
+ {
+ codeRet = scriptCodeVarRef((yyvsp[(2) - (2)].vSymbol), &psCurrPBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.pblock) = psCurrPBlock;
+ }
+ break;
+
+ case 138:
+
+/* Line 1806 of yacc.c */
+#line 3909 "script_parser.ypp"
+ {
+ codeRet = scriptCodeVarRef((yyvsp[(2) - (2)].vSymbol), &psCurrPBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.pblock) = psCurrPBlock;
+ }
+ break;
+
+ case 139:
+
+/* Line 1806 of yacc.c */
+#line 3917 "script_parser.ypp"
+ {
+ codeRet = scriptCodeVarRef((yyvsp[(2) - (2)].vSymbol), &psCurrPBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.pblock) = psCurrPBlock;
+ }
+ break;
+
+ case 140:
+
+/* Line 1806 of yacc.c */
+#line 3932 "script_parser.ypp"
+ {
+ RULE( "conditional: cond_clause_list");
+
+ codeRet = scriptCodeConditional((yyvsp[(1) - (1)].condBlock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 141:
+
+/* Line 1806 of yacc.c */
+#line 3941 "script_parser.ypp"
+ {
+ RULE( "conditional: cond_clause_list ELSE terminal_cond");
+
+ ALLOC_CONDBLOCK(psCondBlock, (yyvsp[(1) - (3)].condBlock)->numOffsets + (yyvsp[(3) - (3)].condBlock)->numOffsets, (yyvsp[(1) - (3)].condBlock)->size + (yyvsp[(3) - (3)].condBlock)->size);
+ ALLOC_DEBUG(psCondBlock, (yyvsp[(1) - (3)].condBlock)->debugEntries + (yyvsp[(3) - (3)].condBlock)->debugEntries);
+ ip = psCondBlock->pCode;
+
+ /* Store the two blocks of code */
+ PUT_BLOCK(ip, (yyvsp[(1) - (3)].condBlock));
+ PUT_BLOCK(ip, (yyvsp[(3) - (3)].condBlock));
+
+ /* Copy over the offset information */
+ /* (There isn't any in the terminal_cond) */
+ memcpy(psCondBlock->aOffsets, (yyvsp[(1) - (3)].condBlock)->aOffsets,
+ (yyvsp[(1) - (3)].condBlock)->numOffsets * sizeof(SDWORD));
+ psCondBlock->numOffsets = (yyvsp[(1) - (3)].condBlock)->numOffsets;
+
+ /* Put in the debugging information */
+ PUT_DEBUG(psCondBlock, (yyvsp[(1) - (3)].condBlock));
+ APPEND_DEBUG(psCondBlock, (yyvsp[(1) - (3)].condBlock)->size, (yyvsp[(3) - (3)].condBlock));
+
+ /* Free the code blocks */
+ FREE_DEBUG((yyvsp[(1) - (3)].condBlock));
+ FREE_DEBUG((yyvsp[(3) - (3)].condBlock));
+ FREE_CONDBLOCK((yyvsp[(1) - (3)].condBlock));
+ FREE_CONDBLOCK((yyvsp[(3) - (3)].condBlock));
+
+ /* Do the final processing of the conditional */
+ codeRet = scriptCodeConditional(psCondBlock, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 142:
+
+/* Line 1806 of yacc.c */
+#line 3977 "script_parser.ypp"
+ {
+ RULE( "cond_clause_list: cond_clause");
+
+ (yyval.condBlock) = (yyvsp[(1) - (1)].condBlock);
+ }
+ break;
+
+ case 143:
+
+/* Line 1806 of yacc.c */
+#line 3983 "script_parser.ypp"
+ {
+ RULE( "cond_clause_list: cond_clause_list ELSE cond_clause");
+
+ ALLOC_CONDBLOCK(psCondBlock,
+ (yyvsp[(1) - (3)].condBlock)->numOffsets + (yyvsp[(3) - (3)].condBlock)->numOffsets,
+ (yyvsp[(1) - (3)].condBlock)->size + (yyvsp[(3) - (3)].condBlock)->size);
+ ALLOC_DEBUG(psCondBlock, (yyvsp[(1) - (3)].condBlock)->debugEntries + (yyvsp[(3) - (3)].condBlock)->debugEntries);
+ ip = psCondBlock->pCode;
+
+ /* Store the two blocks of code */
+ PUT_BLOCK(ip, (yyvsp[(1) - (3)].condBlock));
+ PUT_BLOCK(ip, (yyvsp[(3) - (3)].condBlock));
+
+ /* Copy over the offset information */
+ memcpy(psCondBlock->aOffsets, (yyvsp[(1) - (3)].condBlock)->aOffsets,
+ (yyvsp[(1) - (3)].condBlock)->numOffsets * sizeof(SDWORD));
+ psCondBlock->aOffsets[(yyvsp[(1) - (3)].condBlock)->numOffsets] =
+ (yyvsp[(3) - (3)].condBlock)->aOffsets[0] + (yyvsp[(1) - (3)].condBlock)->size;
+ psCondBlock->numOffsets = (yyvsp[(1) - (3)].condBlock)->numOffsets + 1;
+
+ /* Put in the debugging information */
+ PUT_DEBUG(psCondBlock, (yyvsp[(1) - (3)].condBlock));
+ APPEND_DEBUG(psCondBlock, (yyvsp[(1) - (3)].condBlock)->size, (yyvsp[(3) - (3)].condBlock));
+
+ /* Free the code blocks */
+ FREE_DEBUG((yyvsp[(1) - (3)].condBlock));
+ FREE_DEBUG((yyvsp[(3) - (3)].condBlock));
+ FREE_CONDBLOCK((yyvsp[(1) - (3)].condBlock));
+ FREE_CONDBLOCK((yyvsp[(3) - (3)].condBlock));
+
+ (yyval.condBlock) = psCondBlock;
+ }
+ break;
+
+ case 144:
+
+/* Line 1806 of yacc.c */
+#line 4019 "script_parser.ypp"
+ {
+ RULE( "terminal_cond: '{' statement_list '}'");
+
+ /* Allocate the block */
+ ALLOC_CONDBLOCK(psCondBlock, 1, (yyvsp[(2) - (3)].cblock)->size);
+ ALLOC_DEBUG(psCondBlock, (yyvsp[(2) - (3)].cblock)->debugEntries);
+ ip = psCondBlock->pCode;
+
+ /* Put in the debugging information */
+ PUT_DEBUG(psCondBlock, (yyvsp[(2) - (3)].cblock));
+
+ /* Store the statements */
+ PUT_BLOCK(ip, (yyvsp[(2) - (3)].cblock));
+ FREE_DEBUG((yyvsp[(2) - (3)].cblock));
+ FREE_BLOCK((yyvsp[(2) - (3)].cblock));
+
+ (yyval.condBlock) = psCondBlock;
+ }
+ break;
+
+ case 145:
+
+/* Line 1806 of yacc.c */
+#line 4040 "script_parser.ypp"
+ {
+ char *pDummy;
+
+ RULE( "cond_clause: IF '(' boolexp ')' '{' statement_list '}'");
+
+ /* Get the line number for the end of the boolean expression */
+ /* and store it in debugLine. */
+ scriptGetErrorData((SDWORD *)&debugLine, &pDummy);
+ }
+ break;
+
+ case 146:
+
+/* Line 1806 of yacc.c */
+#line 4050 "script_parser.ypp"
+ {
+ /* Allocate the block */
+ ALLOC_CONDBLOCK(psCondBlock, 1, //1 offset
+ (yyvsp[(3) - (8)].cblock)->size + (yyvsp[(7) - (8)].cblock)->size +
+ 1 + 1); //size + size + OP_JUMPFALSE + OP_JUMP
+
+ ALLOC_DEBUG(psCondBlock, (yyvsp[(7) - (8)].cblock)->debugEntries + 1);
+ ip = psCondBlock->pCode;
+
+ /* Store the boolean expression code */
+ PUT_BLOCK(ip, (yyvsp[(3) - (8)].cblock));
+ FREE_BLOCK((yyvsp[(3) - (8)].cblock));
+
+ /* Put in the jump to the end of the block if the */
+ /* condition is false */
+ PUT_PKOPCODE(ip, OP_JUMPFALSE, (yyvsp[(7) - (8)].cblock)->size + 2);
+
+ /* Put in the debugging information */
+ if (genDebugInfo)
+ {
+ psCondBlock->debugEntries = 1;
+ psCondBlock->psDebug->line = debugLine;
+ psCondBlock->psDebug->offset = 0;
+ APPEND_DEBUG(psCondBlock, ip - psCondBlock->pCode, (yyvsp[(7) - (8)].cblock));
+ }
+
+ /* Store the statements */
+ PUT_BLOCK(ip, (yyvsp[(7) - (8)].cblock));
+ FREE_DEBUG((yyvsp[(7) - (8)].cblock));
+ FREE_BLOCK((yyvsp[(7) - (8)].cblock));
+
+ /* Store the location that has to be filled in */
+ //TODO: don't want to store pointers as ints
+ psCondBlock->aOffsets[0] = (UDWORD)(ip - psCondBlock->pCode);
+
+ /* Put in a jump to skip the rest of the conditional */
+ /* The correct offset will be set once the whole */
+ /* conditional has been parsed */
+ /* The jump should be to the instruction after the */
+ /* entire conditonal block */
+ PUT_PKOPCODE(ip, OP_JUMP, 0);
+
+ (yyval.condBlock) = psCondBlock;
+ }
+ break;
+
+ case 147:
+
+/* Line 1806 of yacc.c */
+#line 4096 "script_parser.ypp"
+ {
+ char *pDummy;
+
+ RULE( "cond_clause: IF '(' boolexp ')' statement");
+
+ /* Get the line number for the end of the boolean expression */
+ /* and store it in debugLine. */
+ scriptGetErrorData((SDWORD *)&debugLine, &pDummy);
+ }
+ break;
+
+ case 148:
+
+/* Line 1806 of yacc.c */
+#line 4106 "script_parser.ypp"
+ {
+ /* Allocate the block */
+ ALLOC_CONDBLOCK(psCondBlock, 1,
+ (yyvsp[(3) - (6)].cblock)->size + (yyvsp[(6) - (6)].cblock)->size +
+ 1 + 1); //size + size + opcode + opcode
+
+ ALLOC_DEBUG(psCondBlock, (yyvsp[(6) - (6)].cblock)->debugEntries + 1);
+ ip = psCondBlock->pCode;
+
+ /* Store the boolean expression code */
+ PUT_BLOCK(ip, (yyvsp[(3) - (6)].cblock));
+ FREE_BLOCK((yyvsp[(3) - (6)].cblock));
+
+
+ /* Put in the jump to the end of the block if the */
+ /* condition is false */
+ PUT_PKOPCODE(ip, OP_JUMPFALSE, (yyvsp[(6) - (6)].cblock)->size + 2);
+
+ /* Put in the debugging information */
+ if (genDebugInfo)
+ {
+ psCondBlock->debugEntries = 1;
+ psCondBlock->psDebug->line = debugLine;
+ psCondBlock->psDebug->offset = 0;
+ APPEND_DEBUG(psCondBlock, ip - psCondBlock->pCode, (yyvsp[(6) - (6)].cblock));
+ }
+
+ /* Store the statements */
+ PUT_BLOCK(ip, (yyvsp[(6) - (6)].cblock));
+ FREE_DEBUG((yyvsp[(6) - (6)].cblock));
+ FREE_BLOCK((yyvsp[(6) - (6)].cblock));
+
+ /* Store the location that has to be filled in */
+ psCondBlock->aOffsets[0] = (UDWORD)(ip - psCondBlock->pCode);
+
+ /* Put in a jump to skip the rest of the conditional */
+ /* The correct offset will be set once the whole */
+ /* conditional has been parsed */
+ /* The jump should be to the instruction after the */
+ /* entire conditonal block */
+ PUT_PKOPCODE(ip, OP_JUMP, 0);
+
+ (yyval.condBlock) = psCondBlock;
+ }
+ break;
+
+ case 149:
+
+/* Line 1806 of yacc.c */
+#line 4163 "script_parser.ypp"
+ {
+ char *pDummy;
+
+ /* Get the line number for the end of the boolean expression */
+ /* and store it in debugLine. */
+ scriptGetErrorData((SDWORD *)&debugLine, &pDummy);
+ }
+ break;
+
+ case 150:
+
+/* Line 1806 of yacc.c */
+#line 4171 "script_parser.ypp"
+ {
+ RULE("loop: WHILE '(' boolexp ')'");
+
+ //ALLOC_BLOCK(psCurrBlock, $3->size + $7->size + sizeof(OPCODE) * 2);
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(3) - (8)].cblock)->size + (yyvsp[(7) - (8)].cblock)->size + 1 + 1); //size + size + opcode + opcode
+
+ ALLOC_DEBUG(psCurrBlock, (yyvsp[(7) - (8)].cblock)->debugEntries + 1);
+ ip = psCurrBlock->pCode;
+
+ /* Copy in the loop expression */
+ PUT_BLOCK(ip, (yyvsp[(3) - (8)].cblock));
+ FREE_BLOCK((yyvsp[(3) - (8)].cblock));
+
+ /* Now a conditional jump out of the loop if the */
+ /* expression is false. */
+ PUT_PKOPCODE(ip, OP_JUMPFALSE, (yyvsp[(7) - (8)].cblock)->size + 2);
+
+ /* Now put in the debugging information */
+ if (genDebugInfo)
+ {
+ psCurrBlock->debugEntries = 1;
+ psCurrBlock->psDebug->line = debugLine;
+ psCurrBlock->psDebug->offset = 0;
+ APPEND_DEBUG(psCurrBlock, ip - psCurrBlock->pCode, (yyvsp[(7) - (8)].cblock));
+ }
+
+ /* Copy in the body of the loop */
+ PUT_BLOCK(ip, (yyvsp[(7) - (8)].cblock));
+ FREE_DEBUG((yyvsp[(7) - (8)].cblock));
+ FREE_BLOCK((yyvsp[(7) - (8)].cblock));
+
+ /* Put in a jump back to the start of the loop expression */
+ PUT_PKOPCODE(ip, OP_JUMP, (SWORD)( -(SWORD)(psCurrBlock->size) + 1));
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 151:
+
+/* Line 1806 of yacc.c */
+#line 4211 "script_parser.ypp"
+ {
+ RULE("expression: NUM_VAR++");
+
+ scriptCodeIncDec((yyvsp[(1) - (2)].vSymbol), &psCurrBlock, OP_INC);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 152:
+
+/* Line 1806 of yacc.c */
+#line 4220 "script_parser.ypp"
+ {
+ RULE("expression: NUM_VAR--");
+
+ scriptCodeIncDec((yyvsp[(1) - (2)].vSymbol), &psCurrBlock, OP_DEC);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 153:
+
+/* Line 1806 of yacc.c */
+#line 4236 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_ADD, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 154:
+
+/* Line 1806 of yacc.c */
+#line 4244 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_SUB, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 155:
+
+/* Line 1806 of yacc.c */
+#line 4252 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_MUL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 156:
+
+/* Line 1806 of yacc.c */
+#line 4260 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_DIV, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 157:
+
+/* Line 1806 of yacc.c */
+#line 4269 "script_parser.ypp"
+ {
+ //ALLOC_BLOCK(psCurrBlock, $2->size + sizeof(OPCODE));
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(2) - (2)].cblock)->size + 1); //size + unary minus opcode
+
+ ip = psCurrBlock->pCode;
+
+ /* Copy the already generated bits of code into the code block */
+ PUT_BLOCK(ip, (yyvsp[(2) - (2)].cblock));
+
+ /* Now put a negation operator into the code */
+ PUT_PKOPCODE(ip, OP_UNARYOP, OP_NEG);
+
+ /* Free the two code blocks that have been copied */
+ FREE_BLOCK((yyvsp[(2) - (2)].cblock));
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 158:
+
+/* Line 1806 of yacc.c */
+#line 4288 "script_parser.ypp"
+ {
+ /* Just pass the code up the tree */
+ (yyval.cblock) = (yyvsp[(2) - (3)].cblock);
+ }
+ break;
+
+ case 159:
+
+/* Line 1806 of yacc.c */
+#line 4293 "script_parser.ypp"
+ {
+ RULE("expression: (int) floatexp");
+
+ /* perform cast */
+ (yyvsp[(2) - (2)].cblock)->type = VAL_INT;
+
+ //ALLOC_BLOCK(psCurrBlock, $4->size + sizeof(OPCODE));
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(2) - (2)].cblock)->size + 1); //size + opcode
+ ip = psCurrBlock->pCode;
+
+ PUT_BLOCK(ip, (yyvsp[(2) - (2)].cblock));
+ PUT_OPCODE(ip, OP_TO_INT);
+
+ FREE_BLOCK((yyvsp[(2) - (2)].cblock)); // free floatexp
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 160:
+
+/* Line 1806 of yacc.c */
+#line 4311 "script_parser.ypp"
+ {
+
+ RULE( "expression: NUM_FUNC '(' param_list ')'");
+
+ /* Generate the code for the function call */
+ codeRet = scriptCodeFunction((yyvsp[(1) - (4)].fSymbol), (yyvsp[(3) - (4)].pblock), true, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 161:
+
+/* Line 1806 of yacc.c */
+#line 4324 "script_parser.ypp"
+ {
+ UDWORD paramNumber;
+
+ RULE( "expression: NUM_FUNC_CUST '(' param_list ')'");
+
+ /* if($4->numParams != $3->numParams) */
+ if((yyvsp[(3) - (4)].pblock)->numParams != (yyvsp[(1) - (4)].eSymbol)->numParams)
+ {
+ debug(LOG_ERROR, "Wrong number of arguments for function call: '%s'. Expected %d parameters instead of %d.", (yyvsp[(1) - (4)].eSymbol)->pIdent, (yyvsp[(1) - (4)].eSymbol)->numParams, (yyvsp[(3) - (4)].pblock)->numParams);
+ scr_error("Wrong number of arguments in function call");
+ return CE_PARSE;
+ }
+
+ if(!(yyvsp[(1) - (4)].eSymbol)->bFunction)
+ {
+ debug(LOG_ERROR, "'%s' is not a function", (yyvsp[(1) - (4)].eSymbol)->pIdent);
+ scr_error("Can't call an event");
+ return CE_PARSE;
+ }
+
+ /* make sure function has a return type */
+ if((yyvsp[(1) - (4)].eSymbol)->retType != VAL_INT)
+ {
+ debug(LOG_ERROR, "'%s' does not return an integer value", (yyvsp[(1) - (4)].eSymbol)->pIdent);
+ scr_error("assignment type conflict");
+ return CE_PARSE;
+ }
+
+ /* check if right parameters were passed */
+ paramNumber = checkFuncParamTypes((yyvsp[(1) - (4)].eSymbol), (yyvsp[(3) - (4)].pblock));
+ if(paramNumber > 0)
+ {
+ debug(LOG_ERROR, "Parameter mismatch in function call: '%s'. Mismatch in parameter %d.", (yyvsp[(1) - (4)].eSymbol)->pIdent, paramNumber);
+ YYABORT;
+ }
+
+ /* Allocate the code block */
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(3) - (4)].pblock)->size + 1 + 1); //Params + Opcode + event index
+
+ ip = psCurrBlock->pCode;
+
+ if((yyvsp[(3) - (4)].pblock)->numParams > 0) /* if any parameters declared */
+ {
+ /* Copy in the code for the parameters */
+ PUT_BLOCK(ip, (yyvsp[(3) - (4)].pblock));
+ }
+
+ FREE_PBLOCK((yyvsp[(3) - (4)].pblock));
+
+ /* Store the instruction */
+ PUT_OPCODE(ip, OP_FUNC);
+ PUT_EVENT(ip,(yyvsp[(1) - (4)].eSymbol)->index); //Put event index
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 162:
+
+/* Line 1806 of yacc.c */
+#line 4380 "script_parser.ypp"
+ {
+ RULE("expression: NUM_VAR");
+
+ codeRet = scriptCodeVarGet((yyvsp[(1) - (1)].vSymbol), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 163:
+
+/* Line 1806 of yacc.c */
+#line 4390 "script_parser.ypp"
+ {
+ RULE("expression: NUM_CONSTANT");
+
+ codeRet = scriptCodeConstant((yyvsp[(1) - (1)].cSymbol), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 164:
+
+/* Line 1806 of yacc.c */
+#line 4400 "script_parser.ypp"
+ {
+ RULE( "expression: num_objvar");
+ RULE( "type=%d", (yyvsp[(1) - (1)].objVarBlock)->psObjVar->type);
+
+ codeRet = scriptCodeObjGet((yyvsp[(1) - (1)].objVarBlock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 165:
+
+/* Line 1806 of yacc.c */
+#line 4411 "script_parser.ypp"
+ {
+ codeRet = scriptCodeArrayGet((yyvsp[(1) - (1)].arrayBlock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 166:
+
+/* Line 1806 of yacc.c */
+#line 4419 "script_parser.ypp"
+ {
+ RULE("expression: INTEGER");
+
+ //ALLOC_BLOCK(psCurrBlock, sizeof(OPCODE) + sizeof(UDWORD));
+ ALLOC_BLOCK(psCurrBlock, 1 + 1); //opcode + integer value
+
+ ip = psCurrBlock->pCode;
+
+ /* Code to store the value on the stack */
+ PUT_PKOPCODE(ip, OP_PUSH, VAL_INT);
+ PUT_DATA_INT(ip, (yyvsp[(1) - (1)].ival));
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 167:
+
+/* Line 1806 of yacc.c */
+#line 4437 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_ADD, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 168:
+
+/* Line 1806 of yacc.c */
+#line 4445 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_SUB, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 169:
+
+/* Line 1806 of yacc.c */
+#line 4453 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_MUL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 170:
+
+/* Line 1806 of yacc.c */
+#line 4461 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_DIV, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 171:
+
+/* Line 1806 of yacc.c */
+#line 4469 "script_parser.ypp"
+ {
+ RULE("floatexp: (float) expression");
+
+ /* perform cast */
+ (yyvsp[(2) - (2)].cblock)->type = VAL_FLOAT;
+
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(2) - (2)].cblock)->size + 1); //size + opcode
+ ip = psCurrBlock->pCode;
+
+ PUT_BLOCK(ip, (yyvsp[(2) - (2)].cblock));
+ PUT_OPCODE(ip, OP_TO_FLOAT);
+
+ FREE_BLOCK((yyvsp[(2) - (2)].cblock)); // free 'expression'
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 172:
+
+/* Line 1806 of yacc.c */
+#line 4486 "script_parser.ypp"
+ {
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(2) - (2)].cblock)->size + 1); //size + opcode
+
+ ip = psCurrBlock->pCode;
+
+ /* Copy the already generated bits of code into the code block */
+ PUT_BLOCK(ip, (yyvsp[(2) - (2)].cblock));
+
+ /* Now put a negation operator into the code */
+ PUT_PKOPCODE(ip, OP_UNARYOP, OP_NEG);
+
+ /* Free the code block that have been copied */
+ FREE_BLOCK((yyvsp[(2) - (2)].cblock));
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 173:
+
+/* Line 1806 of yacc.c */
+#line 4504 "script_parser.ypp"
+ {
+ /* Just pass the code up the tree */
+ (yyval.cblock) = (yyvsp[(2) - (3)].cblock);
+ }
+ break;
+
+ case 174:
+
+/* Line 1806 of yacc.c */
+#line 4509 "script_parser.ypp"
+ {
+ RULE("floatexp: FLOAT_FUNC '(' param_list ')'");
+
+ /* Generate the code for the function call */
+ codeRet = scriptCodeFunction((yyvsp[(1) - (4)].fSymbol), (yyvsp[(3) - (4)].pblock), true, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 175:
+
+/* Line 1806 of yacc.c */
+#line 4520 "script_parser.ypp"
+ {
+ UDWORD line,paramNumber;
+ char *pDummy;
+
+ RULE("floatexp: FLOAT_FUNC_CUST '(' param_list ')'");
+
+ if((yyvsp[(3) - (4)].pblock)->numParams != (yyvsp[(1) - (4)].eSymbol)->numParams)
+ {
+ debug(LOG_ERROR, "Wrong number of arguments for function call: '%s'. Expected %d parameters instead of %d.", (yyvsp[(1) - (4)].eSymbol)->pIdent, (yyvsp[(1) - (4)].eSymbol)->numParams, (yyvsp[(3) - (4)].pblock)->numParams);
+ scr_error("Wrong number of arguments in function call");
+ return CE_PARSE;
+ }
+
+ if(!(yyvsp[(1) - (4)].eSymbol)->bFunction)
+ {
+ debug(LOG_ERROR, "'%s' is not a function", (yyvsp[(1) - (4)].eSymbol)->pIdent);
+ scr_error("Can't call an event");
+ return CE_PARSE;
+ }
+
+ /* make sure function has a return type */
+ if((yyvsp[(1) - (4)].eSymbol)->retType != VAL_FLOAT)
+ {
+ debug(LOG_ERROR, "'%s' does not return a float value", (yyvsp[(1) - (4)].eSymbol)->pIdent);
+ scr_error("assignment type conflict");
+ return CE_PARSE;
+ }
+
+ /* check if right parameters were passed */
+ paramNumber = checkFuncParamTypes((yyvsp[(1) - (4)].eSymbol), (yyvsp[(3) - (4)].pblock));
+ if(paramNumber > 0)
+ {
+ debug(LOG_ERROR, "Parameter mismatch in function call: '%s'. Mismatch in parameter %d.", (yyvsp[(1) - (4)].eSymbol)->pIdent, paramNumber);
+ YYABORT;
+ }
+
+ /* Allocate the code block */
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(3) - (4)].pblock)->size + 1 + 1); //Params + Opcode + event index
+
+ ALLOC_DEBUG(psCurrBlock, 1);
+ ip = psCurrBlock->pCode;
+
+ if((yyvsp[(3) - (4)].pblock)->numParams > 0) /* if any parameters declared */
+ {
+ /* Copy in the code for the parameters */
+ PUT_BLOCK(ip, (yyvsp[(3) - (4)].pblock));
+ }
+
+ FREE_PBLOCK((yyvsp[(3) - (4)].pblock));
+
+ /* Store the instruction */
+ PUT_OPCODE(ip, OP_FUNC);
+ PUT_EVENT(ip,(yyvsp[(1) - (4)].eSymbol)->index); //Put event/function index
+
+ /* Add the debugging information */
+ if (genDebugInfo)
+ {
+ psCurrBlock->psDebug[0].offset = 0;
+ scriptGetErrorData((SDWORD *)&line, &pDummy);
+ psCurrBlock->psDebug[0].line = line;
+ }
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 176:
+
+/* Line 1806 of yacc.c */
+#line 4585 "script_parser.ypp"
+ {
+ RULE( "floatexp: FLOAT_VAR");
+
+ codeRet = scriptCodeVarGet((yyvsp[(1) - (1)].vSymbol), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 177:
+
+/* Line 1806 of yacc.c */
+#line 4595 "script_parser.ypp"
+ {
+ RULE( "floatexp: FLOAT_T");
+
+ //ALLOC_BLOCK(psCurrBlock, sizeof(OPCODE) + sizeof(float));
+ ALLOC_BLOCK(psCurrBlock, 1 + 1); //opcode + float
+
+ ip = psCurrBlock->pCode;
+
+ /* Code to store the value on the stack */
+ PUT_PKOPCODE(ip, OP_PUSH, VAL_FLOAT);
+ PUT_DATA_FLOAT(ip, (yyvsp[(1) - (1)].fval));
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 178:
+
+/* Line 1806 of yacc.c */
+#line 4619 "script_parser.ypp"
+ {
+ RULE("stringexp: stringexp '&' stringexp");
+
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_CONC, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+
+ //debug(LOG_SCRIPT, "END stringexp: stringexp '&' stringexp");
+ }
+ break;
+
+ case 179:
+
+/* Line 1806 of yacc.c */
+#line 4631 "script_parser.ypp"
+ {
+ RULE( "stringexp: stringexp '&' expression");
+
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_CONC, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 180:
+
+/* Line 1806 of yacc.c */
+#line 4641 "script_parser.ypp"
+ {
+ RULE( "stringexp: expression '&' stringexp");
+
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_CONC, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 181:
+
+/* Line 1806 of yacc.c */
+#line 4651 "script_parser.ypp"
+ {
+ RULE( "stringexp: stringexp '&' boolexp");
+
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_CONC, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 182:
+
+/* Line 1806 of yacc.c */
+#line 4661 "script_parser.ypp"
+ {
+ RULE( "stringexp: boolexp '&' stringexp");
+
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_CONC, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 183:
+
+/* Line 1806 of yacc.c */
+#line 4671 "script_parser.ypp"
+ {
+ RULE( "stringexp: stringexp '&' floatexp");
+
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_CONC, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 184:
+
+/* Line 1806 of yacc.c */
+#line 4681 "script_parser.ypp"
+ {
+ RULE( "stringexp: floatexp '&' stringexp");
+
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_CONC, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 185:
+
+/* Line 1806 of yacc.c */
+#line 4691 "script_parser.ypp"
+ {
+ /* Just pass the code up the tree */
+ (yyval.cblock) = (yyvsp[(2) - (3)].cblock);
+ }
+ break;
+
+ case 186:
+
+/* Line 1806 of yacc.c */
+#line 4697 "script_parser.ypp"
+ {
+ RULE("stringexp: STRING_FUNC '(' param_list ')'");
+
+ /* Generate the code for the function call */
+ codeRet = scriptCodeFunction((yyvsp[(1) - (4)].fSymbol), (yyvsp[(3) - (4)].pblock), true, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 187:
+
+/* Line 1806 of yacc.c */
+#line 4708 "script_parser.ypp"
+ {
+ RULE("stringexp: STRING_FUNC_CUST '(' param_list ')'");
+
+ if((yyvsp[(3) - (4)].pblock)->numParams != (yyvsp[(1) - (4)].eSymbol)->numParams)
+ {
+ debug(LOG_ERROR, "Wrong number of arguments for function call: '%s'. Expected %d parameters instead of %d.", (yyvsp[(1) - (4)].eSymbol)->pIdent, (yyvsp[(1) - (4)].eSymbol)->numParams, (yyvsp[(3) - (4)].pblock)->numParams);
+ scr_error("Wrong number of arguments in function call");
+ return CE_PARSE;
+ }
+
+ if(!(yyvsp[(1) - (4)].eSymbol)->bFunction)
+ {
+ debug(LOG_ERROR, "'%s' is not a function", (yyvsp[(1) - (4)].eSymbol)->pIdent);
+ scr_error("Can't call an event");
+ return CE_PARSE;
+ }
+
+ /* make sure function has a return type */
+ if((yyvsp[(1) - (4)].eSymbol)->retType != VAL_STRING)
+ {
+ debug(LOG_ERROR, "'%s' does not return a string value", (yyvsp[(1) - (4)].eSymbol)->pIdent);
+ scr_error("assignment type conflict");
+ return CE_PARSE;
+ }
+
+ /* Allocate the code block */
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(3) - (4)].pblock)->size + 1 + 1); //Params + Opcode + event index
+
+ ip = psCurrBlock->pCode;
+
+ if((yyvsp[(3) - (4)].pblock)->numParams > 0) /* if any parameters declared */
+ {
+ /* Copy in the code for the parameters */
+ PUT_BLOCK(ip, (yyvsp[(3) - (4)].pblock));
+ }
+
+ FREE_PBLOCK((yyvsp[(3) - (4)].pblock));
+
+ /* Store the instruction */
+ PUT_OPCODE(ip, OP_FUNC);
+ PUT_EVENT(ip,(yyvsp[(1) - (4)].eSymbol)->index); //Put event index
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 188:
+
+/* Line 1806 of yacc.c */
+#line 4754 "script_parser.ypp"
+ {
+ RULE("stringexpr: STRING_VAR");
+
+ codeRet = scriptCodeVarGet((yyvsp[(1) - (1)].vSymbol), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 189:
+
+/* Line 1806 of yacc.c */
+#line 4764 "script_parser.ypp"
+ {
+ RULE("QTEXT: '%s'", yyvsp[0].sval);
+
+ //ALLOC_BLOCK(psCurrBlock, sizeof(OPCODE) + sizeof(UDWORD));
+ ALLOC_BLOCK(psCurrBlock, 1 + 1); //opcode + string pointer
+
+ ip = psCurrBlock->pCode;
+
+ /* Code to store the value on the stack */
+ PUT_PKOPCODE(ip, OP_PUSH, VAL_STRING);
+ PUT_DATA_STRING(ip, STRSTACK[CURSTACKSTR]);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+
+ /* Manage string stack */
+ sstrcpy(STRSTACK[CURSTACKSTR], yyvsp[0].sval);
+
+ CURSTACKSTR = CURSTACKSTR + 1; /* Increment 'pointer' to the top of the string stack */
+
+ if(CURSTACKSTR >= MAXSTACKLEN)
+ {
+ scr_error("Can't store more than %d strings", MAXSTACKLEN);
+ }
+
+ //debug(LOG_SCRIPT, "END QTEXT found");
+ }
+ break;
+
+ case 190:
+
+/* Line 1806 of yacc.c */
+#line 4792 "script_parser.ypp"
+ {
+ RULE( "stringexp: expression");
+
+ /* Just pass the code up the tree */
+ (yyval.cblock) = (yyvsp[(1) - (1)].cblock);
+ }
+ break;
+
+ case 191:
+
+/* Line 1806 of yacc.c */
+#line 4807 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_AND, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 192:
+
+/* Line 1806 of yacc.c */
+#line 4815 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_OR, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 193:
+
+/* Line 1806 of yacc.c */
+#line 4823 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_EQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 194:
+
+/* Line 1806 of yacc.c */
+#line 4831 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_NOTEQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 195:
+
+/* Line 1806 of yacc.c */
+#line 4839 "script_parser.ypp"
+ {
+ //ALLOC_BLOCK(psCurrBlock, $2->size + sizeof(OPCODE));
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(2) - (2)].cblock)->size + 1); //size + opcode
+
+ ip = psCurrBlock->pCode;
+
+ /* Copy the already generated bits of code into the code block */
+ PUT_BLOCK(ip, (yyvsp[(2) - (2)].cblock));
+
+ /* Now put a negation operator into the code */
+ PUT_PKOPCODE(ip, OP_UNARYOP, OP_NOT);
+
+ /* Free the two code blocks that have been copied */
+ FREE_BLOCK((yyvsp[(2) - (2)].cblock));
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 196:
+
+/* Line 1806 of yacc.c */
+#line 4858 "script_parser.ypp"
+ {
+ /* Just pass the code up the tree */
+ (yyval.cblock) = (yyvsp[(2) - (3)].cblock);
+ }
+ break;
+
+ case 197:
+
+/* Line 1806 of yacc.c */
+#line 4863 "script_parser.ypp"
+ {
+ RULE("boolexp: BOOL_FUNC '(' param_list ')'");
+
+ /* Generate the code for the function call */
+ codeRet = scriptCodeFunction((yyvsp[(1) - (4)].fSymbol), (yyvsp[(3) - (4)].pblock), true, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 198:
+
+/* Line 1806 of yacc.c */
+#line 4874 "script_parser.ypp"
+ {
+ UDWORD paramNumber;
+
+ RULE("boolexp: BOOL_FUNC_CUST '(' param_list ')'");
+
+ if((yyvsp[(3) - (4)].pblock)->numParams != (yyvsp[(1) - (4)].eSymbol)->numParams)
+ {
+ debug(LOG_ERROR, "Wrong number of arguments for function call: '%s'. Expected %d parameters instead of %d.", (yyvsp[(1) - (4)].eSymbol)->pIdent, (yyvsp[(1) - (4)].eSymbol)->numParams, (yyvsp[(3) - (4)].pblock)->numParams);
+ scr_error("Wrong number of arguments in function call");
+ return CE_PARSE;
+ }
+
+ if(!(yyvsp[(1) - (4)].eSymbol)->bFunction)
+ {
+ debug(LOG_ERROR, "'%s' is not a function", (yyvsp[(1) - (4)].eSymbol)->pIdent);
+ scr_error("Can't call an event");
+ return CE_PARSE;
+ }
+
+ /* make sure function has a return type */
+ if((yyvsp[(1) - (4)].eSymbol)->retType != VAL_BOOL)
+ {
+ debug(LOG_ERROR, "'%s' does not return a boolean value", (yyvsp[(1) - (4)].eSymbol)->pIdent);
+ scr_error("assignment type conflict");
+ return CE_PARSE;
+ }
+
+ /* check if right parameters were passed */
+ paramNumber = checkFuncParamTypes((yyvsp[(1) - (4)].eSymbol), (yyvsp[(3) - (4)].pblock));
+ if(paramNumber > 0)
+ {
+ debug(LOG_ERROR, "Parameter mismatch in function call: '%s'. Mismatch in parameter %d.", (yyvsp[(1) - (4)].eSymbol)->pIdent, paramNumber);
+ YYABORT;
+ }
+
+ /* Allocate the code block */
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(3) - (4)].pblock)->size + 1 + 1); //Params + Opcode + event index
+
+ ip = psCurrBlock->pCode;
+
+ if((yyvsp[(3) - (4)].pblock)->numParams > 0) /* if any parameters declared */
+ {
+ /* Copy in the code for the parameters */
+ PUT_BLOCK(ip, (yyvsp[(3) - (4)].pblock));
+ }
+
+ FREE_PBLOCK((yyvsp[(3) - (4)].pblock));
+
+ /* Store the instruction */
+ PUT_OPCODE(ip, OP_FUNC);
+ PUT_EVENT(ip,(yyvsp[(1) - (4)].eSymbol)->index); //Put event/function index
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 199:
+
+/* Line 1806 of yacc.c */
+#line 4929 "script_parser.ypp"
+ {
+ RULE("boolexp: BOOL_VAR");
+
+ codeRet = scriptCodeVarGet((yyvsp[(1) - (1)].vSymbol), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 200:
+
+/* Line 1806 of yacc.c */
+#line 4939 "script_parser.ypp"
+ {
+ RULE("boolexp: BOOL_CONSTANT");
+
+ codeRet = scriptCodeConstant((yyvsp[(1) - (1)].cSymbol), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 201:
+
+/* Line 1806 of yacc.c */
+#line 4949 "script_parser.ypp"
+ {
+ codeRet = scriptCodeObjGet((yyvsp[(1) - (1)].objVarBlock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 202:
+
+/* Line 1806 of yacc.c */
+#line 4957 "script_parser.ypp"
+ {
+ codeRet = scriptCodeArrayGet((yyvsp[(1) - (1)].arrayBlock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 203:
+
+/* Line 1806 of yacc.c */
+#line 4965 "script_parser.ypp"
+ {
+ RULE("boolexp: BOOLEAN_T");
+
+ //ALLOC_BLOCK(psCurrBlock, sizeof(OPCODE) + sizeof(UDWORD));
+ ALLOC_BLOCK(psCurrBlock, 1 + 1); //opcode + value
+ ip = psCurrBlock->pCode;
+
+ /* Code to store the value on the stack */
+ PUT_PKOPCODE(ip, OP_PUSH, VAL_BOOL);
+ PUT_DATA_BOOL(ip, (yyvsp[(1) - (1)].bval));
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 204:
+
+/* Line 1806 of yacc.c */
+#line 4980 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_EQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 205:
+
+/* Line 1806 of yacc.c */
+#line 4988 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_EQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 206:
+
+/* Line 1806 of yacc.c */
+#line 4996 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_EQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 207:
+
+/* Line 1806 of yacc.c */
+#line 5004 "script_parser.ypp"
+ {
+ if (!interpCheckEquiv((yyvsp[(1) - (3)].cblock)->type,(yyvsp[(3) - (3)].cblock)->type))
+ {
+ scr_error("Type mismatch for equality");
+ YYABORT;
+ }
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_EQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 208:
+
+/* Line 1806 of yacc.c */
+#line 5017 "script_parser.ypp"
+ {
+ if (!interpCheckEquiv((yyvsp[(1) - (3)].cblock)->type,(yyvsp[(3) - (3)].cblock)->type))
+ {
+ scr_error("Type mismatch for equality");
+ YYABORT;
+ }
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_EQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 209:
+
+/* Line 1806 of yacc.c */
+#line 5030 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_NOTEQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 210:
+
+/* Line 1806 of yacc.c */
+#line 5038 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_NOTEQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 211:
+
+/* Line 1806 of yacc.c */
+#line 5046 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_NOTEQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 212:
+
+/* Line 1806 of yacc.c */
+#line 5054 "script_parser.ypp"
+ {
+ if (!interpCheckEquiv((yyvsp[(1) - (3)].cblock)->type,(yyvsp[(3) - (3)].cblock)->type))
+ {
+ scr_error("Type mismatch for inequality");
+ YYABORT;
+ }
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_NOTEQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 213:
+
+/* Line 1806 of yacc.c */
+#line 5067 "script_parser.ypp"
+ {
+ if (!interpCheckEquiv((yyvsp[(1) - (3)].cblock)->type,(yyvsp[(3) - (3)].cblock)->type))
+ {
+ scr_error("Type mismatch for inequality");
+ YYABORT;
+ }
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_NOTEQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 214:
+
+/* Line 1806 of yacc.c */
+#line 5080 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_LESSEQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 215:
+
+/* Line 1806 of yacc.c */
+#line 5088 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_LESSEQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 216:
+
+/* Line 1806 of yacc.c */
+#line 5096 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_GREATEREQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 217:
+
+/* Line 1806 of yacc.c */
+#line 5104 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_GREATEREQUAL, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 218:
+
+/* Line 1806 of yacc.c */
+#line 5112 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_GREATER, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 219:
+
+/* Line 1806 of yacc.c */
+#line 5120 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_GREATER, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 220:
+
+/* Line 1806 of yacc.c */
+#line 5128 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_LESS, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 221:
+
+/* Line 1806 of yacc.c */
+#line 5136 "script_parser.ypp"
+ {
+ codeRet = scriptCodeBinaryOperator((yyvsp[(1) - (3)].cblock), (yyvsp[(3) - (3)].cblock), OP_LESS, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 222:
+
+/* Line 1806 of yacc.c */
+#line 5151 "script_parser.ypp"
+ {
+ codeRet = scriptCodeVarGet((yyvsp[(1) - (1)].vSymbol), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 223:
+
+/* Line 1806 of yacc.c */
+#line 5159 "script_parser.ypp"
+ {
+ RULE("userexp: USER_CONSTANT");
+
+ codeRet = scriptCodeConstant((yyvsp[(1) - (1)].cSymbol), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 224:
+
+/* Line 1806 of yacc.c */
+#line 5169 "script_parser.ypp"
+ {
+ codeRet = scriptCodeObjGet((yyvsp[(1) - (1)].objVarBlock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 225:
+
+/* Line 1806 of yacc.c */
+#line 5176 "script_parser.ypp"
+ {
+ RULE("userexp: user_array_var");
+
+ codeRet = scriptCodeArrayGet((yyvsp[(1) - (1)].arrayBlock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 226:
+
+/* Line 1806 of yacc.c */
+#line 5186 "script_parser.ypp"
+ {
+ /* Generate the code for the function call */
+ codeRet = scriptCodeFunction((yyvsp[(1) - (4)].fSymbol), (yyvsp[(3) - (4)].pblock), true, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 227:
+
+/* Line 1806 of yacc.c */
+#line 5195 "script_parser.ypp"
+ {
+ UDWORD line,paramNumber;
+ char *pDummy;
+
+ if((yyvsp[(3) - (4)].pblock)->numParams != (yyvsp[(1) - (4)].eSymbol)->numParams)
+ {
+ debug(LOG_ERROR, "Wrong number of arguments for function call: '%s'. Expected %d parameters instead of %d.", (yyvsp[(1) - (4)].eSymbol)->pIdent, (yyvsp[(1) - (4)].eSymbol)->numParams, (yyvsp[(3) - (4)].pblock)->numParams);
+ scr_error("Wrong number of arguments in function call");
+ return CE_PARSE;
+ }
+
+ if(!(yyvsp[(1) - (4)].eSymbol)->bFunction)
+ {
+ debug(LOG_ERROR, "'%s' is not a function", (yyvsp[(1) - (4)].eSymbol)->pIdent);
+ scr_error("Can't call an event");
+ return CE_PARSE;
+ }
+
+ /* check if right parameters were passed */
+ paramNumber = checkFuncParamTypes((yyvsp[(1) - (4)].eSymbol), (yyvsp[(3) - (4)].pblock));
+ if(paramNumber > 0)
+ {
+ debug(LOG_ERROR, "Parameter mismatch in function call: '%s'. Mismatch in parameter %d.", (yyvsp[(1) - (4)].eSymbol)->pIdent, paramNumber);
+ YYABORT;
+ }
+
+ /* Allocate the code block */
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(3) - (4)].pblock)->size + 1 + 1); //Params + Opcode + event index
+
+ ALLOC_DEBUG(psCurrBlock, 1);
+ ip = psCurrBlock->pCode;
+
+ if((yyvsp[(3) - (4)].pblock)->numParams > 0) /* if any parameters declared */
+ {
+ /* Copy in the code for the parameters */
+ PUT_BLOCK(ip, (yyvsp[(3) - (4)].pblock));
+ FREE_PBLOCK((yyvsp[(3) - (4)].pblock));
+ }
+
+ /* Store the instruction */
+ PUT_OPCODE(ip, OP_FUNC);
+ PUT_EVENT(ip,(yyvsp[(1) - (4)].eSymbol)->index); //Put event index
+
+ /* Add the debugging information */
+ if (genDebugInfo)
+ {
+ psCurrBlock->psDebug[0].offset = 0;
+ scriptGetErrorData((SDWORD *)&line, &pDummy);
+ psCurrBlock->psDebug[0].line = line;
+ }
+
+ /* remember objexp type for further stuff, like myVar = objFunc(); to be able to check type equivalency */
+ psCurrBlock->type = (yyvsp[(1) - (4)].eSymbol)->retType;
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 228:
+
+/* Line 1806 of yacc.c */
+#line 5252 "script_parser.ypp"
+ {
+ //ALLOC_BLOCK(psCurrBlock, sizeof(OPCODE) + sizeof(UDWORD));
+ ALLOC_BLOCK(psCurrBlock, 1 + 1); //opcode + trigger index
+
+ ip = psCurrBlock->pCode;
+
+ /* Code to store the value on the stack */
+ PUT_PKOPCODE(ip, OP_PUSH, VAL_TRIGGER); //TODO: don't need to put VAL_TRIGGER here, since stored in ip->type now
+ PUT_TRIGGER(ip, (yyvsp[(1) - (1)].tSymbol)->index);
+
+ psCurrBlock->type = VAL_TRIGGER;
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 229:
+
+/* Line 1806 of yacc.c */
+#line 5268 "script_parser.ypp"
+ {
+ //ALLOC_BLOCK(psCurrBlock, sizeof(OPCODE) + sizeof(UDWORD));
+ ALLOC_BLOCK(psCurrBlock, 1 + 1); //opcode + '-1' for 'inactive'
+
+ ip = psCurrBlock->pCode;
+
+ /* Code to store the value on the stack */
+ PUT_PKOPCODE(ip, OP_PUSH, VAL_TRIGGER);
+ PUT_TRIGGER(ip, -1);
+
+ psCurrBlock->type = VAL_TRIGGER;
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 230:
+
+/* Line 1806 of yacc.c */
+#line 5284 "script_parser.ypp"
+ {
+ //ALLOC_BLOCK(psCurrBlock, sizeof(OPCODE) + sizeof(UDWORD));
+ ALLOC_BLOCK(psCurrBlock, 1 + 1); //opcode + event index
+
+ ip = psCurrBlock->pCode;
+
+ /* Code to store the value on the stack */
+ PUT_PKOPCODE(ip, OP_PUSH, VAL_EVENT);
+ PUT_EVENT(ip, (yyvsp[(1) - (1)].eSymbol)->index);
+
+ psCurrBlock->type = VAL_EVENT;
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 231:
+
+/* Line 1806 of yacc.c */
+#line 5307 "script_parser.ypp"
+ {
+ codeRet = scriptCodeVarGet((yyvsp[(1) - (1)].vSymbol), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 232:
+
+/* Line 1806 of yacc.c */
+#line 5315 "script_parser.ypp"
+ {
+ RULE("objexp: OBJ_CONSTANT");
+
+ codeRet = scriptCodeConstant((yyvsp[(1) - (1)].cSymbol), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 233:
+
+/* Line 1806 of yacc.c */
+#line 5325 "script_parser.ypp"
+ {
+ /* Generate the code for the function call */
+ codeRet = scriptCodeFunction((yyvsp[(1) - (4)].fSymbol), (yyvsp[(3) - (4)].pblock), true, &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 234:
+
+/* Line 1806 of yacc.c */
+#line 5334 "script_parser.ypp"
+ {
+ UDWORD paramNumber;
+
+ if((yyvsp[(3) - (4)].pblock)->numParams != (yyvsp[(1) - (4)].eSymbol)->numParams)
+ {
+ debug(LOG_ERROR, "Wrong number of arguments for function call: '%s'. Expected %d parameters instead of %d.", (yyvsp[(1) - (4)].eSymbol)->pIdent, (yyvsp[(1) - (4)].eSymbol)->numParams, (yyvsp[(3) - (4)].pblock)->numParams);
+ scr_error("Wrong number of arguments in function call");
+ return CE_PARSE;
+ }
+
+ if(!(yyvsp[(1) - (4)].eSymbol)->bFunction)
+ {
+ debug(LOG_ERROR, "'%s' is not a function", (yyvsp[(1) - (4)].eSymbol)->pIdent);
+ scr_error("Can't call an event");
+ return CE_PARSE;
+ }
+
+ /* make sure function has a return type */
+ /* if($1->retType != OBJ_VAR) */
+ if(asScrTypeTab[(yyvsp[(1) - (4)].eSymbol)->retType - VAL_USERTYPESTART].accessType != AT_OBJECT)
+ {
+ scr_error("'%s' does not return an object value (%d )", (yyvsp[(1) - (4)].eSymbol)->pIdent, (yyvsp[(1) - (4)].eSymbol)->retType);
+ return CE_PARSE;
+ }
+
+ /* check if right parameters were passed */
+ paramNumber = checkFuncParamTypes((yyvsp[(1) - (4)].eSymbol), (yyvsp[(3) - (4)].pblock));
+ if(paramNumber > 0)
+ {
+ debug(LOG_ERROR, "Parameter mismatch in function call: '%s'. Mismatch in parameter %d.", (yyvsp[(1) - (4)].eSymbol)->pIdent, paramNumber);
+ YYABORT;
+ }
+
+ /* Allocate the code block */
+ ALLOC_BLOCK(psCurrBlock, (yyvsp[(3) - (4)].pblock)->size + 1 + 1); //Params + Opcode + event index
+
+ ip = psCurrBlock->pCode;
+
+ if((yyvsp[(3) - (4)].pblock)->numParams > 0) /* if any parameters declared */
+ {
+ /* Copy in the code for the parameters */
+ PUT_BLOCK(ip, (yyvsp[(3) - (4)].pblock));
+ }
+
+ FREE_PBLOCK((yyvsp[(3) - (4)].pblock));
+
+ /* Store the instruction */
+ PUT_OPCODE(ip, OP_FUNC);
+ PUT_EVENT(ip,(yyvsp[(1) - (4)].eSymbol)->index); //Put event index
+
+ /* remember objexp type for further stuff, like myVar = objFunc(); to be able to check type equivalency */
+ psCurrBlock->type = (yyvsp[(1) - (4)].eSymbol)->retType;
+
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 235:
+
+/* Line 1806 of yacc.c */
+#line 5390 "script_parser.ypp"
+ {
+ codeRet = scriptCodeObjGet((yyvsp[(1) - (1)].objVarBlock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 236:
+
+/* Line 1806 of yacc.c */
+#line 5398 "script_parser.ypp"
+ {
+ codeRet = scriptCodeArrayGet((yyvsp[(1) - (1)].arrayBlock), &psCurrBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.cblock) = psCurrBlock;
+ }
+ break;
+
+ case 237:
+
+/* Line 1806 of yacc.c */
+#line 5412 "script_parser.ypp"
+ {
+ RULE( "objexp_dot: objexp '.', type=%d", (yyvsp[(1) - (2)].cblock)->type);
+
+ // Store the object type for the variable lookup
+ objVarContext = (yyvsp[(1) - (2)].cblock)->type;
+ }
+ break;
+
+ case 238:
+
+/* Line 1806 of yacc.c */
+#line 5420 "script_parser.ypp"
+ {
+ RULE( "objexp_dot: userexp '.', type=%d", (yyvsp[(1) - (2)].cblock)->type);
+
+ // Store the object type for the variable lookup
+ objVarContext = (yyvsp[(1) - (2)].cblock)->type;
+ }
+ break;
+
+ case 239:
+
+/* Line 1806 of yacc.c */
+#line 5433 "script_parser.ypp"
+ {
+
+ RULE( "num_objvar: objexp_dot NUM_OBJVAR");
+
+ codeRet = scriptCodeObjectVariable((yyvsp[(1) - (2)].cblock), (yyvsp[(2) - (2)].vSymbol), &psObjVarBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ // reset the object type
+ objVarContext = (INTERP_TYPE)0;
+
+ /* Return the code block */
+ (yyval.objVarBlock) = psObjVarBlock;
+ }
+ break;
+
+ case 240:
+
+/* Line 1806 of yacc.c */
+#line 5449 "script_parser.ypp"
+ {
+ codeRet = scriptCodeObjectVariable((yyvsp[(1) - (2)].cblock), (yyvsp[(2) - (2)].vSymbol), &psObjVarBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ // reset the object type
+ objVarContext = (INTERP_TYPE)0;
+
+ /* Return the code block */
+ (yyval.objVarBlock) = psObjVarBlock;
+ }
+ break;
+
+ case 241:
+
+/* Line 1806 of yacc.c */
+#line 5462 "script_parser.ypp"
+ {
+ codeRet = scriptCodeObjectVariable((yyvsp[(1) - (2)].cblock), (yyvsp[(2) - (2)].vSymbol), &psObjVarBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ // reset the object type
+ objVarContext = (INTERP_TYPE)0;
+
+ /* Return the code block */
+ (yyval.objVarBlock) = psObjVarBlock;
+ }
+ break;
+
+ case 242:
+
+/* Line 1806 of yacc.c */
+#line 5474 "script_parser.ypp"
+ {
+ codeRet = scriptCodeObjectVariable((yyvsp[(1) - (2)].cblock), (yyvsp[(2) - (2)].vSymbol), &psObjVarBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ // reset the object type
+ objVarContext = (INTERP_TYPE)0;
+
+ /* Return the code block */
+ (yyval.objVarBlock) = psObjVarBlock;
+ }
+ break;
+
+ case 243:
+
+/* Line 1806 of yacc.c */
+#line 5493 "script_parser.ypp"
+ {
+ ALLOC_ARRAYBLOCK(psCurrArrayBlock, (yyvsp[(2) - (3)].cblock)->size, NULL);
+ ip = psCurrArrayBlock->pCode;
+
+ /* Copy the index expression code into the code block */
+ PUT_BLOCK(ip, (yyvsp[(2) - (3)].cblock));
+ FREE_BLOCK((yyvsp[(2) - (3)].cblock));
+
+ (yyval.arrayBlock) = psCurrArrayBlock;
+ }
+ break;
+
+ case 244:
+
+/* Line 1806 of yacc.c */
+#line 5506 "script_parser.ypp"
+ {
+ (yyval.arrayBlock) = (yyvsp[(1) - (1)].arrayBlock);
+ }
+ break;
+
+ case 245:
+
+/* Line 1806 of yacc.c */
+#line 5511 "script_parser.ypp"
+ {
+ ALLOC_ARRAYBLOCK(psCurrArrayBlock, (yyvsp[(1) - (4)].arrayBlock)->size + (yyvsp[(3) - (4)].cblock)->size, NULL);
+
+ ip = psCurrArrayBlock->pCode;
+
+ /* Copy the index expression code into the code block */
+ psCurrArrayBlock->dimensions = (yyvsp[(1) - (4)].arrayBlock)->dimensions + 1;
+ PUT_BLOCK(ip, (yyvsp[(1) - (4)].arrayBlock));
+ PUT_BLOCK(ip, (yyvsp[(3) - (4)].cblock));
+ FREE_ARRAYBLOCK((yyvsp[(1) - (4)].arrayBlock));
+ FREE_ARRAYBLOCK((yyvsp[(3) - (4)].cblock));
+
+ (yyval.arrayBlock) = psCurrArrayBlock;
+ }
+ break;
+
+ case 246:
+
+/* Line 1806 of yacc.c */
+#line 5528 "script_parser.ypp"
+ {
+ codeRet = scriptCodeArrayVariable((yyvsp[(2) - (2)].arrayBlock), (yyvsp[(1) - (2)].vSymbol), &psCurrArrayBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.arrayBlock) = psCurrArrayBlock;
+ }
+ break;
+
+ case 247:
+
+/* Line 1806 of yacc.c */
+#line 5538 "script_parser.ypp"
+ {
+ codeRet = scriptCodeArrayVariable((yyvsp[(2) - (2)].arrayBlock), (yyvsp[(1) - (2)].vSymbol), &psCurrArrayBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.arrayBlock) = psCurrArrayBlock;
+ }
+ break;
+
+ case 248:
+
+/* Line 1806 of yacc.c */
+#line 5548 "script_parser.ypp"
+ {
+ codeRet = scriptCodeArrayVariable((yyvsp[(2) - (2)].arrayBlock), (yyvsp[(1) - (2)].vSymbol), &psCurrArrayBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.arrayBlock) = psCurrArrayBlock;
+ }
+ break;
+
+ case 249:
+
+/* Line 1806 of yacc.c */
+#line 5558 "script_parser.ypp"
+ {
+ RULE("user_array_var: VAR_ARRAY array_index_list");
+
+ codeRet = scriptCodeArrayVariable((yyvsp[(2) - (2)].arrayBlock), (yyvsp[(1) - (2)].vSymbol), &psCurrArrayBlock);
+ CHECK_CODE_ERROR(codeRet);
+
+ /* Return the code block */
+ (yyval.arrayBlock) = psCurrArrayBlock;
+ }
+ break;
+
+
+
+/* Line 1806 of yacc.c */
+#line 8600 "script_parser.cpp"
+ default: break;
+ }
+ /* User semantic actions sometimes alter yychar, and that requires
+ that yytoken be updated with the new translation. We take the
+ approach of translating immediately before every use of yytoken.
+ One alternative is translating here after every semantic action,
+ but that translation would be missed if the semantic action invokes
+ YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
+ if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
+ incorrect destructor might then be invoked immediately. In the
+ case of YYERROR or YYBACKUP, subsequent parser actions might lead
+ to an incorrect destructor call or verbose syntax error message
+ before the lookahead is translated. */
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
+
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+
+ *++yyvsp = yyval;
+
+ /* Now `shift' the result of the reduction. Determine what state
+ that goes to, based on the state we popped back to and the rule
+ number reduced by. */
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTOKENS];
+
+ goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
+
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus)
+ {
+ ++yynerrs;
+#if ! YYERROR_VERBOSE
+ yyerror (YY_("syntax error"));
+#else
+# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
+ yyssp, yytoken)
+ {
+ char const *yymsgp = YY_("syntax error");
+ int yysyntax_error_status;
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ if (yysyntax_error_status == 0)
+ yymsgp = yymsg;
+ else if (yysyntax_error_status == 1)
+ {
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+ yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
+ if (!yymsg)
+ {
+ yymsg = yymsgbuf;
+ yymsg_alloc = sizeof yymsgbuf;
+ yysyntax_error_status = 2;
+ }
+ else
+ {
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ yymsgp = yymsg;
+ }
+ }
+ yyerror (yymsgp);
+ if (yysyntax_error_status == 2)
+ goto yyexhaustedlab;
+ }
+# undef YYSYNTAX_ERROR
+#endif
+ }
+
+
+
+ if (yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ if (yychar <= YYEOF)
+ {
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ YYABORT;
+ }
+ else
+ {
+ yydestruct ("Error: discarding",
+ yytoken, &yylval);
+ yychar = YYEMPTY;
+ }
+ }
+
+ /* Else will try to reuse lookahead token after shifting the error
+ token. */
+ goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR. |
+`---------------------------------------------------*/
+yyerrorlab:
+
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label yyerrorlab therefore never appears in user
+ code. */
+ if (/*CONSTCOND*/ 0)
+ goto yyerrorlab;
+
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYERROR. */
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+ yystate = *yyssp;
+ goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR. |
+`-------------------------------------------------------------*/
+yyerrlab1:
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
+
+ for (;;)
+ {
+ yyn = yypact[yystate];
+ if (!yypact_value_is_default (yyn))
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yyssp == yyss)
+ YYABORT;
+
+
+ yydestruct ("Error: popping",
+ yystos[yystate], yyvsp);
+ YYPOPSTACK (1);
+ yystate = *yyssp;
+ YY_STACK_PRINT (yyss, yyssp);
+ }
+
+ *++yyvsp = yylval;
+
+
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+#if !defined(yyoverflow) || YYERROR_VERBOSE
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here. |
+`-------------------------------------------------*/
+yyexhaustedlab:
+ yyerror (YY_("memory exhausted"));
+ yyresult = 2;
+ /* Fall through. */
+#endif
+
+yyreturn:
+ if (yychar != YYEMPTY)
+ {
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = YYTRANSLATE (yychar);
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval);
+ }
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYABORT or YYACCEPT. */
+ YYPOPSTACK (yylen);
+ YY_STACK_PRINT (yyss, yyssp);
+ while (yyssp != yyss)
+ {
+ yydestruct ("Cleanup: popping",
+ yystos[*yyssp], yyvsp);
+ YYPOPSTACK (1);
+ }
+#ifndef yyoverflow
+ if (yyss != yyssa)
+ YYSTACK_FREE (yyss);
+#endif
+#if YYERROR_VERBOSE
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+#endif
+ /* Make sure YYID is used. */
+ return YYID (yyresult);
+}
+
+
+
+/* Line 2067 of yacc.c */
+#line 5569 "script_parser.ypp"
+
+
+// Reset all the symbol tables
+static void scriptResetTables(void)
+{
+ VAR_SYMBOL *psCurr, *psNext;
+ TRIGGER_SYMBOL *psTCurr, *psTNext;
+ EVENT_SYMBOL *psECurr, *psENext;
+
+ SDWORD i;
+
+ /* start with global vars definition */
+ localVariableDef = false;
+ //debug(LOG_SCRIPT, "localVariableDef = false 4");
+
+ /* Reset the global variable symbol table */
+ for(psCurr = psGlobalVars; psCurr != NULL; psCurr = psNext)
+ {
+ psNext = psCurr->psNext;
+ free(psCurr);
+ }
+ psGlobalVars = NULL;
+
+ /* Reset the global variable symbol table */
+ psCurEvent = NULL;
+ for(i=0; ipsNext;
+ free(psCurr);
+ }
+ psLocalVarsB[i] = NULL;
+ }
+
+ /* Reset the global array symbol table */
+ for(psCurr = psGlobalArrays; psCurr != NULL; psCurr = psNext)
+ {
+ psNext = psCurr->psNext;
+ free(psCurr);
+ }
+ psGlobalArrays = NULL;
+
+ // Reset the trigger table
+ for(psTCurr = psTriggers; psTCurr; psTCurr = psTNext)
+ {
+ psTNext = psTCurr->psNext;
+ if (psTCurr->psDebug)
+ {
+ free(psTCurr->psDebug);
+ }
+ if (psTCurr->pCode)
+ {
+ free(psTCurr->pCode);
+ }
+ free(psTCurr->pIdent);
+ free(psTCurr);
+ }
+ psTriggers = NULL;
+ numTriggers = 0;
+
+ // Reset the event table
+ for(psECurr = psEvents; psECurr; psECurr = psENext)
+ {
+ psENext = psECurr->psNext;
+ if (psECurr->psDebug)
+ {
+ free(psECurr->psDebug);
+ }
+ free(psECurr->pIdent);
+ free(psECurr->pCode);
+ free(psECurr);
+ }
+ psEvents = NULL;
+ numEvents = 0;
+}
+
+/* Compile a script program */
+SCRIPT_CODE* scriptCompile(PHYSFS_file* fileHandle, SCR_DEBUGTYPE debugType)
+{
+ /* Feed flex with initial input buffer */
+ scriptSetInputFile(fileHandle);
+
+ scriptResetTables();
+ psFinalProg = NULL;
+ if (debugType == SCR_DEBUGINFO)
+ {
+ genDebugInfo = true;
+ }
+ else
+ {
+ genDebugInfo = false;
+ }
+
+ if (scr_parse() != 0 || bError)
+ {
+ scr_lex_destroy();
+ return NULL;
+ }
+ scr_lex_destroy();
+
+ scriptResetTables();
+
+ return psFinalProg;
+}
+
+
+/* A simple error reporting routine */
+void scr_error(const char *pMessage, ...)
+{
+ int line;
+ char *text;
+ va_list args;
+ char aBuff[1024];
+
+ va_start(args, pMessage);
+ vsnprintf(aBuff, sizeof(aBuff), pMessage, args);
+ va_end(args);
+
+ scriptGetErrorData(&line, &text);
+
+ bError = true;
+
+#ifdef DEBUG
+ debug( LOG_ERROR, "script parse error:\n%s at %s:%d\nToken: %d, Text: '%s'\n",
+ aBuff, GetLastResourceFilename(), line, scr_char, text );
+ ASSERT( false, "script parse error:\n%s at %s:%d\nToken: %d, Text: '%s'\n",
+ aBuff, GetLastResourceFilename(), line, scr_char, text );
+#else
+ //DBERROR(("script parse error:\n%s at line %d\nToken: %d, Text: '%s'\n",
+ // pMessage, line, scr_char, text));
+ debug( LOG_ERROR, "script parse error:\n'%s' at %s:%d\nToken: %d, Text: '%s'\n",
+ aBuff, GetLastResourceFilename(), line, scr_char, text );
+ abort();
+#endif
+}
+
+
+/* Look up a type symbol */
+bool scriptLookUpType(const char *pIdent, INTERP_TYPE *pType)
+{
+ UDWORD i;
+
+ //debug(LOG_SCRIPT, "scriptLookUpType");
+
+ if (asScrTypeTab)
+ {
+ for(i=0; asScrTypeTab[i].typeID != 0; i++)
+ {
+ if (strcmp(asScrTypeTab[i].pIdent, pIdent) == 0)
+ {
+ *pType = asScrTypeTab[i].typeID;
+ return true;
+ }
+ }
+ }
+
+ //debug(LOG_SCRIPT, "END scriptLookUpType");
+
+ return false;
+}
+
+/* pop passed arguments (if any) */
+bool popArguments(INTERP_VAL **ip_temp, SDWORD numParams)
+{
+ SDWORD i;
+
+ /* code to pop passed params right before the main code begins */
+ for(i = numParams-1; i >= 0 ; i--)
+ {
+ PUT_PKOPCODE(*ip_temp, OP_POPLOCAL, i); //pop parameters into first i local params
+ }
+
+ return true;
+}
+
+
+/* Add a new variable symbol.
+ * If localVariableDef is true a local variable symbol is defined,
+ * otherwise a global variable symbol is defined.
+ */
+bool scriptAddVariable(VAR_DECL *psStorage, VAR_IDENT_DECL *psVarIdent)
+{
+ VAR_SYMBOL *psNew;
+ unsigned int i;
+ char* ident;
+
+ /* Allocate the memory for the symbol structure plus the symbol name */
+ psNew = (VAR_SYMBOL *)malloc(sizeof(VAR_SYMBOL) + strlen(psVarIdent->pIdent) + 1);
+ if (psNew == NULL)
+ {
+ scr_error("Out of memory");
+ return false;
+ }
+
+ // This ensures we only need to call free() on the VAR_SYMBOL* pointer and not on its members
+ ident = (char*)(psNew + 1);
+ strcpy(ident, psVarIdent->pIdent);
+ psNew->pIdent = ident;
+
+ psNew->type = psStorage->type;
+ psNew->storage = psStorage->storage;
+ psNew->dimensions = psVarIdent->dimensions;
+
+
+ for(i=0; idimensions; i++)
+ {
+ psNew->elements[i] = psVarIdent->elements[i];
+ }
+ if (psNew->dimensions == 0)
+ {
+ if(psStorage->storage != ST_LOCAL) //if not a local var
+ {
+ if (psGlobalVars == NULL)
+ {
+ psNew->index = 0;
+ }
+ else
+ {
+ psNew->index = psGlobalVars->index + 1;
+ }
+
+ /* Add the symbol to the list */
+ psNew->psNext = psGlobalVars;
+ psGlobalVars = psNew;
+ }
+ else //local var
+ {
+ if(psCurEvent == NULL)
+ debug(LOG_ERROR, "Can't declare local variables before defining an event");
+
+ //debug(LOG_SCRIPT, "local variable declared for event %d, type=%d \n", psCurEvent->index, psNew->type);
+ //debug(LOG_SCRIPT, "%s \n", psNew->pIdent);
+
+ if (psLocalVarsB[psCurEvent->index] == NULL)
+ {
+ psNew->index = 0;
+ }
+ else
+ {
+ psNew->index = psLocalVarsB[psCurEvent->index]->index + 1;
+ }
+
+ numEventLocalVars[psCurEvent->index] = numEventLocalVars[psCurEvent->index] + 1;
+
+ psNew->psNext = psLocalVarsB[psCurEvent->index];
+ psLocalVarsB[psCurEvent->index] = psNew;
+
+ //debug(LOG_SCRIPT, "local variable declared. ");
+ }
+ }
+ else
+ {
+ if (psGlobalArrays == NULL)
+ {
+ psNew->index = 0;
+ }
+ else
+ {
+ psNew->index = psGlobalArrays->index + 1;
+ }
+
+ psNew->psNext = psGlobalArrays;
+ psGlobalArrays = psNew;
+ }
+
+
+ return true;
+}
+
+/* Look up a variable symbol */
+bool scriptLookUpVariable(const char *pIdent, VAR_SYMBOL **ppsSym)
+{
+ VAR_SYMBOL *psCurr;
+ UDWORD i;
+
+ //debug(LOG_SCRIPT, "scriptLookUpVariable");
+
+ /* See if the symbol is an object variable */
+ if (asScrObjectVarTab && objVarContext != 0)
+ {
+ for(psCurr = asScrObjectVarTab; psCurr->pIdent != NULL; psCurr++)
+ {
+ if (interpCheckEquiv((INTERP_TYPE)psCurr->objType, objVarContext) &&
+ strcmp(psCurr->pIdent, pIdent) == 0)
+ {
+ *ppsSym = psCurr;
+ return true;
+ }
+ }
+ }
+
+ /* See if the symbol is an external variable */
+ if (asScrExternalTab)
+ {
+ for(psCurr = asScrExternalTab; psCurr->pIdent != NULL; psCurr++)
+ {
+ if (strcmp(psCurr->pIdent, pIdent) == 0)
+ {
+ //debug(LOG_SCRIPT, "scriptLookUpVariable: extern");
+ *ppsSym = psCurr;
+ return true;
+ }
+ }
+ }
+
+ /* check local vars if we are inside of an event */
+ if(psCurEvent != NULL)
+ {
+ if(psCurEvent->index >= maxEventsLocalVars)
+ debug(LOG_ERROR, "psCurEvent->index (%d) >= maxEventsLocalVars", psCurEvent->index);
+
+ i = psCurEvent->index;
+
+ if(psLocalVarsB[i] != NULL) //any vars stored for this event
+ {
+ int line;
+ char *text;
+
+ //debug(LOG_SCRIPT, "now checking event %s; index = %d\n", psCurEvent->pIdent, psCurEvent->index);
+ scriptGetErrorData(&line, &text);
+ for(psCurr = psLocalVarsB[i]; psCurr != NULL; psCurr = psCurr->psNext)
+ {
+
+ if(psCurr->pIdent == NULL)
+ {
+ debug(LOG_ERROR, "psCurr->pIdent == NULL");
+ debug(LOG_ERROR, "psCurr->index = %d", psCurr->index);
+ }
+
+ //debug(LOG_SCRIPT, "start comparing, num local vars=%d, at line %d\n", numEventLocalVars[i], line);
+ //debug(LOG_SCRIPT, "current var=%s\n", psCurr->pIdent);
+ //debug(LOG_SCRIPT, "passed string=%s\n", pIdent);
+
+ //debug(LOG_SCRIPT, "comparing %s with %s \n", psCurr->pIdent, pIdent);
+ if (strcmp(psCurr->pIdent, pIdent) == 0)
+ {
+ //debug(LOG_SCRIPT, "scriptLookUpVariable - local var found, type=%d\n", psCurr->type);
+ *ppsSym = psCurr;
+ return true;
+ }
+ }
+ }
+ }
+
+ /* See if the symbol is in the global variable list.
+ * This is not checked for when local variables are being defined.
+ * This allows local variables to have the same name as global ones.
+ */
+ if (!localVariableDef)
+ {
+ for(psCurr = psGlobalVars; psCurr != NULL; psCurr = psCurr->psNext)
+ {
+ if (strcmp(psCurr->pIdent, pIdent) == 0)
+ {
+ *ppsSym = psCurr;
+ return true;
+ }
+ }
+ for(psCurr = psGlobalArrays; psCurr != NULL; psCurr = psCurr->psNext)
+ {
+ if (strcmp(psCurr->pIdent, pIdent) == 0)
+ {
+ *ppsSym = psCurr;
+ return true;
+ }
+ }
+ }
+
+ /* Failed to find the variable */
+ *ppsSym = NULL;
+
+ //debug(LOG_SCRIPT, "END scriptLookUpVariable");
+ return false;
+}
+
+
+/* Add a new trigger symbol */
+bool scriptAddTrigger(const char *pIdent, TRIGGER_DECL *psDecl, UDWORD line)
+{
+ TRIGGER_SYMBOL *psTrigger, *psCurr, *psPrev;
+
+ // Allocate the trigger
+ psTrigger = (TRIGGER_SYMBOL *)malloc(sizeof(TRIGGER_SYMBOL));
+ if (!psTrigger)
+ {
+ scr_error("Out of memory");
+ return false;
+ }
+ psTrigger->pIdent = (char *)malloc(strlen(pIdent) + 1);
+ if (!psTrigger->pIdent)
+ {
+ scr_error("Out of memory");
+ return false;
+ }
+ strcpy(psTrigger->pIdent, pIdent);
+ if (psDecl->size > 0)
+ {
+ psTrigger->pCode = (INTERP_VAL *)malloc(psDecl->size * sizeof(INTERP_VAL));
+ if (!psTrigger->pCode)
+ {
+ scr_error("Out of memory");
+ return false;
+ }
+ memcpy(psTrigger->pCode, psDecl->pCode, psDecl->size * sizeof(INTERP_VAL));
+ }
+ else
+ {
+ psTrigger->pCode = NULL;
+ }
+ psTrigger->size = psDecl->size;
+ psTrigger->type = psDecl->type;
+ psTrigger->time = psDecl->time;
+ psTrigger->index = numTriggers++;
+ psTrigger->psNext = NULL;
+
+ // Add debug info
+ if (genDebugInfo)
+ {
+ psTrigger->psDebug = (SCRIPT_DEBUG *)malloc(sizeof(SCRIPT_DEBUG));
+ psTrigger->psDebug[0].offset = 0;
+ psTrigger->psDebug[0].line = line;
+ psTrigger->debugEntries = 1;
+ }
+ else
+ {
+ psTrigger->debugEntries = 0;
+ psTrigger->psDebug = NULL;
+ }
+
+
+ // Store the trigger
+ psPrev = NULL;
+ for(psCurr = psTriggers; psCurr; psCurr = psCurr->psNext)
+ {
+ psPrev = psCurr;
+ }
+ if (psPrev)
+ {
+ psPrev->psNext = psTrigger;
+ }
+ else
+ {
+ psTriggers = psTrigger;
+ }
+
+ return true;
+}
+
+
+/* Lookup a trigger symbol */
+bool scriptLookUpTrigger(const char *pIdent, TRIGGER_SYMBOL **ppsTrigger)
+{
+ TRIGGER_SYMBOL *psCurr;
+
+ //debug(LOG_SCRIPT, "scriptLookUpTrigger");
+
+ for(psCurr = psTriggers; psCurr; psCurr=psCurr->psNext)
+ {
+ if (strcmp(pIdent, psCurr->pIdent) == 0)
+ {
+ //debug(LOG_SCRIPT, "scriptLookUpTrigger: found");
+ *ppsTrigger = psCurr;
+ return true;
+ }
+ }
+
+ //debug(LOG_SCRIPT, "END scriptLookUpTrigger");
+
+ return false;
+}
+
+
+/* Lookup a callback trigger symbol */
+bool scriptLookUpCallback(const char *pIdent, CALLBACK_SYMBOL **ppsCallback)
+{
+ CALLBACK_SYMBOL *psCurr;
+
+ //debug(LOG_SCRIPT, "scriptLookUpCallback");
+
+ if (!asScrCallbackTab)
+ {
+ return false;
+ }
+
+ for(psCurr = asScrCallbackTab; psCurr->type != 0; psCurr += 1)
+ {
+ if (strcmp(pIdent, psCurr->pIdent) == 0)
+ {
+ //debug(LOG_SCRIPT, "scriptLookUpCallback: found");
+ *ppsCallback = psCurr;
+ return true;
+ }
+ }
+
+ //debug(LOG_SCRIPT, "END scriptLookUpCallback: found");
+ return false;
+}
+
+/* Add a new event symbol */
+bool scriptDeclareEvent(const char *pIdent, EVENT_SYMBOL **ppsEvent, SDWORD numArgs)
+{
+ EVENT_SYMBOL *psEvent, *psCurr, *psPrev;
+
+ // Allocate the event
+ psEvent = (EVENT_SYMBOL *)malloc(sizeof(EVENT_SYMBOL));
+ if (!psEvent)
+ {
+ scr_error("Out of memory");
+ return false;
+ }
+ psEvent->pIdent = (char *)malloc(strlen(pIdent) + 1);
+ if (!psEvent->pIdent)
+ {
+ scr_error("Out of memory");
+ return false;
+ }
+ strcpy(psEvent->pIdent, pIdent);
+ psEvent->pCode = NULL;
+ psEvent->size = 0;
+ psEvent->psDebug = NULL;
+ psEvent->debugEntries = 0;
+ psEvent->index = numEvents++;
+ psEvent->psNext = NULL;
+
+ /* remember how many params this event has */
+ psEvent->numParams = numArgs;
+ psEvent->bFunction = false;
+ psEvent->bDeclared = false;
+ psEvent->retType = VAL_VOID; /* functions can return a value */
+
+ // Add the event to the list
+ psPrev = NULL;
+ for(psCurr = psEvents; psCurr; psCurr = psCurr->psNext)
+ {
+ psPrev = psCurr;
+ }
+ if (psPrev)
+ {
+ psPrev->psNext = psEvent;
+ }
+ else
+ {
+ psEvents = psEvent;
+ }
+
+ *ppsEvent = psEvent;
+
+ return true;
+}
+
+// Add the code to a defined event
+bool scriptDefineEvent(EVENT_SYMBOL *psEvent, CODE_BLOCK *psCode, SDWORD trigger)
+{
+ ASSERT(psCode != NULL, "scriptDefineEvent: psCode == NULL");
+ ASSERT(psCode->size > 0,
+ "Event '%s' is empty, please add at least 1 statement", psEvent->pIdent);
+
+ // events with arguments can't have a trigger assigned
+ ASSERT(!(psEvent->numParams > 0 && trigger >= 0),
+ "Events with parameters can't have a trigger assigned, event: '%s' ", psEvent->pIdent);
+
+ // Store the event code
+ psEvent->pCode = (INTERP_VAL *)malloc(psCode->size * sizeof(INTERP_VAL));
+ if (!psEvent->pCode)
+ {
+ scr_error("Out of memory");
+ return false;
+ }
+
+ memcpy(psEvent->pCode, psCode->pCode, psCode->size * sizeof(INTERP_VAL));
+ psEvent->size = psCode->size;
+ psEvent->trigger = trigger;
+
+ // Add debug info
+ if (genDebugInfo && (psCode->debugEntries > 0))
+ {
+ psEvent->psDebug = (SCRIPT_DEBUG *)malloc(sizeof(SCRIPT_DEBUG) * psCode->debugEntries);
+
+ if (!psEvent->psDebug)
+ {
+ scr_error("Out of memory");
+ return false;
+ }
+
+ memcpy(psEvent->psDebug, psCode->psDebug,
+ sizeof(SCRIPT_DEBUG) * psCode->debugEntries);
+ psEvent->debugEntries = psCode->debugEntries;
+ }
+ else
+ {
+ psEvent->debugEntries = 0;
+ psEvent->psDebug = NULL;
+ }
+
+ //debug(LOG_SCRIPT, "before define event");
+
+ /* store local vars */
+ if(psEvent->index >= maxEventsLocalVars)
+ debug(LOG_ERROR, "scriptDefineEvent - psEvent->index >= maxEventsLocalVars");
+
+ return true;
+}
+
+/* Lookup an event symbol */
+bool scriptLookUpEvent(const char *pIdent, EVENT_SYMBOL **ppsEvent)
+{
+ EVENT_SYMBOL *psCurr;
+ //debug(LOG_SCRIPT, "scriptLookUpEvent");
+
+ for(psCurr = psEvents; psCurr; psCurr=psCurr->psNext)
+ {
+ if (strcmp(pIdent, psCurr->pIdent) == 0)
+ {
+ //debug(LOG_SCRIPT, "scriptLookUpEvent:found");
+ *ppsEvent = psCurr;
+ return true;
+ }
+ }
+ //debug(LOG_SCRIPT, "END scriptLookUpEvent");
+ return false;
+}
+
+
+/* Look up a constant variable symbol */
+bool scriptLookUpConstant(const char *pIdent, CONST_SYMBOL **ppsSym)
+{
+ CONST_SYMBOL *psCurr;
+
+ //debug(LOG_SCRIPT, "scriptLookUpConstant");
+
+ /* Scan the Constant list */
+ if (asScrConstantTab)
+ {
+ for(psCurr = asScrConstantTab; psCurr->type != VAL_VOID; psCurr++)
+ {
+ if (strcmp(psCurr->pIdent, pIdent) == 0)
+ {
+ *ppsSym = psCurr;
+ return true;
+ }
+ }
+ }
+
+ //debug(LOG_SCRIPT, "END scriptLookUpConstant");
+
+ return false;
+}
+
+
+/* Look up a function symbol */
+bool scriptLookUpFunction(const char *pIdent, FUNC_SYMBOL **ppsSym)
+{
+ UDWORD i;
+
+ //debug(LOG_SCRIPT, "scriptLookUpFunction");
+
+ /* See if the function is defined as an instinct function */
+ if (asScrInstinctTab)
+ {
+ for(i = 0; asScrInstinctTab[i].pFunc != NULL; i++)
+ {
+ if (strcmp(asScrInstinctTab[i].pIdent, pIdent) == 0)
+ {
+ *ppsSym = asScrInstinctTab + i;
+ return true;
+ }
+ }
+ }
+
+ /* Failed to find the indentifier */
+ *ppsSym = NULL;
+
+ //debug(LOG_SCRIPT, "END scriptLookUpFunction");
+ return false;
+}
+
+/* Look up a function symbol defined in script */
+bool scriptLookUpCustomFunction(const char *pIdent, EVENT_SYMBOL **ppsSym)
+{
+ EVENT_SYMBOL *psCurr;
+
+ //debug(LOG_SCRIPT, "scriptLookUpCustomFunction");
+
+ /* See if the function is defined as a script function */
+ for(psCurr = psEvents; psCurr; psCurr = psCurr->psNext)
+ {
+ if(psCurr->bFunction) /* event defined as function */
+ {
+ if (strcmp(psCurr->pIdent, pIdent) == 0)
+ {
+ //debug(LOG_SCRIPT, "scriptLookUpCustomFunction: %s is a custom function", pIdent);
+ *ppsSym = psCurr;
+ return true;
+ }
+ }
+ }
+
+ /* Failed to find the indentifier */
+ *ppsSym = NULL;
+
+ //debug(LOG_SCRIPT, "END scriptLookUpCustomFunction");
+ return false;
+}
+
+
+/* Set the type table */
+void scriptSetTypeTab(TYPE_SYMBOL *psTypeTab)
+{
+#ifdef DEBUG
+ SDWORD i;
+ INTERP_TYPE type;
+
+ for(i=0, type=VAL_USERTYPESTART; psTypeTab[i].typeID != 0; i++)
+ {
+ ASSERT( psTypeTab[i].typeID == type,
+ "scriptSetTypeTab: ID's must be >= VAL_USERTYPESTART and sequential" );
+ type = (INTERP_TYPE)(type + 1);
+ }
+#endif
+
+ asScrTypeTab = psTypeTab;
+}
+
+
+/* Set the function table */
+void scriptSetFuncTab(FUNC_SYMBOL *psFuncTab)
+{
+ asScrInstinctTab = psFuncTab;
+}
+
+/* Set the object variable table */
+void scriptSetObjectTab(VAR_SYMBOL *psObjTab)
+{
+ asScrObjectVarTab = psObjTab;
+}
+
+/* Set the external variable table */
+void scriptSetExternalTab(VAR_SYMBOL *psExtTab)
+{
+ asScrExternalTab = psExtTab;
+}
+
+/* Set the constant table */
+void scriptSetConstTab(CONST_SYMBOL *psConstTab)
+{
+ asScrConstantTab = psConstTab;
+}
+
+/* Set the callback table */
+void scriptSetCallbackTab(CALLBACK_SYMBOL *psCallTab)
+{
+#ifdef DEBUG
+ SDWORD i;
+ TRIGGER_TYPE type;
+
+ for(i=0, type=TR_CALLBACKSTART; psCallTab[i].type != 0; i++)
+ {
+ ASSERT( psCallTab[i].type == type,
+ "scriptSetCallbackTab: ID's must be >= VAL_CALLBACKSTART and sequential" );
+ type = (TRIGGER_TYPE)(type + 1);
+ }
+#endif
+
+ asScrCallbackTab = psCallTab;
+}
+
diff --git a/lib/script/script_parser.h b/lib/script/script_parser.h
new file mode 100644
index 000000000..2a7991c5a
--- /dev/null
+++ b/lib/script/script_parser.h
@@ -0,0 +1,227 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ lexFUNCTION = 258,
+ TRIGGER = 259,
+ EVENT = 260,
+ WAIT = 261,
+ EVERY = 262,
+ INACTIVE = 263,
+ INITIALISE = 264,
+ LINK = 265,
+ REF = 266,
+ RET = 267,
+ _VOID = 268,
+ WHILE = 269,
+ IF = 270,
+ ELSE = 271,
+ EXIT = 272,
+ PAUSE = 273,
+ BOOLEQUAL = 274,
+ NOTEQUAL = 275,
+ GREATEQUAL = 276,
+ LESSEQUAL = 277,
+ GREATER = 278,
+ LESS = 279,
+ _AND = 280,
+ _OR = 281,
+ _NOT = 282,
+ _INC = 283,
+ _DEC = 284,
+ TO_INT_CAST = 285,
+ TO_FLOAT_CAST = 286,
+ UMINUS = 287,
+ BOOLEAN_T = 288,
+ FLOAT_T = 289,
+ INTEGER = 290,
+ QTEXT = 291,
+ TYPE = 292,
+ STORAGE = 293,
+ IDENT = 294,
+ VAR = 295,
+ BOOL_VAR = 296,
+ NUM_VAR = 297,
+ FLOAT_VAR = 298,
+ OBJ_VAR = 299,
+ STRING_VAR = 300,
+ VAR_ARRAY = 301,
+ BOOL_ARRAY = 302,
+ NUM_ARRAY = 303,
+ FLOAT_ARRAY = 304,
+ OBJ_ARRAY = 305,
+ BOOL_OBJVAR = 306,
+ NUM_OBJVAR = 307,
+ USER_OBJVAR = 308,
+ OBJ_OBJVAR = 309,
+ BOOL_CONSTANT = 310,
+ NUM_CONSTANT = 311,
+ USER_CONSTANT = 312,
+ OBJ_CONSTANT = 313,
+ STRING_CONSTANT = 314,
+ FUNC = 315,
+ BOOL_FUNC = 316,
+ NUM_FUNC = 317,
+ FLOAT_FUNC = 318,
+ USER_FUNC = 319,
+ OBJ_FUNC = 320,
+ STRING_FUNC = 321,
+ VOID_FUNC_CUST = 322,
+ BOOL_FUNC_CUST = 323,
+ NUM_FUNC_CUST = 324,
+ FLOAT_FUNC_CUST = 325,
+ USER_FUNC_CUST = 326,
+ OBJ_FUNC_CUST = 327,
+ STRING_FUNC_CUST = 328,
+ TRIG_SYM = 329,
+ EVENT_SYM = 330,
+ CALLBACK_SYM = 331
+ };
+#endif
+/* Tokens. */
+#define lexFUNCTION 258
+#define TRIGGER 259
+#define EVENT 260
+#define WAIT 261
+#define EVERY 262
+#define INACTIVE 263
+#define INITIALISE 264
+#define LINK 265
+#define REF 266
+#define RET 267
+#define _VOID 268
+#define WHILE 269
+#define IF 270
+#define ELSE 271
+#define EXIT 272
+#define PAUSE 273
+#define BOOLEQUAL 274
+#define NOTEQUAL 275
+#define GREATEQUAL 276
+#define LESSEQUAL 277
+#define GREATER 278
+#define LESS 279
+#define _AND 280
+#define _OR 281
+#define _NOT 282
+#define _INC 283
+#define _DEC 284
+#define TO_INT_CAST 285
+#define TO_FLOAT_CAST 286
+#define UMINUS 287
+#define BOOLEAN_T 288
+#define FLOAT_T 289
+#define INTEGER 290
+#define QTEXT 291
+#define TYPE 292
+#define STORAGE 293
+#define IDENT 294
+#define VAR 295
+#define BOOL_VAR 296
+#define NUM_VAR 297
+#define FLOAT_VAR 298
+#define OBJ_VAR 299
+#define STRING_VAR 300
+#define VAR_ARRAY 301
+#define BOOL_ARRAY 302
+#define NUM_ARRAY 303
+#define FLOAT_ARRAY 304
+#define OBJ_ARRAY 305
+#define BOOL_OBJVAR 306
+#define NUM_OBJVAR 307
+#define USER_OBJVAR 308
+#define OBJ_OBJVAR 309
+#define BOOL_CONSTANT 310
+#define NUM_CONSTANT 311
+#define USER_CONSTANT 312
+#define OBJ_CONSTANT 313
+#define STRING_CONSTANT 314
+#define FUNC 315
+#define BOOL_FUNC 316
+#define NUM_FUNC 317
+#define FLOAT_FUNC 318
+#define USER_FUNC 319
+#define OBJ_FUNC 320
+#define STRING_FUNC 321
+#define VOID_FUNC_CUST 322
+#define BOOL_FUNC_CUST 323
+#define NUM_FUNC_CUST 324
+#define FLOAT_FUNC_CUST 325
+#define USER_FUNC_CUST 326
+#define OBJ_FUNC_CUST 327
+#define STRING_FUNC_CUST 328
+#define TRIG_SYM 329
+#define EVENT_SYM 330
+#define CALLBACK_SYM 331
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 2068 of yacc.c */
+#line 1559 "script_parser.ypp"
+
+ /* Types returned by the lexer */
+ int32_t bval;
+ float fval;
+ SDWORD ival;
+ char *sval;
+ INTERP_TYPE tval;
+ STORAGE_TYPE stype;
+ VAR_SYMBOL *vSymbol;
+ CONST_SYMBOL *cSymbol;
+ FUNC_SYMBOL *fSymbol;
+ TRIGGER_SYMBOL *tSymbol;
+ EVENT_SYMBOL *eSymbol;
+ CALLBACK_SYMBOL *cbSymbol;
+
+ /* Types only returned by rules */
+ CODE_BLOCK *cblock;
+ COND_BLOCK *condBlock;
+ OBJVAR_BLOCK *objVarBlock;
+ ARRAY_BLOCK *arrayBlock;
+ PARAM_BLOCK *pblock;
+ PARAM_DECL *pdecl;
+ TRIGGER_DECL *tdecl;
+ UDWORD integer_val;
+ VAR_DECL *vdecl;
+ VAR_IDENT_DECL *videcl;
+
+
+
+/* Line 2068 of yacc.c */
+#line 232 "script_parser.h"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+extern YYSTYPE scr_lval;
+
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 9bcc29435..da59e08fe 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,8 +1,6 @@
AM_CPPFLAGS = -DYY_NO_INPUT $(SDL_CFLAGS) $(PHYSFS_CFLAGS) $(PNG_CFLAGS) $(VORBISFILE_CFLAGS) $(VORBIS_CFLAGS) $(OPENAL_CFLAGS) $(OPENGLC_CFLAGS) $(OPENGL_CFLAGS) $(WZ_CPPFLAGS) $(GLEW_CFLAGS)
AM_CFLAGS = $(WZ_CFLAGS)
AM_CXXFLAGS = $(WZ_CXXFLAGS) $(QT4_CFLAGS)
-AM_LFLAGS = $(FLEX_FLAGS)
-AM_YFLAGS = -d
.PHONY: autorevision.h
@@ -16,8 +14,7 @@ CLEANFILES = \
autorevision.h.new
BUILT_SOURCES = \
- autorevision.h \
- scriptvals_parser.h
+ autorevision.h
EXTRA_DIST = \
autorevision.cache \
@@ -133,6 +130,7 @@ noinst_HEADERS = \
scriptobj.h \
scripttabs.h \
scriptvals.h \
+ scriptvals_parser.h \
selection.h \
seqdisp.h \
statsdef.h \
@@ -200,7 +198,7 @@ warzone2100_SOURCES = \
keybind.cpp \
keyedit.cpp \
keymap.cpp \
- level_lexer.lpp \
+ level_lexer.cpp \
levels.cpp \
lighting.cpp \
loadsave.cpp \
@@ -246,8 +244,8 @@ warzone2100_SOURCES = \
scriptobj.cpp \
scripttabs.cpp \
scriptvals.cpp \
- scriptvals_lexer.lpp \
- scriptvals_parser.ypp \
+ scriptvals_lexer.cpp \
+ scriptvals_parser.cpp \
selection.cpp \
seqdisp.cpp \
stats.cpp \
diff --git a/src/Warzone2100.vcxproj b/src/Warzone2100.vcxproj
index c28e04490..fb2018aac 100644
--- a/src/Warzone2100.vcxproj
+++ b/src/Warzone2100.vcxproj
@@ -66,9 +66,7 @@
CustomBuild
-
-
-
+
@@ -90,9 +88,9 @@
<_ProjectFileVersion>10.0.30319.1
- $(SolutionDir)$(Configuration)\
- $(SolutionDir)$(Configuration)\
- $(SolutionDir)$(Configuration)\
+ ..\data
+ ..\data
+ ..\data
$(Configuration)\
$(Configuration)\
$(Configuration)\
@@ -103,9 +101,9 @@
true
true
true
- $(SolutionDir)$(Configuration)\
- $(SolutionDir)$(Configuration)\
- $(SolutionDir)$(Configuration)\
+ ..\data
+ ..\data
+ ..\data
$(Configuration)\
$(Configuration)\
$(Configuration)\
@@ -133,12 +131,18 @@
..\devpkg\libsx86;$(Qtdir)\lib;$(LibraryPath)
..\devpkg\libsx86;$(Qtdir)\lib;$(LibraryPath)
..\devpkg\libsx86;$(Qtdir)\lib;$(LibraryPath)
- *.lex.cpp;*.tab.cpp;*.tab.hpp;$(ExtensionsToDeleteOnClean)
- *.lex.cpp;*.tab.cpp;*.tab.hpp;$(ExtensionsToDeleteOnClean)
- *.lex.cpp;*.tab.cpp;*.tab.hpp;$(ExtensionsToDeleteOnClean)
+ $(ExtensionsToDeleteOnClean)
+ $(ExtensionsToDeleteOnClean)
+ $(ExtensionsToDeleteOnClean)
Midl
Midl
Midl
+ false
+ false
+ false
+ false
+ false
+ false
@@ -184,8 +188,10 @@
NotSet
- *** Copying $(TargetPath) to $(SolutionDir)..\data\$(TargetFileName) ***
- copy /Y /B $(TargetPath) $(ProjectDir)..\data\
+
+
+
+
false
@@ -235,8 +241,10 @@
NotSet
- *** Copying $(TargetPath) to $(SolutionDir)..\data\$(TargetFileName) ***
- copy /Y /B $(TargetPath) $(ProjectDir)..\data\
+
+
+
+
false
@@ -286,8 +294,10 @@
NotSet
- *** Copying $(TargetPath) to $(SolutionDir)..\data\$(TargetFileName) ***
- copy /Y /B $(TargetPath) $(ProjectDir)..\data\
+
+
+
+
false
@@ -327,8 +337,10 @@
MachineX86
- *** Copying $(TargetPath) to $(SolutionDir)..\data\$(TargetFileName) ***
- copy /Y /B $(TargetPath) $(ProjectDir)..\data\
+
+
+
+
@@ -364,8 +376,10 @@
MachineX86
- *** Copying $(TargetPath) to $(SolutionDir)..\data\$(TargetFileName) ***
- copy /Y /B $(TargetPath) $(ProjectDir)..\data\
+
+
+
+
@@ -401,8 +415,10 @@
MachineX86
- *** Copying $(TargetPath) to $(SolutionDir)..\data\$(TargetFileName) ***
- copy /Y /B $(TargetPath) $(ProjectDir)..\data\
+
+
+
+
@@ -689,19 +705,6 @@
-
-
- Document
-
-
- Document
-
-
- Document
-
-
-
-
-
+
\ No newline at end of file
diff --git a/src/Warzone2100.vcxproj.filters b/src/Warzone2100.vcxproj.filters
index 6aa407bcf..59d5635f1 100644
--- a/src/Warzone2100.vcxproj.filters
+++ b/src/Warzone2100.vcxproj.filters
@@ -13,9 +13,6 @@
{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
-
- {4af8247e-eb4a-428b-9177-04f2c30a3675}
-
@@ -728,17 +725,4 @@
Resource Files
-
-
- FlexBison
-
-
- FlexBison
-
-
-
-
- FlexBison
-
-
\ No newline at end of file
diff --git a/src/level_lexer.cpp b/src/level_lexer.cpp
new file mode 100644
index 000000000..3d00f6b15
--- /dev/null
+++ b/src/level_lexer.cpp
@@ -0,0 +1,2138 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+#line 2 "level_lexer.cpp"
+
+#line 4 "level_lexer.cpp"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define yy_create_buffer lev__create_buffer
+#define yy_delete_buffer lev__delete_buffer
+#define yy_flex_debug lev__flex_debug
+#define yy_init_buffer lev__init_buffer
+#define yy_flush_buffer lev__flush_buffer
+#define yy_load_buffer_state lev__load_buffer_state
+#define yy_switch_to_buffer lev__switch_to_buffer
+#define yyin lev_in
+#define yyleng lev_leng
+#define yylex lev_lex
+#define yylineno lev_lineno
+#define yyout lev_out
+#define yyrestart lev_restart
+#define yytext lev_text
+#define yywrap lev_wrap
+#define yyalloc lev_alloc
+#define yyrealloc lev_realloc
+#define yyfree lev_free
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 35
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+#include "lib/framework/frame.h"
+/* begin standard C headers. */
+#include
+#include
+#include
+#include
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have . Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#endif /* ! C99 */
+
+#endif /* ! FLEXINT_H */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
+
+#define YY_USE_CONST
+
+#endif /* defined (__STDC__) */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index. If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN (yy_start) = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START (((yy_start) - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE lev_restart(lev_in )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
+#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
+#endif
+
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+extern int lev_leng;
+
+extern FILE *lev_in, *lev_out;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+ /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
+ * access to the local variable yy_act. Since yyless() is a macro, it would break
+ * existing scanners that call yyless() from OUTSIDE lev_lex.
+ * One obvious solution it to make yy_act a global. I tried that, and saw
+ * a 5% performance hit in a non-lev_lineno scanner, because yy_act is
+ * normally declared as a register variable-- so it is not worth it.
+ */
+ #define YY_LESS_LINENO(n) \
+ do { \
+ int yyl;\
+ for ( yyl = n; yyl < lev_leng; ++yyl )\
+ if ( lev_text[yyl] == '\n' )\
+ --lev_lineno;\
+ }while(0)
+
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up lev_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ *yy_cp = (yy_hold_char); \
+ YY_RESTORE_YY_MORE_OFFSET \
+ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up lev_text again */ \
+ } \
+ while ( 0 )
+
+#define unput(c) yyunput( c, (yytext_ptr) )
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via lev_restart()), so that the user can continue scanning by
+ * just pointing lev_in at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+ : NULL)
+
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+
+/* yy_hold_char holds the character lost when lev_text is formed. */
+static char yy_hold_char;
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+int lev_leng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 0; /* whether we need to initialize */
+static int yy_start = 0; /* start state number */
+
+/* Flag which is used to allow lev_wrap()'s to do buffer switches
+ * instead of setting up a fresh lev_in. A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void lev_restart (FILE *input_file );
+void lev__switch_to_buffer (YY_BUFFER_STATE new_buffer );
+YY_BUFFER_STATE lev__create_buffer (FILE *file,int size );
+void lev__delete_buffer (YY_BUFFER_STATE b );
+void lev__flush_buffer (YY_BUFFER_STATE b );
+void lev_push_buffer_state (YY_BUFFER_STATE new_buffer );
+void lev_pop_buffer_state (void );
+
+static void lev_ensure_buffer_stack (void );
+static void lev__load_buffer_state (void );
+static void lev__init_buffer (YY_BUFFER_STATE b,FILE *file );
+
+#define YY_FLUSH_BUFFER lev__flush_buffer(YY_CURRENT_BUFFER )
+
+YY_BUFFER_STATE lev__scan_buffer (char *base,yy_size_t size );
+YY_BUFFER_STATE lev__scan_string (yyconst char *yy_str );
+YY_BUFFER_STATE lev__scan_bytes (yyconst char *bytes,int len );
+
+void *lev_alloc (yy_size_t );
+void *lev_realloc (void *,yy_size_t );
+void lev_free (void * );
+
+#define yy_new_buffer lev__create_buffer
+
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ lev_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ lev__create_buffer(lev_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+ }
+
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){\
+ lev_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ lev__create_buffer(lev_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+ }
+
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* Begin user sect3 */
+
+#define lev_wrap(n) 1
+#define YY_SKIP_YYWRAP
+
+typedef unsigned char YY_CHAR;
+
+FILE *lev_in = (FILE *) 0, *lev_out = (FILE *) 0;
+
+typedef int yy_state_type;
+
+extern int lev_lineno;
+
+int lev_lineno = 1;
+
+extern char *lev_text;
+#define yytext_ptr lev_text
+
+static yy_state_type yy_get_previous_state (void );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
+static int yy_get_next_buffer (void );
+static void yy_fatal_error (yyconst char msg[] );
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up lev_text.
+ */
+#define YY_DO_BEFORE_ACTION \
+ (yytext_ptr) = yy_bp; \
+ lev_leng = (size_t) (yy_cp - yy_bp); \
+ (yy_hold_char) = *yy_cp; \
+ *yy_cp = '\0'; \
+ (yy_c_buf_p) = yy_cp;
+
+#define YY_NUM_RULES 32
+#define YY_END_OF_BUFFER 33
+/* This struct is not used in this scanner,
+ but its presence is necessary. */
+struct yy_trans_info
+ {
+ flex_int32_t yy_verify;
+ flex_int32_t yy_nxt;
+ };
+static yyconst flex_int16_t yy_accept[120] =
+ { 0,
+ 0, 0, 0, 0, 30, 30, 20, 20, 33, 31,
+ 22, 22, 17, 31, 31, 21, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 26, 27, 26, 30,
+ 29, 20, 19, 18, 21, 23, 28, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 24, 30, 20,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 25,
+ 16, 16, 16, 16, 4, 16, 5, 16, 16, 16,
+ 3, 16, 16, 16, 16, 16, 16, 1, 16, 16,
+ 16, 16, 16, 16, 16, 10, 16, 16, 16, 12,
+ 16, 16, 16, 9, 16, 16, 16, 2, 16, 6,
+
+ 7, 16, 16, 16, 8, 16, 16, 13, 16, 15,
+ 16, 16, 16, 11, 16, 16, 16, 14, 0
+ } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 1, 4, 1, 1, 1, 1, 1, 1,
+ 1, 5, 1, 1, 6, 1, 7, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 1, 1, 1,
+ 1, 1, 1, 1, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 1, 1, 1, 1, 10, 1, 11, 12, 13, 14,
+
+ 15, 9, 16, 17, 18, 9, 19, 20, 21, 22,
+ 23, 24, 9, 25, 26, 27, 9, 28, 29, 30,
+ 31, 9, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1
+ } ;
+
+static yyconst flex_int32_t yy_meta[32] =
+ { 0,
+ 1, 1, 2, 3, 1, 4, 1, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4
+ } ;
+
+static yyconst flex_int16_t yy_base[126] =
+ { 0,
+ 0, 0, 29, 30, 141, 140, 33, 35, 142, 145,
+ 145, 145, 145, 133, 35, 132, 0, 124, 127, 126,
+ 106, 124, 119, 115, 112, 100, 145, 145, 123, 0,
+ 145, 0, 0, 145, 121, 145, 145, 0, 101, 106,
+ 99, 101, 103, 95, 96, 110, 96, 116, 0, 0,
+ 89, 28, 106, 105, 100, 99, 87, 81, 96, 145,
+ 95, 92, 97, 80, 80, 83, 0, 84, 93, 87,
+ 0, 86, 89, 81, 87, 82, 82, 0, 30, 70,
+ 72, 71, 76, 66, 63, 79, 68, 72, 60, 0,
+ 69, 62, 56, 0, 62, 66, 65, 0, 64, 0,
+
+ 0, 60, 66, 52, 0, 54, 48, 58, 41, 0,
+ 31, 27, 30, 0, 26, 34, 22, 0, 145, 54,
+ 58, 62, 40, 66, 70
+ } ;
+
+static yyconst flex_int16_t yy_def[126] =
+ { 0,
+ 119, 1, 120, 120, 121, 121, 122, 122, 119, 119,
+ 119, 119, 119, 119, 119, 119, 123, 123, 123, 123,
+ 123, 123, 123, 123, 123, 123, 119, 119, 119, 124,
+ 119, 125, 125, 119, 119, 119, 119, 123, 123, 123,
+ 123, 123, 123, 123, 123, 123, 123, 119, 124, 125,
+ 123, 123, 123, 123, 123, 123, 123, 123, 123, 119,
+ 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
+ 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
+ 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
+ 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
+
+ 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
+ 123, 123, 123, 123, 123, 123, 123, 123, 0, 119,
+ 119, 119, 119, 119, 119
+ } ;
+
+static yyconst flex_int16_t yy_nxt[177] =
+ { 0,
+ 10, 11, 12, 13, 10, 14, 15, 16, 17, 10,
+ 17, 18, 19, 20, 21, 22, 17, 17, 17, 23,
+ 24, 17, 17, 25, 17, 17, 26, 17, 17, 17,
+ 17, 28, 28, 29, 29, 33, 34, 33, 34, 36,
+ 62, 37, 87, 38, 118, 117, 116, 115, 88, 114,
+ 113, 63, 112, 64, 27, 27, 27, 27, 30, 30,
+ 30, 30, 32, 32, 32, 32, 49, 111, 49, 49,
+ 50, 50, 110, 50, 109, 108, 107, 106, 105, 104,
+ 103, 102, 101, 100, 99, 98, 97, 96, 95, 94,
+ 93, 92, 91, 90, 89, 86, 85, 84, 83, 82,
+
+ 81, 80, 79, 78, 77, 76, 75, 74, 73, 72,
+ 71, 70, 69, 68, 67, 66, 65, 61, 60, 59,
+ 58, 57, 56, 55, 54, 53, 52, 51, 35, 48,
+ 47, 46, 45, 44, 43, 42, 41, 40, 39, 35,
+ 35, 119, 31, 31, 9, 119, 119, 119, 119, 119,
+ 119, 119, 119, 119, 119, 119, 119, 119, 119, 119,
+ 119, 119, 119, 119, 119, 119, 119, 119, 119, 119,
+ 119, 119, 119, 119, 119, 119
+ } ;
+
+static yyconst flex_int16_t yy_chk[177] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 3, 4, 3, 4, 7, 7, 8, 8, 15,
+ 52, 15, 79, 123, 117, 116, 115, 113, 79, 112,
+ 111, 52, 109, 52, 120, 120, 120, 120, 121, 121,
+ 121, 121, 122, 122, 122, 122, 124, 108, 124, 124,
+ 125, 125, 107, 125, 106, 104, 103, 102, 99, 97,
+ 96, 95, 93, 92, 91, 89, 88, 87, 86, 85,
+ 84, 83, 82, 81, 80, 77, 76, 75, 74, 73,
+
+ 72, 70, 69, 68, 66, 65, 64, 63, 62, 61,
+ 59, 58, 57, 56, 55, 54, 53, 51, 48, 47,
+ 46, 45, 44, 43, 42, 41, 40, 39, 35, 29,
+ 26, 25, 24, 23, 22, 21, 20, 19, 18, 16,
+ 14, 9, 6, 5, 119, 119, 119, 119, 119, 119,
+ 119, 119, 119, 119, 119, 119, 119, 119, 119, 119,
+ 119, 119, 119, 119, 119, 119, 119, 119, 119, 119,
+ 119, 119, 119, 119, 119, 119
+ } ;
+
+/* Table of booleans, true if rule could match eol. */
+static yyconst flex_int32_t yy_rule_can_match_eol[33] =
+ { 0,
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, };
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+extern int lev__flex_debug;
+int lev__flex_debug = 0;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *lev_text;
+#line 1 "level_lexer.lpp"
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 1999-2004 Eidos Interactive
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+#line 21 "level_lexer.lpp"
+/* @file
+ *
+ * lexer for loading level description files
+ */
+
+#include "lib/framework/frame.h"
+#include "lib/framework/string_ext.h"
+
+#include "src/levels.h"
+#include "src/levelint.h"
+
+// fwrite declared with warn_unused_result, resulting in mysterious errors in "%%" on some distros.
+static inline bool no_warn_unused_result(int ignore) { if (ignore) {} return true; }
+#define fwrite(a, b, c, d) no_warn_unused_result(fwrite(a, b, c, d))
+
+/* Maximum length for any TEXT value */
+#ifndef YYLMAX
+#define YYLMAX 255
+#endif
+
+#include "lib/framework/lexer_input.h"
+
+/* Store for any string values */
+static char aText[YYLMAX];
+
+#ifndef yyextra
+# define yyextra lev_get_extra()
+#endif
+
+/* Older GNU Flex versions don't define lev_get_extra(), lev_set_extra(),
+ * lev_get_text() and lev_get_lineno().
+ * (and neither define a subminor version)
+ */
+#if !defined(YY_FLEX_SUBMINOR_VERSION) || (YY_FLEX_SUBMINOR_VERSION < 9)
+# define lev_get_extra lev_get_extra
+# define lev_set_extra lev_set_extra
+# define lev_get_lineno lev_get_lineno
+# define lev_get_text lev_get_text
+extern void lev_set_extra(YY_EXTRA_TYPE user_defined);
+extern YY_EXTRA_TYPE lev_get_extra(void);
+extern int lev_get_lineno(void);
+int lev_get_lineno()
+{
+ return lev_lineno;
+}
+
+extern char* lev_get_text(void);
+char* lev_get_text()
+{
+ return lev_text;
+}
+#elif defined(YY_FLEX_SUBMINOR_VERSION) && YY_FLEX_SUBMINOR_VERSION == 33
+extern YY_EXTRA_TYPE lev_get_extra(void);
+extern int lev_get_lineno(void);
+extern FILE *lev_get_in(void);
+extern FILE *lev_get_out(void);
+extern int lev_get_leng(void);
+extern char *lev_get_text(void);
+extern void lev_set_lineno(int line_number);
+extern void lev_set_in(FILE* in_str);
+extern void lev_set_out(FILE* out_str);
+extern int lev_get_debug(void);
+extern void lev_set_debug(int bdebug);
+extern int lev_lex_destroy(void);
+extern void lev_set_extra(YY_EXTRA_TYPE user_defined);
+#endif
+
+
+
+
+#line 667 "level_lexer.cpp"
+
+#define INITIAL 0
+#define COMMENT 1
+#define SLCOMMENT 2
+#define QUOTE 3
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#include
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+static int yy_init_globals (void );
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int lev_lex_destroy (void );
+
+int lev_get_debug (void );
+
+void lev_set_debug (int debug_flag );
+
+YY_EXTRA_TYPE lev_get_extra (void );
+
+void lev_set_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *lev_get_in (void );
+
+void lev_set_in (FILE * in_str );
+
+FILE *lev_get_out (void );
+
+void lev_set_out (FILE * out_str );
+
+int lev_get_leng (void );
+
+char *lev_get_text (void );
+
+int lev_get_lineno (void );
+
+void lev_set_lineno (int line_number );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int lev_wrap (void );
+#else
+extern int lev_wrap (void );
+#endif
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int );
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * );
+#endif
+
+#ifndef YY_NO_INPUT
+
+#ifdef __cplusplus
+static int yyinput (void );
+#else
+static int input (void );
+#endif
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
+#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO do { if (fwrite( lev_text, lev_leng, 1, lev_out )) {} } while (0)
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ { \
+ int c = '*'; \
+ size_t n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( lev_in )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( lev_in ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else \
+ { \
+ errno=0; \
+ while ( (result = fread(buf, 1, max_size, lev_in))==0 && ferror(lev_in)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(lev_in); \
+ } \
+ }\
+\
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* end tables serialization structures and prototypes */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int lev_lex (void);
+
+#define YY_DECL int lev_lex (void)
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after lev_text and lev_leng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+ YY_USER_ACTION
+
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp, *yy_bp;
+ register int yy_act;
+
+#line 97 "level_lexer.lpp"
+
+
+ /* Keywords */
+#line 859 "level_lexer.cpp"
+
+ if ( !(yy_init) )
+ {
+ (yy_init) = 1;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! (yy_start) )
+ (yy_start) = 1; /* first start state */
+
+ if ( ! lev_in )
+ lev_in = stdin;
+
+ if ( ! lev_out )
+ lev_out = stdout;
+
+ if ( ! YY_CURRENT_BUFFER ) {
+ lev_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ lev__create_buffer(lev_in,YY_BUF_SIZE );
+ }
+
+ lev__load_buffer_state( );
+ }
+
+ while ( 1 ) /* loops until end-of-file is reached */
+ {
+ yy_cp = (yy_c_buf_p);
+
+ /* Support of lev_text. */
+ *yy_cp = (yy_hold_char);
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+ yy_current_state = (yy_start);
+yy_match:
+ do
+ {
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 120 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ ++yy_cp;
+ }
+ while ( yy_current_state != 119 );
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+
+yy_find_action:
+ yy_act = yy_accept[yy_current_state];
+
+ YY_DO_BEFORE_ACTION;
+
+ if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
+ {
+ int yyl;
+ for ( yyl = 0; yyl < lev_leng; ++yyl )
+ if ( lev_text[yyl] == '\n' )
+
+ lev_lineno++;
+;
+ }
+
+do_action: /* This label is used only to access EOF actions. */
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = (yy_hold_char);
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 100 "level_lexer.lpp"
+return LTK_LEVEL;
+ YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 101 "level_lexer.lpp"
+return LTK_PLAYERS;
+ YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 102 "level_lexer.lpp"
+return LTK_TYPE;
+ YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 103 "level_lexer.lpp"
+return LTK_DATA;
+ YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 104 "level_lexer.lpp"
+return LTK_GAME;
+ YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 105 "level_lexer.lpp"
+return LTK_CAMPAIGN;
+ YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 106 "level_lexer.lpp"
+return LTK_CAMSTART;
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 107 "level_lexer.lpp"
+return LTK_CAMCHANGE;
+ YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 108 "level_lexer.lpp"
+return LTK_DATASET;
+ YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 109 "level_lexer.lpp"
+return LTK_EXPAND;
+ YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 110 "level_lexer.lpp"
+return LTK_EXPAND_LIMBO;
+ YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 111 "level_lexer.lpp"
+return LTK_BETWEEN;
+ YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 112 "level_lexer.lpp"
+return LTK_MKEEP;
+ YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 113 "level_lexer.lpp"
+return LTK_MKEEP_LIMBO;
+ YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 114 "level_lexer.lpp"
+return LTK_MCLEAR;
+ YY_BREAK
+/* Match text values */
+case 16:
+YY_RULE_SETUP
+#line 117 "level_lexer.lpp"
+{
+ sstrcpy(aText, lev_text);
+ pLevToken = aText;
+ return LTK_IDENT;
+ }
+ YY_BREAK
+/* Match quoted text */
+case 17:
+YY_RULE_SETUP
+#line 124 "level_lexer.lpp"
+{ BEGIN QUOTE; }
+ YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 125 "level_lexer.lpp"
+{ BEGIN 0; }
+ YY_BREAK
+case 19:
+/* rule 19 can match eol */
+YY_RULE_SETUP
+#line 126 "level_lexer.lpp"
+{ lev_error("Unexpected end of line in string"); }
+ YY_BREAK
+case 20:
+/* rule 20 can match eol */
+YY_RULE_SETUP
+#line 127 "level_lexer.lpp"
+{
+ sstrcpy(aText, lev_text);
+ pLevToken = aText;
+ return LTK_STRING;
+ }
+ YY_BREAK
+/* Match integer numbers */
+case 21:
+YY_RULE_SETUP
+#line 134 "level_lexer.lpp"
+{ levVal = (LEVEL_TYPE)atol(lev_text); return LTK_INTEGER; }
+ YY_BREAK
+/* Skip white space */
+case 22:
+/* rule 22 can match eol */
+YY_RULE_SETUP
+#line 137 "level_lexer.lpp"
+;
+ YY_BREAK
+/* Strip comments */
+case 23:
+YY_RULE_SETUP
+#line 140 "level_lexer.lpp"
+{ BEGIN COMMENT; }
+ YY_BREAK
+case 24:
+#line 142 "level_lexer.lpp"
+case 25:
+/* rule 25 can match eol */
+YY_RULE_SETUP
+#line 142 "level_lexer.lpp"
+{ BEGIN 0; }
+ YY_BREAK
+case 26:
+#line 144 "level_lexer.lpp"
+case 27:
+/* rule 27 can match eol */
+YY_RULE_SETUP
+#line 144 "level_lexer.lpp"
+;
+ YY_BREAK
+/* Strip single line comments */
+case 28:
+YY_RULE_SETUP
+#line 147 "level_lexer.lpp"
+{ BEGIN SLCOMMENT; }
+ YY_BREAK
+case 29:
+/* rule 29 can match eol */
+YY_RULE_SETUP
+#line 148 "level_lexer.lpp"
+{ BEGIN 0; }
+ YY_BREAK
+case 30:
+YY_RULE_SETUP
+#line 149 "level_lexer.lpp"
+;
+ YY_BREAK
+/* Match anything that's been missed and pass it as a char */
+case 31:
+YY_RULE_SETUP
+#line 152 "level_lexer.lpp"
+return lev_text[0];
+ YY_BREAK
+case 32:
+YY_RULE_SETUP
+#line 154 "level_lexer.lpp"
+ECHO;
+ YY_BREAK
+#line 1123 "level_lexer.cpp"
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(COMMENT):
+case YY_STATE_EOF(SLCOMMENT):
+case YY_STATE_EOF(QUOTE):
+ yyterminate();
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = (yy_hold_char);
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed lev_in at a new source and called
+ * lev_lex(). If so, then we have to assure
+ * consistency between YY_CURRENT_BUFFER and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = lev_in;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++(yy_c_buf_p);
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ (yy_did_buffer_switch_on_eof) = 0;
+
+ if ( lev_wrap( ) )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * lev_text, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) =
+ (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ (yy_c_buf_p) =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+} /* end of lev_lex */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+static int yy_get_next_buffer (void)
+{
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ register char *source = (yytext_ptr);
+ register int number_to_move, i;
+ int ret_val;
+
+ if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
+
+ else
+ {
+ int num_to_read =
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+
+ int yy_c_buf_p_offset =
+ (int) ((yy_c_buf_p) - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ lev_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = 0;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+ number_to_move - 1;
+
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+ (yy_n_chars), (size_t) num_to_read );
+
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ if ( (yy_n_chars) == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ lev_restart(lev_in );
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) lev_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
+ (yy_n_chars) += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
+
+ (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+ return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+ static yy_state_type yy_get_previous_state (void)
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp;
+
+ yy_current_state = (yy_start);
+
+ for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
+ {
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 120 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ }
+
+ return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
+{
+ register int yy_is_jam;
+ register char *yy_cp = (yy_c_buf_p);
+
+ register YY_CHAR yy_c = 1;
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 120 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_is_jam = (yy_current_state == 119);
+
+ return yy_is_jam ? 0 : yy_current_state;
+}
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+ static int yyinput (void)
+#else
+ static int input (void)
+#endif
+
+{
+ int c;
+
+ *(yy_c_buf_p) = (yy_hold_char);
+
+ if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ /* This was really a NUL. */
+ *(yy_c_buf_p) = '\0';
+
+ else
+ { /* need more input */
+ int offset = (yy_c_buf_p) - (yytext_ptr);
+ ++(yy_c_buf_p);
+
+ switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ lev_restart(lev_in );
+
+ /*FALLTHROUGH*/
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( lev_wrap( ) )
+ return EOF;
+
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput();
+#else
+ return input();
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) = (yytext_ptr) + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
+ *(yy_c_buf_p) = '\0'; /* preserve lev_text */
+ (yy_hold_char) = *++(yy_c_buf_p);
+
+ if ( c == '\n' )
+
+ lev_lineno++;
+;
+
+ return c;
+}
+#endif /* ifndef YY_NO_INPUT */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ *
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+ void lev_restart (FILE * input_file )
+{
+
+ if ( ! YY_CURRENT_BUFFER ){
+ lev_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ lev__create_buffer(lev_in,YY_BUF_SIZE );
+ }
+
+ lev__init_buffer(YY_CURRENT_BUFFER,input_file );
+ lev__load_buffer_state( );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ *
+ */
+ void lev__switch_to_buffer (YY_BUFFER_STATE new_buffer )
+{
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * lev_pop_buffer_state();
+ * lev_push_buffer_state(new_buffer);
+ */
+ lev_ensure_buffer_stack ();
+ if ( YY_CURRENT_BUFFER == new_buffer )
+ return;
+
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ lev__load_buffer_state( );
+
+ /* We don't actually know whether we did this switch during
+ * EOF (lev_wrap()) processing, but the only time this flag
+ * is looked at is after lev_wrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+static void lev__load_buffer_state (void)
+{
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ lev_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ (yy_hold_char) = *(yy_c_buf_p);
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ *
+ * @return the allocated buffer state.
+ */
+ YY_BUFFER_STATE lev__create_buffer (FILE * file, int size )
+{
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) lev_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in lev__create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) lev_alloc(b->yy_buf_size + 2 );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in lev__create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ lev__init_buffer(b,file );
+
+ return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with lev__create_buffer()
+ *
+ */
+ void lev__delete_buffer (YY_BUFFER_STATE b )
+{
+
+ if ( ! b )
+ return;
+
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ lev_free((void *) b->yy_ch_buf );
+
+ lev_free((void *) b );
+}
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a lev_restart() or at EOF.
+ */
+ static void lev__init_buffer (YY_BUFFER_STATE b, FILE * file )
+
+{
+ int oerrno = errno;
+
+ lev__flush_buffer(b );
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+ /* If b is the current buffer, then lev__init_buffer was _probably_
+ * called from lev_restart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
+
+ b->yy_is_interactive = 0;
+
+ errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ *
+ */
+ void lev__flush_buffer (YY_BUFFER_STATE b )
+{
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == YY_CURRENT_BUFFER )
+ lev__load_buffer_state( );
+}
+
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ *
+ */
+void lev_push_buffer_state (YY_BUFFER_STATE new_buffer )
+{
+ if (new_buffer == NULL)
+ return;
+
+ lev_ensure_buffer_stack();
+
+ /* This block is copied from lev__switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ (yy_buffer_stack_top)++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from lev__switch_to_buffer. */
+ lev__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ *
+ */
+void lev_pop_buffer_state (void)
+{
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ lev__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if ((yy_buffer_stack_top) > 0)
+ --(yy_buffer_stack_top);
+
+ if (YY_CURRENT_BUFFER) {
+ lev__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+ }
+}
+
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+static void lev_ensure_buffer_stack (void)
+{
+ int num_to_alloc;
+
+ if (!(yy_buffer_stack)) {
+
+ /* First allocation is just for 2 elements, since we don't know if this
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
+ * immediate realloc on the next call.
+ */
+ num_to_alloc = 1;
+ (yy_buffer_stack) = (struct yy_buffer_state**)lev_alloc
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in lev_ensure_buffer_stack()" );
+
+ memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+
+ (yy_buffer_stack_max) = num_to_alloc;
+ (yy_buffer_stack_top) = 0;
+ return;
+ }
+
+ if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+
+ /* Increase the buffer to prepare for a possible push. */
+ int grow_size = 8 /* arbitrary grow size */;
+
+ num_to_alloc = (yy_buffer_stack_max) + grow_size;
+ (yy_buffer_stack) = (struct yy_buffer_state**)lev_realloc
+ ((yy_buffer_stack),
+ num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in lev_ensure_buffer_stack()" );
+
+ /* zero only the new slots.*/
+ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+ (yy_buffer_stack_max) = num_to_alloc;
+ }
+}
+
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE lev__scan_buffer (char * base, yy_size_t size )
+{
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return 0;
+
+ b = (YY_BUFFER_STATE) lev_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in lev__scan_buffer()" );
+
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = 0;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ lev__switch_to_buffer(b );
+
+ return b;
+}
+
+/** Setup the input buffer state to scan a string. The next call to lev_lex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ *
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * lev__scan_bytes() instead.
+ */
+YY_BUFFER_STATE lev__scan_string (yyconst char * yystr )
+{
+
+ return lev__scan_bytes(yystr,strlen(yystr) );
+}
+
+/** Setup the input buffer state to scan the given bytes. The next call to lev_lex() will
+ * scan from a @e copy of @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE lev__scan_bytes (yyconst char * yybytes, int _yybytes_len )
+{
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = _yybytes_len + 2;
+ buf = (char *) lev_alloc(n );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in lev__scan_bytes()" );
+
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
+
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = lev__scan_buffer(buf,n );
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in lev__scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+}
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+static void yy_fatal_error (yyconst char* msg )
+{
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+}
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up lev_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ lev_text[lev_leng] = (yy_hold_char); \
+ (yy_c_buf_p) = lev_text + yyless_macro_arg; \
+ (yy_hold_char) = *(yy_c_buf_p); \
+ *(yy_c_buf_p) = '\0'; \
+ lev_leng = yyless_macro_arg; \
+ } \
+ while ( 0 )
+
+/* Accessor methods (get/set functions) to struct members. */
+
+/** Get the current line number.
+ *
+ */
+int lev_get_lineno (void)
+{
+
+ return lev_lineno;
+}
+
+/** Get the input stream.
+ *
+ */
+FILE *lev_get_in (void)
+{
+ return lev_in;
+}
+
+/** Get the output stream.
+ *
+ */
+FILE *lev_get_out (void)
+{
+ return lev_out;
+}
+
+/** Get the length of the current token.
+ *
+ */
+int lev_get_leng (void)
+{
+ return lev_leng;
+}
+
+/** Get the current token.
+ *
+ */
+
+char *lev_get_text (void)
+{
+ return lev_text;
+}
+
+/** Set the current line number.
+ * @param line_number
+ *
+ */
+void lev_set_lineno (int line_number )
+{
+
+ lev_lineno = line_number;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ *
+ * @see lev__switch_to_buffer
+ */
+void lev_set_in (FILE * in_str )
+{
+ lev_in = in_str ;
+}
+
+void lev_set_out (FILE * out_str )
+{
+ lev_out = out_str ;
+}
+
+int lev_get_debug (void)
+{
+ return lev__flex_debug;
+}
+
+void lev_set_debug (int bdebug )
+{
+ lev__flex_debug = bdebug ;
+}
+
+static int yy_init_globals (void)
+{
+ /* Initialization is the same as for the non-reentrant scanner.
+ * This function is called from lev_lex_destroy(), so don't allocate here.
+ */
+
+ /* We do not touch lev_lineno unless the option is enabled. */
+ lev_lineno = 1;
+
+ (yy_buffer_stack) = 0;
+ (yy_buffer_stack_top) = 0;
+ (yy_buffer_stack_max) = 0;
+ (yy_c_buf_p) = (char *) 0;
+ (yy_init) = 0;
+ (yy_start) = 0;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ lev_in = stdin;
+ lev_out = stdout;
+#else
+ lev_in = (FILE *) 0;
+ lev_out = (FILE *) 0;
+#endif
+
+ /* For future reference: Set errno on error, since we are called by
+ * lev_lex_init()
+ */
+ return 0;
+}
+
+/* lev_lex_destroy is for both reentrant and non-reentrant scanners. */
+int lev_lex_destroy (void)
+{
+
+ /* Pop the buffer stack, destroying each element. */
+ while(YY_CURRENT_BUFFER){
+ lev__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ lev_pop_buffer_state();
+ }
+
+ /* Destroy the stack itself. */
+ lev_free((yy_buffer_stack) );
+ (yy_buffer_stack) = NULL;
+
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * lev_lex() is called, initialization will occur. */
+ yy_init_globals( );
+
+ return 0;
+}
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+{
+ register int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * s )
+{
+ register int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+}
+#endif
+
+void *lev_alloc (yy_size_t size )
+{
+ return (void *) malloc( size );
+}
+
+void *lev_realloc (void * ptr, yy_size_t size )
+{
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return (void *) realloc( (char *) ptr, size );
+}
+
+void lev_free (void * ptr )
+{
+ free( (char *) ptr ); /* see lev_realloc() for (char *) cast */
+}
+
+#define YYTABLES_NAME "yytables"
+
+#line 154 "level_lexer.lpp"
+
+
+
+static YY_EXTRA_TYPE pBuffer = NULL;
+
+void lev_set_extra(YY_EXTRA_TYPE user_defined)
+{
+ pBuffer = user_defined;
+}
+
+YY_EXTRA_TYPE lev_get_extra()
+{
+ return pBuffer;
+}
+
+/* Older GNU Flex versions don't define lev_lex_destroy()
+ * (and neither define a subminor version)
+ */
+#if !defined(YY_FLEX_SUBMINOR_VERSION) || (YY_FLEX_SUBMINOR_VERSION < 9)
+int lev_lex_destroy(void)
+{
+ /* For non-reentrant C scanner only. */
+ lev__delete_buffer(YY_CURRENT_BUFFER);
+ yy_init = 1;
+ return 0;
+}
+#endif
+
diff --git a/src/scriptvals_lexer.cpp b/src/scriptvals_lexer.cpp
new file mode 100644
index 000000000..96ca90131
--- /dev/null
+++ b/src/scriptvals_lexer.cpp
@@ -0,0 +1,2124 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+#line 2 "scriptvals_lexer.cpp"
+
+#line 4 "scriptvals_lexer.cpp"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define yy_create_buffer scrv__create_buffer
+#define yy_delete_buffer scrv__delete_buffer
+#define yy_flex_debug scrv__flex_debug
+#define yy_init_buffer scrv__init_buffer
+#define yy_flush_buffer scrv__flush_buffer
+#define yy_load_buffer_state scrv__load_buffer_state
+#define yy_switch_to_buffer scrv__switch_to_buffer
+#define yyin scrv_in
+#define yyleng scrv_leng
+#define yylex scrv_lex
+#define yylineno scrv_lineno
+#define yyout scrv_out
+#define yyrestart scrv_restart
+#define yytext scrv_text
+#define yywrap scrv_wrap
+#define yyalloc scrv_alloc
+#define yyrealloc scrv_realloc
+#define yyfree scrv_free
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 35
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+#include "lib/framework/frame.h"
+/* begin standard C headers. */
+#include
+#include
+#include
+#include
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have . Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#endif /* ! C99 */
+
+#endif /* ! FLEXINT_H */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
+
+#define YY_USE_CONST
+
+#endif /* defined (__STDC__) */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index. If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN (yy_start) = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START (((yy_start) - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE scrv_restart(scrv_in )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
+#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
+#endif
+
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+extern int scrv_leng;
+
+extern FILE *scrv_in, *scrv_out;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+ /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
+ * access to the local variable yy_act. Since yyless() is a macro, it would break
+ * existing scanners that call yyless() from OUTSIDE scrv_lex.
+ * One obvious solution it to make yy_act a global. I tried that, and saw
+ * a 5% performance hit in a non-scrv_lineno scanner, because yy_act is
+ * normally declared as a register variable-- so it is not worth it.
+ */
+ #define YY_LESS_LINENO(n) \
+ do { \
+ int yyl;\
+ for ( yyl = n; yyl < scrv_leng; ++yyl )\
+ if ( scrv_text[yyl] == '\n' )\
+ --scrv_lineno;\
+ }while(0)
+
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up scrv_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ *yy_cp = (yy_hold_char); \
+ YY_RESTORE_YY_MORE_OFFSET \
+ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up scrv_text again */ \
+ } \
+ while ( 0 )
+
+#define unput(c) yyunput( c, (yytext_ptr) )
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via scrv_restart()), so that the user can continue scanning by
+ * just pointing scrv_in at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+ : NULL)
+
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+
+/* yy_hold_char holds the character lost when scrv_text is formed. */
+static char yy_hold_char;
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+int scrv_leng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 0; /* whether we need to initialize */
+static int yy_start = 0; /* start state number */
+
+/* Flag which is used to allow scrv_wrap()'s to do buffer switches
+ * instead of setting up a fresh scrv_in. A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void scrv_restart (FILE *input_file );
+void scrv__switch_to_buffer (YY_BUFFER_STATE new_buffer );
+YY_BUFFER_STATE scrv__create_buffer (FILE *file,int size );
+void scrv__delete_buffer (YY_BUFFER_STATE b );
+void scrv__flush_buffer (YY_BUFFER_STATE b );
+void scrv_push_buffer_state (YY_BUFFER_STATE new_buffer );
+void scrv_pop_buffer_state (void );
+
+static void scrv_ensure_buffer_stack (void );
+static void scrv__load_buffer_state (void );
+static void scrv__init_buffer (YY_BUFFER_STATE b,FILE *file );
+
+#define YY_FLUSH_BUFFER scrv__flush_buffer(YY_CURRENT_BUFFER )
+
+YY_BUFFER_STATE scrv__scan_buffer (char *base,yy_size_t size );
+YY_BUFFER_STATE scrv__scan_string (yyconst char *yy_str );
+YY_BUFFER_STATE scrv__scan_bytes (yyconst char *bytes,int len );
+
+void *scrv_alloc (yy_size_t );
+void *scrv_realloc (void *,yy_size_t );
+void scrv_free (void * );
+
+#define yy_new_buffer scrv__create_buffer
+
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ scrv_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ scrv__create_buffer(scrv_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+ }
+
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){\
+ scrv_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ scrv__create_buffer(scrv_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+ }
+
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* Begin user sect3 */
+
+#define scrv_wrap(n) 1
+#define YY_SKIP_YYWRAP
+
+typedef unsigned char YY_CHAR;
+
+FILE *scrv_in = (FILE *) 0, *scrv_out = (FILE *) 0;
+
+typedef int yy_state_type;
+
+extern int scrv_lineno;
+
+int scrv_lineno = 1;
+
+extern char *scrv_text;
+#define yytext_ptr scrv_text
+
+static yy_state_type yy_get_previous_state (void );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
+static int yy_get_next_buffer (void );
+static void yy_fatal_error (yyconst char msg[] );
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up scrv_text.
+ */
+#define YY_DO_BEFORE_ACTION \
+ (yytext_ptr) = yy_bp; \
+ scrv_leng = (size_t) (yy_cp - yy_bp); \
+ (yy_hold_char) = *yy_cp; \
+ *yy_cp = '\0'; \
+ (yy_c_buf_p) = yy_cp;
+
+#define YY_NUM_RULES 28
+#define YY_END_OF_BUFFER 29
+/* This struct is not used in this scanner,
+ but its presence is necessary. */
+struct yy_trans_info
+ {
+ flex_int32_t yy_verify;
+ flex_int32_t yy_nxt;
+ };
+static yyconst flex_int16_t yy_accept[80] =
+ { 0,
+ 0, 0, 0, 0, 26, 26, 17, 17, 29, 27,
+ 18, 18, 14, 27, 27, 13, 12, 12, 12, 12,
+ 12, 12, 12, 12, 12, 12, 12, 22, 23, 22,
+ 26, 25, 17, 16, 15, 13, 19, 24, 12, 12,
+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+ 20, 26, 17, 12, 12, 2, 12, 12, 12, 1,
+ 7, 12, 12, 12, 21, 4, 12, 9, 3, 12,
+ 12, 12, 8, 11, 10, 12, 6, 5, 0
+ } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 1, 4, 1, 1, 1, 1, 1, 1,
+ 1, 5, 1, 1, 6, 1, 7, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 1, 1, 1,
+ 1, 1, 1, 1, 9, 10, 11, 11, 12, 13,
+ 11, 11, 14, 11, 11, 15, 11, 16, 17, 11,
+ 11, 18, 19, 20, 21, 11, 11, 11, 11, 11,
+ 1, 1, 1, 1, 22, 1, 23, 24, 25, 11,
+
+ 26, 27, 11, 11, 28, 11, 11, 29, 11, 30,
+ 31, 32, 11, 33, 34, 35, 36, 11, 11, 11,
+ 11, 11, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1
+ } ;
+
+static yyconst flex_int32_t yy_meta[37] =
+ { 0,
+ 1, 1, 2, 3, 1, 4, 1, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4
+ } ;
+
+static yyconst flex_int16_t yy_base[86] =
+ { 0,
+ 0, 0, 34, 35, 104, 103, 38, 40, 105, 108,
+ 108, 108, 108, 96, 40, 95, 0, 85, 92, 84,
+ 81, 67, 74, 66, 59, 21, 61, 108, 108, 86,
+ 0, 108, 0, 108, 108, 84, 108, 108, 0, 74,
+ 75, 69, 67, 56, 57, 50, 54, 50, 51, 45,
+ 77, 0, 0, 64, 59, 0, 65, 46, 40, 0,
+ 0, 42, 22, 28, 108, 0, 41, 0, 0, 26,
+ 19, 24, 0, 0, 0, 14, 0, 0, 108, 56,
+ 60, 64, 44, 68, 72
+ } ;
+
+static yyconst flex_int16_t yy_def[86] =
+ { 0,
+ 79, 1, 80, 80, 81, 81, 82, 82, 79, 79,
+ 79, 79, 79, 79, 79, 79, 83, 83, 83, 83,
+ 83, 83, 83, 83, 83, 83, 83, 79, 79, 79,
+ 84, 79, 85, 79, 79, 79, 79, 79, 83, 83,
+ 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
+ 79, 84, 85, 83, 83, 83, 83, 83, 83, 83,
+ 83, 83, 83, 83, 79, 83, 83, 83, 83, 83,
+ 83, 83, 83, 83, 83, 83, 83, 83, 0, 79,
+ 79, 79, 79, 79, 79
+ } ;
+
+static yyconst flex_int16_t yy_nxt[145] =
+ { 0,
+ 10, 11, 12, 13, 10, 14, 15, 16, 17, 18,
+ 17, 17, 19, 20, 17, 17, 17, 17, 17, 21,
+ 17, 10, 17, 22, 17, 17, 23, 24, 17, 17,
+ 17, 17, 25, 26, 27, 17, 29, 29, 30, 30,
+ 34, 35, 34, 35, 37, 48, 38, 39, 78, 77,
+ 76, 75, 74, 73, 72, 49, 28, 28, 28, 28,
+ 31, 31, 31, 31, 33, 33, 33, 33, 52, 71,
+ 52, 52, 53, 70, 69, 53, 68, 67, 66, 65,
+ 64, 63, 62, 61, 60, 59, 58, 57, 56, 55,
+ 54, 36, 51, 50, 47, 46, 45, 44, 43, 42,
+
+ 41, 40, 36, 36, 79, 32, 32, 9, 79, 79,
+ 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
+ 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
+ 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
+ 79, 79, 79, 79
+ } ;
+
+static yyconst flex_int16_t yy_chk[145] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 3, 4, 3, 4,
+ 7, 7, 8, 8, 15, 26, 15, 83, 76, 72,
+ 71, 70, 67, 64, 63, 26, 80, 80, 80, 80,
+ 81, 81, 81, 81, 82, 82, 82, 82, 84, 62,
+ 84, 84, 85, 59, 58, 85, 57, 55, 54, 51,
+ 50, 49, 48, 47, 46, 45, 44, 43, 42, 41,
+ 40, 36, 30, 27, 25, 24, 23, 22, 21, 20,
+
+ 19, 18, 16, 14, 9, 6, 5, 79, 79, 79,
+ 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
+ 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
+ 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
+ 79, 79, 79, 79
+ } ;
+
+/* Table of booleans, true if rule could match eol. */
+static yyconst flex_int32_t yy_rule_can_match_eol[29] =
+ { 0,
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0,
+ 0, 1, 0, 1, 0, 1, 0, 0, 0, };
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+extern int scrv__flex_debug;
+int scrv__flex_debug = 0;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *scrv_text;
+#line 1 "scriptvals_lexer.lpp"
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 1999-2004 Eidos Interactive
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+#line 21 "scriptvals_lexer.lpp"
+/*
+ * ScriptVals.l
+ *
+ * lexer for loading script variable values
+ *
+ */
+#include "lib/framework/frame.h"
+
+#include
+
+#include "lib/script/script.h"
+#include "src/scriptvals.h"
+
+/* Get the Yacc definitions */
+#include "scriptvals_parser.h"
+
+/* Maximum length for any TEXT value */
+#ifndef YYLMAX
+#define YYLMAX 255
+#endif
+
+/* Store for any string values */
+static char aText[TEXT_BUFFERS][YYLMAX];
+static UDWORD currText=0;
+
+#include "lib/framework/lexer_input.h"
+
+#ifndef yyextra
+# define yyextra scrv_get_extra()
+#endif
+
+#define yylval (&scrv_lval)
+
+/* Older GNU Flex versions don't define scrv_get_extra(), scrv_set_extra(),
+ * scrv_get_text() and scrv_get_lineno().
+ * (and neither define a subminor version)
+ */
+#if !defined(YY_FLEX_SUBMINOR_VERSION) || (YY_FLEX_SUBMINOR_VERSION < 9)
+# define scrv_get_extra scrv_get_extra
+# define scrv_set_extra scrv_set_extra
+# define scrv_get_lineno scrv_get_lineno
+# define scrv_get_text scrv_get_text
+extern void scrv_set_extra(YY_EXTRA_TYPE user_defined);
+extern YY_EXTRA_TYPE scrv_get_extra(void);
+extern int scrv_get_lineno(void);
+int scrv_get_lineno()
+{
+ return scrv_lineno;
+}
+
+extern char* scrv_get_text(void);
+char* scrv_get_text()
+{
+ return scrv_text;
+}
+#elif defined(YY_FLEX_SUBMINOR_VERSION) && YY_FLEX_SUBMINOR_VERSION == 33
+extern YY_EXTRA_TYPE scrv_get_extra(void);
+extern int scrv_get_lineno(void);
+extern FILE *scrv_get_in(void);
+extern FILE *scrv_get_out(void);
+extern int scrv_get_leng(void);
+extern char *scrv_get_text(void);
+extern void scrv_set_lineno(int line_number);
+extern void scrv_set_in(FILE* in_str);
+extern void scrv_set_out(FILE* out_str);
+extern int scrv_get_debug(void);
+extern void scrv_set_debug(int bdebug);
+extern int scrv_lex_destroy(void);
+extern void scrv_set_extra(YY_EXTRA_TYPE user_defined);
+#endif
+
+
+
+
+#line 654 "scriptvals_lexer.cpp"
+
+#define INITIAL 0
+#define COMMENT 1
+#define SLCOMMENT 2
+#define QUOTE 3
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#include
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+static int yy_init_globals (void );
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int scrv_lex_destroy (void );
+
+int scrv_get_debug (void );
+
+void scrv_set_debug (int debug_flag );
+
+YY_EXTRA_TYPE scrv_get_extra (void );
+
+void scrv_set_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *scrv_get_in (void );
+
+void scrv_set_in (FILE * in_str );
+
+FILE *scrv_get_out (void );
+
+void scrv_set_out (FILE * out_str );
+
+int scrv_get_leng (void );
+
+char *scrv_get_text (void );
+
+int scrv_get_lineno (void );
+
+void scrv_set_lineno (int line_number );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int scrv_wrap (void );
+#else
+extern int scrv_wrap (void );
+#endif
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int );
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * );
+#endif
+
+#ifndef YY_NO_INPUT
+
+#ifdef __cplusplus
+static int yyinput (void );
+#else
+static int input (void );
+#endif
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
+#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO do { if (fwrite( scrv_text, scrv_leng, 1, scrv_out )) {} } while (0)
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ { \
+ int c = '*'; \
+ size_t n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( scrv_in )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( scrv_in ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else \
+ { \
+ errno=0; \
+ while ( (result = fread(buf, 1, max_size, scrv_in))==0 && ferror(scrv_in)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(scrv_in); \
+ } \
+ }\
+\
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* end tables serialization structures and prototypes */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int scrv_lex (void);
+
+#define YY_DECL int scrv_lex (void)
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after scrv_text and scrv_leng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+ YY_USER_ACTION
+
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp, *yy_bp;
+ register int yy_act;
+
+#line 106 "scriptvals_lexer.lpp"
+
+
+ /* Keywords */
+#line 846 "scriptvals_lexer.cpp"
+
+ if ( !(yy_init) )
+ {
+ (yy_init) = 1;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! (yy_start) )
+ (yy_start) = 1; /* first start state */
+
+ if ( ! scrv_in )
+ scrv_in = stdin;
+
+ if ( ! scrv_out )
+ scrv_out = stdout;
+
+ if ( ! YY_CURRENT_BUFFER ) {
+ scrv_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ scrv__create_buffer(scrv_in,YY_BUF_SIZE );
+ }
+
+ scrv__load_buffer_state( );
+ }
+
+ while ( 1 ) /* loops until end-of-file is reached */
+ {
+ yy_cp = (yy_c_buf_p);
+
+ /* Support of scrv_text. */
+ *yy_cp = (yy_hold_char);
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+ yy_current_state = (yy_start);
+yy_match:
+ do
+ {
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 80 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ ++yy_cp;
+ }
+ while ( yy_current_state != 79 );
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+
+yy_find_action:
+ yy_act = yy_accept[yy_current_state];
+
+ YY_DO_BEFORE_ACTION;
+
+ if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
+ {
+ int yyl;
+ for ( yyl = 0; yyl < scrv_leng; ++yyl )
+ if ( scrv_text[yyl] == '\n' )
+
+ scrv_lineno++;
+;
+ }
+
+do_action: /* This label is used only to access EOF actions. */
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = (yy_hold_char);
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 109 "scriptvals_lexer.lpp"
+{ yylval->tval = VAL_INT; return TYPE; }
+ YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 110 "scriptvals_lexer.lpp"
+{ yylval->tval = VAL_INT; return TYPE; }
+ YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 111 "scriptvals_lexer.lpp"
+{ yylval->tval = VAL_BOOL; return TYPE; }
+ YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 112 "scriptvals_lexer.lpp"
+{ yylval->tval = VAL_BOOL; return TYPE; }
+ YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 113 "scriptvals_lexer.lpp"
+return SCRIPT;
+ YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 114 "scriptvals_lexer.lpp"
+return STORE;
+ YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 115 "scriptvals_lexer.lpp"
+return RUN;
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 117 "scriptvals_lexer.lpp"
+{ yylval->bval = true; return BOOLEAN_T; }
+ YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 118 "scriptvals_lexer.lpp"
+{ yylval->bval = true; return BOOLEAN_T; }
+ YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 119 "scriptvals_lexer.lpp"
+{ yylval->bval = false; return BOOLEAN_T; }
+ YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 120 "scriptvals_lexer.lpp"
+{ yylval->bval = false; return BOOLEAN_T; }
+ YY_BREAK
+/* Match text values */
+case 12:
+YY_RULE_SETUP
+#line 123 "scriptvals_lexer.lpp"
+{
+ INTERP_TYPE type;
+ UDWORD index;
+
+ /* See if this is a variable id or a type */
+ if (scrvLookUpType(scrv_text, &type))
+ {
+ yylval->tval = type;
+ return TYPE;
+ }
+ else if (scrvLookUpVar(scrv_text, &index))
+ {
+ yylval->vindex = index;
+ return VAR;
+ }
+ else if (scrvLookUpArray(scrv_text, &index))
+ {
+ yylval->vindex = index;
+ return ARRAY;
+ }
+ else
+ {
+ strcpy(aText[currText], scrv_text);
+ yylval->sval = aText[currText];
+ currText = (currText + 1) % TEXT_BUFFERS;
+ return IDENT;
+ }
+ }
+ YY_BREAK
+/* Match integer numbers */
+case 13:
+YY_RULE_SETUP
+#line 153 "scriptvals_lexer.lpp"
+{ yylval->ival = atol(scrv_text); return INTEGER; }
+ YY_BREAK
+/* Match quoted text */
+case 14:
+YY_RULE_SETUP
+#line 156 "scriptvals_lexer.lpp"
+{ BEGIN QUOTE; }
+ YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 157 "scriptvals_lexer.lpp"
+{ BEGIN 0; }
+ YY_BREAK
+case 16:
+/* rule 16 can match eol */
+YY_RULE_SETUP
+#line 158 "scriptvals_lexer.lpp"
+{ scrv_error("Unexpected end of line in string"); }
+ YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 159 "scriptvals_lexer.lpp"
+{
+ strcpy(aText[currText], scrv_text);
+ yylval->sval = aText[currText];
+ currText = (currText + 1) % TEXT_BUFFERS;
+ return QTEXT;
+ }
+ YY_BREAK
+/* Skip white space */
+case 18:
+/* rule 18 can match eol */
+YY_RULE_SETUP
+#line 167 "scriptvals_lexer.lpp"
+;
+ YY_BREAK
+/* Strip comments */
+case 19:
+YY_RULE_SETUP
+#line 170 "scriptvals_lexer.lpp"
+{ BEGIN COMMENT; }
+ YY_BREAK
+case 20:
+#line 172 "scriptvals_lexer.lpp"
+case 21:
+/* rule 21 can match eol */
+YY_RULE_SETUP
+#line 172 "scriptvals_lexer.lpp"
+{ BEGIN 0; }
+ YY_BREAK
+case 22:
+#line 174 "scriptvals_lexer.lpp"
+case 23:
+/* rule 23 can match eol */
+YY_RULE_SETUP
+#line 174 "scriptvals_lexer.lpp"
+;
+ YY_BREAK
+/* Strip single line comments */
+case 24:
+YY_RULE_SETUP
+#line 177 "scriptvals_lexer.lpp"
+{ BEGIN SLCOMMENT; }
+ YY_BREAK
+case 25:
+/* rule 25 can match eol */
+YY_RULE_SETUP
+#line 178 "scriptvals_lexer.lpp"
+{ BEGIN 0; }
+ YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 179 "scriptvals_lexer.lpp"
+;
+ YY_BREAK
+/* Match anything that's been missed and pass it as a char */
+case 27:
+YY_RULE_SETUP
+#line 182 "scriptvals_lexer.lpp"
+return scrv_text[0];
+ YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 184 "scriptvals_lexer.lpp"
+YY_FATAL_ERROR( "flex scanner jammed" );
+ YY_BREAK
+#line 1113 "scriptvals_lexer.cpp"
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(COMMENT):
+case YY_STATE_EOF(SLCOMMENT):
+case YY_STATE_EOF(QUOTE):
+ yyterminate();
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = (yy_hold_char);
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed scrv_in at a new source and called
+ * scrv_lex(). If so, then we have to assure
+ * consistency between YY_CURRENT_BUFFER and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = scrv_in;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++(yy_c_buf_p);
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ (yy_did_buffer_switch_on_eof) = 0;
+
+ if ( scrv_wrap( ) )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * scrv_text, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) =
+ (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ (yy_c_buf_p) =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+} /* end of scrv_lex */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+static int yy_get_next_buffer (void)
+{
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ register char *source = (yytext_ptr);
+ register int number_to_move, i;
+ int ret_val;
+
+ if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
+
+ else
+ {
+ int num_to_read =
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+
+ int yy_c_buf_p_offset =
+ (int) ((yy_c_buf_p) - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ scrv_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = 0;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+ number_to_move - 1;
+
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+ (yy_n_chars), (size_t) num_to_read );
+
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ if ( (yy_n_chars) == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ scrv_restart(scrv_in );
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) scrv_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
+ (yy_n_chars) += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
+
+ (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+ return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+ static yy_state_type yy_get_previous_state (void)
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp;
+
+ yy_current_state = (yy_start);
+
+ for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
+ {
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 80 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ }
+
+ return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
+{
+ register int yy_is_jam;
+ register char *yy_cp = (yy_c_buf_p);
+
+ register YY_CHAR yy_c = 1;
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 80 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_is_jam = (yy_current_state == 79);
+
+ return yy_is_jam ? 0 : yy_current_state;
+}
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+ static int yyinput (void)
+#else
+ static int input (void)
+#endif
+
+{
+ int c;
+
+ *(yy_c_buf_p) = (yy_hold_char);
+
+ if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ /* This was really a NUL. */
+ *(yy_c_buf_p) = '\0';
+
+ else
+ { /* need more input */
+ int offset = (yy_c_buf_p) - (yytext_ptr);
+ ++(yy_c_buf_p);
+
+ switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ scrv_restart(scrv_in );
+
+ /*FALLTHROUGH*/
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( scrv_wrap( ) )
+ return EOF;
+
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput();
+#else
+ return input();
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) = (yytext_ptr) + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
+ *(yy_c_buf_p) = '\0'; /* preserve scrv_text */
+ (yy_hold_char) = *++(yy_c_buf_p);
+
+ if ( c == '\n' )
+
+ scrv_lineno++;
+;
+
+ return c;
+}
+#endif /* ifndef YY_NO_INPUT */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ *
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+ void scrv_restart (FILE * input_file )
+{
+
+ if ( ! YY_CURRENT_BUFFER ){
+ scrv_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ scrv__create_buffer(scrv_in,YY_BUF_SIZE );
+ }
+
+ scrv__init_buffer(YY_CURRENT_BUFFER,input_file );
+ scrv__load_buffer_state( );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ *
+ */
+ void scrv__switch_to_buffer (YY_BUFFER_STATE new_buffer )
+{
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * scrv_pop_buffer_state();
+ * scrv_push_buffer_state(new_buffer);
+ */
+ scrv_ensure_buffer_stack ();
+ if ( YY_CURRENT_BUFFER == new_buffer )
+ return;
+
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ scrv__load_buffer_state( );
+
+ /* We don't actually know whether we did this switch during
+ * EOF (scrv_wrap()) processing, but the only time this flag
+ * is looked at is after scrv_wrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+static void scrv__load_buffer_state (void)
+{
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ scrv_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ (yy_hold_char) = *(yy_c_buf_p);
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ *
+ * @return the allocated buffer state.
+ */
+ YY_BUFFER_STATE scrv__create_buffer (FILE * file, int size )
+{
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) scrv_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in scrv__create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) scrv_alloc(b->yy_buf_size + 2 );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in scrv__create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ scrv__init_buffer(b,file );
+
+ return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with scrv__create_buffer()
+ *
+ */
+ void scrv__delete_buffer (YY_BUFFER_STATE b )
+{
+
+ if ( ! b )
+ return;
+
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ scrv_free((void *) b->yy_ch_buf );
+
+ scrv_free((void *) b );
+}
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a scrv_restart() or at EOF.
+ */
+ static void scrv__init_buffer (YY_BUFFER_STATE b, FILE * file )
+
+{
+ int oerrno = errno;
+
+ scrv__flush_buffer(b );
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+ /* If b is the current buffer, then scrv__init_buffer was _probably_
+ * called from scrv_restart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
+
+ b->yy_is_interactive = 0;
+
+ errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ *
+ */
+ void scrv__flush_buffer (YY_BUFFER_STATE b )
+{
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == YY_CURRENT_BUFFER )
+ scrv__load_buffer_state( );
+}
+
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ *
+ */
+void scrv_push_buffer_state (YY_BUFFER_STATE new_buffer )
+{
+ if (new_buffer == NULL)
+ return;
+
+ scrv_ensure_buffer_stack();
+
+ /* This block is copied from scrv__switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ (yy_buffer_stack_top)++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from scrv__switch_to_buffer. */
+ scrv__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ *
+ */
+void scrv_pop_buffer_state (void)
+{
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ scrv__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if ((yy_buffer_stack_top) > 0)
+ --(yy_buffer_stack_top);
+
+ if (YY_CURRENT_BUFFER) {
+ scrv__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+ }
+}
+
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+static void scrv_ensure_buffer_stack (void)
+{
+ int num_to_alloc;
+
+ if (!(yy_buffer_stack)) {
+
+ /* First allocation is just for 2 elements, since we don't know if this
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
+ * immediate realloc on the next call.
+ */
+ num_to_alloc = 1;
+ (yy_buffer_stack) = (struct yy_buffer_state**)scrv_alloc
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in scrv_ensure_buffer_stack()" );
+
+ memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+
+ (yy_buffer_stack_max) = num_to_alloc;
+ (yy_buffer_stack_top) = 0;
+ return;
+ }
+
+ if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+
+ /* Increase the buffer to prepare for a possible push. */
+ int grow_size = 8 /* arbitrary grow size */;
+
+ num_to_alloc = (yy_buffer_stack_max) + grow_size;
+ (yy_buffer_stack) = (struct yy_buffer_state**)scrv_realloc
+ ((yy_buffer_stack),
+ num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in scrv_ensure_buffer_stack()" );
+
+ /* zero only the new slots.*/
+ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+ (yy_buffer_stack_max) = num_to_alloc;
+ }
+}
+
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE scrv__scan_buffer (char * base, yy_size_t size )
+{
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return 0;
+
+ b = (YY_BUFFER_STATE) scrv_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in scrv__scan_buffer()" );
+
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = 0;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ scrv__switch_to_buffer(b );
+
+ return b;
+}
+
+/** Setup the input buffer state to scan a string. The next call to scrv_lex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ *
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * scrv__scan_bytes() instead.
+ */
+YY_BUFFER_STATE scrv__scan_string (yyconst char * yystr )
+{
+
+ return scrv__scan_bytes(yystr,strlen(yystr) );
+}
+
+/** Setup the input buffer state to scan the given bytes. The next call to scrv_lex() will
+ * scan from a @e copy of @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE scrv__scan_bytes (yyconst char * yybytes, int _yybytes_len )
+{
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = _yybytes_len + 2;
+ buf = (char *) scrv_alloc(n );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in scrv__scan_bytes()" );
+
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
+
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = scrv__scan_buffer(buf,n );
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in scrv__scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+}
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+static void yy_fatal_error (yyconst char* msg )
+{
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+}
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up scrv_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ scrv_text[scrv_leng] = (yy_hold_char); \
+ (yy_c_buf_p) = scrv_text + yyless_macro_arg; \
+ (yy_hold_char) = *(yy_c_buf_p); \
+ *(yy_c_buf_p) = '\0'; \
+ scrv_leng = yyless_macro_arg; \
+ } \
+ while ( 0 )
+
+/* Accessor methods (get/set functions) to struct members. */
+
+/** Get the current line number.
+ *
+ */
+int scrv_get_lineno (void)
+{
+
+ return scrv_lineno;
+}
+
+/** Get the input stream.
+ *
+ */
+FILE *scrv_get_in (void)
+{
+ return scrv_in;
+}
+
+/** Get the output stream.
+ *
+ */
+FILE *scrv_get_out (void)
+{
+ return scrv_out;
+}
+
+/** Get the length of the current token.
+ *
+ */
+int scrv_get_leng (void)
+{
+ return scrv_leng;
+}
+
+/** Get the current token.
+ *
+ */
+
+char *scrv_get_text (void)
+{
+ return scrv_text;
+}
+
+/** Set the current line number.
+ * @param line_number
+ *
+ */
+void scrv_set_lineno (int line_number )
+{
+
+ scrv_lineno = line_number;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ *
+ * @see scrv__switch_to_buffer
+ */
+void scrv_set_in (FILE * in_str )
+{
+ scrv_in = in_str ;
+}
+
+void scrv_set_out (FILE * out_str )
+{
+ scrv_out = out_str ;
+}
+
+int scrv_get_debug (void)
+{
+ return scrv__flex_debug;
+}
+
+void scrv_set_debug (int bdebug )
+{
+ scrv__flex_debug = bdebug ;
+}
+
+static int yy_init_globals (void)
+{
+ /* Initialization is the same as for the non-reentrant scanner.
+ * This function is called from scrv_lex_destroy(), so don't allocate here.
+ */
+
+ /* We do not touch scrv_lineno unless the option is enabled. */
+ scrv_lineno = 1;
+
+ (yy_buffer_stack) = 0;
+ (yy_buffer_stack_top) = 0;
+ (yy_buffer_stack_max) = 0;
+ (yy_c_buf_p) = (char *) 0;
+ (yy_init) = 0;
+ (yy_start) = 0;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ scrv_in = stdin;
+ scrv_out = stdout;
+#else
+ scrv_in = (FILE *) 0;
+ scrv_out = (FILE *) 0;
+#endif
+
+ /* For future reference: Set errno on error, since we are called by
+ * scrv_lex_init()
+ */
+ return 0;
+}
+
+/* scrv_lex_destroy is for both reentrant and non-reentrant scanners. */
+int scrv_lex_destroy (void)
+{
+
+ /* Pop the buffer stack, destroying each element. */
+ while(YY_CURRENT_BUFFER){
+ scrv__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ scrv_pop_buffer_state();
+ }
+
+ /* Destroy the stack itself. */
+ scrv_free((yy_buffer_stack) );
+ (yy_buffer_stack) = NULL;
+
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * scrv_lex() is called, initialization will occur. */
+ yy_init_globals( );
+
+ return 0;
+}
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+{
+ register int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * s )
+{
+ register int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+}
+#endif
+
+void *scrv_alloc (yy_size_t size )
+{
+ return (void *) malloc( size );
+}
+
+void *scrv_realloc (void * ptr, yy_size_t size )
+{
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return (void *) realloc( (char *) ptr, size );
+}
+
+void scrv_free (void * ptr )
+{
+ free( (char *) ptr ); /* see scrv_realloc() for (char *) cast */
+}
+
+#define YYTABLES_NAME "yytables"
+
+#line 184 "scriptvals_lexer.lpp"
+
+
+
+static YY_EXTRA_TYPE pBuffer = NULL;
+
+void scrv_set_extra(YY_EXTRA_TYPE user_defined)
+{
+ pBuffer = user_defined;
+}
+
+YY_EXTRA_TYPE scrv_get_extra()
+{
+ return pBuffer;
+}
+
+/* Older GNU Flex versions don't define scrv_lex_destroy()
+ * (and neither define a subminor version)
+ */
+#if !defined(YY_FLEX_SUBMINOR_VERSION) || (YY_FLEX_SUBMINOR_VERSION < 9)
+int scrv_lex_destroy(void)
+{
+ /* For non-reentrant C scanner only. */
+ scrv__delete_buffer(YY_CURRENT_BUFFER);
+ yy_init = 1;
+ return 0;
+}
+#endif
+
diff --git a/src/scriptvals_parser.cpp b/src/scriptvals_parser.cpp
new file mode 100644
index 000000000..03ee299e4
--- /dev/null
+++ b/src/scriptvals_parser.cpp
@@ -0,0 +1,2497 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "2.5"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 0
+
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+/* Substitute the variable and function names. */
+#define yyparse scrv_parse
+#define yylex scrv_lex
+#define yyerror scrv_error
+#define yylval scrv_lval
+#define yychar scrv_char
+#define yydebug scrv_debug
+#define yynerrs scrv_nerrs
+
+
+/* Copy the first part of user declarations. */
+
+/* Line 268 of yacc.c */
+#line 20 "scriptvals_parser.ypp"
+
+/*
+ * ScriptVals.y
+ *
+ * yacc grammar for loading script variable values
+ *
+ */
+#include "lib/framework/frame.h"
+#include "lib/framework/frameresource.h"
+#include "lib/framework/strres.h"
+
+#include "lib/gamelib/gtime.h"
+#include "lib/script/script.h"
+#include "lib/sound/audio.h"
+
+#include "src/scriptvals.h"
+#include "lib/framework/lexer_input.h"
+
+#include "scriptvals_parser.h"
+
+#include "src/scripttabs.h"
+#include "src/objects.h"
+#include "src/droid.h"
+#include "src/structure.h"
+#include "src/message.h"
+#include "src/levels.h"
+#include "src/research.h"
+#include "src/text.h"
+#include "src/template.h"
+
+// The current script code
+static SCRIPT_CODE *psCurrScript;
+
+extern int scrv_lex(void);
+extern void scrv_set_extra(YY_EXTRA_TYPE user_defined);
+extern int scrv_lex_destroy(void);
+extern int scrv_get_lineno(void);
+extern char* scrv_get_text(void);
+
+// The current script context
+static SCRIPT_CONTEXT *psCurrContext;
+
+// the current array indexes
+static ARRAY_INDEXES sCurrArrayIndexes;
+
+// check that an array index is valid
+static bool scrvCheckArrayIndex(SDWORD base, ARRAY_INDEXES *psIndexes, UDWORD *pIndex)
+{
+ SDWORD i, size;
+
+ if (!psCurrScript || psCurrScript->psDebug == NULL)
+ {
+ return false;
+ }
+
+ if (base < 0 || base >= psCurrScript->numArrays)
+ {
+ yyerror("Array index out of range");
+ return false;
+ }
+
+ if (psIndexes->dimensions != psCurrScript->psArrayInfo[base].dimensions)
+ {
+ yyerror("Invalid number of dimensions for array initialiser");
+ return false;
+ }
+
+ for(i=0; ipsArrayInfo[base].dimensions; i++)
+ {
+ if ((psIndexes->elements[i] < 0) ||
+ (psIndexes->elements[i] >= psCurrScript->psArrayInfo[base].elements[i]))
+ {
+ yyerror("Invalid index for dimension %d", i);
+ return false;
+ }
+ }
+
+ *pIndex = 0;
+ size = 1;
+ for(i = psCurrScript->psArrayInfo[base].dimensions-1; i >= 0; i--)
+ {
+ *pIndex += psIndexes->elements[i] * size;
+ size *= psCurrScript->psArrayInfo[base].elements[i];
+ }
+
+ *pIndex += psCurrScript->psArrayInfo[base].base;
+
+ return true;
+}
+
+
+
+/* Line 268 of yacc.c */
+#line 176 "scriptvals_parser.cpp"
+
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 1
+#endif
+
+/* Enabling the token table. */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ BOOLEAN_T = 258,
+ INTEGER = 259,
+ IDENT = 260,
+ QTEXT = 261,
+ TYPE = 262,
+ VAR = 263,
+ ARRAY = 264,
+ SCRIPT = 265,
+ STORE = 266,
+ RUN = 267
+ };
+#endif
+/* Tokens. */
+#define BOOLEAN_T 258
+#define INTEGER 259
+#define IDENT 260
+#define QTEXT 261
+#define TYPE 262
+#define VAR 263
+#define ARRAY 264
+#define SCRIPT 265
+#define STORE 266
+#define RUN 267
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 293 of yacc.c */
+#line 120 "scriptvals_parser.ypp"
+
+ bool bval;
+ INTERP_TYPE tval;
+ char *sval;
+ UDWORD vindex;
+ SDWORD ival;
+ VAR_INIT sInit;
+ ARRAY_INDEXES *arrayIndex;
+
+
+
+/* Line 293 of yacc.c */
+#line 248 "scriptvals_parser.cpp"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+
+/* Copy the second part of user declarations. */
+
+
+/* Line 343 of yacc.c */
+#line 260 "scriptvals_parser.cpp"
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if defined YYENABLE_NLS && YYENABLE_NLS
+# if ENABLE_NLS
+# include /* INFRINGES ON USER NAME SPACE */
+# define YY_(msgid) dgettext ("bison-runtime", msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions. */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int yyi)
+#else
+static int
+YYID (yyi)
+ int yyi;
+#endif
+{
+ return yyi;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined EXIT_SUCCESS \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+};
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+# define YYCOPY_NEEDED 1
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (YYID (0))
+
+#endif
+
+#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (YYID (0))
+# endif
+# endif
+#endif /* !YYCOPY_NEEDED */
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 6
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 33
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 17
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 12
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 20
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 37
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 267
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const yytype_uint8 yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 15, 2, 16, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 13, 2, 14, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const yytype_uint8 yyprhs[] =
+{
+ 0, 0, 3, 5, 8, 9, 16, 17, 25, 28,
+ 29, 31, 34, 38, 42, 44, 49, 51, 54, 56,
+ 58
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yytype_int8 yyrhs[] =
+{
+ 18, 0, -1, 19, -1, 18, 19, -1, -1, 22,
+ 12, 20, 13, 23, 14, -1, -1, 22, 11, 6,
+ 21, 13, 23, 14, -1, 10, 6, -1, -1, 24,
+ -1, 23, 24, -1, 27, 7, 28, -1, 15, 4,
+ 16, -1, 25, -1, 26, 15, 4, 16, -1, 8,
+ -1, 9, 26, -1, 3, -1, 4, -1, 6, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const yytype_uint16 yyrline[] =
+{
+ 0, 153, 153, 154, 158, 157, 178, 177, 193, 234,
+ 235, 236, 239, 730, 739, 743, 756, 760, 773, 778,
+ 783
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "$end", "error", "$undefined", "BOOLEAN_T", "INTEGER", "IDENT", "QTEXT",
+ "TYPE", "VAR", "ARRAY", "SCRIPT", "STORE", "RUN", "'{'", "'}'", "'['",
+ "']'", "$accept", "val_file", "script_entry", "$@1", "$@2",
+ "script_name", "var_init_list", "var_init", "array_index",
+ "array_index_list", "var_entry", "var_value", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const yytype_uint16 yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 267, 123, 125, 91, 93
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const yytype_uint8 yyr1[] =
+{
+ 0, 17, 18, 18, 20, 19, 21, 19, 22, 23,
+ 23, 23, 24, 25, 26, 26, 27, 27, 28, 28,
+ 28
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const yytype_uint8 yyr2[] =
+{
+ 0, 2, 1, 2, 0, 6, 0, 7, 2, 0,
+ 1, 2, 3, 3, 1, 4, 1, 2, 1, 1,
+ 1
+};
+
+/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
+ Performed when YYTABLE doesn't specify something else to do. Zero
+ means the default is an error. */
+static const yytype_uint8 yydefact[] =
+{
+ 0, 0, 0, 2, 0, 8, 1, 3, 0, 4,
+ 6, 0, 0, 9, 9, 16, 0, 0, 10, 0,
+ 0, 0, 14, 17, 5, 11, 0, 7, 0, 0,
+ 18, 19, 20, 12, 13, 0, 15
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const yytype_int8 yydefgoto[] =
+{
+ -1, 2, 3, 11, 12, 4, 17, 18, 22, 23,
+ 19, 33
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -8
+static const yytype_int8 yypact[] =
+{
+ 8, 11, 0, -8, 1, -8, -8, -8, 13, -8,
+ -8, 9, 10, 7, 7, -8, 5, -7, -8, 14,
+ -5, 20, -8, 12, -8, -8, 2, -8, 15, 21,
+ -8, -8, -8, -8, -8, 16, -8
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const yytype_int8 yypgoto[] =
+{
+ -8, -8, 24, -8, -8, -8, 19, -6, -8, -8,
+ -8, -8
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If YYTABLE_NINF, syntax error. */
+#define YYTABLE_NINF -1
+static const yytype_uint8 yytable[] =
+{
+ 6, 15, 16, 15, 16, 30, 31, 24, 32, 27,
+ 1, 25, 8, 9, 25, 15, 16, 5, 1, 10,
+ 21, 26, 13, 14, 28, 35, 7, 29, 0, 0,
+ 0, 34, 36, 20
+};
+
+#define yypact_value_is_default(yystate) \
+ ((yystate) == (-8))
+
+#define yytable_value_is_error(yytable_value) \
+ YYID (0)
+
+static const yytype_int8 yycheck[] =
+{
+ 0, 8, 9, 8, 9, 3, 4, 14, 6, 14,
+ 10, 17, 11, 12, 20, 8, 9, 6, 10, 6,
+ 15, 7, 13, 13, 4, 4, 2, 15, -1, -1,
+ -1, 16, 16, 14
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const yytype_uint8 yystos[] =
+{
+ 0, 10, 18, 19, 22, 6, 0, 19, 11, 12,
+ 6, 20, 21, 13, 13, 8, 9, 23, 24, 27,
+ 23, 15, 25, 26, 14, 24, 7, 14, 4, 15,
+ 3, 4, 6, 28, 16, 4, 16
+};
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
+
+
+/* Like YYERROR except do call yyerror. This remains here temporarily
+ to ease the transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. However,
+ YYFAIL appears to be in use. Nevertheless, it is formally deprecated
+ in Bison 2.4.2's NEWS entry, where a plan to phase it out is
+ discussed. */
+
+#define YYFAIL goto yyerrlab
+#if defined YYFAIL
+ /* This is here to suppress warnings from the GCC cpp's
+ -Wunused-macros. Normally we don't worry about that warning, but
+ some users do, and we want to make it easy for users to remove
+ YYFAIL uses, which will produce warnings from Bison 2.5. */
+#endif
+
+#define YYRECOVERING() (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (1); \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+while (YYID (0))
+
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+ If N is 0, then set CURRENT to the empty location which ends
+ the previous symbol: RHS[0] (always defined). */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (YYID (N)) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ } \
+ while (YYID (0))
+#endif
+
+
+/* This macro is provided for backward compatibility. */
+
+#ifndef YY_LOCATION_PRINT
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+#endif
+
+
+/* YYLEX -- calling `yylex' with the right arguments. */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (YYLEX_PARAM)
+#else
+# define YYLEX yylex ()
+#endif
+
+/* Enable debugging if requested. */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+# include /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, \
+ Type, Value); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (YYID (0))
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (!yyvaluep)
+ return;
+# ifdef YYPRINT
+ if (yytype < YYNTOKENS)
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# else
+ YYUSE (yyoutput);
+# endif
+ switch (yytype)
+ {
+ default:
+ break;
+ }
+}
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (yytype < YYNTOKENS)
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+ else
+ YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+ yy_symbol_value_print (yyoutput, yytype, yyvaluep);
+ YYFPRINTF (yyoutput, ")");
+}
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included). |
+`------------------------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
+#else
+static void
+yy_stack_print (yybottom, yytop)
+ yytype_int16 *yybottom;
+ yytype_int16 *yytop;
+#endif
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
+ YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (YYID (0))
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
+#else
+static void
+yy_reduce_print (yyvsp, yyrule)
+ YYSTYPE *yyvsp;
+ int yyrule;
+#endif
+{
+ int yynrhs = yyr2[yyrule];
+ int yyi;
+ unsigned long int yylno = yyrline[yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+ yyrule - 1, yylno);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+ &(yyvsp[(yyi + 1) - (yynrhs)])
+ );
+ YYFPRINTF (stderr, "\n");
+ }
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyvsp, Rule); \
+} while (YYID (0))
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+# if defined __GLIBC__ && defined _STRING_H
+# define yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static YYSIZE_T
+yystrlen (const char *yystr)
+#else
+static YYSIZE_T
+yystrlen (yystr)
+ const char *yystr;
+#endif
+{
+ YYSIZE_T yylen;
+ for (yylen = 0; yystr[yylen]; yylen++)
+ continue;
+ return yylen;
+}
+# endif
+# endif
+
+# ifndef yystpcpy
+# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static char *
+yystpcpy (char *yydest, const char *yysrc)
+#else
+static char *
+yystpcpy (yydest, yysrc)
+ char *yydest;
+ const char *yysrc;
+#endif
+{
+ char *yyd = yydest;
+ const char *yys = yysrc;
+
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
+
+ return yyd - 1;
+}
+# endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+ if (*yystr == '"')
+ {
+ YYSIZE_T yyn = 0;
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
+ do_not_strip_quotes: ;
+ }
+
+ if (! yyres)
+ return yystrlen (yystr);
+
+ return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
+ about the unexpected token YYTOKEN for the state stack whose top is
+ YYSSP.
+
+ Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
+ not large enough to hold the message. In that case, also set
+ *YYMSG_ALLOC to the required number of bytes. Return 2 if the
+ required number of bytes is too large to store. */
+static int
+yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
+ yytype_int16 *yyssp, int yytoken)
+{
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
+ YYSIZE_T yysize = yysize0;
+ YYSIZE_T yysize1;
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ /* Internationalized format string. */
+ const char *yyformat = 0;
+ /* Arguments of yyformat. */
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ /* Number of reported tokens (one for the "unexpected", one per
+ "expected"). */
+ int yycount = 0;
+
+ /* There are many possibilities here to consider:
+ - Assume YYFAIL is not used. It's too flawed to consider. See
+
+ for details. YYERROR is fine as it does not invoke this
+ function.
+ - If this state is a consistent state with a default action, then
+ the only way this function was invoked is if the default action
+ is an error action. In that case, don't check for expected
+ tokens because there are none.
+ - The only way there can be no lookahead present (in yychar) is if
+ this state is a consistent state with a default action. Thus,
+ detecting the absence of a lookahead is sufficient to determine
+ that there is no unexpected or expected token to report. In that
+ case, just report a simple "syntax error".
+ - Don't assume there isn't a lookahead just because this state is a
+ consistent state with a default action. There might have been a
+ previous inconsistent state, consistent state with a non-default
+ action, or user semantic action that manipulated yychar.
+ - Of course, the expected token list depends on states to have
+ correct lookahead information, and it depends on the parser not
+ to perform extra reductions after fetching a lookahead from the
+ scanner and before detecting a syntax error. Thus, state merging
+ (from LALR or IELR) and default reductions corrupt the expected
+ token list. However, the list is correct for canonical LR with
+ one exception: it will still contain any token that will not be
+ accepted due to an error action in a later state.
+ */
+ if (yytoken != YYEMPTY)
+ {
+ int yyn = yypact[*yyssp];
+ yyarg[yycount++] = yytname[yytoken];
+ if (!yypact_value_is_default (yyn))
+ {
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. In other words, skip the first -YYN actions for
+ this state because they are default actions. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn + 1;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yyx;
+
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
+ && !yytable_value_is_error (yytable[yyx + yyn]))
+ {
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ yycount = 1;
+ yysize = yysize0;
+ break;
+ }
+ yyarg[yycount++] = yytname[yyx];
+ yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+ if (! (yysize <= yysize1
+ && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+ }
+ }
+ }
+
+ switch (yycount)
+ {
+# define YYCASE_(N, S) \
+ case N: \
+ yyformat = S; \
+ break
+ YYCASE_(0, YY_("syntax error"));
+ YYCASE_(1, YY_("syntax error, unexpected %s"));
+ YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
+ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
+ YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
+ YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
+# undef YYCASE_
+ }
+
+ yysize1 = yysize + yystrlen (yyformat);
+ if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+
+ if (*yymsg_alloc < yysize)
+ {
+ *yymsg_alloc = 2 * yysize;
+ if (! (yysize <= *yymsg_alloc
+ && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
+ *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
+ return 1;
+ }
+
+ /* Avoid sprintf, as that infringes on the user's name space.
+ Don't have undefined behavior even if the translation
+ produced a string with the wrong number of "%s"s. */
+ {
+ char *yyp = *yymsg;
+ int yyi = 0;
+ while ((*yyp = *yyformat) != '\0')
+ if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyformat += 2;
+ }
+ else
+ {
+ yyp++;
+ yyformat++;
+ }
+ }
+ return 0;
+}
+#endif /* YYERROR_VERBOSE */
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol. |
+`-----------------------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
+#else
+static void
+yydestruct (yymsg, yytype, yyvaluep)
+ const char *yymsg;
+ int yytype;
+ YYSTYPE *yyvaluep;
+#endif
+{
+ YYUSE (yyvaluep);
+
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+ switch (yytype)
+ {
+
+ default:
+ break;
+ }
+}
+
+
+/* Prevent warnings from -Wmissing-prototypes. */
+#ifdef YYPARSE_PARAM
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void *YYPARSE_PARAM);
+#else
+int yyparse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+/* The lookahead symbol. */
+int yychar;
+
+/* The semantic value of the lookahead symbol. */
+YYSTYPE yylval;
+
+/* Number of syntax errors so far. */
+int yynerrs;
+
+
+/*----------.
+| yyparse. |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *YYPARSE_PARAM)
+#else
+int
+yyparse (YYPARSE_PARAM)
+ void *YYPARSE_PARAM;
+#endif
+#else /* ! YYPARSE_PARAM */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void)
+#else
+int
+yyparse ()
+
+#endif
+#endif
+{
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
+
+ YYSIZE_T yystacksize;
+
+ int yyn;
+ int yyresult;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char yymsgbuf[128];
+ char *yymsg = yymsgbuf;
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+
+ /* The number of symbols on the RHS of the reduced rule.
+ Keep to zero when no symbol should be popped. */
+ int yylen = 0;
+
+ yytoken = 0;
+ yyss = yyssa;
+ yyvs = yyvsa;
+ yystacksize = YYINITDEPTH;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+ yyssp = yyss;
+ yyvsp = yyvs;
+
+ goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate. |
+`------------------------------------------------------------*/
+ yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. So pushing a state here evens the stacks. */
+ yyssp++;
+
+ yysetstate:
+ *yyssp = yystate;
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ {
+ /* Get the current used size of the three stacks, in elements. */
+ YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ {
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ yytype_int16 *yyss1 = yyss;
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
+ &yystacksize);
+
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+# else
+ /* Extend the stack our own way. */
+ if (YYMAXDEPTH <= yystacksize)
+ goto yyexhaustedlab;
+ yystacksize *= 2;
+ if (YYMAXDEPTH < yystacksize)
+ yystacksize = YYMAXDEPTH;
+
+ {
+ yytype_int16 *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyexhaustedlab;
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+# undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+ }
+# endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + yysize - 1;
+ yyvsp = yyvs + yysize - 1;
+
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ YYABORT;
+ }
+
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
+ goto yybackup;
+
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
+
+ /* Do appropriate processing given the current state. Read a
+ lookahead token if we need one and don't already have one. */
+
+ /* First try to decide what to do without reference to lookahead token. */
+ yyn = yypact[yystate];
+ if (yypact_value_is_default (yyn))
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
+ }
+
+ if (yychar <= YYEOF)
+ {
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ }
+
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
+ detect an error, take that action. */
+ yyn += yytoken;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+ goto yydefault;
+ yyn = yytable[yyn];
+ if (yyn <= 0)
+ {
+ if (yytable_value_is_error (yyn))
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
+
+ /* Shift the lookahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
+
+ yystate = yyn;
+ *++yyvsp = yylval;
+
+ goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+yydefault:
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction. |
+`-----------------------------*/
+yyreduce:
+ /* yyn is the number of a rule to reduce with. */
+ yylen = yyr2[yyn];
+
+ /* If YYLEN is nonzero, implement the default value of the action:
+ `$$ = $1'.
+
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ yyval = yyvsp[1-yylen];
+
+
+ YY_REDUCE_PRINT (yyn);
+ switch (yyn)
+ {
+ case 4:
+
+/* Line 1806 of yacc.c */
+#line 158 "scriptvals_parser.ypp"
+ {
+ if (!eventNewContext(psCurrScript, CR_RELEASE, &psCurrContext))
+ {
+ yyerror("Couldn't create context");
+ YYABORT;
+ }
+ if (!scrvAddContext((yyvsp[(1) - (2)].sval), psCurrContext, SCRV_EXEC))
+ {
+ yyerror("Couldn't store context");
+ YYABORT;
+ }
+ }
+ break;
+
+ case 5:
+
+/* Line 1806 of yacc.c */
+#line 171 "scriptvals_parser.ypp"
+ {
+ if (!eventRunContext(psCurrContext, gameTime/SCR_TICKRATE))
+ {
+ YYABORT;
+ }
+ }
+ break;
+
+ case 6:
+
+/* Line 1806 of yacc.c */
+#line 178 "scriptvals_parser.ypp"
+ {
+ if (!eventNewContext(psCurrScript, CR_NORELEASE, &psCurrContext))
+ {
+ yyerror("Couldn't create context");
+ YYABORT;
+ }
+ if (!scrvAddContext((yyvsp[(3) - (3)].sval), psCurrContext, SCRV_NOEXEC))
+ {
+ yyerror("Couldn't store context");
+ YYABORT;
+ }
+ }
+ break;
+
+ case 8:
+
+/* Line 1806 of yacc.c */
+#line 194 "scriptvals_parser.ypp"
+ {
+
+ int namelen,extpos;
+ char *stringname;
+
+ stringname=(yyvsp[(2) - (2)].sval);
+
+ namelen=strlen( stringname);
+ extpos=namelen-3;
+ if (strncmp(&stringname[extpos],"blo",3)==0)
+ {
+ if (resPresent("BLO",stringname)==true)
+ {
+ psCurrScript = (SCRIPT_CODE*)resGetData("BLO",stringname);
+ }
+ else
+ {
+ // change extension to "slo"
+ stringname[extpos]='s';
+ psCurrScript = (SCRIPT_CODE*)resGetData("SCRIPT",stringname);
+ }
+ }
+ else if (strncmp(&stringname[extpos],"slo",3)==0)
+ {
+ if (resPresent("SCRIPT",stringname)==true)
+ {
+ psCurrScript = (SCRIPT_CODE*)resGetData("SCRIPT",stringname);
+ }
+ }
+
+ if (!psCurrScript)
+ {
+ yyerror("Script file %s not found", stringname);
+ YYABORT;
+ }
+
+ (yyval.sval) = (yyvsp[(2) - (2)].sval);
+ }
+ break;
+
+ case 12:
+
+/* Line 1806 of yacc.c */
+#line 240 "scriptvals_parser.ypp"
+ {
+ INTERP_VAL data; /* structure to to hold all types */
+ BASE_OBJECT *psObj;
+ SDWORD compIndex;
+
+ /* set type */
+ data.type = (yyvsp[(2) - (3)].tval);
+
+ switch ((unsigned)(yyvsp[(2) - (3)].tval)) // Unsigned cast to suppress compiler warnings due to enum abuse.
+ {
+ case VAL_INT:
+ data.v.ival = (yyvsp[(3) - (3)].sInit).index; //index = integer value of the variable, not var index
+ if ((yyvsp[(3) - (3)].sInit).type != IT_INDEX ||
+ !eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ case ST_DROID:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_INDEX)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ psObj = getBaseObjFromId((UDWORD)(yyvsp[(3) - (3)].sInit).index);
+ if (!psObj)
+ {
+ yyerror("Droid id %d not found", (UDWORD)(yyvsp[(3) - (3)].sInit).index);
+ YYABORT;
+ }
+
+ data.v.oval = psObj; /* store as pointer */
+
+ if (psObj->type != OBJ_DROID)
+ {
+ yyerror("Object id %d is not a droid", (UDWORD)(yyvsp[(3) - (3)].sInit).index);
+ YYABORT;
+ }
+ else
+ {
+ if(!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ }
+ break;
+
+ case ST_STRUCTURE:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_INDEX)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ psObj = getBaseObjFromId((UDWORD)(yyvsp[(3) - (3)].sInit).index);
+ if (!psObj)
+ {
+ yyerror("Structure id %d not found", (UDWORD)(yyvsp[(3) - (3)].sInit).index);
+ YYABORT;
+ }
+
+ data.v.oval = psObj;
+
+ if (psObj->type != OBJ_STRUCTURE)
+ {
+ yyerror("Object id %d is not a structure", (UDWORD)(yyvsp[(3) - (3)].sInit).index);
+ YYABORT;
+ }
+ else
+ {
+ if(!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ }
+ break;
+ case ST_FEATURE:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_INDEX)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ psObj = getBaseObjFromId((UDWORD)(yyvsp[(3) - (3)].sInit).index);
+ if (!psObj)
+ {
+ yyerror("Feature id %d not found", (UDWORD)(yyvsp[(3) - (3)].sInit).index);
+ YYABORT;
+ }
+
+ data.v.oval = psObj;
+
+ if (psObj->type != OBJ_FEATURE)
+ {
+ yyerror("Object id %d is not a feature", (UDWORD)(yyvsp[(3) - (3)].sInit).index);
+ YYABORT;
+ }
+ else
+ {
+ if(!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ }
+ break;
+ case ST_FEATURESTAT:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+
+ data.v.ival = getFeatureStatFromName((yyvsp[(3) - (3)].sInit).pString);
+
+ if (data.v.ival == -1)
+ {
+ yyerror("Feature Stat %s not found", (yyvsp[(3) - (3)].sInit).pString);
+ YYABORT;
+ }
+ if (!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ case VAL_BOOL:
+ data.v.bval = (yyvsp[(3) - (3)].sInit).index; //index = boolean value, not var index
+ if ((yyvsp[(3) - (3)].sInit).type != IT_BOOL ||
+ !eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ case ST_BODY:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ data.v.ival = getCompFromResName(COMP_BODY, (yyvsp[(3) - (3)].sInit).pString);
+ if (data.v.ival == -1)
+ {
+ yyerror("body component %s not found", (yyvsp[(3) - (3)].sInit).pString);
+ YYABORT;
+ }
+ if (!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ case ST_PROPULSION:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ data.v.ival = getCompFromResName(COMP_PROPULSION, (yyvsp[(3) - (3)].sInit).pString);
+ if (data.v.ival == -1)
+ {
+ yyerror("Propulsion component %s not found", (yyvsp[(3) - (3)].sInit).pString);
+ YYABORT;
+ }
+ if (!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ case ST_ECM:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ data.v.ival = getCompFromResName(COMP_ECM, (yyvsp[(3) - (3)].sInit).pString);
+ if (data.v.ival == -1)
+ {
+ yyerror("ECM component %s not found", (yyvsp[(3) - (3)].sInit).pString);
+ YYABORT;
+ }
+ if (!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ case ST_SENSOR:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ data.v.ival = getCompFromResName(COMP_SENSOR, (yyvsp[(3) - (3)].sInit).pString);
+ if (data.v.ival == -1)
+ {
+ yyerror("Sensor component %s not found", (yyvsp[(3) - (3)].sInit).pString);
+ YYABORT;
+ }
+ if (!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ case ST_CONSTRUCT:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ data.v.ival = getCompFromResName(COMP_CONSTRUCT, (yyvsp[(3) - (3)].sInit).pString);
+ if (data.v.ival == -1)
+ {
+ yyerror("Construct component %s not found", (yyvsp[(3) - (3)].sInit).pString);
+ YYABORT;
+ }
+ if (!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ case ST_REPAIR:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ data.v.ival = getCompFromResName(COMP_REPAIRUNIT, (yyvsp[(3) - (3)].sInit).pString);
+ if (data.v.ival == -1)
+ {
+ yyerror("Repair component %s not found", (yyvsp[(3) - (3)].sInit).pString);
+ YYABORT;
+ }
+ if (!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ case ST_BRAIN:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ data.v.ival = getCompFromResName(COMP_BRAIN, (yyvsp[(3) - (3)].sInit).pString);
+ if (data.v.ival == -1)
+ {
+ yyerror("Brain component %s not found", (yyvsp[(3) - (3)].sInit).pString);
+ YYABORT;
+ }
+ if (!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ case ST_WEAPON:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ data.v.ival = getCompFromResName(COMP_WEAPON, (yyvsp[(3) - (3)].sInit).pString);
+ if (data.v.ival == -1)
+ {
+ yyerror("Weapon component %s not found", (yyvsp[(3) - (3)].sInit).pString);
+ YYABORT;
+ }
+ if (!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ case ST_TEMPLATE:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ data.v.oval = getTemplateFromTranslatedNameNoPlayer((yyvsp[(3) - (3)].sInit).pString); /* store pointer to the template */
+ if (data.v.oval == NULL)
+ {
+ yyerror("Template %s not found", (yyvsp[(3) - (3)].sInit).pString);
+ YYABORT;
+ }
+ if (!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ case ST_STRUCTURESTAT:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ data.v.ival = getStructStatFromName((yyvsp[(3) - (3)].sInit).pString);
+ if (data.v.ival == -1)
+ {
+ yyerror("Structure Stat %s not found", (yyvsp[(3) - (3)].sInit).pString);
+ YYABORT;
+ }
+ if (!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ case ST_STRUCTUREID:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_INDEX)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ psObj = getBaseObjFromId((UDWORD)(yyvsp[(3) - (3)].sInit).index);
+ if (!psObj)
+ {
+ yyerror("Structure id %d not found", (UDWORD)(yyvsp[(3) - (3)].sInit).index);
+ YYABORT;
+ }
+ data.v.ival = (yyvsp[(3) - (3)].sInit).index; /* store structure id */
+ if (psObj->type != OBJ_STRUCTURE)
+ {
+ yyerror("Object id %d is not a structure", (UDWORD)(yyvsp[(3) - (3)].sInit).index);
+ YYABORT;
+ }
+ else
+ {
+ if(!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ }
+ break;
+ case ST_DROIDID:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_INDEX)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ psObj = getBaseObjFromId((UDWORD)(yyvsp[(3) - (3)].sInit).index);
+ if (!psObj)
+ {
+ yyerror("Droid id %d not found", (UDWORD)(yyvsp[(3) - (3)].sInit).index);
+ YYABORT;
+ }
+ data.v.ival = (yyvsp[(3) - (3)].sInit).index; /* store id*/
+ if (psObj->type != OBJ_DROID)
+ {
+ yyerror("Object id %d is not a droid", (UDWORD)(yyvsp[(3) - (3)].sInit).index);
+ YYABORT;
+ }
+ else
+ {
+ if(!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ }
+ break;
+ case ST_INTMESSAGE:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ data.v.oval = getViewData((yyvsp[(3) - (3)].sInit).pString); /* store pointer to the intelligence message */
+ if (data.v.oval == NULL)
+ {
+ yyerror("Message %s not found", (yyvsp[(3) - (3)].sInit).pString);
+ YYABORT;
+ }
+ if(!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ case ST_TEXTSTRING:
+ {
+ const char* pString;
+
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ pString = strresGetString(psStringRes, (yyvsp[(3) - (3)].sInit).pString);
+ if (!pString)
+ {
+ yyerror("Cannot find the string for id \"%s\"", (yyvsp[(3) - (3)].sInit).pString);
+ YYABORT;
+ }
+ data.v.sval = strdup(pString);
+ if (!data.v.sval)
+ {
+ debug(LOG_ERROR, "Out of memory");
+ abort();
+ YYABORT;
+ }
+ if (!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ }
+ case ST_LEVEL:
+ {
+ LEVEL_DATASET *psLevel;
+
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ // just check the level exists
+ psLevel = levFindDataSet((yyvsp[(3) - (3)].sInit).pString);
+ if (psLevel == NULL)
+ {
+ yyerror("Level %s not found", (yyvsp[(3) - (3)].sInit).pString);
+ YYABORT;
+ }
+ data.v.sval = psLevel->pName; /* store string pointer */
+ if (!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ }
+ break;
+ case ST_SOUND:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ /* find audio id */
+ compIndex = audio_GetTrackID( (yyvsp[(3) - (3)].sInit).pString );
+ if (compIndex == SAMPLE_NOT_FOUND)
+ {
+ /* set track vals */
+ compIndex = audio_SetTrackVals((yyvsp[(3) - (3)].sInit).pString, false, 100, 1800);
+ }
+ /* save track ID */
+ data.v.ival = compIndex;
+ if (!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ case ST_RESEARCH:
+ if ((yyvsp[(3) - (3)].sInit).type != IT_STRING)
+ {
+ yyerror("Typemismatch for variable %d", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ data.v.oval = getResearch((yyvsp[(3) - (3)].sInit).pString); /* store pointer */
+#if 0
+ if (data.v.oval == NULL)
+ {
+ yyerror("Research %s not found", (yyvsp[(3) - (3)].sInit).pString);
+ YYABORT;
+ }
+#endif
+ if(!eventSetContextVar(psCurrContext, (yyvsp[(1) - (3)].vindex), &data))
+ {
+ yyerror("Set Value Failed for %u", (yyvsp[(1) - (3)].vindex));
+ YYABORT;
+ }
+ break;
+ default:
+ yyerror("Unknown type: %s", asTypeTable[(yyvsp[(2) - (3)].tval)].pIdent);
+ YYABORT;
+ break;
+ }
+ }
+ break;
+
+ case 13:
+
+/* Line 1806 of yacc.c */
+#line 731 "scriptvals_parser.ypp"
+ {
+ sCurrArrayIndexes.dimensions = 1;
+ sCurrArrayIndexes.elements[0] = (yyvsp[(2) - (3)].ival);
+
+ (yyval.arrayIndex) = &sCurrArrayIndexes;
+ }
+ break;
+
+ case 14:
+
+/* Line 1806 of yacc.c */
+#line 740 "scriptvals_parser.ypp"
+ {
+ (yyval.arrayIndex) = (yyvsp[(1) - (1)].arrayIndex);
+ }
+ break;
+
+ case 15:
+
+/* Line 1806 of yacc.c */
+#line 744 "scriptvals_parser.ypp"
+ {
+ if ((yyvsp[(1) - (4)].arrayIndex)->dimensions >= VAR_MAX_DIMENSIONS)
+ {
+ yyerror("Too many dimensions for array");
+ YYABORT;
+ }
+ (yyvsp[(1) - (4)].arrayIndex)->elements[(yyvsp[(1) - (4)].arrayIndex)->dimensions] = (yyvsp[(3) - (4)].ival);
+ (yyvsp[(1) - (4)].arrayIndex)->dimensions += 1;
+ }
+ break;
+
+ case 16:
+
+/* Line 1806 of yacc.c */
+#line 757 "scriptvals_parser.ypp"
+ {
+ (yyval.vindex) = (yyvsp[(1) - (1)].vindex);
+ }
+ break;
+
+ case 17:
+
+/* Line 1806 of yacc.c */
+#line 761 "scriptvals_parser.ypp"
+ {
+ UDWORD index;
+
+ if (!scrvCheckArrayIndex((yyvsp[(1) - (2)].vindex), (yyvsp[(2) - (2)].arrayIndex), &index))
+ {
+ YYABORT;
+ }
+
+ (yyval.vindex) = index;
+ }
+ break;
+
+ case 18:
+
+/* Line 1806 of yacc.c */
+#line 774 "scriptvals_parser.ypp"
+ {
+ (yyval.sInit).type = IT_BOOL;
+ (yyval.sInit).index = (yyvsp[(1) - (1)].bval);
+ }
+ break;
+
+ case 19:
+
+/* Line 1806 of yacc.c */
+#line 779 "scriptvals_parser.ypp"
+ {
+ (yyval.sInit).type = IT_INDEX;
+ (yyval.sInit).index = (yyvsp[(1) - (1)].ival);
+ }
+ break;
+
+ case 20:
+
+/* Line 1806 of yacc.c */
+#line 784 "scriptvals_parser.ypp"
+ {
+ (yyval.sInit).type = IT_STRING;
+ (yyval.sInit).pString = (yyvsp[(1) - (1)].sval);
+ }
+ break;
+
+
+
+/* Line 1806 of yacc.c */
+#line 2181 "scriptvals_parser.cpp"
+ default: break;
+ }
+ /* User semantic actions sometimes alter yychar, and that requires
+ that yytoken be updated with the new translation. We take the
+ approach of translating immediately before every use of yytoken.
+ One alternative is translating here after every semantic action,
+ but that translation would be missed if the semantic action invokes
+ YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
+ if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
+ incorrect destructor might then be invoked immediately. In the
+ case of YYERROR or YYBACKUP, subsequent parser actions might lead
+ to an incorrect destructor call or verbose syntax error message
+ before the lookahead is translated. */
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
+
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+
+ *++yyvsp = yyval;
+
+ /* Now `shift' the result of the reduction. Determine what state
+ that goes to, based on the state we popped back to and the rule
+ number reduced by. */
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTOKENS];
+
+ goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
+
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus)
+ {
+ ++yynerrs;
+#if ! YYERROR_VERBOSE
+ yyerror (YY_("syntax error"));
+#else
+# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
+ yyssp, yytoken)
+ {
+ char const *yymsgp = YY_("syntax error");
+ int yysyntax_error_status;
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ if (yysyntax_error_status == 0)
+ yymsgp = yymsg;
+ else if (yysyntax_error_status == 1)
+ {
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+ yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
+ if (!yymsg)
+ {
+ yymsg = yymsgbuf;
+ yymsg_alloc = sizeof yymsgbuf;
+ yysyntax_error_status = 2;
+ }
+ else
+ {
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ yymsgp = yymsg;
+ }
+ }
+ yyerror (yymsgp);
+ if (yysyntax_error_status == 2)
+ goto yyexhaustedlab;
+ }
+# undef YYSYNTAX_ERROR
+#endif
+ }
+
+
+
+ if (yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ if (yychar <= YYEOF)
+ {
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ YYABORT;
+ }
+ else
+ {
+ yydestruct ("Error: discarding",
+ yytoken, &yylval);
+ yychar = YYEMPTY;
+ }
+ }
+
+ /* Else will try to reuse lookahead token after shifting the error
+ token. */
+ goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR. |
+`---------------------------------------------------*/
+yyerrorlab:
+
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label yyerrorlab therefore never appears in user
+ code. */
+ if (/*CONSTCOND*/ 0)
+ goto yyerrorlab;
+
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYERROR. */
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+ yystate = *yyssp;
+ goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR. |
+`-------------------------------------------------------------*/
+yyerrlab1:
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
+
+ for (;;)
+ {
+ yyn = yypact[yystate];
+ if (!yypact_value_is_default (yyn))
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yyssp == yyss)
+ YYABORT;
+
+
+ yydestruct ("Error: popping",
+ yystos[yystate], yyvsp);
+ YYPOPSTACK (1);
+ yystate = *yyssp;
+ YY_STACK_PRINT (yyss, yyssp);
+ }
+
+ *++yyvsp = yylval;
+
+
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+#if !defined(yyoverflow) || YYERROR_VERBOSE
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here. |
+`-------------------------------------------------*/
+yyexhaustedlab:
+ yyerror (YY_("memory exhausted"));
+ yyresult = 2;
+ /* Fall through. */
+#endif
+
+yyreturn:
+ if (yychar != YYEMPTY)
+ {
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = YYTRANSLATE (yychar);
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval);
+ }
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYABORT or YYACCEPT. */
+ YYPOPSTACK (yylen);
+ YY_STACK_PRINT (yyss, yyssp);
+ while (yyssp != yyss)
+ {
+ yydestruct ("Cleanup: popping",
+ yystos[*yyssp], yyvsp);
+ YYPOPSTACK (1);
+ }
+#ifndef yyoverflow
+ if (yyss != yyssa)
+ YYSTACK_FREE (yyss);
+#endif
+#if YYERROR_VERBOSE
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+#endif
+ /* Make sure YYID is used. */
+ return YYID (yyresult);
+}
+
+
+
+/* Line 2067 of yacc.c */
+#line 790 "scriptvals_parser.ypp"
+
+
+// Lookup a type
+bool scrvLookUpType(const char *pIdent, INTERP_TYPE *pType)
+{
+ TYPE_SYMBOL *psCurr;
+
+ for(psCurr = asTypeTable; psCurr->typeID != 0; psCurr++)
+ {
+ if (strcmp(psCurr->pIdent, pIdent) == 0)
+ {
+ *pType = psCurr->typeID;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+// Lookup a variable identifier
+bool scrvLookUpVar(const char *pIdent, UDWORD *pIndex)
+{
+ UDWORD i;
+
+ if (!psCurrScript || psCurrScript->psDebug == NULL)
+ {
+ return false;
+ }
+
+ for(i=0; inumGlobals; i++)
+ {
+ if (psCurrScript->psVarDebug[i].pIdent != NULL &&
+ strcmp(psCurrScript->psVarDebug[i].pIdent, pIdent) == 0)
+ {
+ *pIndex = i;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+// Lookup an array identifier
+bool scrvLookUpArray(const char *pIdent, UDWORD *pIndex)
+{
+ UDWORD i;
+
+ if (!psCurrScript || psCurrScript->psDebug == NULL)
+ {
+ return false;
+ }
+
+ for(i=0; inumArrays; i++)
+ {
+ if (psCurrScript->psArrayDebug[i].pIdent != NULL &&
+ strcmp(psCurrScript->psArrayDebug[i].pIdent, pIdent) == 0)
+ {
+ *pIndex = i;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+// Load a script value file
+bool scrvLoad(PHYSFS_file* fileHandle)
+{
+ bool retval;
+ lexerinput_t input;
+
+ input.type = LEXINPUT_PHYSFS;
+ input.input.physfsfile = fileHandle;
+
+ scrv_set_extra(&input);
+
+ retval = (scrv_parse() == 0);
+ scrv_lex_destroy();
+
+ return retval;
+}
+
+/* A simple error reporting routine */
+void yyerror(const char* fmt, ...)
+{
+ char* txtBuf;
+ size_t size;
+ va_list args;
+
+ va_start(args, fmt);
+ size = vsnprintf(NULL, 0, fmt, args);
+ va_end(args);
+
+ txtBuf = (char *)alloca(size + 1);
+
+ va_start(args, fmt);
+ vsprintf(txtBuf, fmt, args);
+ va_end(args);
+
+ debug(LOG_ERROR, "VLO parse error: %s at line %d, text: '%s'",
+ txtBuf, scrv_get_lineno(), scrv_get_text());
+}
+
diff --git a/src/scriptvals_parser.h b/src/scriptvals_parser.h
new file mode 100644
index 000000000..8a120037b
--- /dev/null
+++ b/src/scriptvals_parser.h
@@ -0,0 +1,81 @@
+/*
+ This file is part of Warzone 2100.
+ Copyright (C) 2005-2013 Warzone 2100 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
+*/
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ BOOLEAN_T = 258,
+ INTEGER = 259,
+ IDENT = 260,
+ QTEXT = 261,
+ TYPE = 262,
+ VAR = 263,
+ ARRAY = 264,
+ SCRIPT = 265,
+ STORE = 266,
+ RUN = 267
+ };
+#endif
+/* Tokens. */
+#define BOOLEAN_T 258
+#define INTEGER 259
+#define IDENT 260
+#define QTEXT 261
+#define TYPE 262
+#define VAR 263
+#define ARRAY 264
+#define SCRIPT 265
+#define STORE 266
+#define RUN 267
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 2068 of yacc.c */
+#line 120 "scriptvals_parser.ypp"
+
+ bool bval;
+ INTERP_TYPE tval;
+ char *sval;
+ UDWORD vindex;
+ SDWORD ival;
+ VAR_INIT sInit;
+ ARRAY_INDEXES *arrayIndex;
+
+
+
+/* Line 2068 of yacc.c */
+#line 86 "scriptvals_parser.h"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+extern YYSTYPE scrv_lval;
+
+
diff --git a/win32/MSVCdelparser.bat b/win32/MSVCdelparser.bat
deleted file mode 100644
index 93af4351b..000000000
--- a/win32/MSVCdelparser.bat
+++ /dev/null
@@ -1,23 +0,0 @@
-del ..\lib\framework\resource_lexer.cpp
-del ..\lib\framework\resource_parser.cpp
-del ..\lib\framework\resource_parser.hpp
-del ..\lib\framework\strres_lexer.cpp
-del ..\lib\framework\strres_parser.cpp
-del ..\lib\framework\strres_parser.hpp
-del ..\lib\gamelib\audp_lexer.cpp
-del ..\lib\gamelib\audp_parser.cpp
-del ..\lib\gamelib\audp_parser.hpp
-del ..\lib\script\chat_lexer.cpp
-del ..\lib\script\chat_parser.cpp
-del ..\lib\script\chat_parser.hpp
-del ..\lib\script\script_lexer.cpp
-del ..\lib\script\script_parser.cpp
-del ..\lib\script\script_parser.hpp
-del ..\src\autorevision.h
-del ..\src\level_lexer.cpp
-del ..\src\message_lexer.cpp
-del ..\src\message_parser.cpp
-del ..\src\message_parser.hpp
-del ..\src\scriptvals_lexer.cpp
-del ..\src\scriptvals_parser.cpp
-del ..\src\scriptvals_parser.hpp