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 bool assertError = false;
static const char *assertString;
static char *stringChars = "\"", *charChars = "'";
static const char *errors[] = {
"LT_Error: Syntax error",
@ -105,6 +106,62 @@ void LT_Init(LT_InitInfo initInfo)
{
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()
@ -528,19 +585,39 @@ LT_Token LT_GetToken()
}
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];
}
else
{
tk.token = LT_TkNames[TOK_Charac];
}
return tk;
}
}
for(size_t i = 0; i < 6;)
{
char cc = charChars[i++];
if(cc == '\0')
{
break;
}
else if(c == cc)
{
tk.string = LT_ReadString(c);
tk.token = LT_TkNames[TOK_Charac];
return tk;
}
}
if(isdigit(c))
{

View File

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