2007-11-04 03:34:51 +00:00
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
|
|
|
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
This file is part of GtkRadiant.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
GtkRadiant is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
GtkRadiant is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GtkRadiant; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
//**************************************************************************
|
|
|
|
//**
|
|
|
|
//** token.c
|
|
|
|
//**
|
|
|
|
//**************************************************************************
|
|
|
|
|
|
|
|
// HEADER FILES ------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "token.h"
|
|
|
|
#include "inout.h"
|
|
|
|
|
|
|
|
// MACROS ------------------------------------------------------------------
|
|
|
|
|
|
|
|
// TYPES -------------------------------------------------------------------
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
CHR_EOF,
|
|
|
|
CHR_LETTER,
|
|
|
|
CHR_NUMBER,
|
|
|
|
CHR_QUOTE,
|
|
|
|
CHR_SPECIAL
|
|
|
|
} chr_t;
|
|
|
|
|
|
|
|
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
|
|
|
|
|
|
|
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
|
|
|
|
|
|
|
|
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
static void ProcessLetterToken( void );
|
|
|
|
static void ProcessNumberToken( void );
|
|
|
|
static void ProcessQuoteToken( void );
|
|
|
|
static void ProcessSpecialToken( void );
|
|
|
|
static qboolean CheckForKeyword( void );
|
|
|
|
static void NextChr( void );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
|
|
|
|
|
|
|
|
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
|
|
|
|
|
|
|
tokenType_t tk_Token;
|
|
|
|
int tk_Line;
|
|
|
|
int tk_IntNumber;
|
|
|
|
float tk_FloatNumber;
|
|
|
|
char *tk_String;
|
|
|
|
char tk_SourceName[MAX_FILE_NAME_LENGTH];
|
|
|
|
|
|
|
|
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
|
|
|
|
|
|
|
static char Chr;
|
|
|
|
static char *FileStart;
|
|
|
|
static char *FilePtr;
|
|
|
|
static char *FileEnd;
|
|
|
|
static qboolean SourceOpen;
|
|
|
|
static char ASCIIToChrCode[256];
|
|
|
|
static char TokenStringBuffer[MAX_QUOTED_LENGTH];
|
|
|
|
static qboolean IncLineNumber;
|
|
|
|
static char TempBuffer[2048];
|
|
|
|
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
tokenType_t token;
|
|
|
|
} Keywords[] =
|
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
"model", TK_MODEL,
|
|
|
|
"mesh", TK_MESH,
|
|
|
|
"vertices", TK_VERTICES,
|
|
|
|
"edges", TK_EDGES,
|
|
|
|
"position", TK_POSITION,
|
|
|
|
"polygons", TK_POLYGONS,
|
|
|
|
"nodes", TK_NODES,
|
|
|
|
"rotation", TK_ROTATION,
|
|
|
|
"scaling", TK_SCALING,
|
|
|
|
"translation", TK_TRANSLATION,
|
|
|
|
"vertex", TK_VERTEX,
|
|
|
|
"HRCH", TK_HRCH,
|
|
|
|
"Softimage", TK_SOFTIMAGE,
|
|
|
|
"material", TK_MATERIAL,
|
|
|
|
"spline", TK_SPLINE,
|
|
|
|
|
|
|
|
"Named", TK_C_NAMED,
|
|
|
|
"object", TK_OBJECT,
|
|
|
|
"Tri", TK_C_TRI,
|
|
|
|
"Vertices", TK_C_VERTICES,
|
|
|
|
"Faces", TK_C_FACES,
|
|
|
|
"Vertex", TK_C_VERTEX,
|
|
|
|
"list", TK_LIST,
|
|
|
|
"Face", TK_C_FACE,
|
|
|
|
|
|
|
|
"Hexen", TK_C_HEXEN,
|
|
|
|
"Triangles", TK_C_TRIANGLES,
|
|
|
|
"Version", TK_C_VERSION,
|
|
|
|
"faces", TK_FACES,
|
|
|
|
"face", TK_FACE,
|
|
|
|
"origin", TK_ORIGIN,
|
|
|
|
|
|
|
|
"DK_clusters", TK_CLUSTERS,
|
|
|
|
"DK_cluster_ncvs", TK_NUM_CLUSTER_VERTICES,
|
|
|
|
"name", TK_NAME,
|
|
|
|
"DK_cluster_name", TK_CLUSTER_NAME,
|
|
|
|
"DK_cluster_state", TK_CLUSTER_STATE,
|
|
|
|
|
|
|
|
"actor_data", TK_ACTOR_DATA,
|
|
|
|
"uvTexture", TK_UVTEXTURE,
|
|
|
|
|
|
|
|
NULL, -1
|
2007-11-04 03:34:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static char *TokenNames[] =
|
|
|
|
{
|
|
|
|
"<nothing>",
|
|
|
|
"<unknown_char>",
|
|
|
|
"<EOF>",
|
|
|
|
"<identifier>",
|
|
|
|
"<string>",
|
|
|
|
"<int_number>",
|
|
|
|
"<float_number>",
|
|
|
|
"(",
|
|
|
|
")",
|
|
|
|
"{",
|
|
|
|
"}",
|
|
|
|
"[",
|
|
|
|
"]",
|
|
|
|
":",
|
|
|
|
"mesh",
|
|
|
|
"model",
|
|
|
|
"nodes",
|
|
|
|
"rotation",
|
|
|
|
"scaling",
|
|
|
|
"translation",
|
|
|
|
"polygons",
|
|
|
|
"position",
|
|
|
|
"vertex",
|
|
|
|
"vertices",
|
|
|
|
"HRCH",
|
|
|
|
"Softimage"
|
|
|
|
};
|
|
|
|
|
|
|
|
// CODE --------------------------------------------------------------------
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// TK_Init
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void TK_Init( void ){
|
2007-11-04 03:34:51 +00:00
|
|
|
int i;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < 256; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
ASCIIToChrCode[i] = CHR_SPECIAL;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = '0'; i <= '9'; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
ASCIIToChrCode[i] = CHR_NUMBER;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 'A'; i <= 'Z'; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
ASCIIToChrCode[i] = CHR_LETTER;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 'a'; i <= 'z'; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
ASCIIToChrCode[i] = CHR_LETTER;
|
|
|
|
}
|
|
|
|
ASCIIToChrCode[ASCII_QUOTE] = CHR_QUOTE;
|
|
|
|
ASCIIToChrCode[ASCII_UNDERSCORE] = CHR_LETTER;
|
|
|
|
ASCIIToChrCode[EOF_CHARACTER] = CHR_EOF;
|
|
|
|
tk_String = TokenStringBuffer;
|
|
|
|
IncLineNumber = FALSE;
|
|
|
|
SourceOpen = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// TK_OpenSource
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void TK_OpenSource( char *fileName ){
|
2007-11-04 03:34:51 +00:00
|
|
|
int size;
|
|
|
|
|
|
|
|
TK_CloseSource();
|
2012-03-17 20:01:54 +00:00
|
|
|
size = LoadFile( fileName, (void **)&FileStart );
|
|
|
|
strcpy( tk_SourceName, fileName );
|
2007-11-04 03:34:51 +00:00
|
|
|
SourceOpen = TRUE;
|
2012-03-17 20:01:54 +00:00
|
|
|
FileEnd = FileStart + size;
|
2007-11-04 03:34:51 +00:00
|
|
|
FilePtr = FileStart;
|
|
|
|
tk_Line = 1;
|
|
|
|
tk_Token = TK_NONE;
|
|
|
|
NextChr();
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// TK_CloseSource
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void TK_CloseSource( void ){
|
|
|
|
if ( SourceOpen ) {
|
|
|
|
free( FileStart );
|
2007-11-04 03:34:51 +00:00
|
|
|
SourceOpen = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// TK_Fetch
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
tokenType_t TK_Fetch( void ){
|
|
|
|
while ( Chr == ASCII_SPACE )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
NextChr();
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( Chr == '-' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
ProcessNumberToken();
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else{switch ( ASCIIToChrCode[(byte)Chr] )
|
|
|
|
{
|
|
|
|
case CHR_EOF:
|
|
|
|
tk_Token = TK_EOF;
|
|
|
|
break;
|
|
|
|
case CHR_LETTER:
|
|
|
|
ProcessLetterToken();
|
|
|
|
break;
|
|
|
|
case CHR_NUMBER:
|
|
|
|
ProcessNumberToken();
|
|
|
|
break;
|
|
|
|
case CHR_QUOTE:
|
|
|
|
ProcessQuoteToken();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ProcessSpecialToken();
|
|
|
|
break;
|
|
|
|
}}
|
2007-11-04 03:34:51 +00:00
|
|
|
return tk_Token;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// TK_Require
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void TK_Require( tokenType_t tokType ){
|
|
|
|
if ( tokType == TK_FLOATNUMBER && tk_Token == TK_INTNUMBER ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
tk_FloatNumber = (float)tk_IntNumber;
|
|
|
|
tk_Token = TK_FLOATNUMBER;
|
|
|
|
return;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( tk_Token != tokType ) {
|
|
|
|
Error( "File '%s', line %d:\nExpected '%s', found '%s'.\n",
|
|
|
|
tk_SourceName, tk_Line, TokenNames[tokType],
|
|
|
|
TokenNames[tk_Token] );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void TK_FetchRequire( tokenType_t tokType ){
|
2007-11-04 03:34:51 +00:00
|
|
|
TK_Fetch();
|
2012-03-17 20:01:54 +00:00
|
|
|
TK_Require( tokType );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
tokenType_t TK_RequireFetch( tokenType_t tokType ){
|
|
|
|
TK_Require( tokType );
|
2007-11-04 03:34:51 +00:00
|
|
|
return TK_Fetch();
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
tokenType_t TK_FetchRequireFetch( tokenType_t tokType ){
|
2007-11-04 03:34:51 +00:00
|
|
|
TK_Fetch();
|
2012-03-17 20:01:54 +00:00
|
|
|
TK_Require( tokType );
|
2007-11-04 03:34:51 +00:00
|
|
|
return TK_Fetch();
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
tokenType_t TK_Beyond( tokenType_t tokType ){
|
|
|
|
while ( tk_Token != tokType )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( TK_Fetch() == TK_EOF ) {
|
|
|
|
Error( "File '%s':\nCould not find token '%s'.\n", // FIXME: TokenNames table not big enuff
|
|
|
|
tk_SourceName, TokenNames[tokType] );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return TK_Fetch();
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void TK_BeyondRequire( tokenType_t bTok, tokenType_t rTok ){
|
|
|
|
TK_Beyond( bTok );
|
|
|
|
TK_Require( rTok );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
tokenType_t TK_Search( tokenType_t tokType ){
|
|
|
|
while ( tk_Token != tokType )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( TK_Fetch() == TK_EOF ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return TK_EOF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TK_Fetch();
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
tokenType_t TK_Get( tokenType_t tokType ){
|
|
|
|
while ( tk_Token != tokType )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( TK_Fetch() == TK_EOF ) {
|
|
|
|
Error( "File '%s':\nCould not find token '%s'.\n",
|
|
|
|
tk_SourceName, TokenNames[tokType] );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return tk_Token;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// ProcessLetterToken
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
static void ProcessLetterToken( void ){
|
2007-11-04 03:34:51 +00:00
|
|
|
int i;
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
text = TokenStringBuffer;
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( ASCIIToChrCode[(byte)Chr] == CHR_LETTER
|
|
|
|
|| ASCIIToChrCode[(byte)Chr] == CHR_NUMBER )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( ++i == MAX_IDENTIFIER_LENGTH ) {
|
|
|
|
Error( "File '%s', line %d:\nIdentifier too long.\n",
|
|
|
|
tk_SourceName, tk_Line );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
*text++ = Chr;
|
|
|
|
NextChr();
|
|
|
|
}
|
|
|
|
*text = 0;
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( CheckForKeyword() == FALSE ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
tk_Token = TK_IDENTIFIER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// CheckForKeyword
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
static qboolean CheckForKeyword( void ){
|
2007-11-04 03:34:51 +00:00
|
|
|
int i;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; Keywords[i].name != NULL; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( strcmp( tk_String, Keywords[i].name ) == 0 ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
tk_Token = Keywords[i].token;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// ProcessNumberToken
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
static void ProcessNumberToken( void ){
|
2007-11-04 03:34:51 +00:00
|
|
|
char *buffer;
|
|
|
|
|
|
|
|
buffer = TempBuffer;
|
|
|
|
*buffer++ = Chr;
|
|
|
|
NextChr();
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( ASCIIToChrCode[(byte)Chr] == CHR_NUMBER )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
*buffer++ = Chr;
|
|
|
|
NextChr();
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( Chr == '.' ) { // Float
|
2007-11-04 03:34:51 +00:00
|
|
|
*buffer++ = Chr;
|
|
|
|
NextChr(); // Skip period
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( ASCIIToChrCode[(byte)Chr] == CHR_NUMBER )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
*buffer++ = Chr;
|
|
|
|
NextChr();
|
|
|
|
}
|
|
|
|
*buffer = 0;
|
2012-03-17 20:01:54 +00:00
|
|
|
tk_FloatNumber = (float)atof( TempBuffer );
|
2007-11-04 03:34:51 +00:00
|
|
|
tk_Token = TK_FLOATNUMBER;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Integer
|
|
|
|
*buffer = 0;
|
2012-03-17 20:01:54 +00:00
|
|
|
tk_IntNumber = atoi( TempBuffer );
|
2007-11-04 03:34:51 +00:00
|
|
|
tk_Token = TK_INTNUMBER;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// ProcessQuoteToken
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
static void ProcessQuoteToken( void ){
|
2007-11-04 03:34:51 +00:00
|
|
|
int i;
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
text = TokenStringBuffer;
|
|
|
|
NextChr();
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( Chr != ASCII_QUOTE )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( Chr == EOF_CHARACTER ) {
|
|
|
|
Error( "File '%s', line %d:\n<EOF> inside string.\n",
|
|
|
|
tk_SourceName, tk_Line );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( ++i > MAX_QUOTED_LENGTH - 1 ) {
|
|
|
|
Error( "File '%s', line %d:\nString literal too long.\n",
|
|
|
|
tk_SourceName, tk_Line );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
*text++ = Chr;
|
|
|
|
NextChr();
|
|
|
|
}
|
|
|
|
*text = 0;
|
|
|
|
NextChr();
|
|
|
|
tk_Token = TK_STRING;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// ProcessSpecialToken
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
static void ProcessSpecialToken( void ){
|
2007-11-04 03:34:51 +00:00
|
|
|
char c;
|
|
|
|
|
|
|
|
c = Chr;
|
|
|
|
NextChr();
|
2012-03-17 20:01:54 +00:00
|
|
|
switch ( c )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
case '(':
|
|
|
|
tk_Token = TK_LPAREN;
|
|
|
|
break;
|
|
|
|
case ')':
|
|
|
|
tk_Token = TK_RPAREN;
|
|
|
|
break;
|
|
|
|
case '{':
|
|
|
|
tk_Token = TK_LBRACE;
|
|
|
|
break;
|
|
|
|
case '}':
|
|
|
|
tk_Token = TK_RBRACE;
|
|
|
|
break;
|
|
|
|
case '[':
|
|
|
|
tk_Token = TK_LBRACKET;
|
|
|
|
break;
|
|
|
|
case ']':
|
|
|
|
tk_Token = TK_RBRACKET;
|
|
|
|
break;
|
|
|
|
case ':':
|
|
|
|
tk_Token = TK_COLON;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
tk_Token = TK_UNKNOWNCHAR;
|
|
|
|
break;
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// NextChr
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
static void NextChr( void ){
|
|
|
|
if ( FilePtr >= FileEnd ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Chr = EOF_CHARACTER;
|
|
|
|
return;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( IncLineNumber == TRUE ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
tk_Line++;
|
|
|
|
IncLineNumber = FALSE;
|
|
|
|
}
|
|
|
|
Chr = *FilePtr++;
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( Chr < ASCII_SPACE ) {
|
|
|
|
if ( Chr == '\n' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
IncLineNumber = TRUE;
|
|
|
|
}
|
|
|
|
Chr = ASCII_SPACE;
|
|
|
|
}
|
|
|
|
}
|