Archived
1
0

nevermind works

This commit is contained in:
Marrub 2015-06-06 10:13:54 -04:00
parent 5c8f7ede03
commit 238b00098a
2 changed files with 85 additions and 6 deletions

View File

@ -40,6 +40,7 @@ static LT_InitInfo info;
static iconv_t icDesc; static iconv_t icDesc;
static bool assertError = false; static bool assertError = false;
static const char *assertString; static const char *assertString;
static char *stringChars = "\"", *charChars = "'";
static const char *errors[] = { static const char *errors[] = {
"LT_Error: Syntax error", "LT_Error: Syntax error",
@ -105,6 +106,62 @@ void LT_Init(LT_InitInfo initInfo)
{ {
info.stripInvalid = false; info.stripInvalid = false;
} }
if(info.stringChars != NULL)
{
int i;
stringChars = malloc(6);
for(i = 0; i < 6; i++)
{
char c = info.stringChars[i];
if(c != '\0')
{
stringChars[i] = c;
}
else
{
break;
}
}
stringChars[i] = '\0';
gbRover->next = malloc(sizeof(LT_GarbageList));
gbRover = gbRover->next;
gbRover->ptr = stringChars;
gbRover->next = NULL;
}
if(info.charChars != NULL)
{
int i;
charChars = malloc(6);
for(i = 0; i < 6; i++)
{
char c = info.charChars[i];
if(c != '\0')
{
charChars[i] = c;
}
else
{
break;
}
}
charChars[i] = '\0';
gbRover->next = malloc(sizeof(LT_GarbageList));
gbRover = gbRover->next;
gbRover->ptr = charChars;
gbRover->next = NULL;
}
} }
void LT_Quit() void LT_Quit()
@ -528,18 +585,38 @@ LT_Token LT_GetToken()
} }
return tk; return tk;
case '"': case '\'': }
tk.string = LT_ReadString(c);
if(c == '"') for(size_t i = 0; i < 6;)
{
char cc = stringChars[i++];
if(cc == '\0')
{ {
break;
}
else if(c == cc)
{
tk.string = LT_ReadString(c);
tk.token = LT_TkNames[TOK_String]; tk.token = LT_TkNames[TOK_String];
return tk;
} }
else }
for(size_t i = 0; i < 6;)
{
char cc = charChars[i++];
if(cc == '\0')
{ {
tk.token = LT_TkNames[TOK_Charac]; break;
}
else if(c == cc)
{
tk.string = LT_ReadString(c);
tk.token = LT_TkNames[TOK_Charac];
return tk;
} }
return tk;
} }
if(isdigit(c)) if(isdigit(c))

View File

@ -72,6 +72,8 @@ typedef struct
bool doConvert; bool doConvert;
const char *fromCode; const char *fromCode;
const char *toCode; const char *toCode;
const char *stringChars;
const char *charChars;
} LT_InitInfo; } LT_InitInfo;
typedef struct typedef struct