Code Monkey home page Code Monkey logo

tree-sitter-perl-tree-sitter-perl's Introduction

tree-sitter-perl-better

This is Yet Another perl tree-sitter module.

Getting Started Developing

To get started, install the dependencies for this repo

npm i

That should get you set up with tree-sitter's cli locally.

Generating the Bindings

In this project, the generated C source code (stored in the src directory) is .gitignored. In order to generate it, run

npx tree-sitter generate 

You'll need to do this after any changes to the grammar.

Running the tests

Tests are stored in the /test/corpus directory, as txt files. A little reference on the syntax can be found here.

You can run the tests with

npx tree-sitter test

See the help output (-h) for that command for some more details on using the test runner.

Contributing

If you'd like to contribute, Pull Requests are welcome! The plan is to build the grammar from the bottom up, from simple statements with solid code coverage, eventually building up to full, complex syntax.

You can see a reference of the grammar's DSL here. It's fairly straigthforward, and makes for pleasant reading. It is stored in grammar.js at the root of this repo.

For subtle points in the grammar implementation, PLEASE leave comments. The extra bytes spent on the comments in dev will go a long way in the big picture.

Using these bindings

Neovim

You can install these bindings in neovim by using the following snippet. Hopefully soon we'll get upstreamed + you won't need this patchery.

local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.perl = {
  install_info = {
    url = 'https://github.com/tree-sitter-perl/tree-sitter-perl',
    revision = 'release',
    files = { "src/parser.c", "src/scanner.c" },
  }
}

Then you just :TSInstall perl. You'll need to copy the queries in the queries directory of this repo into a queries/perl directory somewhere in you rtp.

Emacs

As of version 29, Emacs can be built with tree-sitter support. This version is not yet released, so you need to build it yourself from the Emacs source repository. You need to have tree-sitter itself available to do this.

Once this is done, you can install the Perl bindings by executing two Emacs lisp forms:

(setq treesit-language-source-alist 
  '((perl . ("https://github.com/tree-sitter-perl/tree-sitter-perl" "release"))))
(treesit-install-language-grammar 'perl)

Alternatively, you can run the command interactively:

M-x treesit-install-language-grammar <RET>

Then answer the prompts accordingly. Enter perl for the language, the repository URL is https://github.com/tree-sitter-perl/tree-sitter-perl and the branch is release.

An Emacs major mode which makes use of these binding ... is yet to be written.

In General

You can get the built files off of the release branch in this repo. If you have specific instructions for a particular editor, PRs are welcome.

tree-sitter-perl-tree-sitter-perl's People

Contributors

haraldjoerg avatar leonerd avatar rabbiveesh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.