Remove unused ‘unexpected token’ handling
This commit is contained in:
parent
d3d25f2683
commit
8b1aeee0e3
5 changed files with 14 additions and 68 deletions
|
|
@ -30,7 +30,7 @@ TSTree * TSDocumentTree(const TSDocument *document) {
|
|||
}
|
||||
|
||||
const char * TSDocumentToString(const TSDocument *document) {
|
||||
if (document->error.type != TSParseErrorTypeNone) {
|
||||
if (document->error.expected_inputs != NULL) {
|
||||
return TSParseErrorToString(&document->error, document->text, document->symbol_names);
|
||||
} else {
|
||||
return TSTreeToString(document->tree, document->symbol_names);
|
||||
|
|
|
|||
|
|
@ -2,22 +2,9 @@
|
|||
#include <string>
|
||||
|
||||
using std::string;
|
||||
static const char * EMPTY = "";
|
||||
|
||||
const char * TSParseErrorToString(const TSParseError *error, const char *input_string, const char **symbol_names) {
|
||||
string result;
|
||||
switch (error->type) {
|
||||
case TSParseErrorTypeSyntactic:
|
||||
result = string("Unexpected token ") + symbol_names[error->lookahead_sym] + ". ";
|
||||
break;
|
||||
case TSParseErrorTypeLexical:
|
||||
result = string("Unexpected character '") + input_string[error->position] + "'. ";
|
||||
break;
|
||||
default:
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
result += "Expected: ";
|
||||
string result = string("Unexpected character '") + input_string[error->position] + "'. Expected: ";
|
||||
for (int i = 0; i < error->expected_input_count; i++)
|
||||
result += string(error->expected_inputs[i]) + " ";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue