CMDscan.cpp
Engine/source/console/CMDscan.cpp
Classes:
class
class
Public Defines
define
BEGIN() yy_start = 1 + 2 *
define
ECHO() () fwrite( , , 1, )
define
define
define
define
FLEX_DEBUG() 0
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
YY_BUFFER_NEW() 0
define
YY_BUFFER_NORMAL() 1
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
YY_END_OF_BUFFER() 95
define
define
YY_EXIT_FAILURE() 2
define
YY_FATAL_ERROR(msg) yy_fatal_error( msg )
define
yy_flex_debug() CMD_flex_debug
define
define
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
YY_MORE_ADJ() 0
define
define
define
YY_NEW_FILE() ( )
define
YY_NO_POP_STATE() 1
define
YY_NO_PUSH_STATE() 1
define
YY_NO_TOP_STATE() 1
define
define
YY_NULL() 0
define
YY_NUM_RULES() 94
define
YY_PROTO(proto) ()
define
YY_READ_BUF_SIZE() 8192
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_START_STACK_INCR() 25
define
YY_STATE_EOF(state) ( + state + 1)
define
yy_switch_to_buffer() CMD_switch_to_buffer
define
define
yyconst()
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
yylex()
define
YYLMAX() 4096
define
yymore() yymore_used_but_not_detected
define
yyout() CMDout
define
define
YYSTATE()
define
yyterminate() return
define
yytext() CMDtext
define
define
yywrap()
Public Typedefs
unsigned char
YY_CHAR
unsigned int
yy_size_t
int
yy_state_type
Public Variables
char *
FILE *
bool
int
int
int
const char *
int
int
register int
register char *
char *
register char *
YY_BUFFER_STATE
char
int
char *
int
int
FILE *
int
FILE *
char *
Public Functions
int
charConv(int in)
int
CMDgetc()
const char *
int
const char *
CMDgetFileLine(int & lineNumber)
CMDrestart(FILE * in)
CMDSetScanBuffer(const char * sb, const char * fn)
int
CMDwrap()
bool
collapseEscape(char * buf)
expandEscape(char * dest, const char * src)
for()
int
getHexDigit(char c)
if(! b)
if()
if(yy_accept )
if(yy_current_buffer )
if(yy_init )
int
input()
int
isatty(int )
int
int
int
int
int
Sc_ScanString(int ret)
int
while(1 )
YY_BUFFER_STATE
yy_create_buffer(file , size )
yy_fatal_error(msg )
void *
yy_flex_free((void *) b)
yy_flex_free(ptr )
void *
yy_flex_realloc(ptr , size )
int
yy_init_buffer(b , file )
yy_init_buffer(yy_current_buffer , input_file )
YY_BUFFER_STATE yy_scan_buffer
YY_BUFFER_STATE yy_create_buffer
YY_PROTO((YY_BUFFER_STATE new_buffer) )
yy_state_type yy_try_NUL_trans
YY_PROTO((yy_state_type current_state) )
YY_BUFFER_STATE yy_scan_bytes
YY_BUFFER_STATE yy_scan_string
YY_BUFFER_STATE
yy_scan_buffer(base , size )
YY_BUFFER_STATE
yy_scan_bytes(bytes , len )
return
yy_scan_bytes(str , len )
YY_BUFFER_STATE
yy_scan_string(str )
yy_switch_to_buffer(new_buffer )
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, 308 0, 0, 95, 93, 1, 5, 4, 51, 93, 93, 309 58, 57, 93, 41, 42, 45, 43, 56, 44, 50, 310 46, 90, 90, 52, 53, 47, 61, 48, 38, 36, 311 88, 88, 88, 88, 39, 40, 59, 88, 88, 88, 312 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 313 88, 54, 49, 55, 60, 1, 0, 9, 0, 6, 314 0, 0, 17, 87, 25, 12, 26, 0, 7, 0, 315 23, 16, 21, 15, 22, 31, 91, 37, 3, 24, 316 0, 90, 0, 0, 14, 19, 11, 8, 10, 20, 317 88, 33, 88, 88, 27, 88, 88, 88, 88, 88, 318 319 88, 69, 88, 88, 88, 88, 70, 62, 88, 88, 320 63, 88, 88, 88, 88, 88, 88, 28, 13, 18, 321 92, 87, 0, 32, 3, 3, 91, 0, 91, 89, 322 29, 30, 35, 34, 88, 88, 88, 88, 88, 88, 323 88, 88, 73, 88, 88, 76, 88, 88, 88, 88, 324 88, 88, 92, 0, 3, 2, 88, 88, 79, 88, 325 88, 88, 66, 88, 88, 88, 88, 88, 88, 88, 326 88, 85, 88, 3, 0, 88, 64, 88, 88, 88, 327 86, 88, 88, 88, 88, 88, 88, 88, 68, 0, 328 67, 88, 88, 88, 88, 88, 88, 88, 65, 88, 329 330 81, 0, 88, 88, 82, 72, 88, 88, 83, 88, 331 80, 0, 74, 88, 71, 75, 88, 88, 0, 78, 332 84, 77, 0 333 } ; 334 335static yyconst int yy_ec[256] = 336 { 0, 337 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 338 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, 339 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 340 1, 2, 5, 6, 1, 7, 8, 9, 10, 11, 341 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 342 20, 20, 20, 20, 20, 20, 20, 21, 22, 23, 343 24, 25, 26, 27, 28, 29, 30, 31, 32, 31, 344 33, 33, 33, 33, 33, 34, 33, 35, 33, 36, 345 33, 33, 37, 38, 33, 33, 33, 39, 33, 33, 346 40, 41, 42, 43, 33, 1, 44, 45, 46, 47, 347 348 48, 49, 50, 51, 52, 33, 53, 54, 55, 56, 349 57, 58, 33, 59, 60, 61, 62, 33, 63, 39, 350 33, 33, 64, 65, 66, 67, 1, 1, 1, 1, 351 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 352 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 353 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 354 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 355 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 356 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 357 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 358 359 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 360 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 361 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 362 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 363 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 364 1, 1, 1, 1, 1 365 } ; 366 367static yyconst int yy_meta[68] = 368 { 0, 369 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 370 1, 1, 1, 1, 1, 1, 1, 3, 4, 4, 371 5, 1, 1, 6, 1, 1, 1, 4, 4, 4, 372 4, 4, 7, 7, 7, 7, 7, 7, 7, 1, 373 1, 1, 1, 4, 4, 4, 4, 4, 4, 7, 374 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 375 7, 7, 7, 1, 1, 1, 1 376 } ; 377 378static yyconst short int yy_base[237] = 379 { 0, 380 0, 0, 337, 338, 334, 338, 338, 61, 63, 51, 381 53, 65, 66, 338, 338, 311, 64, 338, 66, 60, 382 68, 76, 80, 313, 338, 60, 309, 77, 338, 338, 383 0, 298, 295, 302, 338, 338, 305, 268, 268, 54, 384 61, 272, 59, 38, 62, 266, 280, 275, 62, 263, 385 270, 338, 89, 338, 338, 318, 295, 338, 111, 338, 386 314, 100, 338, 296, 338, 338, 338, 112, 338, 312, 387 338, 338, 338, 290, 338, 338, 107, 338, 296, 338, 388 110, 114, 121, 0, 338, 289, 338, 338, 338, 288, 389 0, 0, 281, 281, 338, 249, 260, 247, 250, 244, 390 391 255, 0, 243, 248, 242, 244, 0, 0, 244, 235, 392 0, 251, 235, 239, 242, 231, 240, 338, 338, 338, 393 270, 269, 268, 338, 0, 139, 119, 125, 128, 0, 394 338, 338, 0, 0, 240, 243, 238, 224, 240, 239, 395 234, 221, 232, 233, 230, 0, 224, 214, 225, 213, 396 225, 218, 250, 249, 146, 152, 210, 215, 0, 215, 397 221, 203, 0, 216, 219, 201, 201, 216, 200, 204, 398 211, 0, 208, 155, 237, 193, 0, 197, 198, 197, 399 0, 204, 197, 190, 197, 190, 197, 193, 0, 225, 400 0, 180, 184, 179, 177, 153, 158, 151, 0, 134, 401 402 187, 157, 143, 144, 0, 176, 123, 126, 0, 112, 403 338, 160, 0, 115, 338, 0, 88, 76, 162, 0, 404 0, 0, 338, 170, 174, 181, 185, 189, 193, 200, 405 119, 204, 211, 218, 225, 232 406 } ; 407 408static yyconst short int yy_def[237] = 409 { 0, 410 223, 1, 223, 223, 223, 223, 223, 223, 224, 225, 411 225, 223, 226, 223, 223, 223, 223, 223, 223, 223, 412 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 413 227, 227, 227, 227, 223, 223, 223, 227, 227, 227, 414 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 415 227, 223, 223, 223, 223, 223, 223, 223, 224, 223, 416 224, 228, 223, 229, 223, 223, 223, 226, 223, 226, 417 223, 223, 223, 223, 223, 223, 223, 223, 230, 223, 418 223, 223, 223, 231, 223, 223, 223, 223, 223, 223, 419 227, 227, 227, 227, 223, 227, 227, 227, 227, 227, 420 421 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 422 227, 227, 227, 227, 227, 227, 227, 223, 223, 223, 423 232, 229, 229, 223, 230, 233, 223, 223, 223, 231, 424 223, 223, 227, 227, 227, 227, 227, 227, 227, 227, 425 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 426 227, 227, 232, 232, 234, 223, 227, 227, 227, 227, 427 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 428 227, 227, 227, 234, 223, 227, 227, 227, 227, 227, 429 227, 227, 227, 227, 227, 227, 227, 227, 227, 223, 430 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 431 432 227, 235, 227, 227, 227, 227, 227, 227, 227, 227, 433 223, 236, 227, 227, 223, 227, 227, 227, 236, 227, 434 227, 227, 0, 223, 223, 223, 223, 223, 223, 223, 435 223, 223, 223, 223, 223, 223 436 } ; 437 438static yyconst short int yy_nxt[406] = 439 { 0, 440 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 441 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 442 24, 25, 26, 27, 28, 29, 30, 31, 31, 31, 443 31, 31, 31, 31, 32, 31, 33, 34, 31, 35, 444 4, 36, 37, 38, 39, 40, 41, 42, 43, 31, 445 31, 44, 31, 31, 31, 45, 46, 47, 48, 49, 446 50, 31, 51, 52, 53, 54, 55, 57, 60, 62, 447 62, 62, 62, 66, 63, 69, 65, 72, 77, 77, 448 78, 74, 86, 87, 58, 79, 107, 73, 67, 75, 449 76, 80, 81, 108, 82, 82, 81, 98, 82, 82, 450 451 89, 90, 104, 61, 100, 109, 70, 83, 101, 110, 452 99, 83, 118, 114, 84, 105, 60, 102, 62, 62, 453 106, 69, 130, 83, 115, 77, 77, 83, 127, 127, 454 81, 222, 82, 82, 128, 221, 128, 127, 127, 129, 455 129, 156, 156, 129, 129, 83, 129, 129, 156, 156, 456 83, 61, 70, 119, 156, 156, 125, 156, 156, 156, 457 156, 83, 156, 156, 156, 156, 83, 220, 218, 175, 458 59, 217, 59, 59, 59, 59, 59, 64, 216, 64, 459 64, 68, 215, 68, 68, 68, 68, 68, 91, 214, 460 213, 91, 121, 211, 210, 121, 122, 122, 209, 122, 461 462 125, 208, 125, 125, 125, 125, 125, 153, 153, 207, 463 153, 155, 155, 155, 155, 155, 155, 155, 174, 174, 464 174, 174, 174, 174, 174, 212, 212, 206, 212, 212, 465 212, 212, 219, 219, 219, 219, 219, 219, 219, 205, 466 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, 467 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 468 184, 183, 182, 181, 180, 179, 178, 177, 176, 154, 469 154, 173, 172, 171, 170, 169, 168, 167, 166, 165, 470 164, 163, 162, 161, 160, 159, 158, 157, 123, 123, 471 154, 152, 151, 150, 149, 148, 147, 146, 145, 144, 472 473 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 474 133, 132, 131, 126, 124, 68, 123, 59, 120, 56, 475 117, 116, 113, 112, 111, 103, 97, 96, 95, 94, 476 93, 92, 88, 85, 71, 56, 223, 3, 223, 223, 477 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 478 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 479 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 480 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 481 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 482 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 483 484 223, 223, 223, 223, 223 485 } ; 486 487static yyconst short int yy_chk[406] = 488 { 0, 489 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 490 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 491 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 492 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 493 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 494 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 495 1, 1, 1, 1, 1, 1, 1, 8, 9, 10, 496 10, 11, 11, 12, 10, 13, 11, 17, 20, 20, 497 21, 19, 26, 26, 8, 21, 44, 17, 12, 19, 498 19, 21, 22, 44, 22, 22, 23, 40, 23, 23, 499 500 28, 28, 43, 9, 41, 45, 13, 22, 41, 45, 501 40, 23, 53, 49, 22, 43, 59, 41, 62, 62, 502 43, 68, 231, 22, 49, 77, 77, 23, 81, 81, 503 82, 218, 82, 82, 83, 217, 83, 127, 127, 83, 504 83, 126, 126, 128, 128, 82, 129, 129, 155, 155, 505 127, 59, 68, 53, 156, 156, 126, 174, 174, 202, 506 202, 82, 212, 212, 219, 219, 127, 214, 210, 156, 507 224, 208, 224, 224, 224, 224, 224, 225, 207, 225, 508 225, 226, 206, 226, 226, 226, 226, 226, 227, 204, 509 203, 227, 228, 201, 200, 228, 229, 229, 198, 229, 510 511 230, 197, 230, 230, 230, 230, 230, 232, 232, 196, 512 232, 233, 233, 233, 233, 233, 233, 233, 234, 234, 513 234, 234, 234, 234, 234, 235, 235, 195, 235, 235, 514 235, 235, 236, 236, 236, 236, 236, 236, 236, 194, 515 193, 192, 190, 188, 187, 186, 185, 184, 183, 182, 516 180, 179, 178, 176, 175, 173, 171, 170, 169, 168, 517 167, 166, 165, 164, 162, 161, 160, 158, 157, 154, 518 153, 152, 151, 150, 149, 148, 147, 145, 144, 143, 519 142, 141, 140, 139, 138, 137, 136, 135, 123, 122, 520 121, 117, 116, 115, 114, 113, 112, 110, 109, 106, 521 522 105, 104, 103, 101, 100, 99, 98, 97, 96, 94, 523 93, 90, 86, 79, 74, 70, 64, 61, 57, 56, 524 51, 50, 48, 47, 46, 42, 39, 38, 37, 34, 525 33, 32, 27, 24, 16, 5, 3, 223, 223, 223, 526 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 527 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 528 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 529 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 530 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 531 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 532 533 223, 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; 779 register char *yy_cp, *yy_bp; 780 register int yy_act; 781 782#line 105 "CMDscan.l" 783 784 ; 785#line 785 "CMDscan.cpp" 786 787 if ( 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 811 while ( 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 } 842 while ( yy_base[yy_current_state] != 338 ); 843 844yy_find_action: 845 yy_act = yy_accept[yy_current_state]; 846 if ( yy_act == 0 ) 847 { /* have to back up */ 848 yy_cp = yy_last_accepting_cpos; 849 yy_current_state = yy_last_accepting_state; 850 yy_act = yy_accept[yy_current_state]; 851 } 852 853 YY_DO_BEFORE_ACTION; 854 855 856do_action: /* This label is used only to access EOF actions. */ 857 858 859 switch ( yy_act ) 860 { /* beginning of action switch */ 861 case 0: /* must back up */ 862 /* undo the effects of YY_DO_BEFORE_ACTION */ 863 *yy_cp = yy_hold_char; 864 yy_cp = yy_last_accepting_cpos; 865 yy_current_state = yy_last_accepting_state; 866 goto yy_find_action; 867 868case 1: 869YY_RULE_SETUP 870#line 107 "CMDscan.l" 871{ } 872 YY_BREAK 873case 2: 874YY_RULE_SETUP 875#line 108 "CMDscan.l" 876{ return(Sc_ScanDocBlock()); } 877 YY_BREAK 878case 3: 879YY_RULE_SETUP 880#line 109 "CMDscan.l" 881; 882 YY_BREAK 883case 4: 884YY_RULE_SETUP 885#line 110 "CMDscan.l" 886; 887 YY_BREAK 888case 5: 889YY_RULE_SETUP 890#line 111 "CMDscan.l" 891{lineIndex++;} 892 YY_BREAK 893case 6: 894YY_RULE_SETUP 895#line 112 "CMDscan.l" 896{ return(Sc_ScanString(STRATOM)); } 897 YY_BREAK 898case 7: 899YY_RULE_SETUP 900#line 113 "CMDscan.l" 901{ return(Sc_ScanString(TAGATOM)); } 902 YY_BREAK 903case 8: 904YY_RULE_SETUP 905#line 114 "CMDscan.l" 906{ CMDlval.i = MakeToken< int >( opEQ, lineIndex ); return opEQ; } 907 YY_BREAK 908case 9: 909YY_RULE_SETUP 910#line 115 "CMDscan.l" 911{ CMDlval.i = MakeToken< int >( opNE, lineIndex ); return opNE; } 912 YY_BREAK 913case 10: 914YY_RULE_SETUP 915#line 116 "CMDscan.l" 916{ CMDlval.i = MakeToken< int >( opGE, lineIndex ); return opGE; } 917 YY_BREAK 918case 11: 919YY_RULE_SETUP 920#line 117 "CMDscan.l" 921{ CMDlval.i = MakeToken< int >( opLE, lineIndex ); return opLE; } 922 YY_BREAK 923case 12: 924YY_RULE_SETUP 925#line 118 "CMDscan.l" 926{ CMDlval.i = MakeToken< int >( opAND, lineIndex ); return opAND; } 927 YY_BREAK 928case 13: 929YY_RULE_SETUP 930#line 119 "CMDscan.l" 931{ CMDlval.i = MakeToken< int >( opOR, lineIndex ); return opOR; } 932 YY_BREAK 933case 14: 934YY_RULE_SETUP 935#line 120 "CMDscan.l" 936{ CMDlval.i = MakeToken< int >( opCOLONCOLON, lineIndex ); return opCOLONCOLON; } 937 YY_BREAK 938case 15: 939YY_RULE_SETUP 940#line 121 "CMDscan.l" 941{ CMDlval.i = MakeToken< int >( opMINUSMINUS, lineIndex ); return opMINUSMINUS; } 942 YY_BREAK 943case 16: 944YY_RULE_SETUP 945#line 122 "CMDscan.l" 946{ CMDlval.i = MakeToken< int >( opPLUSPLUS, lineIndex ); return opPLUSPLUS; } 947 YY_BREAK 948case 17: 949YY_RULE_SETUP 950#line 123 "CMDscan.l" 951{ CMDlval.i = MakeToken< int >( opSTREQ, lineIndex ); return opSTREQ; } 952 YY_BREAK 953case 18: 954YY_RULE_SETUP 955#line 124 "CMDscan.l" 956{ CMDlval.i = MakeToken< int >( opSTRNE, lineIndex ); return opSTRNE; } 957 YY_BREAK 958case 19: 959YY_RULE_SETUP 960#line 125 "CMDscan.l" 961{ CMDlval.i = MakeToken< int >( opSHL, lineIndex ); return opSHL; } 962 YY_BREAK 963case 20: 964YY_RULE_SETUP 965#line 126 "CMDscan.l" 966{ CMDlval.i = MakeToken< int >( opSHR, lineIndex ); return opSHR; } 967 YY_BREAK 968case 21: 969YY_RULE_SETUP 970#line 127 "CMDscan.l" 971{ CMDlval.i = MakeToken< int >( opPLASN, lineIndex ); return opPLASN; } 972 YY_BREAK 973case 22: 974YY_RULE_SETUP 975#line 128 "CMDscan.l" 976{ CMDlval.i = MakeToken< int >( opMIASN, lineIndex ); return opMIASN; } 977 YY_BREAK 978case 23: 979YY_RULE_SETUP 980#line 129 "CMDscan.l" 981{ CMDlval.i = MakeToken< int >( opMLASN, lineIndex ); return opMLASN; } 982 YY_BREAK 983case 24: 984YY_RULE_SETUP 985#line 130 "CMDscan.l" 986{ CMDlval.i = MakeToken< int >( opDVASN, lineIndex ); return opDVASN; } 987 YY_BREAK 988case 25: 989YY_RULE_SETUP 990#line 131 "CMDscan.l" 991{ CMDlval.i = MakeToken< int >( opMODASN, lineIndex ); return opMODASN; } 992 YY_BREAK 993case 26: 994YY_RULE_SETUP 995#line 132 "CMDscan.l" 996{ CMDlval.i = MakeToken< int >( opANDASN, lineIndex ); return opANDASN; } 997 YY_BREAK 998case 27: 999YY_RULE_SETUP 1000#line 133 "CMDscan.l" 1001{ CMDlval.i = MakeToken< int >( opXORASN, lineIndex ); return opXORASN; } 1002 YY_BREAK 1003case 28: 1004YY_RULE_SETUP 1005#line 134 "CMDscan.l" 1006{ CMDlval.i = MakeToken< int >( opORASN, lineIndex ); return opORASN; } 1007 YY_BREAK 1008case 29: 1009YY_RULE_SETUP 1010#line 135 "CMDscan.l" 1011{ CMDlval.i = MakeToken< int >( opSLASN, lineIndex ); return opSLASN; } 1012 YY_BREAK 1013case 30: 1014YY_RULE_SETUP 1015#line 136 "CMDscan.l" 1016{ CMDlval.i = MakeToken< int >( opSRASN, lineIndex ); return opSRASN; } 1017 YY_BREAK 1018case 31: 1019YY_RULE_SETUP 1020#line 137 "CMDscan.l" 1021{ CMDlval.i = MakeToken< int >( opINTNAME, lineIndex ); return opINTNAME; } 1022 YY_BREAK 1023case 32: 1024YY_RULE_SETUP 1025#line 138 "CMDscan.l" 1026{ CMDlval.i = MakeToken< int >( opINTNAMER, lineIndex ); return opINTNAMER; } 1027 YY_BREAK 1028case 33: 1029YY_RULE_SETUP 1030#line 139 "CMDscan.l" 1031{ CMDlval.i = MakeToken< int >( '\n', lineIndex ); return '@'; } 1032 YY_BREAK 1033case 34: 1034YY_RULE_SETUP 1035#line 140 "CMDscan.l" 1036{ CMDlval.i = MakeToken< int >( '\t', lineIndex ); return '@'; } 1037 YY_BREAK 1038case 35: 1039YY_RULE_SETUP 1040#line 141 "CMDscan.l" 1041{ CMDlval.i = MakeToken< int >( ' ', lineIndex ); return '@'; } 1042 YY_BREAK 1043case 36: 1044YY_RULE_SETUP 1045#line 142 "CMDscan.l" 1046{ CMDlval.i = MakeToken< int >( 0, lineIndex ); return '@'; } 1047 YY_BREAK 1048case 37: 1049YY_RULE_SETUP 1050#line 143 "CMDscan.l" 1051{ /* this comment stops syntax highlighting from getting messed up when editing the lexer in TextPad */ 1052 register int c = 0, l; 1053 for ( ; ; ) 1054 { 1055 l = c; 1056 c = yyinput(); 1057 1058 // Is this an open comment? 1059 if ( c == EOF ) 1060 { 1061 CMDerror( "unexpected end of file found in comment" ); 1062 break; 1063 } 1064 1065 // Increment line numbers. 1066 else if ( c == '\n' ) 1067 lineIndex++; 1068 1069 // Did we find the end of the comment? 1070 else if ( l == '*' && c == '/' ) 1071 break; 1072 } 1073 } 1074 YY_BREAK 1075case 38: 1076#line 167 "CMDscan.l" 1077case 39: 1078#line 168 "CMDscan.l" 1079case 40: 1080#line 169 "CMDscan.l" 1081case 41: 1082#line 170 "CMDscan.l" 1083case 42: 1084#line 171 "CMDscan.l" 1085case 43: 1086#line 172 "CMDscan.l" 1087case 44: 1088#line 173 "CMDscan.l" 1089case 45: 1090#line 174 "CMDscan.l" 1091case 46: 1092#line 175 "CMDscan.l" 1093case 47: 1094#line 176 "CMDscan.l" 1095case 48: 1096#line 177 "CMDscan.l" 1097case 49: 1098#line 178 "CMDscan.l" 1099case 50: 1100#line 179 "CMDscan.l" 1101case 51: 1102#line 180 "CMDscan.l" 1103case 52: 1104#line 181 "CMDscan.l" 1105case 53: 1106#line 182 "CMDscan.l" 1107case 54: 1108#line 183 "CMDscan.l" 1109case 55: 1110#line 184 "CMDscan.l" 1111case 56: 1112#line 185 "CMDscan.l" 1113case 57: 1114#line 186 "CMDscan.l" 1115case 58: 1116#line 187 "CMDscan.l" 1117case 59: 1118#line 188 "CMDscan.l" 1119case 60: 1120#line 189 "CMDscan.l" 1121case 61: 1122YY_RULE_SETUP 1123#line 189 "CMDscan.l" 1124{ CMDlval.i = MakeToken< int >( CMDtext[ 0 ], lineIndex ); return CMDtext[ 0 ]; } 1125 YY_BREAK 1126case 62: 1127YY_RULE_SETUP 1128#line 190 "CMDscan.l" 1129{ CMDlval.i = MakeToken< int >( rwIN, lineIndex ); return(rwIN); } 1130 YY_BREAK 1131case 63: 1132YY_RULE_SETUP 1133#line 191 "CMDscan.l" 1134{ CMDlval.i = MakeToken< int >( rwCASEOR, lineIndex ); return(rwCASEOR); } 1135 YY_BREAK 1136case 64: 1137YY_RULE_SETUP 1138#line 192 "CMDscan.l" 1139{ CMDlval.i = MakeToken< int >( rwBREAK, lineIndex ); return(rwBREAK); } 1140 YY_BREAK 1141case 65: 1142YY_RULE_SETUP 1143#line 193 "CMDscan.l" 1144{ CMDlval.i = MakeToken< int >( rwRETURN, lineIndex ); return(rwRETURN); } 1145 YY_BREAK 1146case 66: 1147YY_RULE_SETUP 1148#line 194 "CMDscan.l" 1149{ CMDlval.i = MakeToken< int >( rwELSE, lineIndex ); return(rwELSE); } 1150 YY_BREAK 1151case 67: 1152YY_RULE_SETUP 1153#line 195 "CMDscan.l" 1154{ CMDlval.i = MakeToken< int >( rwASSERT, lineIndex ); return(rwASSERT); } 1155 YY_BREAK 1156case 68: 1157YY_RULE_SETUP 1158#line 196 "CMDscan.l" 1159{ CMDlval.i = MakeToken< int >( rwWHILE, lineIndex ); return(rwWHILE); } 1160 YY_BREAK 1161case 69: 1162YY_RULE_SETUP 1163#line 197 "CMDscan.l" 1164{ CMDlval.i = MakeToken< int >( rwDO, lineIndex ); return(rwDO); } 1165 YY_BREAK 1166case 70: 1167YY_RULE_SETUP 1168#line 198 "CMDscan.l" 1169{ CMDlval.i = MakeToken< int >( rwIF, lineIndex ); return(rwIF); } 1170 YY_BREAK 1171case 71: 1172YY_RULE_SETUP 1173#line 199 "CMDscan.l" 1174{ CMDlval.i = MakeToken< int >( rwFOREACHSTR, lineIndex ); return(rwFOREACHSTR); } 1175 YY_BREAK 1176case 72: 1177YY_RULE_SETUP 1178#line 200 "CMDscan.l" 1179{ CMDlval.i = MakeToken< int >( rwFOREACH, lineIndex ); return(rwFOREACH); } 1180 YY_BREAK 1181case 73: 1182YY_RULE_SETUP 1183#line 201 "CMDscan.l" 1184{ CMDlval.i = MakeToken< int >( rwFOR, lineIndex ); return(rwFOR); } 1185 YY_BREAK 1186case 74: 1187YY_RULE_SETUP 1188#line 202 "CMDscan.l" 1189{ CMDlval.i = MakeToken< int >( rwCONTINUE, lineIndex ); return(rwCONTINUE); } 1190 YY_BREAK 1191case 75: 1192YY_RULE_SETUP 1193#line 203 "CMDscan.l" 1194{ CMDlval.i = MakeToken< int >( rwDEFINE, lineIndex ); return(rwDEFINE); } 1195 YY_BREAK 1196case 76: 1197YY_RULE_SETUP 1198#line 204 "CMDscan.l" 1199{ CMDlval.i = MakeToken< int >( rwDECLARE, lineIndex ); return(rwDECLARE); } 1200 YY_BREAK 1201case 77: 1202YY_RULE_SETUP 1203#line 205 "CMDscan.l" 1204{ CMDlval.i = MakeToken< int >( rwDECLARESINGLETON, lineIndex ); return(rwDECLARESINGLETON); } 1205 YY_BREAK 1206case 78: 1207YY_RULE_SETUP 1208#line 206 "CMDscan.l" 1209{ CMDlval.i = MakeToken< int >( rwDATABLOCK, lineIndex ); return(rwDATABLOCK); } 1210 YY_BREAK 1211case 79: 1212YY_RULE_SETUP 1213#line 207 "CMDscan.l" 1214{ CMDlval.i = MakeToken< int >( rwCASE, lineIndex ); return(rwCASE); } 1215 YY_BREAK 1216case 80: 1217YY_RULE_SETUP 1218#line 208 "CMDscan.l" 1219{ CMDlval.i = MakeToken< int >( rwSWITCHSTR, lineIndex ); return(rwSWITCHSTR); } 1220 YY_BREAK 1221case 81: 1222YY_RULE_SETUP 1223#line 209 "CMDscan.l" 1224{ CMDlval.i = MakeToken< int >( rwSWITCH, lineIndex ); return(rwSWITCH); } 1225 YY_BREAK 1226case 82: 1227YY_RULE_SETUP 1228#line 210 "CMDscan.l" 1229{ CMDlval.i = MakeToken< int >( rwDEFAULT, lineIndex ); return(rwDEFAULT); } 1230 YY_BREAK 1231case 83: 1232YY_RULE_SETUP 1233#line 211 "CMDscan.l" 1234{ CMDlval.i = MakeToken< int >( rwPACKAGE, lineIndex ); return(rwPACKAGE); } 1235 YY_BREAK 1236case 84: 1237YY_RULE_SETUP 1238#line 212 "CMDscan.l" 1239{ CMDlval.i = MakeToken< int >( rwNAMESPACE, lineIndex ); return(rwNAMESPACE); } 1240 YY_BREAK 1241case 85: 1242YY_RULE_SETUP 1243#line 213 "CMDscan.l" 1244{ CMDlval.i = MakeToken< int >( 1, lineIndex ); return INTCONST; } 1245 YY_BREAK 1246case 86: 1247YY_RULE_SETUP 1248#line 214 "CMDscan.l" 1249{ CMDlval.i = MakeToken< int >( 0, lineIndex ); return INTCONST; } 1250 YY_BREAK 1251case 87: 1252YY_RULE_SETUP 1253#line 215 "CMDscan.l" 1254{ return(Sc_ScanVar()); } 1255 YY_BREAK 1256case 88: 1257YY_RULE_SETUP 1258#line 216 "CMDscan.l" 1259{ return Sc_ScanIdent(); } 1260 YY_BREAK 1261case 89: 1262YY_RULE_SETUP 1263#line 217 "CMDscan.l" 1264return(Sc_ScanHex()); 1265 YY_BREAK 1266case 90: 1267YY_RULE_SETUP 1268#line 218 "CMDscan.l" 1269{ CMDtext[CMDleng] = 0; CMDlval.i = MakeToken< int >( dAtoi(CMDtext), lineIndex ); return INTCONST; } 1270 YY_BREAK 1271case 91: 1272YY_RULE_SETUP 1273#line 219 "CMDscan.l" 1274return Sc_ScanNum(); 1275 YY_BREAK 1276case 92: 1277YY_RULE_SETUP 1278#line 220 "CMDscan.l" 1279return(ILLEGAL_TOKEN); 1280 YY_BREAK 1281case 93: 1282YY_RULE_SETUP 1283#line 221 "CMDscan.l" 1284return(ILLEGAL_TOKEN); 1285 YY_BREAK 1286case 94: 1287YY_RULE_SETUP 1288#line 222 "CMDscan.l" 1289ECHO; 1290 YY_BREAK 1291#line 1291 "CMDscan.cpp" 1292case YY_STATE_EOF(INITIAL): 1293 yyterminate(); 1294 1295 case YY_END_OF_BUFFER: 1296 { 1297 /* Amount of text matched not including the EOB char. */ 1298 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; 1299 1300 /* Undo the effects of YY_DO_BEFORE_ACTION. */ 1301 *yy_cp = yy_hold_char; 1302 1303 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) 1304 { 1305 /* We're scanning a new file or input source. It's 1306 * possible that this happened because the user 1307 * just pointed yyin at a new source and called 1308 * yylex(). If so, then we have to assure 1309 * consistency between yy_current_buffer and our 1310 * globals. Here is the right place to do so, because 1311 * this is the first action (other than possibly a 1312 * back-up) that will match for the new input source. 1313 */ 1314 yy_n_chars = yy_current_buffer->yy_n_chars; 1315 yy_current_buffer->yy_input_file = yyin; 1316 yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; 1317 } 1318 1319 /* Note that here we test for yy_c_buf_p "<=" to the position 1320 * of the first EOB in the buffer, since yy_c_buf_p will 1321 * already have been incremented past the NUL character 1322 * (since all states make transitions on EOB to the 1323 * end-of-buffer state). Contrast this with the test 1324 * in input(). 1325 */ 1326 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) 1327 { /* This was really a NUL. */ 1328 yy_state_type yy_next_state; 1329 1330 yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; 1331 1332 yy_current_state = yy_get_previous_state(); 1333 1334 /* Okay, we're now positioned to make the NUL 1335 * transition. We couldn't have 1336 * yy_get_previous_state() go ahead and do it 1337 * for us because it doesn't know how to deal 1338 * with the possibility of jamming (and we don't 1339 * want to build jamming into it because then it 1340 * will run more slowly). 1341 */ 1342 1343 yy_next_state = yy_try_NUL_trans( yy_current_state ); 1344 1345 yy_bp = yytext_ptr + YY_MORE_ADJ; 1346 1347 if ( yy_next_state ) 1348 { 1349 /* Consume the NUL. */ 1350 yy_cp = ++yy_c_buf_p; 1351 yy_current_state = yy_next_state; 1352 goto yy_match; 1353 } 1354 1355 else 1356 { 1357 yy_cp = yy_c_buf_p; 1358 goto yy_find_action; 1359 } 1360 } 1361 1362 else switch ( yy_get_next_buffer() ) 1363 { 1364 case EOB_ACT_END_OF_FILE: 1365 { 1366 yy_did_buffer_switch_on_eof = 0; 1367 1368 if ( yywrap() ) 1369 { 1370 /* Note: because we've taken care in 1371 * yy_get_next_buffer() to have set up 1372 * yytext, we can now set up 1373 * yy_c_buf_p so that if some total 1374 * hoser (like flex itself) wants to 1375 * call the scanner after we return the 1376 * YY_NULL, it'll still work - another 1377 * YY_NULL will get returned. 1378 */ 1379 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; 1380 1381 yy_act = YY_STATE_EOF(YY_START); 1382 goto do_action; 1383 } 1384 1385 else 1386 { 1387 if ( ! yy_did_buffer_switch_on_eof ) 1388 YY_NEW_FILE; 1389 } 1390 break; 1391 } 1392 1393 case EOB_ACT_CONTINUE_SCAN: 1394 yy_c_buf_p = 1395 yytext_ptr + yy_amount_of_matched_text; 1396 1397 yy_current_state = yy_get_previous_state(); 1398 1399 yy_cp = yy_c_buf_p; 1400 yy_bp = yytext_ptr + YY_MORE_ADJ; 1401 goto yy_match; 1402 1403 case EOB_ACT_LAST_MATCH: 1404 yy_c_buf_p = 1405 &yy_current_buffer->yy_ch_buf[yy_n_chars]; 1406 1407 yy_current_state = yy_get_previous_state(); 1408 1409 yy_cp = yy_c_buf_p; 1410 yy_bp = yytext_ptr + YY_MORE_ADJ; 1411 goto yy_find_action; 1412 } 1413 break; 1414 } 1415 1416 default: 1417 YY_FATAL_ERROR( 1418 "fatal flex scanner internal error--no action found" ); 1419 } /* end of action switch */ 1420 } /* end of scanning one token */ 1421 } /* end of yylex */ 1422 1423 1424/* yy_get_next_buffer - try to read in a new buffer 1425 * 1426 * Returns a code representing an action: 1427 * EOB_ACT_LAST_MATCH - 1428 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position 1429 * EOB_ACT_END_OF_FILE - end of file 1430 */ 1431 1432static int yy_get_next_buffer() 1433 { 1434 register char *dest = yy_current_buffer->yy_ch_buf; 1435 register char *source = yytext_ptr; 1436 register int number_to_move, i; 1437 int ret_val; 1438 1439 if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) 1440 YY_FATAL_ERROR( 1441 "fatal flex scanner internal error--end of buffer missed" ); 1442 1443 if ( yy_current_buffer->yy_fill_buffer == 0 ) 1444 { /* Don't try to fill the buffer, so this is an EOF. */ 1445 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) 1446 { 1447 /* We matched a singled characater, the EOB, so 1448 * treat this as a final EOF. 1449 */ 1450 return EOB_ACT_END_OF_FILE; 1451 } 1452 1453 else 1454 { 1455 /* We matched some text prior to the EOB, first 1456 * process it. 1457 */ 1458 return EOB_ACT_LAST_MATCH; 1459 } 1460 } 1461 1462 /* Try to read more data. */ 1463 1464 /* First move last chars to start of buffer. */ 1465 number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; 1466 1467 for ( i = 0; i < number_to_move; ++i ) 1468 *(dest++) = *(source++); 1469 1470 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) 1471 /* don't do the read, it's not guaranteed to return an EOF, 1472 * just force an EOF 1473 */ 1474 yy_n_chars = 0; 1475 1476 else 1477 { 1478 int num_to_read = 1479 yy_current_buffer->yy_buf_size - number_to_move - 1; 1480 1481 while ( num_to_read <= 0 ) 1482 { /* Not enough room in the buffer - grow it. */ 1483#ifdef YY_USES_REJECT 1484 YY_FATAL_ERROR( 1485"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); 1486#else 1487 1488 /* just a shorter name for the current buffer */ 1489 YY_BUFFER_STATE b = yy_current_buffer; 1490 1491 int yy_c_buf_p_offset = 1492 (int) (yy_c_buf_p - b->yy_ch_buf); 1493 1494 if ( b->yy_is_our_buffer ) 1495 { 1496 int new_size = b->yy_buf_size * 2; 1497 1498 if ( new_size <= 0 ) 1499 b->yy_buf_size += b->yy_buf_size / 8; 1500 else 1501 b->yy_buf_size *= 2; 1502 1503 b->yy_ch_buf = (char *) 1504 /* Include room in for 2 EOB chars. */ 1505 yy_flex_realloc( (void *) b->yy_ch_buf, 1506 b->yy_buf_size + 2 ); 1507 } 1508 else 1509 /* Can't grow it, we don't own it. */ 1510 b->yy_ch_buf = 0; 1511 1512 if ( ! b->yy_ch_buf ) 1513 YY_FATAL_ERROR( 1514 "fatal error - scanner input buffer overflow" ); 1515 1516 yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; 1517 1518 num_to_read = yy_current_buffer->yy_buf_size - 1519 number_to_move - 1; 1520#endif 1521 } 1522 1523 if ( num_to_read > YY_READ_BUF_SIZE ) 1524 num_to_read = YY_READ_BUF_SIZE; 1525 1526 /* Read in more data. */ 1527 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), 1528 yy_n_chars, num_to_read ); 1529 } 1530 1531 if ( yy_n_chars == 0 ) 1532 { 1533 if ( number_to_move == YY_MORE_ADJ ) 1534 { 1535 ret_val = EOB_ACT_END_OF_FILE; 1536 yyrestart( yyin ); 1537 } 1538 1539 else 1540 { 1541 ret_val = EOB_ACT_LAST_MATCH; 1542 yy_current_buffer->yy_buffer_status = 1543 YY_BUFFER_EOF_PENDING; 1544 } 1545 } 1546 1547 else 1548 ret_val = EOB_ACT_CONTINUE_SCAN; 1549 1550 yy_n_chars += number_to_move; 1551 yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; 1552 yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; 1553 1554 yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; 1555 1556 return ret_val; 1557 } 1558 1559 1560/* yy_get_previous_state - get the state just before the EOB char was reached */ 1561 1562static yy_state_type yy_get_previous_state() 1563 { 1564 register yy_state_type yy_current_state; 1565 register char *yy_cp; 1566 1567 yy_current_state = yy_start; 1568 1569 for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) 1570 { 1571 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); 1572 if ( yy_accept[yy_current_state] ) 1573 { 1574 yy_last_accepting_state = yy_current_state; 1575 yy_last_accepting_cpos = yy_cp; 1576 } 1577 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1578 { 1579 yy_current_state = (int) yy_def[yy_current_state]; 1580 if ( yy_current_state >= 224 ) 1581 yy_c = yy_meta[(unsigned int) yy_c]; 1582 } 1583 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1584 } 1585 1586 return yy_current_state; 1587 } 1588 1589 1590/* yy_try_NUL_trans - try to make a transition on the NUL character 1591 * 1592 * synopsis 1593 * next_state = yy_try_NUL_trans( current_state ); 1594 */ 1595 1596#ifdef YY_USE_PROTOS 1597static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) 1598#else 1599static yy_state_type yy_try_NUL_trans( yy_current_state ) 1600yy_state_type yy_current_state; 1601#endif 1602 { 1603 register int yy_is_jam; 1604 register char *yy_cp = yy_c_buf_p; 1605 1606 register YY_CHAR yy_c = 1; 1607 if ( yy_accept[yy_current_state] ) 1608 { 1609 yy_last_accepting_state = yy_current_state; 1610 yy_last_accepting_cpos = yy_cp; 1611 } 1612 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1613 { 1614 yy_current_state = (int) yy_def[yy_current_state]; 1615 if ( yy_current_state >= 224 ) 1616 yy_c = yy_meta[(unsigned int) yy_c]; 1617 } 1618 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1619 yy_is_jam = (yy_current_state == 223); 1620 1621 return yy_is_jam ? 0 : yy_current_state; 1622 } 1623 1624 1625#ifndef YY_NO_UNPUT 1626#ifdef YY_USE_PROTOS 1627static void yyunput( int c, register char *yy_bp ) 1628#else 1629static void yyunput( c, yy_bp ) 1630int c; 1631register char *yy_bp; 1632#endif 1633 { 1634 register char *yy_cp = yy_c_buf_p; 1635 1636 /* undo effects of setting up yytext */ 1637 *yy_cp = yy_hold_char; 1638 1639 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) 1640 { /* need to shift things up to make room */ 1641 /* +2 for EOB chars. */ 1642 register int number_to_move = yy_n_chars + 2; 1643 register char *dest = &yy_current_buffer->yy_ch_buf[ 1644 yy_current_buffer->yy_buf_size + 2]; 1645 register char *source = 1646 &yy_current_buffer->yy_ch_buf[number_to_move]; 1647 1648 while ( source > yy_current_buffer->yy_ch_buf ) 1649 *--dest = *--source; 1650 1651 yy_cp += (int) (dest - source); 1652 yy_bp += (int) (dest - source); 1653 yy_n_chars = yy_current_buffer->yy_buf_size; 1654 1655 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) 1656 YY_FATAL_ERROR( "flex scanner push-back overflow" ); 1657 } 1658 1659 *--yy_cp = (char) c; 1660 1661 1662 yytext_ptr = yy_bp; 1663 yy_hold_char = *yy_cp; 1664 yy_c_buf_p = yy_cp; 1665 } 1666#endif /* ifndef YY_NO_UNPUT */ 1667 1668 1669#ifdef __cplusplus 1670static int yyinput() 1671#else 1672static int input() 1673#endif 1674 { 1675 int c; 1676 1677 *yy_c_buf_p = yy_hold_char; 1678 1679 if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) 1680 { 1681 /* yy_c_buf_p now points to the character we want to return. 1682 * If this occurs *before* the EOB characters, then it's a 1683 * valid NUL; if not, then we've hit the end of the buffer. 1684 */ 1685 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) 1686 /* This was really a NUL. */ 1687 *yy_c_buf_p = '\0'; 1688 1689 else 1690 { /* need more input */ 1691 yytext_ptr = yy_c_buf_p; 1692 ++yy_c_buf_p; 1693 1694 switch ( yy_get_next_buffer() ) 1695 { 1696 case EOB_ACT_END_OF_FILE: 1697 { 1698 if ( yywrap() ) 1699 { 1700 yy_c_buf_p = 1701 yytext_ptr + YY_MORE_ADJ; 1702 return EOF; 1703 } 1704 1705 if ( ! yy_did_buffer_switch_on_eof ) 1706 YY_NEW_FILE; 1707#ifdef __cplusplus 1708 return yyinput(); 1709#else 1710 return input(); 1711#endif 1712 } 1713 1714 case EOB_ACT_CONTINUE_SCAN: 1715 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; 1716 break; 1717 1718 case EOB_ACT_LAST_MATCH: 1719#ifdef __cplusplus 1720 YY_FATAL_ERROR( 1721 "unexpected last match in yyinput()" ); 1722#else 1723 YY_FATAL_ERROR( 1724 "unexpected last match in input()" ); 1725#endif 1726 } 1727 } 1728 } 1729 1730 c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ 1731 *yy_c_buf_p = '\0'; /* preserve yytext */ 1732 yy_hold_char = *++yy_c_buf_p; 1733 1734 1735 return c; 1736 } 1737 1738 1739#ifdef YY_USE_PROTOS 1740void yyrestart( FILE *input_file ) 1741#else 1742void yyrestart( input_file ) 1743FILE *input_file; 1744#endif 1745 { 1746 if ( ! yy_current_buffer ) 1747 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); 1748 1749 yy_init_buffer( yy_current_buffer, input_file ); 1750 yy_load_buffer_state(); 1751 } 1752 1753 1754#ifdef YY_USE_PROTOS 1755void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) 1756#else 1757void yy_switch_to_buffer( new_buffer ) 1758YY_BUFFER_STATE new_buffer; 1759#endif 1760 { 1761 if ( yy_current_buffer == new_buffer ) 1762 return; 1763 1764 if ( yy_current_buffer ) 1765 { 1766 /* Flush out information for old buffer. */ 1767 *yy_c_buf_p = yy_hold_char; 1768 yy_current_buffer->yy_buf_pos = yy_c_buf_p; 1769 yy_current_buffer->yy_n_chars = yy_n_chars; 1770 } 1771 1772 yy_current_buffer = new_buffer; 1773 yy_load_buffer_state(); 1774 1775 /* We don't actually know whether we did this switch during 1776 * EOF (yywrap()) processing, but the only time this flag 1777 * is looked at is after yywrap() is called, so it's safe 1778 * to go ahead and always set it. 1779 */ 1780 yy_did_buffer_switch_on_eof = 1; 1781 } 1782 1783 1784#ifdef YY_USE_PROTOS 1785void yy_load_buffer_state( void ) 1786#else 1787void yy_load_buffer_state() 1788#endif 1789 { 1790 yy_n_chars = yy_current_buffer->yy_n_chars; 1791 yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; 1792 yyin = yy_current_buffer->yy_input_file; 1793 yy_hold_char = *yy_c_buf_p; 1794 } 1795 1796 1797#ifdef YY_USE_PROTOS 1798YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) 1799#else 1800YY_BUFFER_STATE yy_create_buffer( file, size ) 1801FILE *file; 1802int size; 1803#endif 1804 { 1805 YY_BUFFER_STATE b; 1806 1807 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); 1808 if ( ! b ) 1809 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 1810 1811 b->yy_buf_size = size; 1812 1813 /* yy_ch_buf has to be 2 characters longer than the size given because 1814 * we need to put in 2 end-of-buffer characters. 1815 */ 1816 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); 1817 if ( ! b->yy_ch_buf ) 1818 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 1819 1820 b->yy_is_our_buffer = 1; 1821 1822 yy_init_buffer( b, file ); 1823 1824 return b; 1825 } 1826 1827 1828#ifdef YY_USE_PROTOS 1829void yy_delete_buffer( YY_BUFFER_STATE b ) 1830#else 1831void yy_delete_buffer( b ) 1832YY_BUFFER_STATE b; 1833#endif 1834 { 1835 if ( ! b ) 1836 return; 1837 1838 if ( b == yy_current_buffer ) 1839 yy_current_buffer = (YY_BUFFER_STATE) 0; 1840 1841 if ( b->yy_is_our_buffer ) 1842 yy_flex_free( (void *) b->yy_ch_buf ); 1843 1844 yy_flex_free( (void *) b ); 1845 } 1846 1847 1848#ifndef YY_ALWAYS_INTERACTIVE 1849#ifndef YY_NEVER_INTERACTIVE 1850extern int isatty YY_PROTO(( int )); 1851#endif 1852#endif 1853 1854#ifdef YY_USE_PROTOS 1855void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) 1856#else 1857void yy_init_buffer( b, file ) 1858YY_BUFFER_STATE b; 1859FILE *file; 1860#endif 1861 1862 1863 { 1864 yy_flush_buffer( b ); 1865 1866 b->yy_input_file = file; 1867 b->yy_fill_buffer = 1; 1868 1869#if YY_ALWAYS_INTERACTIVE 1870 b->yy_is_interactive = 1; 1871#else 1872#if YY_NEVER_INTERACTIVE 1873 b->yy_is_interactive = 0; 1874#else 1875 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; 1876#endif 1877#endif 1878 } 1879 1880 1881#ifdef YY_USE_PROTOS 1882void yy_flush_buffer( YY_BUFFER_STATE b ) 1883#else 1884void yy_flush_buffer( b ) 1885YY_BUFFER_STATE b; 1886#endif 1887 1888 { 1889 b->yy_n_chars = 0; 1890 1891 /* We always need two end-of-buffer characters. The first causes 1892 * a transition to the end-of-buffer state. The second causes 1893 * a jam in that state. 1894 */ 1895 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; 1896 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; 1897 1898 b->yy_buf_pos = &b->yy_ch_buf[0]; 1899 1900 b->yy_at_bol = 1; 1901 b->yy_buffer_status = YY_BUFFER_NEW; 1902 1903 if ( b == yy_current_buffer ) 1904 yy_load_buffer_state(); 1905 } 1906 1907 1908#ifndef YY_NO_SCAN_BUFFER 1909#ifdef YY_USE_PROTOS 1910YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) 1911#else 1912YY_BUFFER_STATE yy_scan_buffer( base, size ) 1913char *base; 1914yy_size_t size; 1915#endif 1916 { 1917 YY_BUFFER_STATE b; 1918 1919 if ( size < 2 || 1920 base[size-2] != YY_END_OF_BUFFER_CHAR || 1921 base[size-1] != YY_END_OF_BUFFER_CHAR ) 1922 /* They forgot to leave room for the EOB's. */ 1923 return 0; 1924 1925 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); 1926 if ( ! b ) 1927 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); 1928 1929 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ 1930 b->yy_buf_pos = b->yy_ch_buf = base; 1931 b->yy_is_our_buffer = 0; 1932 b->yy_input_file = 0; 1933 b->yy_n_chars = b->yy_buf_size; 1934 b->yy_is_interactive = 0; 1935 b->yy_at_bol = 1; 1936 b->yy_fill_buffer = 0; 1937 b->yy_buffer_status = YY_BUFFER_NEW; 1938 1939 yy_switch_to_buffer( b ); 1940 1941 return b; 1942 } 1943#endif 1944 1945 1946#ifndef YY_NO_SCAN_STRING 1947#ifdef YY_USE_PROTOS 1948YY_BUFFER_STATE yy_scan_string( yyconst char *str ) 1949#else 1950YY_BUFFER_STATE yy_scan_string( str ) 1951yyconst char *str; 1952#endif 1953 { 1954 int len; 1955 for ( len = 0; str[len]; ++len ) 1956 ; 1957 1958 return yy_scan_bytes( str, len ); 1959 } 1960#endif 1961 1962 1963#ifndef YY_NO_SCAN_BYTES 1964#ifdef YY_USE_PROTOS 1965YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) 1966#else 1967YY_BUFFER_STATE yy_scan_bytes( bytes, len ) 1968yyconst char *bytes; 1969int len; 1970#endif 1971 { 1972 YY_BUFFER_STATE b; 1973 char *buf; 1974 yy_size_t n; 1975 int i; 1976 1977 /* Get memory for full buffer, including space for trailing EOB's. */ 1978 n = len + 2; 1979 buf = (char *) yy_flex_alloc( n ); 1980 if ( ! buf ) 1981 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); 1982 1983 for ( i = 0; i < len; ++i ) 1984 buf[i] = bytes[i]; 1985 1986 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; 1987 1988 b = yy_scan_buffer( buf, n ); 1989 if ( ! b ) 1990 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); 1991 1992 /* It's okay to grow etc. this buffer, and we should throw it 1993 * away when we're done. 1994 */ 1995 b->yy_is_our_buffer = 1; 1996 1997 return b; 1998 } 1999#endif 2000 2001 2002#ifndef YY_NO_PUSH_STATE 2003#ifdef YY_USE_PROTOS 2004static void yy_push_state( int new_state ) 2005#else 2006static void yy_push_state( new_state ) 2007int new_state; 2008#endif 2009 { 2010 if ( yy_start_stack_ptr >= yy_start_stack_depth ) 2011 { 2012 yy_size_t new_size; 2013 2014 yy_start_stack_depth += YY_START_STACK_INCR; 2015 new_size = yy_start_stack_depth * sizeof( int ); 2016 2017 if ( ! yy_start_stack ) 2018 yy_start_stack = (int *) yy_flex_alloc( new_size ); 2019 2020 else 2021 yy_start_stack = (int *) yy_flex_realloc( 2022 (void *) yy_start_stack, new_size ); 2023 2024 if ( ! yy_start_stack ) 2025 YY_FATAL_ERROR( 2026 "out of memory expanding start-condition stack" ); 2027 } 2028 2029 yy_start_stack[yy_start_stack_ptr++] = YY_START; 2030 2031 BEGIN(new_state); 2032 } 2033#endif 2034 2035 2036#ifndef YY_NO_POP_STATE 2037static void yy_pop_state() 2038 { 2039 if ( --yy_start_stack_ptr < 0 ) 2040 YY_FATAL_ERROR( "start-condition stack underflow" ); 2041 2042 BEGIN(yy_start_stack[yy_start_stack_ptr]); 2043 } 2044#endif 2045 2046 2047#ifndef YY_NO_TOP_STATE 2048static int yy_top_state() 2049 { 2050 return yy_start_stack[yy_start_stack_ptr - 1]; 2051 } 2052#endif 2053 2054#ifndef YY_EXIT_FAILURE 2055#define YY_EXIT_FAILURE 2 2056#endif 2057 2058#ifdef YY_USE_PROTOS 2059static void yy_fatal_error( yyconst char msg[] ) 2060#else 2061static void yy_fatal_error( msg ) 2062char msg[]; 2063#endif 2064 { 2065 (void) fprintf( stderr, "%s\n", msg ); 2066 exit( YY_EXIT_FAILURE ); 2067 } 2068 2069 2070 2071/* Redefine yyless() so it works in section 3 code. */ 2072 2073#undef yyless 2074#define yyless(n) \ 2075 do \ 2076 { \ 2077 /* Undo effects of setting up yytext. */ \ 2078 yytext[yyleng] = yy_hold_char; \ 2079 yy_c_buf_p = yytext + n - YY_MORE_ADJ; \ 2080 yy_hold_char = *yy_c_buf_p; \ 2081 *yy_c_buf_p = '\0'; \ 2082 yyleng = n; \ 2083 } \ 2084 while ( 0 ) 2085 2086 2087/* Internal utility routines. */ 2088 2089#ifndef yytext_ptr 2090#ifdef YY_USE_PROTOS 2091static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) 2092#else 2093static void yy_flex_strncpy( s1, s2, n ) 2094char *s1; 2095yyconst char *s2; 2096int n; 2097#endif 2098 { 2099 register int i; 2100 for ( i = 0; i < n; ++i ) 2101 s1[i] = s2[i]; 2102 } 2103#endif 2104 2105 2106#ifdef YY_USE_PROTOS 2107static void *yy_flex_alloc( yy_size_t size ) 2108#else 2109static void *yy_flex_alloc( size ) 2110yy_size_t size; 2111#endif 2112 { 2113 return (void *) malloc( size ); 2114 } 2115 2116#ifdef YY_USE_PROTOS 2117static void *yy_flex_realloc( void *ptr, yy_size_t size ) 2118#else 2119static void *yy_flex_realloc( ptr, size ) 2120void *ptr; 2121yy_size_t size; 2122#endif 2123 { 2124 /* The cast to (char *) in the following accommodates both 2125 * implementations that use char* generic pointers, and those 2126 * that use void* generic pointers. It works with the latter 2127 * because both ANSI C and C++ allow castless assignment from 2128 * any pointer type to void*, and deal with argument conversions 2129 * as though doing an assignment. 2130 */ 2131 return (void *) realloc( (char *) ptr, size ); 2132 } 2133 2134#ifdef YY_USE_PROTOS 2135static void yy_flex_free( void *ptr ) 2136#else 2137static void yy_flex_free( ptr ) 2138void *ptr; 2139#endif 2140 { 2141 free( ptr ); 2142 } 2143 2144#if YY_MAIN 2145int main() 2146 { 2147 yylex(); 2148 return 0; 2149 } 2150#endif 2151#line 222 "CMDscan.l" 2152 2153 2154static const char *scanBuffer; 2155static const char *fileName; 2156static int scanIndex; 2157 2158const char * CMDGetCurrentFile() 2159{ 2160 return fileName; 2161} 2162 2163int CMDGetCurrentLine() 2164{ 2165 return lineIndex; 2166} 2167 2168extern bool gConsoleSyntaxError; 2169 2170void CMDerror(char *format, ...) 2171{ 2172 Compiler::gSyntaxError = true; 2173 2174 const int BUFMAX = 1024; 2175 char tempBuf[BUFMAX]; 2176 va_list args; 2177 va_start( args, format ); 2178#ifdef TORQUE_OS_WIN 2179 _vsnprintf( tempBuf, BUFMAX, format, args ); 2180#else 2181 vsnprintf( tempBuf, BUFMAX, format, args ); 2182#endif 2183 va_end(args); 2184 2185 if(fileName) 2186 { 2187 Con::errorf(ConsoleLogEntry::Script, "%s Line: %d - %s", fileName, lineIndex, tempBuf); 2188 2189#ifndef NO_ADVANCED_ERROR_REPORT 2190 // dhc - lineIndex is bogus. let's try to add some sanity back in. 2191 int i,j,n; 2192 char c; 2193 int linediv = 1; 2194 // first, walk the buffer, trying to detect line ending type. 2195 // this is imperfect, if inconsistant line endings exist... 2196 for (i=0; i<scanIndex; i++) 2197 { 2198 c = scanBuffer[i]; 2199 if (c=='\r' && scanBuffer[i+1]=='\n') linediv = 2; // crlf detected 2200 if (c=='\r' || c=='\n' || c==0) break; // enough for us to stop. 2201 } 2202 // grab some of the chars starting at the error location - lineending. 2203 i = 1; j = 0; n = 1; 2204 // find prev lineending 2205 while (n<BUFMAX-8 && i<scanIndex) // cap at file start 2206 { 2207 c = scanBuffer[scanIndex-i]; 2208 if ((c=='\r' || c=='\n') && i>BUFMAX>>2) break; // at least get a little data 2209 n++; i++; 2210 } 2211 // find next lineending 2212 while (n<BUFMAX-8 && j<BUFMAX>>1) // cap at half-buf-size forward 2213 { 2214 c = scanBuffer[scanIndex+j]; 2215 if (c==0) break; 2216 if ((c=='\r' || c=='\n') && j>BUFMAX>>2) break; // at least get a little data 2217 n++; j++; 2218 } 2219 if (i) i--; // chop off extra linefeed. 2220 if (j) j--; // chop off extra linefeed. 2221 // build our little text block 2222 if (i) dStrncpy(tempBuf,scanBuffer+scanIndex-i,i); 2223 dStrncpy(tempBuf+i,"##", 2); // bracketing. 2224 tempBuf[i+2] = scanBuffer[scanIndex]; // copy the halt character. 2225 dStrncpy(tempBuf+i+3,"##", 2); // bracketing. 2226 if (j) dStrncpy(tempBuf+i+5,scanBuffer+scanIndex+1,j); // +1 to go past current char. 2227 tempBuf[i+j+5] = 0; // null terminate 2228 for(n=0; n<i+j+5; n++) // convert CR to LF if alone... 2229 if (tempBuf[n]=='\r' && tempBuf[n+1]!='\n') tempBuf[n] = '\n'; 2230 // write out to console the advanced error report 2231 Con::warnf(ConsoleLogEntry::Script, ">>> Advanced script error report. Line %d.", lineIndex); 2232 Con::warnf(ConsoleLogEntry::Script, ">>> Some error context, with ## on sides of error halt:"); 2233 Con::errorf(ConsoleLogEntry::Script, "%s", tempBuf); 2234 Con::warnf(ConsoleLogEntry::Script, ">>> Error report complete.\n"); 2235#endif 2236 2237 // Update the script-visible error buffer. 2238 const char *prevStr = Con::getVariable("$ScriptError"); 2239 if (prevStr[0]) 2240 dSprintf(tempBuf, sizeof(tempBuf), "%s\n%s Line: %d - Syntax error.", prevStr, fileName, lineIndex); 2241 else 2242 dSprintf(tempBuf, sizeof(tempBuf), "%s Line: %d - Syntax error.", fileName, lineIndex); 2243 Con::setVariable("$ScriptError", tempBuf); 2244 2245 // We also need to mark that we came up with a new error. 2246 static S32 sScriptErrorHash=1000; 2247 Con::setIntVariable("$ScriptErrorHash", sScriptErrorHash++); 2248 } 2249 else 2250 Con::errorf(ConsoleLogEntry::Script, tempBuf); 2251} 2252 2253void CMDSetScanBuffer(const char *sb, const char *fn) 2254{ 2255 scanBuffer = sb; 2256 fileName = fn; 2257 scanIndex = 0; 2258 lineIndex = 1; 2259} 2260 2261int CMDgetc() 2262{ 2263 int ret = scanBuffer[scanIndex]; 2264 if(ret) 2265 scanIndex++; 2266 else 2267 ret = -1; 2268 return ret; 2269} 2270 2271int CMDwrap() 2272{ 2273 return 1; 2274} 2275 2276static int Sc_ScanVar() 2277{ 2278 // Truncate the temp buffer... 2279 CMDtext[CMDleng] = 0; 2280 2281 // Make it a stringtable string! 2282 CMDlval.s = MakeToken< StringTableEntry >( StringTable->insert(CMDtext), lineIndex ); 2283 return(VAR); 2284} 2285 2286static int charConv(int in) 2287{ 2288 switch(in) 2289 { 2290 case 'r': 2291 return '\r'; 2292 case 'n': 2293 return '\n'; 2294 case 't': 2295 return '\t'; 2296 default: 2297 return in; 2298 } 2299} 2300 2301static int getHexDigit(char c) 2302{ 2303 if(c >= '0' && c <= '9') 2304 return c - '0'; 2305 if(c >= 'A' && c <= 'F') 2306 return c - 'A' + 10; 2307 if(c >= 'a' && c <= 'f') 2308 return c - 'a' + 10; 2309 return -1; 2310} 2311 2312static int Sc_ScanDocBlock() 2313{ 2314 S32 len = dStrlen(CMDtext); 2315 char* text = (char *) consoleAlloc(len + 1); 2316 S32 line = lineIndex; 2317 2318 for( S32 i = 0, j = 0; j <= len; j++ ) 2319 { 2320 if( ( j <= (len - 2) ) && ( CMDtext[j] == '/' ) && ( CMDtext[j + 1] == '/' ) && ( CMDtext[j + 2] == '/' ) ) 2321 { 2322 j += 2; 2323 continue; 2324 } 2325 2326 if( CMDtext[j] == '\r' ) 2327 continue; 2328 2329 if( CMDtext[j] == '\n' ) 2330 lineIndex++; 2331 2332 text[i++] = CMDtext[j]; 2333 } 2334 2335 CMDlval.str = MakeToken< char* >( text, line ); 2336 return(DOCBLOCK); 2337} 2338 2339static int Sc_ScanString(int ret) 2340{ 2341 CMDtext[CMDleng - 1] = 0; 2342 if(!collapseEscape(CMDtext+1)) 2343 return -1; 2344 2345 char* buffer = ( char* ) consoleAlloc( dStrlen( CMDtext ) ); 2346 dStrcpy( buffer, CMDtext + 1 ); 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
