(svn r26784) -Codechange [Squirrel]: use WChar for the lexer

This commit is contained in:
rubidium
2014-09-07 06:46:03 +00:00
parent 0d042630d5
commit 00e1e69187
5 changed files with 21 additions and 21 deletions

View File

@@ -31,6 +31,8 @@ to the following restrictions:
#ifndef _SQUIRREL_H_
#define _SQUIRREL_H_
#include "../../../string_type.h"
typedef __int64 SQInteger;
typedef unsigned __int64 SQUnsignedInteger;
typedef unsigned __int64 SQHash; /*should be the same size of a pointer*/
@@ -178,7 +180,7 @@ typedef void (*SQPRINTFUNCTION)(HSQUIRRELVM,const SQChar * ,...);
typedef SQInteger (*SQWRITEFUNC)(SQUserPointer,SQUserPointer,SQInteger);
typedef SQInteger (*SQREADFUNC)(SQUserPointer,SQUserPointer,SQInteger);
typedef SQInteger (*SQLEXREADFUNC)(SQUserPointer);
typedef WChar (*SQLEXREADFUNC)(SQUserPointer);
typedef struct tagSQRegFunction{
const SQChar *name;

View File

@@ -1264,7 +1264,7 @@ struct BufState{
SQInteger size;
};
SQInteger buf_lexfeed(SQUserPointer file)
WChar buf_lexfeed(SQUserPointer file)
{
BufState *buf=(BufState*)file;
if(buf->size<(buf->ptr+1))

View File

@@ -27,11 +27,11 @@ SQLexer::~SQLexer()
_keywords->Release();
}
void SQLexer::APPEND_CHAR(LexChar c)
void SQLexer::APPEND_CHAR(WChar c)
{
char buf[4];
int chars = Utf8Encode(buf, c);
for (int i = 0; i < chars; i++) {
size_t chars = Utf8Encode(buf, c);
for (size_t i = 0; i < chars; i++) {
_longstr.push_back(buf[i]);
}
}
@@ -96,10 +96,10 @@ void SQLexer::Error(const SQChar *err)
void SQLexer::Next()
{
SQInteger t = _readf(_up);
WChar t = _readf(_up);
if(t > MAX_CHAR) Error("Invalid character");
if(t != 0) {
_currdata = (LexChar)t;
_currdata = t;
return;
}
_currdata = SQUIRREL_EOB;
@@ -285,7 +285,7 @@ SQInteger SQLexer::GetIDType(SQChar *s)
}
SQInteger SQLexer::ReadString(LexChar ndelim,bool verbatim)
SQInteger SQLexer::ReadString(WChar ndelim,bool verbatim)
{
INIT_TEMP_STRING();
NEXT();

View File

@@ -2,8 +2,6 @@
#ifndef _SQLEXER_H_
#define _SQLEXER_H_
typedef unsigned short LexChar;
struct SQLexer
{
SQLexer();
@@ -14,7 +12,7 @@ struct SQLexer
const SQChar *Tok2Str(SQInteger tok);
private:
SQInteger GetIDType(SQChar *s);
SQInteger ReadString(LexChar ndelim,bool verbatim);
SQInteger ReadString(WChar ndelim,bool verbatim);
SQInteger ReadNumber();
void LexBlockComment();
SQInteger ReadID();
@@ -22,7 +20,7 @@ private:
SQInteger _curtoken;
SQTable *_keywords;
void INIT_TEMP_STRING() { _longstr.resize(0); }
void APPEND_CHAR(LexChar c);
void APPEND_CHAR(WChar c);
void TERMINATE_BUFFER() { _longstr.push_back('\0'); }
public:
@@ -35,7 +33,7 @@ public:
SQFloat _fvalue;
SQLEXREADFUNC _readf;
SQUserPointer _up;
LexChar _currdata;
WChar _currdata;
SQSharedState *_sharedstate;
sqvector<SQChar> _longstr;
CompilerErrorFunc _errfunc;