CMDscan.cpp

Engine/source/console/CMDscan.cpp

More...

Classes:

Public Defines

define
BEGIN() yy_start = 1 + 2 *
define
ECHO() () fwrite( , , 1,  )
define
define
define
INITIAL() 0
define
REJECT() reject_used_but_not_detected
define
unput(c) yyunput( c,  )
define
YY_AT_BOL() (yy_current_buffer->)
define
YY_BREAK() break;
define
YY_BUF_SIZE() 16384
define
define
define
yy_create_buffer() CMD_create_buffer
define
YY_CURRENT_BUFFER() yy_current_buffer
define
YY_DECL() int  ((  ))
define
yy_delete_buffer() CMD_delete_buffer
define
YY_DO_BEFORE_ACTION() 	 = ; \
	 = (int) ( - ); \
	yy_hold_char = *; \
	* = '\0'; \
	yy_c_buf_p = ;
define
define
define
YY_FATAL_ERROR(msg) yy_fatal_error( msg )
define
yy_flex_debug() CMD_flex_debug
define
yy_flush_buffer() CMD_flush_buffer
define
YY_FLUSH_BUFFER() ( yy_current_buffer )
define
yy_init_buffer() CMD_init_buffer
define
YY_INPUT(buf, result, max_size)    { \
      int c = '*', ; \
       (  = 0;  < max_size && \
            (c = ()) != EOF && c != '\'; ++ ) \
         [] = (char) c; \
       ( c == '\' ) \
         [++] = (char) c; \
      result = ; \
   }
define
yy_load_buffer_state() CMD_load_buffer_state
define
define
define
define
define
define
define
YY_NULL() 0
define
define
YY_PROTO(proto) ()
define
define
define
YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
define
yy_scan_buffer() CMD_scan_buffer
define
yy_scan_bytes() CMD_scan_bytes
define
yy_scan_string() CMD_scan_string
define
yy_set_bol(at_bol) 	{ \
	 ( ! yy_current_buffer ) \
		yy_current_buffer = ( ,  ); \
	yy_current_buffer-> = at_bol; \
	}
define
yy_set_interactive(is_interactive) 	{ \
	 ( ! yy_current_buffer ) \
		yy_current_buffer = ( ,  ); \
	yy_current_buffer-> = is_interactive; \
	}
define
YY_START() ((yy_start - 1) / 2)
define
YY_STATE_EOF(state) ( + state + 1)
define
yy_switch_to_buffer() CMD_switch_to_buffer
define
define
yyin() CMDin
define
yyleng() CMDleng
define
yyless(n) 	do \
		{ \
		/* Undo effects of setting up yytext. */ \
		* = yy_hold_char; \
		yy_c_buf_p =  =  +  - ; \
		; /* set up  again */ \
		} \
	 ( 0 )
define
yyless(n) 	do \
		{ \
		/* Undo effects of setting up yytext. */ \
		[] = yy_hold_char; \
		yy_c_buf_p =  +  - ; \
		yy_hold_char = *yy_c_buf_p; \
		*yy_c_buf_p = '\0'; \
		 = ; \
		} \
	 ( 0 )
define
define
YYLMAX() 4096
define
yymore() yymore_used_but_not_detected
define
yyout() CMDout
define
define
define
yyterminate() return 
define
yytext() CMDtext
define
define

Public Typedefs

unsigned char
YY_CHAR 
unsigned int
yy_size_t 
int
yy_state_type 

Public Variables

Public Functions

int
charConv(int in)
CMDerror(char * s, ... )
int
const char *
CMDgetFileLine(int & lineNumber)
CMDrestart(FILE * in)
CMDSetScanBuffer(const char * sb, const char * fn)
int
bool
collapseEscape(char * buf)
expandEscape(char * dest, const char * src)
for()
for(len )
int
getHexDigit(char c)
if(! b)
if(!b-> yy_ch_buf)
if(b-> yy_is_our_buffer)
if(b )
if()
if(yy_accept )
if(yy_cp< yy_current_buffer->yy_ch_buf+ 2)
if(yy_current_buffer )
if(yy_init )
int
int
isatty(int )
Token< T >
MakeToken(T value, U32 lineNumber)
int
int
int
Sc_ScanString(int ret)
int
while(1 )
while(yy_chk+yy_c] ! )
YY_BUFFER_STATE
yy_init_buffer(yy_current_buffer , input_file )
YY_BUFFER_STATE yy_scan_buffer
YY_PROTO((char *base, yy_size_t size) )
YY_BUFFER_STATE yy_create_buffer
YY_PROTO((FILE *file, int size) )
YY_PROTO((FILE *input_file) )
void yyunput
YY_PROTO((int c, char *buf_ptr) )
void *yy_flex_realloc
YY_PROTO((YY_BUFFER_STATE b) )
YY_PROTO((YY_BUFFER_STATE b, FILE *file) )
YY_PROTO((YY_BUFFER_STATE new_buffer) )
void *yy_flex_alloc
yy_state_type yy_try_NUL_trans
YY_PROTO((yy_state_type current_state) )
YY_BUFFER_STATE yy_scan_bytes
YY_PROTO((yyconst char *bytes, int len) )
YY_BUFFER_STATE yy_scan_string
YY_PROTO((yyconst char *str) )
void yy_fatal_error
YY_PROTO((yyconst char msg[]) )
YY_BUFFER_STATE
YY_BUFFER_STATE
yy_scan_bytes(bytes , len )
return
YY_BUFFER_STATE
yyrestart(input_file )

Detailed Description

Public Defines

BEGIN() yy_start = 1 + 2 *
ECHO() () fwrite( , , 1,  )
EOB_ACT_CONTINUE_SCAN() 0
EOB_ACT_END_OF_FILE() 1
EOB_ACT_LAST_MATCH() 2
FLEX_DEBUG() 0
FLEX_SCANNER() 
INITIAL() 0
REJECT() reject_used_but_not_detected
unput(c) yyunput( c,  )
YY_AT_BOL() (yy_current_buffer->)
YY_BREAK() break;
YY_BUF_SIZE() 16384
YY_BUFFER_EOF_PENDING() 2
YY_BUFFER_NEW() 0
YY_BUFFER_NORMAL() 1
yy_create_buffer() CMD_create_buffer
YY_CURRENT_BUFFER() yy_current_buffer
YY_DECL() int  ((  ))
yy_delete_buffer() CMD_delete_buffer
YY_DO_BEFORE_ACTION() 	 = ; \
	 = (int) ( - ); \
	yy_hold_char = *; \
	* = '\0'; \
	yy_c_buf_p = ;
YY_END_OF_BUFFER() 95
YY_END_OF_BUFFER_CHAR() 0
YY_EXIT_FAILURE() 2
YY_FATAL_ERROR(msg) yy_fatal_error( msg )
yy_flex_debug() CMD_flex_debug
YY_FLEX_MAJOR_VERSION() 2
YY_FLEX_MINOR_VERSION() 5
yy_flush_buffer() CMD_flush_buffer
YY_FLUSH_BUFFER() ( yy_current_buffer )
yy_init_buffer() CMD_init_buffer
YY_INPUT(buf, result, max_size)    { \
      int c = '*', ; \
       (  = 0;  < max_size && \
            (c = ()) != EOF && c != '\'; ++ ) \
         [] = (char) c; \
       ( c == '\' ) \
         [++] = (char) c; \
      result = ; \
   }
yy_load_buffer_state() CMD_load_buffer_state
YY_MORE_ADJ() 0
YY_NEVER_INTERACTIVE() 1
yy_new_buffer() 
YY_NEW_FILE() (  )
YY_NO_POP_STATE() 1
YY_NO_PUSH_STATE() 1
YY_NO_TOP_STATE() 1
YY_NO_UNISTD_H() 
YY_NULL() 0
YY_NUM_RULES() 94
YY_PROTO(proto) ()
YY_READ_BUF_SIZE() 8192
YY_RULE_SETUP() 	
YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
yy_scan_buffer() CMD_scan_buffer
yy_scan_bytes() CMD_scan_bytes
yy_scan_string() CMD_scan_string
yy_set_bol(at_bol) 	{ \
	 ( ! yy_current_buffer ) \
		yy_current_buffer = ( ,  ); \
	yy_current_buffer-> = at_bol; \
	}
yy_set_interactive(is_interactive) 	{ \
	 ( ! yy_current_buffer ) \
		yy_current_buffer = ( ,  ); \
	yy_current_buffer-> = is_interactive; \
	}
YY_START() ((yy_start - 1) / 2)
YY_START_STACK_INCR() 25
YY_STATE_EOF(state) ( + state + 1)
yy_switch_to_buffer() CMD_switch_to_buffer
YY_USER_ACTION() 
yyconst() 
yyin() CMDin
yyleng() CMDleng
yyless(n) 	do \
		{ \
		/* Undo effects of setting up yytext. */ \
		* = yy_hold_char; \
		yy_c_buf_p =  =  +  - ; \
		; /* set up  again */ \
		} \
	 ( 0 )
yyless(n) 	do \
		{ \
		/* Undo effects of setting up yytext. */ \
		[] = yy_hold_char; \
		yy_c_buf_p =  +  - ; \
		yy_hold_char = *yy_c_buf_p; \
		*yy_c_buf_p = '\0'; \
		 = ; \
		} \
	 ( 0 )
yylex() 
YYLMAX() 4096
yymore() yymore_used_but_not_detected
yyout() CMDout
yyrestart() 
YYSTATE() 
yyterminate() return 
yytext() CMDtext
yytext_ptr() 
yywrap() 

Public Typedefs

typedef unsigned char YY_CHAR 
typedef unsigned int yy_size_t 
typedef int yy_state_type 

Public Variables

 b 
char * buf 
FILE * file 
const char * fileName 
bool gConsoleSyntaxError 
int i 
int len 
int lineIndex 
yy_size_t n 
const char * scanBuffer 
int scanIndex 
int size 
yyconst short int yy_accept [224]
register int yy_act 
b yy_at_bol 
yyconst short int yy_base [237]
register char * yy_bp 
b yy_buf_pos 
b yy_buf_size 
b yy_buffer_status 
register YY_CHAR yy_c 
char * yy_c_buf_p 
b yy_ch_buf 
yyconst short int yy_chk [406]
register char * yy_cp 
YY_BUFFER_STATE yy_current_buffer 
 yy_current_state 
 YY_DECL 
yyconst short int yy_def [237]
int yy_did_buffer_switch_on_eof 
yyconst int yy_ec [256]
b yy_fill_buffer 
char yy_hold_char 
int yy_init 
b yy_input_file 
b yy_is_interactive 
 yy_is_jam 
b yy_is_our_buffer 
char * yy_last_accepting_cpos 
yy_state_type yy_last_accepting_state 
yyconst int yy_meta [68]
int yy_n_chars 
yyconst short int yy_nxt [406]
int yy_start 
FILE * yyin 
int yyleng 
FILE * yyout 
char * yytext 
 yytext_ptr 

Public Functions

charConv(int in)

CMD_reset()

CMDerror(char * s, ... )

CMDgetc()

CMDGetCurrentFile()

CMDGetCurrentLine()

CMDgetFileLine(int & lineNumber)

CMDrestart(FILE * in)

CMDSetScanBuffer(const char * sb, const char * fn)

CMDwrap()

collapseEscape(char * buf)

exit(YY_EXIT_FAILURE )

expandEscape(char * dest, const char * src)

for()

for(len )

getHexDigit(char c)

if(! b)

if(!b-> yy_ch_buf)

if(b-> yy_is_our_buffer)

if(b )

if()

if(yy_accept )

if(yy_cp< yy_current_buffer->yy_ch_buf+ 2)

if(yy_current_buffer )

if(yy_init )

input()

isatty(int )

MakeToken(T value, U32 lineNumber)

Sc_ScanDocBlock()

Sc_ScanHex()

Sc_ScanIdent()

Sc_ScanNum()

Sc_ScanString(int ret)

Sc_ScanVar()

while(1 )

while(yy_chk+yy_c] ! )

yy_create_buffer(file , size )

yy_delete_buffer(b )

yy_fatal_error(msg )

yy_flex_alloc(size )

yy_flex_free((void *) b)

yy_flex_free(ptr )

yy_flex_realloc(ptr , size )

yy_flush_buffer(b )

yy_get_next_buffer()

yy_get_previous_state()

yy_init_buffer(b , file )

yy_init_buffer(yy_current_buffer , input_file )

YY_PROTO((char *base, yy_size_t size) )

YY_PROTO((FILE *file, int size) )

YY_PROTO((FILE *input_file) )

YY_PROTO((int c, char *buf_ptr) )

YY_PROTO((void *) )

YY_PROTO((void *, yy_size_t) )

YY_PROTO((void) )

YY_PROTO((YY_BUFFER_STATE b) )

YY_PROTO((YY_BUFFER_STATE b, FILE *file) )

YY_PROTO((YY_BUFFER_STATE new_buffer) )

YY_PROTO((yy_size_t) )

YY_PROTO((yy_state_type current_state) )

YY_PROTO((yyconst char *bytes, int len) )

YY_PROTO((yyconst char *str) )

YY_PROTO((yyconst char msg[]) )

yy_scan_buffer(base , size )

yy_scan_bytes(bytes , len )

yy_scan_bytes(str , len )

yy_scan_string(str )

yy_switch_to_buffer(b )

yy_switch_to_buffer(new_buffer )

yy_try_NUL_trans(yy_current_state )

yyrestart(input_file )

yyunput(c , yy_bp )

   1
   2#define yy_create_buffer CMD_create_buffer
   3#define yy_delete_buffer CMD_delete_buffer
   4#define yy_scan_buffer CMD_scan_buffer
   5#define yy_scan_string CMD_scan_string
   6#define yy_scan_bytes CMD_scan_bytes
   7#define yy_flex_debug CMD_flex_debug
   8#define yy_init_buffer CMD_init_buffer
   9#define yy_flush_buffer CMD_flush_buffer
  10#define yy_load_buffer_state CMD_load_buffer_state
  11#define yy_switch_to_buffer CMD_switch_to_buffer
  12#define yyin CMDin
  13#define yyleng CMDleng
  14#define yylex CMDlex
  15#define yyout CMDout
  16#define yyrestart CMDrestart
  17#define yytext CMDtext
  18#define yywrap CMDwrap
  19
  20#line 20 "CMDscan.cpp"
  21/* A lexical scanner generated by flex */
  22
  23/* Scanner skeleton version:
  24* $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.85 95/04/24 10:48:47 vern Exp $
  25*/
  26
  27#define FLEX_SCANNER
  28#define YY_FLEX_MAJOR_VERSION 2
  29#define YY_FLEX_MINOR_VERSION 5
  30
  31#include <stdio.h>
  32
  33
  34/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
  35#ifdef c_plusplus
  36#ifndef __cplusplus
  37#define __cplusplus
  38#endif
  39#endif
  40
  41
  42#ifdef __cplusplus
  43
  44#include <stdlib.h>
  45//nclude <unistd.h>
  46
  47/* Use prototypes in function declarations. */
  48#define YY_USE_PROTOS
  49
  50/* The "const" storage-class-modifier is valid. */
  51#define YY_USE_CONST
  52
  53#else /* ! __cplusplus */
  54
  55#if __STDC__
  56
  57#define YY_USE_PROTOS
  58#define YY_USE_CONST
  59
  60#endif   /* __STDC__ */
  61#endif   /* ! __cplusplus */
  62
  63#ifdef __TURBOC__
  64#pragma warn -rch
  65#pragma warn -use
  66#include <io.h>
  67#include <stdlib.h>
  68#define YY_USE_CONST
  69#define YY_USE_PROTOS
  70#endif
  71
  72#ifdef YY_USE_CONST
  73#define yyconst const
  74#else
  75#define yyconst
  76#endif
  77
  78
  79#ifdef YY_USE_PROTOS
  80#define YY_PROTO(proto) proto
  81#else
  82#define YY_PROTO(proto) ()
  83#endif
  84
  85/* Returned upon end-of-file. */
  86#define YY_NULL 0
  87
  88/* Promotes a possibly negative, possibly signed char to an unsigned
  89* integer for use as an array index.  If the signed char is negative,
  90* we want to instead treat it as an 8-bit unsigned char, hence the
  91* double cast.
  92*/
  93#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
  94
  95/* Enter a start condition.  This macro really ought to take a parameter,
  96* but we do it the disgusting crufty way forced on us by the ()-less
  97* definition of BEGIN.
  98*/
  99#define BEGIN yy_start = 1 + 2 *
 100
 101/* Translate the current start state into a value that can be later handed
 102* to BEGIN to return to the state.  The YYSTATE alias is for lex
 103* compatibility.
 104*/
 105#define YY_START ((yy_start - 1) / 2)
 106#define YYSTATE YY_START
 107
 108/* Action number for EOF rule of a given start state. */
 109#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
 110
 111/* Special action meaning "start processing a new file". */
 112#define YY_NEW_FILE yyrestart( yyin )
 113
 114#define YY_END_OF_BUFFER_CHAR 0
 115
 116/* Size of default input buffer. */
 117#define YY_BUF_SIZE 16384
 118
 119typedef struct yy_buffer_state *YY_BUFFER_STATE;
 120
 121extern int yyleng;
 122extern FILE *yyin, *yyout;
 123
 124#define EOB_ACT_CONTINUE_SCAN 0
 125#define EOB_ACT_END_OF_FILE 1
 126#define EOB_ACT_LAST_MATCH 2
 127
 128/* The funky do-while in the following #define is used to turn the definition
 129* int a single C statement (which needs a semi-colon terminator).  This
 130* avoids problems with code like:
 131*
 132*  if ( condition_holds )
 133*     yyless( 5 );
 134*  else
 135*     do_something_else();
 136*
 137* Prior to using the do-while the compiler would get upset at the
 138* "else" because it interpreted the "if" statement as being all
 139* done when it reached the ';' after the yyless() call.
 140*/
 141
 142/* Return all but the first 'n' matched characters back to the input stream. */
 143
 144#define yyless(n) \
 145   do \
 146      { \
 147      /* Undo effects of setting up yytext. */ \
 148      *yy_cp = yy_hold_char; \
 149      yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
 150      YY_DO_BEFORE_ACTION; /* set up yytext again */ \
 151      } \
 152   while ( 0 )
 153
 154#define unput(c) yyunput( c, yytext_ptr )
 155
 156/* The following is because we cannot portably get our hands on size_t
 157* (without autoconf's help, which isn't available because we want
 158* flex-generated scanners to compile on their own).
 159*/
 160typedef unsigned int yy_size_t;
 161
 162
 163struct yy_buffer_state
 164{
 165   FILE *yy_input_file;
 166
 167   char *yy_ch_buf;     /* input buffer */
 168   char *yy_buf_pos;    /* current position in input buffer */
 169
 170                        /* Size of input buffer in bytes, not including room for EOB
 171                        * characters.
 172                        */
 173   yy_size_t yy_buf_size;
 174
 175   /* Number of characters read into yy_ch_buf, not including EOB
 176   * characters.
 177   */
 178   int yy_n_chars;
 179
 180   /* Whether we "own" the buffer - i.e., we know we created it,
 181   * and can realloc() it to grow it, and should free() it to
 182   * delete it.
 183   */
 184   int yy_is_our_buffer;
 185
 186   /* Whether this is an "interactive" input source; if so, and
 187   * if we're using stdio for input, then we want to use getc()
 188   * instead of fread(), to make sure we stop fetching input after
 189   * each newline.
 190   */
 191   int yy_is_interactive;
 192
 193   /* Whether we're considered to be at the beginning of a line.
 194   * If so, '^' rules will be active on the next match, otherwise
 195   * not.
 196   */
 197   int yy_at_bol;
 198
 199   /* Whether to try to fill the input buffer when we reach the
 200   * end of it.
 201   */
 202   int yy_fill_buffer;
 203
 204   int yy_buffer_status;
 205#define YY_BUFFER_NEW 0
 206#define YY_BUFFER_NORMAL 1
 207   /* When an EOF's been seen but there's still some text to process
 208   * then we mark the buffer as YY_EOF_PENDING, to indicate that we
 209   * shouldn't try reading from the input source any more.  We might
 210   * still have a bunch of tokens to match, though, because of
 211   * possible backing-up.
 212   *
 213   * When we actually see the EOF, we change the status to "new"
 214   * (via yyrestart()), so that the user can continue scanning by
 215   * just pointing yyin at a new input file.
 216   */
 217#define YY_BUFFER_EOF_PENDING 2
 218};
 219
 220static YY_BUFFER_STATE yy_current_buffer = 0;
 221
 222/* We provide macros for accessing buffer states in case in the
 223* future we want to put the buffer states in a more general
 224* "scanner state".
 225*/
 226#define YY_CURRENT_BUFFER yy_current_buffer
 227
 228
 229/* yy_hold_char holds the character lost when yytext is formed. */
 230static char yy_hold_char;
 231
 232static int yy_n_chars;     /* number of characters read into yy_ch_buf */
 233
 234
 235int yyleng;
 236
 237/* Points to current character in buffer. */
 238static char *yy_c_buf_p = (char *)0;
 239static int yy_init = 1;    /* whether we need to initialize */
 240static int yy_start = 0;   /* start state number */
 241
 242                           /* Flag which is used to allow yywrap()'s to do buffer switches
 243                           * instead of setting up a fresh yyin.  A bit of a hack ...
 244                           */
 245static int yy_did_buffer_switch_on_eof;
 246
 247void yyrestart YY_PROTO((FILE *input_file));
 248
 249void yy_switch_to_buffer YY_PROTO((YY_BUFFER_STATE new_buffer));
 250void yy_load_buffer_state YY_PROTO((void));
 251YY_BUFFER_STATE yy_create_buffer YY_PROTO((FILE *file, int size));
 252void yy_delete_buffer YY_PROTO((YY_BUFFER_STATE b));
 253void yy_init_buffer YY_PROTO((YY_BUFFER_STATE b, FILE *file));
 254void yy_flush_buffer YY_PROTO((YY_BUFFER_STATE b));
 255#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
 256
 257YY_BUFFER_STATE yy_scan_buffer YY_PROTO((char *base, yy_size_t size));
 258YY_BUFFER_STATE yy_scan_string YY_PROTO((yyconst char *str));
 259YY_BUFFER_STATE yy_scan_bytes YY_PROTO((yyconst char *bytes, int len));
 260
 261static void *yy_flex_alloc YY_PROTO((yy_size_t));
 262static void *yy_flex_realloc YY_PROTO((void *, yy_size_t));
 263static void yy_flex_free YY_PROTO((void *));
 264
 265#define yy_new_buffer yy_create_buffer
 266
 267#define yy_set_interactive(is_interactive) \
 268   { \
 269   if ( ! yy_current_buffer ) \
 270      yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
 271   yy_current_buffer->yy_is_interactive = is_interactive; \
 272   }
 273
 274#define yy_set_bol(at_bol) \
 275   { \
 276   if ( ! yy_current_buffer ) \
 277      yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
 278   yy_current_buffer->yy_at_bol = at_bol; \
 279   }
 280
 281#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
 282
 283typedef unsigned char YY_CHAR;
 284FILE *yyin = (FILE *)0, *yyout = (FILE *)0;
 285typedef int yy_state_type;
 286extern char *yytext;
 287#define yytext_ptr yytext
 288
 289static yy_state_type yy_get_previous_state YY_PROTO((void));
 290static yy_state_type yy_try_NUL_trans YY_PROTO((yy_state_type current_state));
 291static int yy_get_next_buffer YY_PROTO((void));
 292static void yy_fatal_error YY_PROTO((yyconst char msg[]));
 293
 294/* Done after the current pattern has been matched and before the
 295* corresponding action - sets up yytext.
 296*/
 297#define YY_DO_BEFORE_ACTION \
 298   yytext_ptr = yy_bp; \
 299   yyleng = (int) (yy_cp - yy_bp); \
 300   yy_hold_char = *yy_cp; \
 301   *yy_cp = '\0'; \
 302   yy_c_buf_p = yy_cp;
 303
 304#define YY_NUM_RULES 94
 305#define YY_END_OF_BUFFER 95
 306static yyconst short int yy_accept[224] =
 307{ 0,
 3080,    0,   95,   93,    1,    5,    4,   51,   93,   93,
 30958,   57,   93,   41,   42,   45,   43,   56,   44,   50,
 31046,   90,   90,   52,   53,   47,   61,   48,   38,   36,
 31188,   88,   88,   88,   39,   40,   59,   88,   88,   88,
 31288,   88,   88,   88,   88,   88,   88,   88,   88,   88,
 31388,   54,   49,   55,   60,    1,    0,    9,    0,    6,
 3140,    0,   17,   87,   25,   12,   26,    0,    7,    0,
 31523,   16,   21,   15,   22,   31,   91,   37,    3,   24,
 3160,   90,    0,    0,   14,   19,   11,    8,   10,   20,
 31788,   33,   88,   88,   27,   88,   88,   88,   88,   88,
 318
 31988,   69,   88,   88,   88,   88,   70,   62,   88,   88,
 32063,   88,   88,   88,   88,   88,   88,   28,   13,   18,
 32192,   87,    0,   32,    3,    3,   91,    0,   91,   89,
 32229,   30,   35,   34,   88,   88,   88,   88,   88,   88,
 32388,   88,   73,   88,   88,   76,   88,   88,   88,   88,
 32488,   88,   92,    0,    3,    2,   88,   88,   79,   88,
 32588,   88,   66,   88,   88,   88,   88,   88,   88,   88,
 32688,   85,   88,    3,    0,   88,   64,   88,   88,   88,
 32786,   88,   88,   88,   88,   88,   88,   88,   68,    0,
 32867,   88,   88,   88,   88,   88,   88,   88,   65,   88,
 329
 33081,    0,   88,   88,   82,   72,   88,   88,   83,   88,
 33180,    0,   74,   88,   71,   75,   88,   88,    0,   78,
 33284,   77,    0
 333};
 334
 335static yyconst int yy_ec[256] =
 336{ 0,
 3371,    1,    1,    1,    1,    1,    1,    1,    2,    3,
 3382,    2,    4,    1,    1,    1,    1,    1,    1,    1,
 3391,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 3401,    2,    5,    6,    1,    7,    8,    9,   10,   11,
 34112,   13,   14,   15,   16,   17,   18,   19,   20,   20,
 34220,   20,   20,   20,   20,   20,   20,   21,   22,   23,
 34324,   25,   26,   27,   28,   29,   30,   31,   32,   31,
 34433,   33,   33,   33,   33,   34,   33,   35,   33,   36,
 34533,   33,   37,   38,   33,   33,   33,   39,   33,   33,
 34640,   41,   42,   43,   33,    1,   44,   45,   46,   47,
 347
 34848,   49,   50,   51,   52,   33,   53,   54,   55,   56,
 34957,   58,   33,   59,   60,   61,   62,   33,   63,   39,
 35033,   33,   64,   65,   66,   67,    1,    1,    1,    1,
 3511,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 3521,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 3531,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 3541,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 3551,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 3561,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 3571,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 358
 3591,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 3601,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 3611,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 3621,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 3631,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 3641,    1,    1,    1,    1
 365};
 366
 367static yyconst int yy_meta[68] =
 368{ 0,
 3691,    1,    2,    2,    1,    1,    1,    1,    1,    1,
 3701,    1,    1,    1,    1,    1,    1,    3,    4,    4,
 3715,    1,    1,    6,    1,    1,    1,    4,    4,    4,
 3724,    4,    7,    7,    7,    7,    7,    7,    7,    1,
 3731,    1,    1,    4,    4,    4,    4,    4,    4,    7,
 3747,    7,    7,    7,    7,    7,    7,    7,    7,    7,
 3757,    7,    7,    1,    1,    1,    1
 376};
 377
 378static yyconst short int yy_base[237] =
 379{ 0,
 3800,    0,  337,  338,  334,  338,  338,   61,   63,   51,
 38153,   65,   66,  338,  338,  311,   64,  338,   66,   60,
 38268,   76,   80,  313,  338,   60,  309,   77,  338,  338,
 3830,  298,  295,  302,  338,  338,  305,  268,  268,   54,
 38461,  272,   59,   38,   62,  266,  280,  275,   62,  263,
 385270,  338,   89,  338,  338,  318,  295,  338,  111,  338,
 386314,  100,  338,  296,  338,  338,  338,  112,  338,  312,
 387338,  338,  338,  290,  338,  338,  107,  338,  296,  338,
 388110,  114,  121,    0,  338,  289,  338,  338,  338,  288,
 3890,    0,  281,  281,  338,  249,  260,  247,  250,  244,
 390
 391255,    0,  243,  248,  242,  244,    0,    0,  244,  235,
 3920,  251,  235,  239,  242,  231,  240,  338,  338,  338,
 393270,  269,  268,  338,    0,  139,  119,  125,  128,    0,
 394338,  338,    0,    0,  240,  243,  238,  224,  240,  239,
 395234,  221,  232,  233,  230,    0,  224,  214,  225,  213,
 396225,  218,  250,  249,  146,  152,  210,  215,    0,  215,
 397221,  203,    0,  216,  219,  201,  201,  216,  200,  204,
 398211,    0,  208,  155,  237,  193,    0,  197,  198,  197,
 3990,  204,  197,  190,  197,  190,  197,  193,    0,  225,
 4000,  180,  184,  179,  177,  153,  158,  151,    0,  134,
 401
 402187,  157,  143,  144,    0,  176,  123,  126,    0,  112,
 403338,  160,    0,  115,  338,    0,   88,   76,  162,    0,
 4040,    0,  338,  170,  174,  181,  185,  189,  193,  200,
 405119,  204,  211,  218,  225,  232
 406};
 407
 408static yyconst short int yy_def[237] =
 409{ 0,
 410223,    1,  223,  223,  223,  223,  223,  223,  224,  225,
 411225,  223,  226,  223,  223,  223,  223,  223,  223,  223,
 412223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
 413227,  227,  227,  227,  223,  223,  223,  227,  227,  227,
 414227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
 415227,  223,  223,  223,  223,  223,  223,  223,  224,  223,
 416224,  228,  223,  229,  223,  223,  223,  226,  223,  226,
 417223,  223,  223,  223,  223,  223,  223,  223,  230,  223,
 418223,  223,  223,  231,  223,  223,  223,  223,  223,  223,
 419227,  227,  227,  227,  223,  227,  227,  227,  227,  227,
 420
 421227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
 422227,  227,  227,  227,  227,  227,  227,  223,  223,  223,
 423232,  229,  229,  223,  230,  233,  223,  223,  223,  231,
 424223,  223,  227,  227,  227,  227,  227,  227,  227,  227,
 425227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
 426227,  227,  232,  232,  234,  223,  227,  227,  227,  227,
 427227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
 428227,  227,  227,  234,  223,  227,  227,  227,  227,  227,
 429227,  227,  227,  227,  227,  227,  227,  227,  227,  223,
 430227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
 431
 432227,  235,  227,  227,  227,  227,  227,  227,  227,  227,
 433223,  236,  227,  227,  223,  227,  227,  227,  236,  227,
 434227,  227,    0,  223,  223,  223,  223,  223,  223,  223,
 435223,  223,  223,  223,  223,  223
 436};
 437
 438static yyconst short int yy_nxt[406] =
 439{ 0,
 4404,    5,    6,    7,    8,    9,   10,   11,   12,   13,
 44114,   15,   16,   17,   18,   19,   20,   21,   22,   23,
 44224,   25,   26,   27,   28,   29,   30,   31,   31,   31,
 44331,   31,   31,   31,   32,   31,   33,   34,   31,   35,
 4444,   36,   37,   38,   39,   40,   41,   42,   43,   31,
 44531,   44,   31,   31,   31,   45,   46,   47,   48,   49,
 44650,   31,   51,   52,   53,   54,   55,   57,   60,   62,
 44762,   62,   62,   66,   63,   69,   65,   72,   77,   77,
 44878,   74,   86,   87,   58,   79,  107,   73,   67,   75,
 44976,   80,   81,  108,   82,   82,   81,   98,   82,   82,
 450
 45189,   90,  104,   61,  100,  109,   70,   83,  101,  110,
 45299,   83,  118,  114,   84,  105,   60,  102,   62,   62,
 453106,   69,  130,   83,  115,   77,   77,   83,  127,  127,
 45481,  222,   82,   82,  128,  221,  128,  127,  127,  129,
 455129,  156,  156,  129,  129,   83,  129,  129,  156,  156,
 45683,   61,   70,  119,  156,  156,  125,  156,  156,  156,
 457156,   83,  156,  156,  156,  156,   83,  220,  218,  175,
 45859,  217,   59,   59,   59,   59,   59,   64,  216,   64,
 45964,   68,  215,   68,   68,   68,   68,   68,   91,  214,
 460213,   91,  121,  211,  210,  121,  122,  122,  209,  122,
 461
 462125,  208,  125,  125,  125,  125,  125,  153,  153,  207,
 463153,  155,  155,  155,  155,  155,  155,  155,  174,  174,
 464174,  174,  174,  174,  174,  212,  212,  206,  212,  212,
 465212,  212,  219,  219,  219,  219,  219,  219,  219,  205,
 466204,  203,  202,  201,  200,  199,  198,  197,  196,  195,
 467194,  193,  192,  191,  190,  189,  188,  187,  186,  185,
 468184,  183,  182,  181,  180,  179,  178,  177,  176,  154,
 469154,  173,  172,  171,  170,  169,  168,  167,  166,  165,
 470164,  163,  162,  161,  160,  159,  158,  157,  123,  123,
 471154,  152,  151,  150,  149,  148,  147,  146,  145,  144,
 472
 473143,  142,  141,  140,  139,  138,  137,  136,  135,  134,
 474133,  132,  131,  126,  124,   68,  123,   59,  120,   56,
 475117,  116,  113,  112,  111,  103,   97,   96,   95,   94,
 47693,   92,   88,   85,   71,   56,  223,    3,  223,  223,
 477223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
 478223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
 479223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
 480223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
 481223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
 482223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
 483
 484223,  223,  223,  223,  223
 485};
 486
 487static yyconst short int yy_chk[406] =
 488{ 0,
 4891,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 4901,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 4911,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 4921,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 4931,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 4941,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 4951,    1,    1,    1,    1,    1,    1,    8,    9,   10,
 49610,   11,   11,   12,   10,   13,   11,   17,   20,   20,
 49721,   19,   26,   26,    8,   21,   44,   17,   12,   19,
 49819,   21,   22,   44,   22,   22,   23,   40,   23,   23,
 499
 50028,   28,   43,    9,   41,   45,   13,   22,   41,   45,
 50140,   23,   53,   49,   22,   43,   59,   41,   62,   62,
 50243,   68,  231,   22,   49,   77,   77,   23,   81,   81,
 50382,  218,   82,   82,   83,  217,   83,  127,  127,   83,
 50483,  126,  126,  128,  128,   82,  129,  129,  155,  155,
 505127,   59,   68,   53,  156,  156,  126,  174,  174,  202,
 506202,   82,  212,  212,  219,  219,  127,  214,  210,  156,
 507224,  208,  224,  224,  224,  224,  224,  225,  207,  225,
 508225,  226,  206,  226,  226,  226,  226,  226,  227,  204,
 509203,  227,  228,  201,  200,  228,  229,  229,  198,  229,
 510
 511230,  197,  230,  230,  230,  230,  230,  232,  232,  196,
 512232,  233,  233,  233,  233,  233,  233,  233,  234,  234,
 513234,  234,  234,  234,  234,  235,  235,  195,  235,  235,
 514235,  235,  236,  236,  236,  236,  236,  236,  236,  194,
 515193,  192,  190,  188,  187,  186,  185,  184,  183,  182,
 516180,  179,  178,  176,  175,  173,  171,  170,  169,  168,
 517167,  166,  165,  164,  162,  161,  160,  158,  157,  154,
 518153,  152,  151,  150,  149,  148,  147,  145,  144,  143,
 519142,  141,  140,  139,  138,  137,  136,  135,  123,  122,
 520121,  117,  116,  115,  114,  113,  112,  110,  109,  106,
 521
 522105,  104,  103,  101,  100,   99,   98,   97,   96,   94,
 52393,   90,   86,   79,   74,   70,   64,   61,   57,   56,
 52451,   50,   48,   47,   46,   42,   39,   38,   37,   34,
 52533,   32,   27,   24,   16,    5,    3,  223,  223,  223,
 526223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
 527223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
 528223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
 529223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
 530223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
 531223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
 532
 533223,  223,  223,  223,  223
 534};
 535
 536static yy_state_type yy_last_accepting_state;
 537static char *yy_last_accepting_cpos;
 538
 539/* The intent behind this definition is that it'll catch
 540* any uses of REJECT which flex missed.
 541*/
 542#define REJECT reject_used_but_not_detected
 543#define yymore() yymore_used_but_not_detected
 544#define YY_MORE_ADJ 0
 545char *yytext;
 546#line 1 "CMDscan.l"
 547#define INITIAL 0
 548#line 2 "CMDscan.l"
 549
 550// flex --nounput -o CMDscan.cpp -P CMD CMDscan.l
 551
 552#define YYLMAX 4096
 553#define YY_NO_UNISTD_H
 554
 555#include <stdio.h>
 556#include "platform/platform.h"
 557#include "core/stringTable.h"
 558#include "console/console.h"
 559#include "console/compiler.h"
 560#include "console/dynamicTypes.h"
 561#include "core/strings/stringFunctions.h"
 562
 563template< typename T >
 564struct Token
 565{
 566   T value;
 567   S32 lineNumber;
 568};
 569
 570// Can't have ctors in structs used in unions, so we have this.
 571template< typename T >
 572inline Token< T> MakeToken(T value, U32 lineNumber)
 573{
 574   Token< T> result;
 575   result.value = value;
 576   result.lineNumber = lineNumber;
 577   return result;
 578}
 579
 580#include "console/cmdgram.h"
 581
 582using namespace Compiler;
 583
 584#define YY_NEVER_INTERACTIVE 1
 585
 586// Some basic parsing primitives...
 587static int Sc_ScanDocBlock();
 588static int Sc_ScanString(int ret);
 589static int Sc_ScanNum();
 590static int Sc_ScanVar();
 591static int Sc_ScanHex();
 592static int Sc_ScanIdent();
 593
 594// Deal with debuggability of FLEX.
 595#ifdef TORQUE_DEBUG
 596#define FLEX_DEBUG 1
 597#else
 598#define FLEX_DEBUG 0
 599#endif
 600
 601// Install our own input code...
 602#undef CMDgetc
 603int CMDgetc();
 604
 605// Hack to make windows lex happy.
 606#ifndef isatty
 607inline int isatty(int) { return 0; }
 608#endif
 609
 610// Wrap our getc, so that lex doesn't try to do its own buffering/file IO.
 611#define YY_INPUT(buf,result,max_size) \
 612   { \
 613      int c = '*', n; \
 614      for ( n = 0; n < max_size && \
 615            (c = CMDgetc()) != EOF && c != '\n'; ++n ) \
 616         buf[n] = (char) c; \
 617      if ( c == '\n' ) \
 618         buf[n++] = (char) c; \
 619      result = n; \
 620   }
 621
 622// General helper stuff.
 623static int lineIndex;
 624
 625// File state
 626void CMDSetScanBuffer(const char *sb, const char *fn);
 627const char * CMDgetFileLine(int &lineNumber);
 628
 629// Error reporting
 630void CMDerror(char * s, ...);
 631
 632// Reset the parser.
 633void CMDrestart(FILE *in);
 634
 635#line 635 "CMDscan.cpp"
 636
 637/* Macros after this point can all be overridden by user definitions in
 638* section 1.
 639*/
 640
 641#ifndef YY_SKIP_YYWRAP
 642#ifdef __cplusplus
 643extern "C" int yywrap YY_PROTO((void));
 644#else
 645extern int yywrap YY_PROTO((void));
 646#endif
 647#endif
 648
 649#ifndef YY_NO_UNPUT
 650static void yyunput YY_PROTO((int c, char *buf_ptr));
 651#endif
 652
 653#ifndef yytext_ptr
 654static void yy_flex_strncpy YY_PROTO((char *, yyconst char *, int));
 655#endif
 656
 657#ifndef YY_NO_INPUT
 658#ifdef __cplusplus
 659static int yyinput YY_PROTO((void));
 660#else
 661static int input YY_PROTO((void));
 662#endif
 663#endif
 664
 665#if YY_STACK_USED
 666static int yy_start_stack_ptr = 0;
 667static int yy_start_stack_depth = 0;
 668static int *yy_start_stack = 0;
 669#ifndef YY_NO_PUSH_STATE
 670static void yy_push_state YY_PROTO((int new_state));
 671#endif
 672#ifndef YY_NO_POP_STATE
 673static void yy_pop_state YY_PROTO((void));
 674#endif
 675#ifndef YY_NO_TOP_STATE
 676static int yy_top_state YY_PROTO((void));
 677#endif
 678
 679#else
 680#define YY_NO_PUSH_STATE 1
 681#define YY_NO_POP_STATE 1
 682#define YY_NO_TOP_STATE 1
 683#endif
 684
 685#ifdef YY_MALLOC_DECL
 686YY_MALLOC_DECL
 687#else
 688#if __STDC__
 689#ifndef __cplusplus
 690#include <stdlib.h>
 691#endif
 692#else
 693/* Just try to get by without declaring the routines.  This will fail
 694* miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
 695* or sizeof(void*) != sizeof(int).
 696*/
 697#endif
 698#endif
 699
 700/* Amount of stuff to slurp up with each read. */
 701#ifndef YY_READ_BUF_SIZE
 702#define YY_READ_BUF_SIZE 8192
 703#endif
 704
 705/* Copy whatever the last rule matched to the standard output. */
 706
 707#ifndef ECHO
 708/* This used to be an fputs(), but since the string might contain NUL's,
 709* we now use fwrite().
 710*/
 711#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
 712#endif
 713
 714/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
 715* is returned in "result".
 716*/
 717#ifndef YY_INPUT
 718#define YY_INPUT(buf,result,max_size) \
 719   if ( yy_current_buffer->yy_is_interactive ) \
 720      { \
 721      int c = '*', n; \
 722      for ( n = 0; n < max_size && \
 723              (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
 724         buf[n] = (char) c; \
 725      if ( c == '\n' ) \
 726         buf[n++] = (char) c; \
 727      if ( c == EOF && ferror( yyin ) ) \
 728         YY_FATAL_ERROR( "input in flex scanner failed" ); \
 729      result = n; \
 730      } \
 731   else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
 732        && ferror( yyin ) ) \
 733      YY_FATAL_ERROR( "input in flex scanner failed" );
 734#endif
 735
 736/* No semi-colon after return; correct usage is to write "yyterminate();" -
 737* we don't want an extra ';' after the "return" because that will cause
 738* some compilers to complain about unreachable statements.
 739*/
 740#ifndef yyterminate
 741#define yyterminate() return YY_NULL
 742#endif
 743
 744/* Number of entries by which start-condition stack grows. */
 745#ifndef YY_START_STACK_INCR
 746#define YY_START_STACK_INCR 25
 747#endif
 748
 749/* Report a fatal error. */
 750#ifndef YY_FATAL_ERROR
 751#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
 752#endif
 753
 754/* Default declaration of generated scanner - a define so the user can
 755* easily add parameters.
 756*/
 757#ifndef YY_DECL
 758#define YY_DECL int yylex YY_PROTO(( void ))
 759#endif
 760
 761/* Code executed at the beginning of each rule, after yytext and yyleng
 762* have been set up.
 763*/
 764#ifndef YY_USER_ACTION
 765#define YY_USER_ACTION
 766#endif
 767
 768/* Code executed at the end of each rule. */
 769#ifndef YY_BREAK
 770#define YY_BREAK break;
 771#endif
 772
 773#define YY_RULE_SETUP \
 774   YY_USER_ACTION
 775
 776YY_DECL
 777{
 778   register yy_state_type yy_current_state;
 779register char *yy_cp, *yy_bp;
 780register int yy_act;
 781
 782#line 105 "CMDscan.l"
 783
 784;
 785#line 785 "CMDscan.cpp"
 786
 787if (yy_init)
 788{
 789   yy_init = 0;
 790
 791#ifdef YY_USER_INIT
 792   YY_USER_INIT;
 793#endif
 794
 795   if (!yy_start)
 796      yy_start = 1;  /* first start state */
 797
 798   if (!yyin)
 799      yyin = stdin;
 800
 801   if (!yyout)
 802      yyout = stdout;
 803
 804   if (!yy_current_buffer)
 805      yy_current_buffer =
 806      yy_create_buffer(yyin, YY_BUF_SIZE);
 807
 808   yy_load_buffer_state();
 809}
 810
 811while (1)      /* loops until end-of-file is reached */
 812{
 813   yy_cp = yy_c_buf_p;
 814
 815   /* Support of yytext. */
 816   *yy_cp = yy_hold_char;
 817
 818   /* yy_bp points to the position in yy_ch_buf of the start of
 819   * the current run.
 820   */
 821   yy_bp = yy_cp;
 822
 823   yy_current_state = yy_start;
 824yy_match:
 825   do
 826   {
 827      register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
 828      if (yy_accept[yy_current_state])
 829      {
 830         yy_last_accepting_state = yy_current_state;
 831         yy_last_accepting_cpos = yy_cp;
 832      }
 833      while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state)
 834      {
 835         yy_current_state = (int)yy_def[yy_current_state];
 836         if (yy_current_state >= 224)
 837            yy_c = yy_meta[(unsigned int)yy_c];
 838      }
 839      yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int)yy_c];
 840      ++yy_cp;
 841   } while (yy_base[yy_current_state] != 338);
 842
 843yy_find_action:
 844   yy_act = yy_accept[yy_current_state];
 845   if (yy_act == 0)
 846   { /* have to back up */
 847      yy_cp = yy_last_accepting_cpos;
 848      yy_current_state = yy_last_accepting_state;
 849      yy_act = yy_accept[yy_current_state];
 850   }
 851
 852   YY_DO_BEFORE_ACTION;
 853
 854
 855do_action:  /* This label is used only to access EOF actions. */
 856
 857
 858   switch (yy_act)
 859   { /* beginning of action switch */
 860      case 0: /* must back up */
 861              /* undo the effects of YY_DO_BEFORE_ACTION */
 862         *yy_cp = yy_hold_char;
 863         yy_cp = yy_last_accepting_cpos;
 864         yy_current_state = yy_last_accepting_state;
 865         goto yy_find_action;
 866
 867      case 1:
 868         YY_RULE_SETUP
 869#line 107 "CMDscan.l"
 870         {}
 871            YY_BREAK
 872      case 2:
 873         YY_RULE_SETUP
 874#line 108 "CMDscan.l"
 875         { return(Sc_ScanDocBlock()); }
 876            YY_BREAK
 877      case 3:
 878         YY_RULE_SETUP
 879#line 109 "CMDscan.l"
 880            ;
 881         YY_BREAK
 882      case 4:
 883         YY_RULE_SETUP
 884#line 110 "CMDscan.l"
 885            ;
 886         YY_BREAK
 887      case 5:
 888         YY_RULE_SETUP
 889#line 111 "CMDscan.l"
 890         { lineIndex++; }
 891            YY_BREAK
 892      case 6:
 893         YY_RULE_SETUP
 894#line 112 "CMDscan.l"
 895         { return(Sc_ScanString(STRATOM)); }
 896            YY_BREAK
 897      case 7:
 898         YY_RULE_SETUP
 899#line 113 "CMDscan.l"
 900         { return(Sc_ScanString(TAGATOM)); }
 901            YY_BREAK
 902      case 8:
 903         YY_RULE_SETUP
 904#line 114 "CMDscan.l"
 905         { CMDlval.i = MakeToken< int >(opEQ, lineIndex); return opEQ; }
 906            YY_BREAK
 907      case 9:
 908         YY_RULE_SETUP
 909#line 115 "CMDscan.l"
 910         { CMDlval.i = MakeToken< int >(opNE, lineIndex); return opNE; }
 911            YY_BREAK
 912      case 10:
 913         YY_RULE_SETUP
 914#line 116 "CMDscan.l"
 915         { CMDlval.i = MakeToken< int >(opGE, lineIndex); return opGE; }
 916            YY_BREAK
 917      case 11:
 918         YY_RULE_SETUP
 919#line 117 "CMDscan.l"
 920         { CMDlval.i = MakeToken< int >(opLE, lineIndex); return opLE; }
 921            YY_BREAK
 922      case 12:
 923         YY_RULE_SETUP
 924#line 118 "CMDscan.l"
 925         { CMDlval.i = MakeToken< int >(opAND, lineIndex); return opAND; }
 926            YY_BREAK
 927      case 13:
 928         YY_RULE_SETUP
 929#line 119 "CMDscan.l"
 930         { CMDlval.i = MakeToken< int >(opOR, lineIndex); return opOR; }
 931            YY_BREAK
 932      case 14:
 933         YY_RULE_SETUP
 934#line 120 "CMDscan.l"
 935         { CMDlval.i = MakeToken< int >(opCOLONCOLON, lineIndex); return opCOLONCOLON; }
 936            YY_BREAK
 937      case 15:
 938         YY_RULE_SETUP
 939#line 121 "CMDscan.l"
 940         { CMDlval.i = MakeToken< int >(opMINUSMINUS, lineIndex); return opMINUSMINUS; }
 941            YY_BREAK
 942      case 16:
 943         YY_RULE_SETUP
 944#line 122 "CMDscan.l"
 945         { CMDlval.i = MakeToken< int >(opPLUSPLUS, lineIndex); return opPLUSPLUS; }
 946            YY_BREAK
 947      case 17:
 948         YY_RULE_SETUP
 949#line 123 "CMDscan.l"
 950         { CMDlval.i = MakeToken< int >(opSTREQ, lineIndex); return opSTREQ; }
 951            YY_BREAK
 952      case 18:
 953         YY_RULE_SETUP
 954#line 124 "CMDscan.l"
 955         { CMDlval.i = MakeToken< int >(opSTRNE, lineIndex); return opSTRNE; }
 956            YY_BREAK
 957      case 19:
 958         YY_RULE_SETUP
 959#line 125 "CMDscan.l"
 960         { CMDlval.i = MakeToken< int >(opSHL, lineIndex); return opSHL; }
 961            YY_BREAK
 962      case 20:
 963         YY_RULE_SETUP
 964#line 126 "CMDscan.l"
 965         { CMDlval.i = MakeToken< int >(opSHR, lineIndex); return opSHR; }
 966            YY_BREAK
 967      case 21:
 968         YY_RULE_SETUP
 969#line 127 "CMDscan.l"
 970         { CMDlval.i = MakeToken< int >(opPLASN, lineIndex); return opPLASN; }
 971            YY_BREAK
 972      case 22:
 973         YY_RULE_SETUP
 974#line 128 "CMDscan.l"
 975         { CMDlval.i = MakeToken< int >(opMIASN, lineIndex); return opMIASN; }
 976            YY_BREAK
 977      case 23:
 978         YY_RULE_SETUP
 979#line 129 "CMDscan.l"
 980         { CMDlval.i = MakeToken< int >(opMLASN, lineIndex); return opMLASN; }
 981            YY_BREAK
 982      case 24:
 983         YY_RULE_SETUP
 984#line 130 "CMDscan.l"
 985         { CMDlval.i = MakeToken< int >(opDVASN, lineIndex); return opDVASN; }
 986            YY_BREAK
 987      case 25:
 988         YY_RULE_SETUP
 989#line 131 "CMDscan.l"
 990         { CMDlval.i = MakeToken< int >(opMODASN, lineIndex); return opMODASN; }
 991            YY_BREAK
 992      case 26:
 993         YY_RULE_SETUP
 994#line 132 "CMDscan.l"
 995         { CMDlval.i = MakeToken< int >(opANDASN, lineIndex); return opANDASN; }
 996            YY_BREAK
 997      case 27:
 998         YY_RULE_SETUP
 999#line 133 "CMDscan.l"
1000         { CMDlval.i = MakeToken< int >(opXORASN, lineIndex); return opXORASN; }
1001            YY_BREAK
1002      case 28:
1003         YY_RULE_SETUP
1004#line 134 "CMDscan.l"
1005         { CMDlval.i = MakeToken< int >(opORASN, lineIndex); return opORASN; }
1006            YY_BREAK
1007      case 29:
1008         YY_RULE_SETUP
1009#line 135 "CMDscan.l"
1010         { CMDlval.i = MakeToken< int >(opSLASN, lineIndex); return opSLASN; }
1011            YY_BREAK
1012      case 30:
1013         YY_RULE_SETUP
1014#line 136 "CMDscan.l"
1015         { CMDlval.i = MakeToken< int >(opSRASN, lineIndex); return opSRASN; }
1016            YY_BREAK
1017      case 31:
1018         YY_RULE_SETUP
1019#line 137 "CMDscan.l"
1020         { CMDlval.i = MakeToken< int >(opINTNAME, lineIndex); return opINTNAME; }
1021            YY_BREAK
1022      case 32:
1023         YY_RULE_SETUP
1024#line 138 "CMDscan.l"
1025         { CMDlval.i = MakeToken< int >(opINTNAMER, lineIndex); return opINTNAMER; }
1026            YY_BREAK
1027      case 33:
1028         YY_RULE_SETUP
1029#line 139 "CMDscan.l"
1030         { CMDlval.i = MakeToken< int >('\n', lineIndex); return '@'; }
1031            YY_BREAK
1032      case 34:
1033         YY_RULE_SETUP
1034#line 140 "CMDscan.l"
1035         { CMDlval.i = MakeToken< int >('\t', lineIndex); return '@'; }
1036            YY_BREAK
1037      case 35:
1038         YY_RULE_SETUP
1039#line 141 "CMDscan.l"
1040         { CMDlval.i = MakeToken< int >(' ', lineIndex); return '@'; }
1041            YY_BREAK
1042      case 36:
1043         YY_RULE_SETUP
1044#line 142 "CMDscan.l"
1045         { CMDlval.i = MakeToken< int >(0, lineIndex); return '@'; }
1046            YY_BREAK
1047      case 37:
1048         YY_RULE_SETUP
1049#line 143 "CMDscan.l"
1050         { /* this comment stops syntax highlighting from getting messed up when editing the lexer in TextPad */
1051            int c = 0, l;
1052         for (; ; )
1053         {
1054            l = c;
1055            c = yyinput();
1056
1057            // Is this an open comment?
1058            if (c == EOF)
1059            {
1060               CMDerror("unexpected end of file found in comment");
1061               break;
1062            }
1063
1064            // Increment line numbers.
1065            else if (c == '\n')
1066               lineIndex++;
1067
1068            // Did we find the end of the comment?
1069            else if (l == '*' && c == '/')
1070               break;
1071         }
1072         }
1073            YY_BREAK
1074      case 38:
1075#line 167 "CMDscan.l"
1076      case 39:
1077#line 168 "CMDscan.l"
1078      case 40:
1079#line 169 "CMDscan.l"
1080      case 41:
1081#line 170 "CMDscan.l"
1082      case 42:
1083#line 171 "CMDscan.l"
1084      case 43:
1085#line 172 "CMDscan.l"
1086      case 44:
1087#line 173 "CMDscan.l"
1088      case 45:
1089#line 174 "CMDscan.l"
1090      case 46:
1091#line 175 "CMDscan.l"
1092      case 47:
1093#line 176 "CMDscan.l"
1094      case 48:
1095#line 177 "CMDscan.l"
1096      case 49:
1097#line 178 "CMDscan.l"
1098      case 50:
1099#line 179 "CMDscan.l"
1100      case 51:
1101#line 180 "CMDscan.l"
1102      case 52:
1103#line 181 "CMDscan.l"
1104      case 53:
1105#line 182 "CMDscan.l"
1106      case 54:
1107#line 183 "CMDscan.l"
1108      case 55:
1109#line 184 "CMDscan.l"
1110      case 56:
1111#line 185 "CMDscan.l"
1112      case 57:
1113#line 186 "CMDscan.l"
1114      case 58:
1115#line 187 "CMDscan.l"
1116      case 59:
1117#line 188 "CMDscan.l"
1118      case 60:
1119#line 189 "CMDscan.l"
1120      case 61:
1121         YY_RULE_SETUP
1122#line 189 "CMDscan.l"
1123         { CMDlval.i = MakeToken< int >(CMDtext[0], lineIndex); return CMDtext[0]; }
1124            YY_BREAK
1125      case 62:
1126         YY_RULE_SETUP
1127#line 190 "CMDscan.l"
1128         { CMDlval.i = MakeToken< int >(rwIN, lineIndex); return(rwIN); }
1129            YY_BREAK
1130      case 63:
1131         YY_RULE_SETUP
1132#line 191 "CMDscan.l"
1133         { CMDlval.i = MakeToken< int >(rwCASEOR, lineIndex); return(rwCASEOR); }
1134            YY_BREAK
1135      case 64:
1136         YY_RULE_SETUP
1137#line 192 "CMDscan.l"
1138         { CMDlval.i = MakeToken< int >(rwBREAK, lineIndex); return(rwBREAK); }
1139            YY_BREAK
1140      case 65:
1141         YY_RULE_SETUP
1142#line 193 "CMDscan.l"
1143         { CMDlval.i = MakeToken< int >(rwRETURN, lineIndex); return(rwRETURN); }
1144            YY_BREAK
1145      case 66:
1146         YY_RULE_SETUP
1147#line 194 "CMDscan.l"
1148         { CMDlval.i = MakeToken< int >(rwELSE, lineIndex); return(rwELSE); }
1149            YY_BREAK
1150      case 67:
1151         YY_RULE_SETUP
1152#line 195 "CMDscan.l"
1153         { CMDlval.i = MakeToken< int >(rwASSERT, lineIndex); return(rwASSERT); }
1154            YY_BREAK
1155      case 68:
1156         YY_RULE_SETUP
1157#line 196 "CMDscan.l"
1158         { CMDlval.i = MakeToken< int >(rwWHILE, lineIndex); return(rwWHILE); }
1159            YY_BREAK
1160      case 69:
1161         YY_RULE_SETUP
1162#line 197 "CMDscan.l"
1163         { CMDlval.i = MakeToken< int >(rwDO, lineIndex); return(rwDO); }
1164            YY_BREAK
1165      case 70:
1166         YY_RULE_SETUP
1167#line 198 "CMDscan.l"
1168         { CMDlval.i = MakeToken< int >(rwIF, lineIndex); return(rwIF); }
1169            YY_BREAK
1170      case 71:
1171         YY_RULE_SETUP
1172#line 199 "CMDscan.l"
1173         { CMDlval.i = MakeToken< int >(rwFOREACHSTR, lineIndex); return(rwFOREACHSTR); }
1174            YY_BREAK
1175      case 72:
1176         YY_RULE_SETUP
1177#line 200 "CMDscan.l"
1178         { CMDlval.i = MakeToken< int >(rwFOREACH, lineIndex); return(rwFOREACH); }
1179            YY_BREAK
1180      case 73:
1181         YY_RULE_SETUP
1182#line 201 "CMDscan.l"
1183         { CMDlval.i = MakeToken< int >(rwFOR, lineIndex); return(rwFOR); }
1184            YY_BREAK
1185      case 74:
1186         YY_RULE_SETUP
1187#line 202 "CMDscan.l"
1188         { CMDlval.i = MakeToken< int >(rwCONTINUE, lineIndex); return(rwCONTINUE); }
1189            YY_BREAK
1190      case 75:
1191         YY_RULE_SETUP
1192#line 203 "CMDscan.l"
1193         { CMDlval.i = MakeToken< int >(rwDEFINE, lineIndex); return(rwDEFINE); }
1194            YY_BREAK
1195      case 76:
1196         YY_RULE_SETUP
1197#line 204 "CMDscan.l"
1198         { CMDlval.i = MakeToken< int >(rwDECLARE, lineIndex); return(rwDECLARE); }
1199            YY_BREAK
1200      case 77:
1201         YY_RULE_SETUP
1202#line 205 "CMDscan.l"
1203         { CMDlval.i = MakeToken< int >(rwDECLARESINGLETON, lineIndex); return(rwDECLARESINGLETON); }
1204            YY_BREAK
1205      case 78:
1206         YY_RULE_SETUP
1207#line 206 "CMDscan.l"
1208         { CMDlval.i = MakeToken< int >(rwDATABLOCK, lineIndex); return(rwDATABLOCK); }
1209            YY_BREAK
1210      case 79:
1211         YY_RULE_SETUP
1212#line 207 "CMDscan.l"
1213         { CMDlval.i = MakeToken< int >(rwCASE, lineIndex); return(rwCASE); }
1214            YY_BREAK
1215      case 80:
1216         YY_RULE_SETUP
1217#line 208 "CMDscan.l"
1218         { CMDlval.i = MakeToken< int >(rwSWITCHSTR, lineIndex); return(rwSWITCHSTR); }
1219            YY_BREAK
1220      case 81:
1221         YY_RULE_SETUP
1222#line 209 "CMDscan.l"
1223         { CMDlval.i = MakeToken< int >(rwSWITCH, lineIndex); return(rwSWITCH); }
1224            YY_BREAK
1225      case 82:
1226         YY_RULE_SETUP
1227#line 210 "CMDscan.l"
1228         { CMDlval.i = MakeToken< int >(rwDEFAULT, lineIndex); return(rwDEFAULT); }
1229            YY_BREAK
1230      case 83:
1231         YY_RULE_SETUP
1232#line 211 "CMDscan.l"
1233         { CMDlval.i = MakeToken< int >(rwPACKAGE, lineIndex); return(rwPACKAGE); }
1234            YY_BREAK
1235      case 84:
1236         YY_RULE_SETUP
1237#line 212 "CMDscan.l"
1238         { CMDlval.i = MakeToken< int >(rwNAMESPACE, lineIndex); return(rwNAMESPACE); }
1239            YY_BREAK
1240      case 85:
1241         YY_RULE_SETUP
1242#line 213 "CMDscan.l"
1243         { CMDlval.i = MakeToken< int >(1, lineIndex); return INTCONST; }
1244            YY_BREAK
1245      case 86:
1246         YY_RULE_SETUP
1247#line 214 "CMDscan.l"
1248         { CMDlval.i = MakeToken< int >(0, lineIndex); return INTCONST; }
1249            YY_BREAK
1250      case 87:
1251         YY_RULE_SETUP
1252#line 215 "CMDscan.l"
1253         { return(Sc_ScanVar()); }
1254            YY_BREAK
1255      case 88:
1256         YY_RULE_SETUP
1257#line 216 "CMDscan.l"
1258         { return Sc_ScanIdent(); }
1259            YY_BREAK
1260      case 89:
1261         YY_RULE_SETUP
1262#line 217 "CMDscan.l"
1263            return(Sc_ScanHex());
1264         YY_BREAK
1265      case 90:
1266         YY_RULE_SETUP
1267#line 218 "CMDscan.l"
1268         { CMDtext[CMDleng] = 0; CMDlval.i = MakeToken< int >(dAtoi(CMDtext), lineIndex); return INTCONST; }
1269            YY_BREAK
1270      case 91:
1271         YY_RULE_SETUP
1272#line 219 "CMDscan.l"
1273            return Sc_ScanNum();
1274         YY_BREAK
1275      case 92:
1276         YY_RULE_SETUP
1277#line 220 "CMDscan.l"
1278            return(ILLEGAL_TOKEN);
1279         YY_BREAK
1280      case 93:
1281         YY_RULE_SETUP
1282#line 221 "CMDscan.l"
1283            return(ILLEGAL_TOKEN);
1284         YY_BREAK
1285      case 94:
1286         YY_RULE_SETUP
1287#line 222 "CMDscan.l"
1288            ECHO;
1289         YY_BREAK
1290#line 1291 "CMDscan.cpp"
1291      case YY_STATE_EOF(INITIAL):
1292         yyterminate();
1293
1294      case YY_END_OF_BUFFER:
1295      {
1296         /* Amount of text matched not including the EOB char. */
1297         int yy_amount_of_matched_text = (int)(yy_cp - yytext_ptr) - 1;
1298
1299         /* Undo the effects of YY_DO_BEFORE_ACTION. */
1300         *yy_cp = yy_hold_char;
1301
1302         if (yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW)
1303         {
1304            /* We're scanning a new file or input source.  It's
1305            * possible that this happened because the user
1306            * just pointed yyin at a new source and called
1307            * yylex().  If so, then we have to assure
1308            * consistency between yy_current_buffer and our
1309            * globals.  Here is the right place to do so, because
1310            * this is the first action (other than possibly a
1311            * back-up) that will match for the new input source.
1312            */
1313            yy_n_chars = yy_current_buffer->yy_n_chars;
1314            yy_current_buffer->yy_input_file = yyin;
1315            yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
1316         }
1317
1318         /* Note that here we test for yy_c_buf_p "<=" to the position
1319         * of the first EOB in the buffer, since yy_c_buf_p will
1320         * already have been incremented past the NUL character
1321         * (since all states make transitions on EOB to the
1322         * end-of-buffer state).  Contrast this with the test
1323         * in input().
1324         */
1325         if (yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars])
1326         { /* This was really a NUL. */
1327            yy_state_type yy_next_state;
1328
1329            yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
1330
1331            yy_current_state = yy_get_previous_state();
1332
1333            /* Okay, we're now positioned to make the NUL
1334            * transition.  We couldn't have
1335            * yy_get_previous_state() go ahead and do it
1336            * for us because it doesn't know how to deal
1337            * with the possibility of jamming (and we don't
1338            * want to build jamming into it because then it
1339            * will run more slowly).
1340            */
1341
1342            yy_next_state = yy_try_NUL_trans(yy_current_state);
1343
1344            yy_bp = yytext_ptr + YY_MORE_ADJ;
1345
1346            if (yy_next_state)
1347            {
1348               /* Consume the NUL. */
1349               yy_cp = ++yy_c_buf_p;
1350               yy_current_state = yy_next_state;
1351               goto yy_match;
1352            }
1353
1354            else
1355            {
1356               yy_cp = yy_c_buf_p;
1357               goto yy_find_action;
1358            }
1359         }
1360
1361         else switch (yy_get_next_buffer())
1362         {
1363            case EOB_ACT_END_OF_FILE:
1364            {
1365               yy_did_buffer_switch_on_eof = 0;
1366
1367               if (yywrap())
1368               {
1369                  /* Note: because we've taken care in
1370                  * yy_get_next_buffer() to have set up
1371                  * yytext, we can now set up
1372                  * yy_c_buf_p so that if some total
1373                  * hoser (like flex itself) wants to
1374                  * call the scanner after we return the
1375                  * YY_NULL, it'll still work - another
1376                  * YY_NULL will get returned.
1377                  */
1378                  yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
1379
1380                  yy_act = YY_STATE_EOF(YY_START);
1381                  goto do_action;
1382               }
1383
1384               else
1385               {
1386                  if (!yy_did_buffer_switch_on_eof)
1387                     YY_NEW_FILE;
1388               }
1389               break;
1390            }
1391
1392            case EOB_ACT_CONTINUE_SCAN:
1393               yy_c_buf_p =
1394                  yytext_ptr + yy_amount_of_matched_text;
1395
1396               yy_current_state = yy_get_previous_state();
1397
1398               yy_cp = yy_c_buf_p;
1399               yy_bp = yytext_ptr + YY_MORE_ADJ;
1400               goto yy_match;
1401
1402            case EOB_ACT_LAST_MATCH:
1403               yy_c_buf_p =
1404                  &yy_current_buffer->yy_ch_buf[yy_n_chars];
1405
1406               yy_current_state = yy_get_previous_state();
1407
1408               yy_cp = yy_c_buf_p;
1409               yy_bp = yytext_ptr + YY_MORE_ADJ;
1410               goto yy_find_action;
1411         }
1412         break;
1413      }
1414
1415      default:
1416         YY_FATAL_ERROR(
1417            "fatal flex scanner internal error--no action found");
1418   } /* end of action switch */
1419} /* end of scanning one token */
1420} /* end of yylex */
1421
1422
1423  /* yy_get_next_buffer - try to read in a new buffer
1424  *
1425  * Returns a code representing an action:
1426  *   EOB_ACT_LAST_MATCH -
1427  *   EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1428  *   EOB_ACT_END_OF_FILE - end of file
1429  */
1430
1431   static int yy_get_next_buffer()
1432{
1433   register char *dest = yy_current_buffer->yy_ch_buf;
1434   register char *source = yytext_ptr;
1435   register int number_to_move, i;
1436   int ret_val;
1437
1438   if (yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1])
1439      YY_FATAL_ERROR(
1440         "fatal flex scanner internal error--end of buffer missed");
1441
1442   if (yy_current_buffer->yy_fill_buffer == 0)
1443   { /* Don't try to fill the buffer, so this is an EOF. */
1444      if (yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1)
1445      {
1446         /* We matched a singled characater, the EOB, so
1447         * treat this as a final EOF.
1448         */
1449         return EOB_ACT_END_OF_FILE;
1450      }
1451
1452      else
1453      {
1454         /* We matched some text prior to the EOB, first
1455         * process it.
1456         */
1457         return EOB_ACT_LAST_MATCH;
1458      }
1459   }
1460
1461   /* Try to read more data. */
1462
1463   /* First move last chars to start of buffer. */
1464   number_to_move = (int)(yy_c_buf_p - yytext_ptr) - 1;
1465
1466   for (i = 0; i < number_to_move; ++i)
1467      *(dest++) = *(source++);
1468
1469   if (yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING)
1470      /* don't do the read, it's not guaranteed to return an EOF,
1471      * just force an EOF
1472      */
1473      yy_n_chars = 0;
1474
1475   else
1476   {
1477      int num_to_read =
1478         yy_current_buffer->yy_buf_size - number_to_move - 1;
1479
1480      while (num_to_read <= 0)
1481      { /* Not enough room in the buffer - grow it. */
1482#ifdef YY_USES_REJECT
1483         YY_FATAL_ERROR(
1484            "input buffer overflow, can't enlarge buffer because scanner uses REJECT");
1485#else
1486
1487        /* just a shorter name for the current buffer */
1488         YY_BUFFER_STATE b = yy_current_buffer;
1489
1490         int yy_c_buf_p_offset =
1491            (int)(yy_c_buf_p - b->yy_ch_buf);
1492
1493         if (b->yy_is_our_buffer)
1494         {
1495            int new_size = b->yy_buf_size * 2;
1496
1497            if (new_size <= 0)
1498               b->yy_buf_size += b->yy_buf_size / 8;
1499            else
1500               b->yy_buf_size *= 2;
1501
1502            b->yy_ch_buf = (char *)
1503               /* Include room in for 2 EOB chars. */
1504               yy_flex_realloc((void *)b->yy_ch_buf,
1505                  b->yy_buf_size + 2);
1506         }
1507         else
1508            /* Can't grow it, we don't own it. */
1509            b->yy_ch_buf = 0;
1510
1511         if (!b->yy_ch_buf)
1512            YY_FATAL_ERROR(
1513               "fatal error - scanner input buffer overflow");
1514
1515         yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1516
1517         num_to_read = yy_current_buffer->yy_buf_size -
1518            number_to_move - 1;
1519#endif
1520      }
1521
1522      if (num_to_read > YY_READ_BUF_SIZE)
1523         num_to_read = YY_READ_BUF_SIZE;
1524
1525      /* Read in more data. */
1526      YY_INPUT((&yy_current_buffer->yy_ch_buf[number_to_move]),
1527         yy_n_chars, num_to_read);
1528   }
1529
1530   if (yy_n_chars == 0)
1531   {
1532      if (number_to_move == YY_MORE_ADJ)
1533      {
1534         ret_val = EOB_ACT_END_OF_FILE;
1535         yyrestart(yyin);
1536      }
1537
1538      else
1539      {
1540         ret_val = EOB_ACT_LAST_MATCH;
1541         yy_current_buffer->yy_buffer_status =
1542            YY_BUFFER_EOF_PENDING;
1543      }
1544   }
1545
1546   else
1547      ret_val = EOB_ACT_CONTINUE_SCAN;
1548
1549   yy_n_chars += number_to_move;
1550   yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1551   yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1552
1553   yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
1554
1555   return ret_val;
1556}
1557
1558
1559/* yy_get_previous_state - get the state just before the EOB char was reached */
1560
1561static yy_state_type yy_get_previous_state()
1562{
1563   register yy_state_type yy_current_state;
1564   register char *yy_cp;
1565
1566   yy_current_state = yy_start;
1567
1568   for (yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp)
1569   {
1570      register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1571      if (yy_accept[yy_current_state])
1572      {
1573         yy_last_accepting_state = yy_current_state;
1574         yy_last_accepting_cpos = yy_cp;
1575      }
1576      while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state)
1577      {
1578         yy_current_state = (int)yy_def[yy_current_state];
1579         if (yy_current_state >= 224)
1580            yy_c = yy_meta[(unsigned int)yy_c];
1581      }
1582      yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int)yy_c];
1583   }
1584
1585   return yy_current_state;
1586}
1587
1588
1589/* yy_try_NUL_trans - try to make a transition on the NUL character
1590*
1591* synopsis
1592*  next_state = yy_try_NUL_trans( current_state );
1593*/
1594
1595#ifdef YY_USE_PROTOS
1596static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state)
1597#else
1598static yy_state_type yy_try_NUL_trans(yy_current_state)
1599yy_state_type yy_current_state;
1600#endif
1601{
1602   register int yy_is_jam;
1603   register char *yy_cp = yy_c_buf_p;
1604
1605   register YY_CHAR yy_c = 1;
1606   if (yy_accept[yy_current_state])
1607   {
1608      yy_last_accepting_state = yy_current_state;
1609      yy_last_accepting_cpos = yy_cp;
1610   }
1611   while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state)
1612   {
1613      yy_current_state = (int)yy_def[yy_current_state];
1614      if (yy_current_state >= 224)
1615         yy_c = yy_meta[(unsigned int)yy_c];
1616   }
1617   yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int)yy_c];
1618   yy_is_jam = (yy_current_state == 223);
1619
1620   return yy_is_jam ? 0 : yy_current_state;
1621}
1622
1623
1624#ifndef YY_NO_UNPUT
1625#ifdef YY_USE_PROTOS
1626static void yyunput(int c, register char *yy_bp)
1627#else
1628static void yyunput(c, yy_bp)
1629int c;
1630register char *yy_bp;
1631#endif
1632{
1633   register char *yy_cp = yy_c_buf_p;
1634
1635   /* undo effects of setting up yytext */
1636   *yy_cp = yy_hold_char;
1637
1638   if (yy_cp < yy_current_buffer->yy_ch_buf + 2)
1639   { /* need to shift things up to make room */
1640     /* +2 for EOB chars. */
1641      register int number_to_move = yy_n_chars + 2;
1642      register char *dest = &yy_current_buffer->yy_ch_buf[
1643         yy_current_buffer->yy_buf_size + 2];
1644      register char *source =
1645         &yy_current_buffer->yy_ch_buf[number_to_move];
1646
1647      while (source > yy_current_buffer->yy_ch_buf)
1648         *--dest = *--source;
1649
1650      yy_cp += (int)(dest - source);
1651      yy_bp += (int)(dest - source);
1652      yy_n_chars = yy_current_buffer->yy_buf_size;
1653
1654      if (yy_cp < yy_current_buffer->yy_ch_buf + 2)
1655         YY_FATAL_ERROR("flex scanner push-back overflow");
1656   }
1657
1658   *--yy_cp = (char)c;
1659
1660
1661   yytext_ptr = yy_bp;
1662   yy_hold_char = *yy_cp;
1663   yy_c_buf_p = yy_cp;
1664}
1665#endif   /* ifndef YY_NO_UNPUT */
1666
1667
1668#ifdef __cplusplus
1669static int yyinput()
1670#else
1671static int input()
1672#endif
1673{
1674   int c;
1675
1676   *yy_c_buf_p = yy_hold_char;
1677
1678   if (*yy_c_buf_p == YY_END_OF_BUFFER_CHAR)
1679   {
1680      /* yy_c_buf_p now points to the character we want to return.
1681      * If this occurs *before* the EOB characters, then it's a
1682      * valid NUL; if not, then we've hit the end of the buffer.
1683      */
1684      if (yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars])
1685         /* This was really a NUL. */
1686         *yy_c_buf_p = '\0';
1687
1688      else
1689      { /* need more input */
1690         yytext_ptr = yy_c_buf_p;
1691         ++yy_c_buf_p;
1692
1693         switch (yy_get_next_buffer())
1694         {
1695            case EOB_ACT_END_OF_FILE:
1696            {
1697               if (yywrap())
1698               {
1699                  yy_c_buf_p =
1700                     yytext_ptr + YY_MORE_ADJ;
1701                  return EOF;
1702               }
1703
1704               if (!yy_did_buffer_switch_on_eof)
1705                  YY_NEW_FILE;
1706#ifdef __cplusplus
1707               return yyinput();
1708#else
1709               return input();
1710#endif
1711            }
1712
1713            case EOB_ACT_CONTINUE_SCAN:
1714               yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
1715               break;
1716
1717            case EOB_ACT_LAST_MATCH:
1718#ifdef __cplusplus
1719               YY_FATAL_ERROR(
1720                  "unexpected last match in yyinput()");
1721#else
1722               YY_FATAL_ERROR(
1723                  "unexpected last match in input()");
1724#endif
1725         }
1726      }
1727   }
1728
1729   c = *(unsigned char *)yy_c_buf_p;   /* cast for 8-bit char's */
1730   *yy_c_buf_p = '\0';  /* preserve yytext */
1731   yy_hold_char = *++yy_c_buf_p;
1732
1733
1734   return c;
1735}
1736
1737
1738#ifdef YY_USE_PROTOS
1739void yyrestart(FILE *input_file)
1740#else
1741void yyrestart(input_file)
1742FILE *input_file;
1743#endif
1744{
1745   if (!yy_current_buffer)
1746      yy_current_buffer = yy_create_buffer(yyin, YY_BUF_SIZE);
1747
1748   yy_init_buffer(yy_current_buffer, input_file);
1749   yy_load_buffer_state();
1750}
1751
1752
1753#ifdef YY_USE_PROTOS
1754void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer)
1755#else
1756void yy_switch_to_buffer(new_buffer)
1757YY_BUFFER_STATE new_buffer;
1758#endif
1759{
1760   if (yy_current_buffer == new_buffer)
1761      return;
1762
1763   if (yy_current_buffer)
1764   {
1765      /* Flush out information for old buffer. */
1766      *yy_c_buf_p = yy_hold_char;
1767      yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1768      yy_current_buffer->yy_n_chars = yy_n_chars;
1769   }
1770
1771   yy_current_buffer = new_buffer;
1772   yy_load_buffer_state();
1773
1774   /* We don't actually know whether we did this switch during
1775   * EOF (yywrap()) processing, but the only time this flag
1776   * is looked at is after yywrap() is called, so it's safe
1777   * to go ahead and always set it.
1778   */
1779   yy_did_buffer_switch_on_eof = 1;
1780}
1781
1782
1783#ifdef YY_USE_PROTOS
1784void yy_load_buffer_state(void)
1785#else
1786void yy_load_buffer_state()
1787#endif
1788{
1789   yy_n_chars = yy_current_buffer->yy_n_chars;
1790   yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1791   yyin = yy_current_buffer->yy_input_file;
1792   yy_hold_char = *yy_c_buf_p;
1793}
1794
1795
1796#ifdef YY_USE_PROTOS
1797YY_BUFFER_STATE yy_create_buffer(FILE *file, int size)
1798#else
1799YY_BUFFER_STATE yy_create_buffer(file, size)
1800FILE *file;
1801int size;
1802#endif
1803{
1804   YY_BUFFER_STATE b;
1805
1806   b = (YY_BUFFER_STATE)yy_flex_alloc(sizeof(struct yy_buffer_state));
1807   if (!b)
1808      YY_FATAL_ERROR("out of dynamic memory in yy_create_buffer()");
1809
1810   b->yy_buf_size = size;
1811
1812   /* yy_ch_buf has to be 2 characters longer than the size given because
1813   * we need to put in 2 end-of-buffer characters.
1814   */
1815   b->yy_ch_buf = (char *)yy_flex_alloc(b->yy_buf_size + 2);
1816   if (!b->yy_ch_buf)
1817      YY_FATAL_ERROR("out of dynamic memory in yy_create_buffer()");
1818
1819   b->yy_is_our_buffer = 1;
1820
1821   yy_init_buffer(b, file);
1822
1823   return b;
1824}
1825
1826
1827#ifdef YY_USE_PROTOS
1828void yy_delete_buffer(YY_BUFFER_STATE b)
1829#else
1830void yy_delete_buffer(b)
1831YY_BUFFER_STATE b;
1832#endif
1833{
1834   if (!b)
1835      return;
1836
1837   if (b == yy_current_buffer)
1838      yy_current_buffer = (YY_BUFFER_STATE)0;
1839
1840   if (b->yy_is_our_buffer)
1841      yy_flex_free((void *)b->yy_ch_buf);
1842
1843   yy_flex_free((void *)b);
1844}
1845
1846
1847#ifndef YY_ALWAYS_INTERACTIVE
1848#ifndef YY_NEVER_INTERACTIVE
1849extern int isatty YY_PROTO((int));
1850#endif
1851#endif
1852
1853#ifdef YY_USE_PROTOS
1854void yy_init_buffer(YY_BUFFER_STATE b, FILE *file)
1855#else
1856void yy_init_buffer(b, file)
1857YY_BUFFER_STATE b;
1858FILE *file;
1859#endif
1860
1861
1862{
1863   yy_flush_buffer(b);
1864
1865   b->yy_input_file = file;
1866   b->yy_fill_buffer = 1;
1867
1868#if YY_ALWAYS_INTERACTIVE
1869   b->yy_is_interactive = 1;
1870#else
1871#if YY_NEVER_INTERACTIVE
1872   b->yy_is_interactive = 0;
1873#else
1874   b->yy_is_interactive = file ? (isatty(fileno(file)) > 0) : 0;
1875#endif
1876#endif
1877}
1878
1879
1880#ifdef YY_USE_PROTOS
1881void yy_flush_buffer(YY_BUFFER_STATE b)
1882#else
1883void yy_flush_buffer(b)
1884YY_BUFFER_STATE b;
1885#endif
1886
1887{
1888   b->yy_n_chars = 0;
1889
1890   /* We always need two end-of-buffer characters.  The first causes
1891   * a transition to the end-of-buffer state.  The second causes
1892   * a jam in that state.
1893   */
1894   b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1895   b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1896
1897   b->yy_buf_pos = &b->yy_ch_buf[0];
1898
1899   b->yy_at_bol = 1;
1900   b->yy_buffer_status = YY_BUFFER_NEW;
1901
1902   if (b == yy_current_buffer)
1903      yy_load_buffer_state();
1904}
1905
1906
1907#ifndef YY_NO_SCAN_BUFFER
1908#ifdef YY_USE_PROTOS
1909YY_BUFFER_STATE yy_scan_buffer(char *base, yy_size_t size)
1910#else
1911YY_BUFFER_STATE yy_scan_buffer(base, size)
1912char *base;
1913yy_size_t size;
1914#endif
1915{
1916   YY_BUFFER_STATE b;
1917
1918   if (size < 2 ||
1919      base[size - 2] != YY_END_OF_BUFFER_CHAR ||
1920      base[size - 1] != YY_END_OF_BUFFER_CHAR)
1921      /* They forgot to leave room for the EOB's. */
1922      return 0;
1923
1924   b = (YY_BUFFER_STATE)yy_flex_alloc(sizeof(struct yy_buffer_state));
1925   if (!b)
1926      YY_FATAL_ERROR("out of dynamic memory in yy_scan_buffer()");
1927
1928   b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1929   b->yy_buf_pos = b->yy_ch_buf = base;
1930   b->yy_is_our_buffer = 0;
1931   b->yy_input_file = 0;
1932   b->yy_n_chars = b->yy_buf_size;
1933   b->yy_is_interactive = 0;
1934   b->yy_at_bol = 1;
1935   b->yy_fill_buffer = 0;
1936   b->yy_buffer_status = YY_BUFFER_NEW;
1937
1938   yy_switch_to_buffer(b);
1939
1940   return b;
1941}
1942#endif
1943
1944
1945#ifndef YY_NO_SCAN_STRING
1946#ifdef YY_USE_PROTOS
1947YY_BUFFER_STATE yy_scan_string(yyconst char *str)
1948#else
1949YY_BUFFER_STATE yy_scan_string(str)
1950yyconst char *str;
1951#endif
1952{
1953   int len;
1954   for (len = 0; str[len]; ++len)
1955      ;
1956
1957   return yy_scan_bytes(str, len);
1958}
1959#endif
1960
1961
1962#ifndef YY_NO_SCAN_BYTES
1963#ifdef YY_USE_PROTOS
1964YY_BUFFER_STATE yy_scan_bytes(yyconst char *bytes, int len)
1965#else
1966YY_BUFFER_STATE yy_scan_bytes(bytes, len)
1967yyconst char *bytes;
1968int len;
1969#endif
1970{
1971   YY_BUFFER_STATE b;
1972   char *buf;
1973   yy_size_t n;
1974   int i;
1975
1976   /* Get memory for full buffer, including space for trailing EOB's. */
1977   n = len + 2;
1978   buf = (char *)yy_flex_alloc(n);
1979   if (!buf)
1980      YY_FATAL_ERROR("out of dynamic memory in yy_scan_bytes()");
1981
1982   for (i = 0; i < len; ++i)
1983      buf[i] = bytes[i];
1984
1985   buf[len] = buf[len + 1] = YY_END_OF_BUFFER_CHAR;
1986
1987   b = yy_scan_buffer(buf, n);
1988   if (!b)
1989      YY_FATAL_ERROR("bad buffer in yy_scan_bytes()");
1990
1991   /* It's okay to grow etc. this buffer, and we should throw it
1992   * away when we're done.
1993   */
1994   b->yy_is_our_buffer = 1;
1995
1996   return b;
1997}
1998#endif
1999
2000
2001#ifndef YY_NO_PUSH_STATE
2002#ifdef YY_USE_PROTOS
2003static void yy_push_state(int new_state)
2004#else
2005static void yy_push_state(new_state)
2006int new_state;
2007#endif
2008{
2009   if (yy_start_stack_ptr >= yy_start_stack_depth)
2010   {
2011      yy_size_t new_size;
2012
2013      yy_start_stack_depth += YY_START_STACK_INCR;
2014      new_size = yy_start_stack_depth * sizeof(int);
2015
2016      if (!yy_start_stack)
2017         yy_start_stack = (int *)yy_flex_alloc(new_size);
2018
2019      else
2020         yy_start_stack = (int *)yy_flex_realloc(
2021         (void *)yy_start_stack, new_size);
2022
2023      if (!yy_start_stack)
2024         YY_FATAL_ERROR(
2025            "out of memory expanding start-condition stack");
2026   }
2027
2028   yy_start_stack[yy_start_stack_ptr++] = YY_START;
2029
2030   BEGIN(new_state);
2031}
2032#endif
2033
2034
2035#ifndef YY_NO_POP_STATE
2036static void yy_pop_state()
2037{
2038   if (--yy_start_stack_ptr < 0)
2039      YY_FATAL_ERROR("start-condition stack underflow");
2040
2041   BEGIN(yy_start_stack[yy_start_stack_ptr]);
2042}
2043#endif
2044
2045
2046#ifndef YY_NO_TOP_STATE
2047static int yy_top_state()
2048{
2049   return yy_start_stack[yy_start_stack_ptr - 1];
2050}
2051#endif
2052
2053#ifndef YY_EXIT_FAILURE
2054#define YY_EXIT_FAILURE 2
2055#endif
2056
2057#ifdef YY_USE_PROTOS
2058static void yy_fatal_error(yyconst char msg[])
2059#else
2060static void yy_fatal_error(msg)
2061char msg[];
2062#endif
2063{
2064   (void)fprintf(stderr, "%s\n", msg);
2065   exit(YY_EXIT_FAILURE);
2066}
2067
2068
2069
2070/* Redefine yyless() so it works in section 3 code. */
2071
2072#undef yyless
2073#define yyless(n) \
2074   do \
2075      { \
2076      /* Undo effects of setting up yytext. */ \
2077      yytext[yyleng] = yy_hold_char; \
2078      yy_c_buf_p = yytext + n - YY_MORE_ADJ; \
2079      yy_hold_char = *yy_c_buf_p; \
2080      *yy_c_buf_p = '\0'; \
2081      yyleng = n; \
2082      } \
2083   while ( 0 )
2084
2085
2086/* Internal utility routines. */
2087
2088#ifndef yytext_ptr
2089#ifdef YY_USE_PROTOS
2090static void yy_flex_strncpy(char *s1, yyconst char *s2, int n)
2091#else
2092static void yy_flex_strncpy(s1, s2, n)
2093char *s1;
2094yyconst char *s2;
2095int n;
2096#endif
2097{
2098   register int i;
2099   for (i = 0; i < n; ++i)
2100      s1[i] = s2[i];
2101}
2102#endif
2103
2104
2105#ifdef YY_USE_PROTOS
2106static void *yy_flex_alloc(yy_size_t size)
2107#else
2108static void *yy_flex_alloc(size)
2109yy_size_t size;
2110#endif
2111{
2112   return (void *)malloc(size);
2113}
2114
2115#ifdef YY_USE_PROTOS
2116static void *yy_flex_realloc(void *ptr, yy_size_t size)
2117#else
2118static void *yy_flex_realloc(ptr, size)
2119void *ptr;
2120yy_size_t size;
2121#endif
2122{
2123   /* The cast to (char *) in the following accommodates both
2124   * implementations that use char* generic pointers, and those
2125   * that use void* generic pointers.  It works with the latter
2126   * because both ANSI C and C++ allow castless assignment from
2127   * any pointer type to void*, and deal with argument conversions
2128   * as though doing an assignment.
2129   */
2130   return (void *)realloc((char *)ptr, size);
2131}
2132
2133#ifdef YY_USE_PROTOS
2134static void yy_flex_free(void *ptr)
2135#else
2136static void yy_flex_free(ptr)
2137void *ptr;
2138#endif
2139{
2140   free(ptr);
2141}
2142
2143#if YY_MAIN
2144int main()
2145{
2146   yylex();
2147   return 0;
2148}
2149#endif
2150#line 222 "CMDscan.l"
2151
2152
2153static const char *scanBuffer;
2154static const char *fileName;
2155static int scanIndex;
2156
2157const char * CMDGetCurrentFile()
2158{
2159   return fileName;
2160}
2161
2162int CMDGetCurrentLine()
2163{
2164   return lineIndex;
2165}
2166
2167extern bool gConsoleSyntaxError;
2168
2169void CMDerror(char *format, ...)
2170{
2171   Compiler::gSyntaxError = true;
2172
2173   const int BUFMAX = 1024;
2174   char tempBuf[BUFMAX];
2175   va_list args;
2176   va_start(args, format);
2177#ifdef TORQUE_OS_WIN
2178   _vsnprintf(tempBuf, BUFMAX, format, args);
2179#else
2180   vsnprintf(tempBuf, BUFMAX, format, args);
2181#endif
2182   va_end(args);
2183
2184   if (fileName)
2185   {
2186      Con::errorf(ConsoleLogEntry::Script, "%s Line: %d - %s", fileName, lineIndex, tempBuf);
2187
2188#ifndef NO_ADVANCED_ERROR_REPORT
2189      // dhc - lineIndex is bogus.  let's try to add some sanity back in.
2190      int i, j, n;
2191      char c;
2192      int linediv = 1;
2193      // first, walk the buffer, trying to detect line ending type.
2194      // this is imperfect, if inconsistant line endings exist...
2195      for (i = 0; i<scanIndex; i++)
2196      {
2197         c = scanBuffer[i];
2198         if (c == '\r' && scanBuffer[i + 1] == '\n') linediv = 2; // crlf detected
2199         if (c == '\r' || c == '\n' || c == 0) break; // enough for us to stop.
2200      }
2201      // grab some of the chars starting at the error location - lineending.
2202      i = 1; j = 0; n = 1;
2203      // find prev lineending
2204      while (n<BUFMAX - 8 && i<scanIndex) // cap at file start
2205      {
2206         c = scanBuffer[scanIndex - i];
2207         if ((c == '\r' || c == '\n') && i>BUFMAX >> 2) break; // at least get a little data
2208         n++; i++;
2209      }
2210      // find next lineending
2211      while (n<BUFMAX - 8 && j<BUFMAX>>1) // cap at half-buf-size forward
2212      {
2213         c = scanBuffer[scanIndex + j];
2214         if (c == 0) break;
2215         if ((c == '\r' || c == '\n') && j>BUFMAX >> 2) break; // at least get a little data
2216         n++; j++;
2217      }
2218      if (i) i--; // chop off extra linefeed.
2219      if (j) j--; // chop off extra linefeed.
2220                  // build our little text block
2221      if (i) dStrncpy(tempBuf, scanBuffer + scanIndex - i, i);
2222      dStrncpy(tempBuf + i, "##", 2); // bracketing.
2223      tempBuf[i + 2] = scanBuffer[scanIndex]; // copy the halt character.
2224      dStrncpy(tempBuf + i + 3, "##", 2); // bracketing.
2225      if (j) dStrncpy(tempBuf + i + 5, scanBuffer + scanIndex + 1, j); // +1 to go past current char.
2226      tempBuf[i + j + 5] = 0; // null terminate
2227      for (n = 0; n<i + j + 5; n++) // convert CR to LF if alone...
2228         if (tempBuf[n] == '\r' && tempBuf[n + 1] != '\n') tempBuf[n] = '\n';
2229      // write out to console the advanced error report
2230      Con::warnf(ConsoleLogEntry::Script, ">>> Advanced script error report.  Line %d.", lineIndex);
2231      Con::warnf(ConsoleLogEntry::Script, ">>> Some error context, with ## on sides of error halt:");
2232      Con::errorf(ConsoleLogEntry::Script, "%s", tempBuf);
2233      Con::warnf(ConsoleLogEntry::Script, ">>> Error report complete.\n");
2234#endif
2235
2236      // Update the script-visible error buffer.
2237      const char *prevStr = Con::getVariable("$ScriptError");
2238      if (prevStr[0])
2239         dSprintf(tempBuf, sizeof(tempBuf), "%s\n%s Line: %d - Syntax error.", prevStr, fileName, lineIndex);
2240      else
2241         dSprintf(tempBuf, sizeof(tempBuf), "%s Line: %d - Syntax error.", fileName, lineIndex);
2242      Con::setVariable("$ScriptError", tempBuf);
2243
2244      // We also need to mark that we came up with a new error.
2245      static S32 sScriptErrorHash = 1000;
2246      Con::setIntVariable("$ScriptErrorHash", sScriptErrorHash++);
2247   }
2248   else
2249      Con::errorf(ConsoleLogEntry::Script, tempBuf);
2250}
2251
2252void CMDSetScanBuffer(const char *sb, const char *fn)
2253{
2254   scanBuffer = sb;
2255   fileName = fn;
2256   scanIndex = 0;
2257   lineIndex = 1;
2258}
2259
2260int CMDgetc()
2261{
2262   int ret = scanBuffer[scanIndex];
2263   if (ret)
2264      scanIndex++;
2265   else
2266      ret = -1;
2267   return ret;
2268}
2269
2270int CMDwrap()
2271{
2272   return 1;
2273}
2274
2275static int Sc_ScanVar()
2276{
2277   // Truncate the temp buffer...
2278   CMDtext[CMDleng] = 0;
2279
2280   // Make it a stringtable string!
2281   CMDlval.s = MakeToken< StringTableEntry >(StringTable->insert(CMDtext), lineIndex);
2282   return(VAR);
2283}
2284
2285static int charConv(int in)
2286{
2287   switch (in)
2288   {
2289      case 'r':
2290         return '\r';
2291      case 'n':
2292         return '\n';
2293      case 't':
2294         return '\t';
2295      default:
2296         return in;
2297   }
2298}
2299
2300static int getHexDigit(char c)
2301{
2302   if (c >= '0' && c <= '9')
2303      return c - '0';
2304   if (c >= 'A' && c <= 'F')
2305      return c - 'A' + 10;
2306   if (c >= 'a' && c <= 'f')
2307      return c - 'a' + 10;
2308   return -1;
2309}
2310
2311static int Sc_ScanDocBlock()
2312{
2313   S32 len = dStrlen(CMDtext);
2314   char* text = (char *)consoleAlloc(len + 1);
2315   S32 line = lineIndex;
2316
2317   for (S32 i = 0, j = 0; j <= len; j++)
2318   {
2319      if ((j <= (len - 2)) && (CMDtext[j] == '/') && (CMDtext[j + 1] == '/') && (CMDtext[j + 2] == '/'))
2320      {
2321         j += 2;
2322         continue;
2323      }
2324
2325      if (CMDtext[j] == '\r')
2326         continue;
2327
2328      if (CMDtext[j] == '\n')
2329         lineIndex++;
2330
2331      text[i++] = CMDtext[j];
2332   }
2333
2334   CMDlval.str = MakeToken< char* >(text, line);
2335   return(DOCBLOCK);
2336}
2337
2338static int Sc_ScanString(int ret)
2339{
2340   CMDtext[CMDleng - 1] = 0;
2341   if (!collapseEscape(CMDtext + 1))
2342      return -1;
2343
2344   dsize_t bufferLen = dStrlen(CMDtext);
2345   char* buffer = (char*)consoleAlloc(bufferLen);
2346   dStrcpy(buffer, CMDtext + 1, bufferLen);
2347
2348   CMDlval.str = MakeToken< char* >(buffer, lineIndex);
2349   return ret;
2350}
2351
2352static int Sc_ScanIdent()
2353{
2354   ConsoleBaseType *type;
2355
2356   CMDtext[CMDleng] = 0;
2357
2358   if ((type = ConsoleBaseType::getTypeByName(CMDtext)) != NULL)
2359   {
2360      /* It's a type */
2361      CMDlval.i = MakeToken< int >(type->getTypeID(), lineIndex);
2362      return TYPEIDENT;
2363   }
2364
2365   /* It's an identifier */
2366   CMDlval.s = MakeToken< StringTableEntry >(StringTable->insert(CMDtext), lineIndex);
2367   return IDENT;
2368}
2369
2370void expandEscape(char *dest, const char *src)
2371{
2372   U8 c;
2373   while ((c = (U8)*src++) != 0)
2374   {
2375      if (c == '\"')
2376      {
2377         *dest++ = '\\';
2378         *dest++ = '\"';
2379      }
2380      else if (c == '\\')
2381      {
2382         *dest++ = '\\';
2383         *dest++ = '\\';
2384      }
2385      else if (c == '\r')
2386      {
2387         *dest++ = '\\';
2388         *dest++ = 'r';
2389      }
2390      else if (c == '\n')
2391      {
2392         *dest++ = '\\';
2393         *dest++ = 'n';
2394      }
2395      else if (c == '\t')
2396      {
2397         *dest++ = '\\';
2398         *dest++ = 't';
2399      }
2400      else if (c == '\'')
2401      {
2402         *dest++ = '\\';
2403         *dest++ = '\'';
2404      }
2405      else if ((c >= 1 && c <= 7) ||
2406         (c >= 11 && c <= 12) ||
2407         (c >= 14 && c <= 15))
2408      {
2409         /*  Remap around: \b = 0x8, \t = 0x9, \n = 0xa, \r = 0xd */
2410         static U8 expandRemap[15] = { 0x0,
2411            0x0,
2412            0x1,
2413            0x2,
2414            0x3,
2415            0x4,
2416            0x5,
2417            0x6,
2418            0x0,
2419            0x0,
2420            0x0,
2421            0x7,
2422            0x8,
2423            0x0,
2424            0x9 };
2425
2426         *dest++ = '\\';
2427         *dest++ = 'c';
2428         if (c == 15)
2429            *dest++ = 'r';
2430         else if (c == 16)
2431            *dest++ = 'p';
2432         else if (c == 17)
2433            *dest++ = 'o';
2434         else
2435            *dest++ = expandRemap[c] + '0';
2436      }
2437      else if (c < 32)
2438      {
2439         *dest++ = '\\';
2440         *dest++ = 'x';
2441         S32 dig1 = c >> 4;
2442         S32 dig2 = c & 0xf;
2443         if (dig1 < 10)
2444            dig1 += '0';
2445         else
2446            dig1 += 'A' - 10;
2447         if (dig2 < 10)
2448            dig2 += '0';
2449         else
2450            dig2 += 'A' - 10;
2451         *dest++ = dig1;
2452         *dest++ = dig2;
2453      }
2454      else
2455         *dest++ = c;
2456   }
2457   *dest = '\0';
2458}
2459
2460bool collapseEscape(char *buf)
2461{
2462   S32 len = dStrlen(buf) + 1;
2463   for (S32 i = 0; i < len;)
2464   {
2465      if (buf[i] == '\\')
2466      {
2467         if (buf[i + 1] == 'x')
2468         {
2469            S32 dig1 = getHexDigit(buf[i + 2]);
2470            if (dig1 == -1)
2471               return false;
2472
2473            S32 dig2 = getHexDigit(buf[i + 3]);
2474            if (dig2 == -1)
2475               return false;
2476            buf[i] = dig1 * 16 + dig2;
2477            dMemmove(buf + i + 1, buf + i + 4, len - i - 3);
2478            len -= 3;
2479            i++;
2480         }
2481         else if (buf[i + 1] == 'c')
2482         {
2483            /*  Remap around: \b = 0x8, \t = 0x9, \n = 0xa, \r = 0xd */
2484            static U8 collapseRemap[10] = { 0x1,
2485               0x2,
2486               0x3,
2487               0x4,
2488               0x5,
2489               0x6,
2490               0x7,
2491               0xb,
2492               0xc,
2493               0xe };
2494
2495            if (buf[i + 2] == 'r')
2496               buf[i] = 15;
2497            else if (buf[i + 2] == 'p')
2498               buf[i] = 16;
2499            else if (buf[i + 2] == 'o')
2500               buf[i] = 17;
2501            else
2502            {
2503               int dig1 = buf[i + 2] - '0';
2504               if (dig1 < 0 || dig1 > 9)
2505                  return false;
2506               buf[i] = collapseRemap[dig1];
2507            }
2508            // Make sure we don't put 0x1 at the beginning of the string.
2509            if ((buf[i] == 0x1) && (i == 0))
2510            {
2511               buf[i] = 0x2;
2512               buf[i + 1] = 0x1;
2513               dMemmove(buf + i + 2, buf + i + 3, len - i - 1);
2514               len -= 1;
2515            }
2516            else
2517            {
2518               dMemmove(buf + i + 1, buf + i + 3, len - i - 2);
2519               len -= 2;
2520            }
2521            i++;
2522         }
2523         else
2524         {
2525            buf[i] = charConv(buf[i + 1]);
2526            dMemmove(buf + i + 1, buf + i + 2, len - i - 1);
2527            len--;
2528            i++;
2529         }
2530      }
2531      else
2532         i++;
2533   }
2534   return true;
2535}
2536
2537static int Sc_ScanNum()
2538{
2539   CMDtext[CMDleng] = 0;
2540   CMDlval.f = MakeToken< double >(dAtof(CMDtext), lineIndex);
2541   return(FLTCONST);
2542}
2543
2544static int Sc_ScanHex()
2545{
2546   S32 val = 0;
2547   dSscanf(CMDtext, "%x", &val);
2548   CMDlval.i = MakeToken< int >(val, lineIndex);
2549   return INTCONST;
2550}
2551
2552void CMD_reset()
2553{
2554   CMDrestart(NULL);
2555}
2556