0

我正在尝试编译用于​​ neovim 的 typescript 、tsx和 python 解析器,但是当我按照tree-sitter tracking issuegcc -o parser.so -shared src/parser.c -Os -I./src的指示运行时,我得到:

Undefined symbols for architecture x86_64:
  "_tree_sitter_tsx_external_scanner_create", referenced from:
      _tree_sitter_tsx.language in parser-eb4e9b.o
  "_tree_sitter_tsx_external_scanner_deserialize", referenced from:
      _tree_sitter_tsx.language in parser-eb4e9b.o
  "_tree_sitter_tsx_external_scanner_destroy", referenced from:
      _tree_sitter_tsx.language in parser-eb4e9b.o
  "_tree_sitter_tsx_external_scanner_scan", referenced from:
      _tree_sitter_tsx.language in parser-eb4e9b.o
  "_tree_sitter_tsx_external_scanner_serialize", referenced from:
      _tree_sitter_tsx.language in parser-eb4e9b.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我已经运行了 npm 构建步骤,并在构建中尝试了 make 文件,但我无法获得最终.so文件。

4

2 回答 2

1

一些语法有外部扫描器——手写的 C/C++ 源文件,按照约定称为scanner.cor scanner.cc,需要与parser.c.

于 2020-07-08T20:58:53.517 回答
0

undefined symbol: tree_sitter_parsername_external_scanner_create当解析器名称和函数名称不匹配时,也会出现错误

  // grammar.js
  name: 'parsername',
// scanner.cc
void *tree_sitter_oldparsername_external_scanner_create() {
  return new Scanner();
}

快速修复:替换扫描仪源中的名称

sed -i -E 's|(tree_sitter)_oldparsername_|\1_parsername_|g' src/scanner.* 
于 2021-10-29T11:33:38.527 回答