Make error printy thingy work
This commit is contained in:
@@ -27,30 +27,31 @@ ResultType(SolsParser, charptr) createSolsParser(SolsTokens* input) {
|
|||||||
|
|
||||||
void createParserError(SolsParser* parser, char* what) {
|
void createParserError(SolsParser* parser, char* what) {
|
||||||
|
|
||||||
ResultType(SolsToken, Nothing) prevToken;
|
ResultType(SolsToken, Nothing) prevToken = Error(SolsToken, Nothing, {});
|
||||||
SolsToken token = parserPeek(parser, 0).as.success;
|
SolsToken token = parserPeek(parser, 0).as.success;
|
||||||
ResultType(SolsToken, Nothing) nextToken;
|
ResultType(SolsToken, Nothing) nextToken = Error(SolsToken, Nothing, {});
|
||||||
|
|
||||||
// Find tokens for previous line and next line
|
// Find tokens for previous line
|
||||||
for (size_t i = parser->current; i > 0; i--) {
|
if (parser->current > 1) {
|
||||||
prevToken = parserLookAt(parser, i);
|
for (size_t i = parser->current - 1; i > 0; i--) {
|
||||||
if (prevToken.error || prevToken.as.success.line.num != token.line.num) {
|
ResultType(SolsToken, Nothing) check = parserLookAt(parser, i - 1);
|
||||||
break;
|
if (check.error) break;
|
||||||
|
if (check.as.success.line.num != token.line.num) {
|
||||||
|
prevToken = check;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (prevToken.error || prevToken.as.success.line.num == token.line.num) {
|
|
||||||
prevToken = Error(SolsToken, Nothing, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = parser->current; i <= parser->input->count; i++) {
|
// Find tokens for next line
|
||||||
nextToken = parserLookAt(parser, i);
|
for (size_t i = parser->current; i < parser->input->count; i++) {
|
||||||
if (nextToken.error || nextToken.as.success.line.num != token.line.num) {
|
ResultType(SolsToken, Nothing) check = parserLookAt(parser, i);
|
||||||
|
if (check.error) break;
|
||||||
|
if (check.as.success.line.num != token.line.num) {
|
||||||
|
nextToken = check;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nextToken.error || nextToken.as.success.line.num == token.line.num) {
|
|
||||||
nextToken = Error(SolsToken, Nothing, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parser->errors.count + 1 >= parser->errors.capacity) {
|
if (parser->errors.count + 1 >= parser->errors.capacity) {
|
||||||
parser->errors.capacity *= 2;
|
parser->errors.capacity *= 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user