tree-sitter/test/helpers/stderr_logger.cc
Max Brunsfeld 6dc0ff359d Rename spec -> test
'Test' is a lot more straightforward of a name.
2017-03-09 20:40:01 -08:00

22 lines
512 B
C++

#include "tree_sitter/runtime.h"
#include <stdio.h>
static void log(void *payload, TSLogType type, const char *msg) {
bool include_lexing = (bool)payload;
switch (type) {
case TSLogTypeParse:
fprintf(stderr, "* %s\n", msg);
break;
case TSLogTypeLex:
if (include_lexing)
fprintf(stderr, " %s\n", msg);
break;
}
}
TSLogger stderr_logger_new(bool include_lexing) {
TSLogger result;
result.payload = (void *)include_lexing;
result.log = log;
return result;
}