Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using @tree-sitter-grammars/tree-sitter-yaml as a replacement for tree-sitter-yaml #4033

Open
char0n opened this issue Apr 15, 2024 · 1 comment
Assignees
Labels
ApiDOM enhancement New feature or request YAML

Comments

@char0n
Copy link
Member

char0n commented Apr 15, 2024

Current state of our YAML 1.2 lexical analysis is described in #194 (comment).

The goal of this issue is to determine if we can use https://github.com/tree-sitter-grammars/tree-sitter-yaml, as a drop it replacement. In https://github.com/tree-sitter-grammars/tree-sitter-yaml. In tree-sitter-grammars/tree-sitter-yaml@ee09311, the new grammar added support for error recovery, which was blocking us from upgrading tree-sitter infrasturcture.

Refs #194
Refs tree-sitter/tree-sitter#2339


This issue deals with tree-sitter GitHub org recommending new YAML grammar: tree-sitter/tree-sitter#3005

@char0n char0n self-assigned this Apr 15, 2024
@char0n char0n added enhancement New feature or request ApiDOM YAML labels Apr 15, 2024
@char0n
Copy link
Member Author

char0n commented Apr 15, 2024

After thorough testing I can say that new grammar is mostly compatible with what we need in ApiDOM. Node.js bindings and compiled WASM integrates with other tree-sitter libraries. One incompatibility I've found is:

        asyncapi: 2.4.0
        info:
          version: '1.0.0'
          title Something # Missing mapping

With old YAML grammar and old tree-sitter we correctly get error just on line 4. In new grammar and new tree-sitter we get Error Node for entire parsed string, and only within that Error Node there are other parsed nodes.

npm scripts need to locally build the grammar:

  "scripts": {
    "build": "tree-sitter generate --no-bindings ./grammar.js",
    "build:wasm": "tree-sitter build --wasm --output ./build/tree-sitter-yaml.wasm .",
    "postbuild": "npm run --prefix schema/json build",
    "test": "tree-sitter test",
    "install": "node-gyp rebuild",
    "prebuildify": "prebuildify --napi --strip"
   }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ApiDOM enhancement New feature or request YAML
Projects
None yet
Development

No branches or pull requests

1 participant