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

@bablr/vm

v0.1.16

Published

A VM for executing BABLR grammars

Downloads

42

Readme

bablr-vm

come chat on Discord

This the home of the Javascript reference implemenation of the BABLR VM, formerly known as cst-tokens. It executes BABLR grammars written in Javascript to define parsers for any programming language.

Explain Like I'm 5

Let's start with what we know for sure: b is a letter, and 3 is a number. Well, of course, except when b is a number, as it may be in the hexidecimal system where it is used to represent the value 11. 3 can also be used to make a pictographic heart: <3. Programming languages are a collection of formal rules about exactly what certain characters mean when they appear in certain contexts, but so far there has been no system of notation to help undrstand how formal rules are applied. BABLR provides one, allowing our "gotcha" example to be expressed clearly as <Number><Digit>'b'</></>.

Features

The VM is a kind of state machine known formally as as "pushdown automaton", and is intended to be sufficiently powerful to recognize the syntax and structure of any programming language. Rather than a formal schema definition, a language is defined through the provision of useful APIs for working with valid documents written in that language.

This API differs from that of most other production-grade parsers, which are most often parser generators. BABLR grammars are purely runtime Javascript, and so tend to be extremely lightweight compared to comparable compiled forms. All parsing and traversal is done in a streaming manner to the extent possible.

Usage

The BABLR VM is unready for production usage, and will continue to be so until v1.0.0 is released. For right now the more people try out this code and provide me feedback, the faster I will make progress towards production-readiness!

import { parseCSTML } from '@bablr/vm';
import { i } from '@bablr/boot';

const digits = class {
  constructor() {
    this.covers = {
      [Symbol.for('@bablr/node')]: ['Number', 'Digit'],
    };
  }

  *Number() {
    while (yield i`eat(<| Digit .digits |>)`);
  }

  *Digit() {
    yield i`eat(/\d/)`;
  }
};

parseCSTML(digits, '42');

// <Number>
//   digits:
//   <Digit>
//     '4'
//   </>
//   digits:
//   <Digit>
//     '2'
//   </>
//  </>

Prior Art

BABLR is actually portmanteau of Babel and ANTLR. It would be reasonable to describe this project as being a mixture of the ideas from those two, with a bit of help from SrcML, Tree-sitter, and the fabulous Redux.

It is also designed with the needs of Prettier and ESLint in mind.