npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tree-sitter-tony

v0.2.0-alpha.38

Published

Tony grammar for tree-sitter

Downloads

15

Readme

tree-sitter-tony

This repository is home to the parser and Tree-sitter grammar of the Tony programming language. It comes with automatically generated TypeScript type declarations.

Tony is a functional, strongly typed, high level, general purpose programming language. Tony employs refinement types, allowing its type checker to catch domain-specific bugs at compile time.

Other core components of Tony can be found through the following links:

Note of caution: New features of Tony are discussed in the repository housing the language spec. This repository merely implements the spec.

Examples for valid syntax can be found in test/corpus.

Philosophy

This project uses Tree-sitter as a parsing library. As such this repository includes a Tree-sitter grammar (at grammar.js). This grammar may be used for any purpose beyond simply parsing the code to compile it. These uses include syntax highlighting, deep integration with code editors and more.

Installation

Prerequisites: Building this parser will require the following tools:

  • Node.js (the version is specified by the engines entry in package.json); and
  • the node-gyp build tool.

Alternatively to building the parser yourself you can use prebuilt versions. If available, a prebuilt version will be used automatically when you install this project.

The tree-sitter-tony package is published on NPM.

You may install it

  • using Yarn (preferred)

    $ yarn add tree-sitter-tony
  • or using NPM

    $ npm install tree-sitter-tony
  • or from source

    $ git clone [email protected]:tony-lang/tree-sitter-tony.git
    $ yarn setup

Usage

The generated parser is in C. There exist bindings to use this parser with a huge variety of programming languages. Below you can find a couple of options of using the parser.

Some may require you to set up a development environment.

CLI (development)

To parse a file and emit a syntax tree run

$ yarn parse-tony file.tn

where file.tn is the relative path to the file you want to parse.

For a simple hello world use

io->print('hello world')

Use yarn parse-dtn file.dtn to parse a module declaration file.

TypeScript / JavaScript

Import the parser with

import Parser from 'tree-sitter'
import TreeSitterTony, { Tree } from 'tree-sitter-tony/tony'

Then you are able to create an instance of the parser as follows:

const parser = new Parser()
parser.setLanguage(TreeSitterTony)

Now you can parse any string into an abstract syntax tree:

const sourceCode: string = await readFile(file)

const tree = parser.parse(sourceCode) as Tree

tree and every child node including their properties are strongly typed.

Import from 'tree-sitter-tony/dtn' instead of 'tree-sitter-tony/tony' to load the declaration file parser.

Development

To start development you first have to fork this repository and locally clone your fork.

Then setup the project locally by running:

$ yarn setup

grammar.js houses the specification of the parser. You can generate a new parser from this specification by running:

$ yarn generate

You can generate type declarations by running:

$ yarn types

Testing

To run the tests:

$ yarn test

To let TypeScript check types:

$ yarn tsc

The linter can be run as follows:

$ yarn lint

We use Prettier for automated code formatting:

$ yarn prettier

You can find all commands run by the CI workflow in .github/workflows/ci.yml.

Contributing

We warmly welcome everyone who is intersted in contributing. Please reference our contributing guidelines and our Code of Conduct.

Releases

Here you can find details on all past releases. Unreleased breaking changes that are on the current master can be found here.

Tony follows Semantic Versioning 2.0 as defined at http://semver.org. Reference our security policy.

Publishing

  1. Review breaking changes and deprecations in CHANGELOG.md.
  2. Change the version in package.json.
  3. Reset CHANGELOG.md.
  4. Create a pull request to merge the changes into master.
  5. After the pull request was merged, create a new release listing the breaking changes, deprecations and commits on master since the last release.
  6. The release workflow will publish the package to NPM and GPR.
  7. The prebuild workflow will upload prebuilt packages to GitHub.