funny looking errors (not working properly)
This commit is contained in:
@@ -346,7 +346,7 @@ ResultType(SolsToken, charptr) identifyToken(const char* token) {
|
||||
|
||||
}
|
||||
|
||||
char* createParsingError(size_t lineNum, char* line, char* why) {
|
||||
char* createLexingError(size_t lineNum, char* line, char* why) {
|
||||
Estr error = CREATE_ESTR(ESC_RESET ESC_BOLD ESC_RED_FG "Lexing Error " ESC_RESET ESC_YELLOW_FG "on line ");
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf), "%zu", lineNum);
|
||||
@@ -476,7 +476,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
if (strcmp(buf.str, "") != 0) {
|
||||
ResultType(SolsToken, charptr) result = identifyToken(buf.str);
|
||||
if (result.error) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, result.as.error);
|
||||
char* err = createLexingError(lineNum, currentLine.str, result.as.error);
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -484,7 +484,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
result.as.success.line.num = lineNum;
|
||||
result.as.success.line.content = malloc(strlen(currentLine.str) + 1);
|
||||
if (result.as.success.line.content == NULL) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
char* err = createLexingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -497,7 +497,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
char tmp[] = {chr.as.success, '\0'};
|
||||
ResultType(SolsToken, charptr) result = identifyToken(tmp);
|
||||
if (result.error) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, result.as.error);
|
||||
char* err = createLexingError(lineNum, currentLine.str, result.as.error);
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -505,7 +505,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
result.as.success.line.num = lineNum;
|
||||
result.as.success.line.content = malloc(strlen(currentLine.str) + 1);
|
||||
if (result.as.success.line.content == NULL) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
char* err = createLexingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -522,7 +522,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
if (strcmp(buf.str, "") != 0) {
|
||||
ResultType(SolsToken, charptr) result = identifyToken(buf.str);
|
||||
if (result.error) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, result.as.error);
|
||||
char* err = createLexingError(lineNum, currentLine.str, result.as.error);
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -530,7 +530,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
result.as.success.line.num = lineNum;
|
||||
result.as.success.line.content = malloc(strlen(currentLine.str) + 1);
|
||||
if (result.as.success.line.content == NULL) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
char* err = createLexingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -545,7 +545,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
char tmp[] = {chr.as.success, '\0'};
|
||||
ResultType(SolsToken, charptr) result = identifyToken(tmp);
|
||||
if (result.error) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, result.as.error);
|
||||
char* err = createLexingError(lineNum, currentLine.str, result.as.error);
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -553,7 +553,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
result.as.success.line.num = lineNum;
|
||||
result.as.success.line.content = malloc(strlen(currentLine.str) + 1);
|
||||
if (result.as.success.line.content == NULL) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
char* err = createLexingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -565,7 +565,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
char tmp[] = {chr.as.success, '=', '\0'};
|
||||
ResultType(SolsToken, charptr) result = identifyToken(tmp);
|
||||
if (result.error) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, result.as.error);
|
||||
char* err = createLexingError(lineNum, currentLine.str, result.as.error);
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -573,7 +573,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
result.as.success.line.num = lineNum;
|
||||
result.as.success.line.content = malloc(strlen(currentLine.str) + 1);
|
||||
if (result.as.success.line.content == NULL) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
char* err = createLexingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -586,7 +586,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
char tmp[] = {chr.as.success, chr.as.success, '\0'};
|
||||
ResultType(SolsToken, charptr) result = identifyToken(tmp);
|
||||
if (result.error) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, result.as.error);
|
||||
char* err = createLexingError(lineNum, currentLine.str, result.as.error);
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -594,7 +594,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
result.as.success.line.num = lineNum;
|
||||
result.as.success.line.content = malloc(strlen(currentLine.str) + 1);
|
||||
if (result.as.success.line.content == NULL) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
char* err = createLexingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -616,7 +616,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
if (strcmp(buf.str, "") != 0) {
|
||||
ResultType(SolsToken, charptr) result = identifyToken(buf.str);
|
||||
if (result.error) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, result.as.error);
|
||||
char* err = createLexingError(lineNum, currentLine.str, result.as.error);
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -624,7 +624,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
result.as.success.line.num = lineNum;
|
||||
result.as.success.line.content = malloc(strlen(currentLine.str) + 1);
|
||||
if (result.as.success.line.content == NULL) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
char* err = createLexingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -639,7 +639,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
char tmp[] = {chr.as.success, '\0'};
|
||||
ResultType(SolsToken, charptr) result = identifyToken(tmp);
|
||||
if (result.error) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, result.as.error);
|
||||
char* err = createLexingError(lineNum, currentLine.str, result.as.error);
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -647,7 +647,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
result.as.success.line.num = lineNum;
|
||||
result.as.success.line.content = malloc(strlen(currentLine.str) + 1);
|
||||
if (result.as.success.line.content == NULL) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
char* err = createLexingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -659,7 +659,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
char tmp[] = {chr.as.success, '=', '\0'};
|
||||
ResultType(SolsToken, charptr) result = identifyToken(tmp);
|
||||
if (result.error) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, result.as.error);
|
||||
char* err = createLexingError(lineNum, currentLine.str, result.as.error);
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -667,7 +667,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
result.as.success.line.num = lineNum;
|
||||
result.as.success.line.content = malloc(strlen(currentLine.str) + 1);
|
||||
if (result.as.success.line.content == NULL) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
char* err = createLexingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -690,7 +690,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
if (strcmp(buf.str, "") != 0) {
|
||||
ResultType(SolsToken, charptr) result = identifyToken(buf.str);
|
||||
if (result.error) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, result.as.error);
|
||||
char* err = createLexingError(lineNum, currentLine.str, result.as.error);
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -698,7 +698,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
result.as.success.line.num = lineNum;
|
||||
result.as.success.line.content = malloc(strlen(currentLine.str) + 1);
|
||||
if (result.as.success.line.content == NULL) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
char* err = createLexingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -719,7 +719,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
if (strcmp(buf.str, "") != 0) {
|
||||
ResultType(SolsToken, charptr) result = identifyToken(buf.str);
|
||||
if (result.error) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, result.as.error);
|
||||
char* err = createLexingError(lineNum, currentLine.str, result.as.error);
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -727,7 +727,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
result.as.success.line.num = lineNum;
|
||||
result.as.success.line.content = malloc(strlen(currentLine.str) + 1);
|
||||
if (result.as.success.line.content == NULL) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
char* err = createLexingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -769,7 +769,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
if (strcmp(buf.str, "") != 0) {
|
||||
ResultType(SolsToken, charptr) result = identifyToken(buf.str);
|
||||
if (result.error) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, result.as.error);
|
||||
char* err = createLexingError(lineNum, currentLine.str, result.as.error);
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -777,7 +777,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
result.as.success.line.num = lineNum;
|
||||
result.as.success.line.content = malloc(strlen(currentLine.str) + 1);
|
||||
if (result.as.success.line.content == NULL) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
char* err = createLexingError(lineNum, currentLine.str, "Couldn't allocate memory to store line information in token (in lex() function)");
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
@@ -787,7 +787,7 @@ ResultType(Nothing, charptr) lex(SolsLexer* lexer) {
|
||||
}
|
||||
|
||||
if (inString) {
|
||||
char* err = createParsingError(lineNum, currentLine.str, "Unterminated string");
|
||||
char* err = createLexingError(lineNum, currentLine.str, "Unterminated string");
|
||||
DESTROY_ESTR(buf);
|
||||
DESTROY_ESTR(currentLine);
|
||||
return Error(Nothing, charptr, err);
|
||||
|
||||
Reference in New Issue
Block a user