addcninblue / tree-sitter-cooklang

Tree-Sitter Grammar for Cooklang
5 stars 1 forks source link

Rewrite scanner in C and update deps/manifests/bindings #2

Closed amaanq closed 7 months ago

amaanq commented 1 year ago

I know this grammar is pretty niche and stale..but this would be a nice improvement, thanks!

androa commented 10 months ago

I'm unable to get this grammar to work at all. The tests fail. This PR works and fixes my issues.

Running macos 14.1.1, node 18.16.1, npm 9.5.1.

Example:

❯ cd /tmp
❯ git clone git@github.com:addcninblue/tree-sitter-cooklang.git
Cloning into 'tree-sitter-cooklang'...
remote: Enumerating objects: 35, done.
remote: Counting objects: 100% (35/35), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 35 (delta 6), reused 35 (delta 6), pack-reused 0
Receiving objects: 100% (35/35), 44.91 KiB | 239.00 KiB/s, done.
Resolving deltas: 100% (6/6), done.
❯ cd tree-sitter-cooklang
❯ npm i
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile

> tree-sitter-cooklang@1.0.0 install
> node-gyp rebuild

gyp info it worked if it ends with ok
gyp info using node-gyp@9.3.1
gyp info using node@18.16.1 | darwin | arm64
gyp info find Python using Python version 3.11.6 found at "/opt/homebrew/opt/python@3.11/bin/python3.11"
gyp info spawn /opt/homebrew/opt/python@3.11/bin/python3.11
gyp info spawn args [
gyp info spawn args   '/Users/androa/.nvm/versions/node/v18.16.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/private/tmp/tree-sitter-cooklang/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/androa/.nvm/versions/node/v18.16.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/androa/Library/Caches/node-gyp/18.16.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/androa/Library/Caches/node-gyp/18.16.1',
gyp info spawn args   '-Dnode_gyp_dir=/Users/androa/.nvm/versions/node/v18.16.1/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/androa/Library/Caches/node-gyp/18.16.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/private/tmp/tree-sitter-cooklang',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/tree_sitter_YOUR_LANGUAGE_NAME_binding/bindings/node/binding.o
In file included from ../bindings/node/binding.cc:3:
../node_modules/nan/nan.h:2544:8: warning: 'SetAccessor' is deprecated: Do signature check in accessor [-Wdeprecated-declarations]
  tpl->SetAccessor(
       ^
/Users/androa/Library/Caches/node-gyp/18.16.1/include/node/v8-template.h:837:3: note: 'SetAccessor' has been explicitly marked deprecated here
  V8_DEPRECATED("Do signature check in accessor")
  ^
/Users/androa/Library/Caches/node-gyp/18.16.1/include/node/v8config.h:460:35: note: expanded from macro 'V8_DEPRECATED'
# define V8_DEPRECATED(message) [[deprecated(message)]]
                                  ^
1 warning generated.
  CC(target) Release/obj.target/tree_sitter_YOUR_LANGUAGE_NAME_binding/src/parser.o
  CXX(target) Release/obj.target/tree_sitter_YOUR_LANGUAGE_NAME_binding/src/scanner.o
  SOLINK_MODULE(target) Release/tree_sitter_YOUR_LANGUAGE_NAME_binding.node
gyp info ok

added 2 packages, and audited 3 packages in 4s

found 0 vulnerabilities
❯ tree-sitter test
  big:
    ✗ Foccacia
  step:
    ✗ Simple Ingredient
    ✗ Multiword Ingredient
    ✗ Big Ingredient
    ✗ Simple Cookware
    ✓ Simple Timer
  metadata:
    ✓ Single line Metadata
    ✓ Multiline Metadata
    ✓ Skipline Metadata
    ✓ Skipline2 Metadata

5 failures:

expected / actual

...
androa commented 10 months ago

image 😢 😟 😔

@addcninblue Do you think you can have a look at this PR?

clason commented 7 months ago

@androa feel free to fork and maintain this grammar; if you change the scanner to C, we can switch to it in nvim-treesitter. (Otherwise we'll drop it at 1.0.)

addcninblue commented 7 months ago

Hey everyone - sorry for the complete lack of response. I'll go ahead and merge this PR over the weekend.