Fix parser position in parse error messages
This commit is contained in:
parent
a21c42ca85
commit
4cacdcba70
2 changed files with 3 additions and 1 deletions
|
|
@ -99,6 +99,7 @@ static void TSParserReduce(TSParser *parser, TSSymbol symbol, int child_count) {
|
|||
static void TSParserError(TSParser *parser, size_t count, const char **expected_inputs) {
|
||||
TSParseError *error = &parser->result.error;
|
||||
error->type = TSParseErrorTypeSyntactic;
|
||||
error->position = parser->position;
|
||||
error->expected_input_count = count;
|
||||
error->expected_inputs = expected_inputs;
|
||||
error->lookahead_sym = TSParserLookaheadSym(parser);
|
||||
|
|
@ -107,6 +108,7 @@ static void TSParserError(TSParser *parser, size_t count, const char **expected_
|
|||
static void TSParserLexError(TSParser *parser, size_t count, const char **expected_inputs) {
|
||||
TSParseError *error = &parser->result.error;
|
||||
error->type = TSParseErrorTypeLexical;
|
||||
error->position = parser->position;
|
||||
error->expected_input_count = count;
|
||||
error->expected_inputs = expected_inputs;
|
||||
error->lookahead_sym = TSParserLookaheadSym(parser);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ const char * TSParseErrorToString(const TSParseError *error, const char *input_s
|
|||
|
||||
result += "Expected: ";
|
||||
for (int i = 0; i < error->expected_input_count; i++)
|
||||
result += string(" '") + error->expected_inputs[i] + "'";
|
||||
result += error->expected_inputs[i];
|
||||
|
||||
char *stuff = (char *)malloc(result.size() * sizeof(char));
|
||||
strcpy(stuff, result.c_str());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue