From 9ea3668f757ae61657a6b6bf2369da1c69c3ef65 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 20 Nov 2019 11:10:49 -0800 Subject: [PATCH] wasm: Fix logic for finding language functions --- lib/binding_web/binding.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/binding_web/binding.js b/lib/binding_web/binding.js index 766abd54..e965992f 100644 --- a/lib/binding_web/binding.js +++ b/lib/binding_web/binding.js @@ -11,6 +11,8 @@ const PREDICATE_STEP_TYPE_DONE = 0; const PREDICATE_STEP_TYPE_CAPTURE = 1; const PREDICATE_STEP_TYPE_STRING = 2; +const LANGUAGE_FUNCTION_REGEX = /^_?tree_sitter_\w+/; + var VERSION; var MIN_COMPATIBLE_VERSION; var TRANSFER_BUFFER; @@ -866,7 +868,7 @@ class Language { .then(bytes => loadWebAssemblyModule(bytes, {loadAsync: true})) .then(mod => { const functionName = Object.keys(mod).find(key => - key.includes("tree_sitter_") && + LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_") ); const languageAddress = mod[functionName]();