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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@liquescens/ebnf

v0.0.1

Published

ISO/IEC 14977 compliant EBNF parser.

Readme

EBNF Parser Library

The library implements a grammar rule parser in EBNF format, compliant with the standard ISO/IEC 19477:1996 [^1].

It is provided as an ECMAScript 6 module.

Installation

NPM package

The library can be installed using the following command:

npm install @liquescens/ebnf

This installation allows you to use the library with type checking and IntelliSense support.

Runtime Configuration

To ensure runtime code support on a web page, you need to configure JavaScript module import mapping.

You can use the version available via CDN for this purpose:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@liquescens/ebnf/default.css" />
<script type="importmap">
    {
        "imports":
        {
            "@liquescens/ebnf": "https://cdn.jsdelivr.net/npm/@liquescens/ebnf/index.js",
        }
    }
</script>

Usage Examples

Using the Default Configuration

The parser can be run with default settings, compliant with the ISO/IEC 14977 standard.

import * as EBNF from '@liquescens/ebnf';
const grammar = EBNF.parse('...');

Choosing a Predefined Configuration

It is possible to use one of several predefined parser configurations.

import * as EBNF from '@liquescens/ebnf';

const grammar_text = '...';
const lexer_configuration = EBNF.LexerConfiguration.iso_14977();
const lexer = new EBNF.Lexer(grammar_text, lexer_configuration);
const grammar = new EBNF.Parser(lexer).parse();

Conversion to DOM

The parser allows converting the resulting grammar structure to a DOM object.

const grammar = new EBNF.parse(grammar_text);
const dom = new EBNF.toDom(grammar);
document.body.appendChild(dom);
const grammar = new EBNF.parse(grammar_text);
const dom = new EBNF.Utilities.DOMGenerator().generate(grammar);
document.body.appendChild(dom);

Other Examples

More examples can be found in the documentation pages.

Object Structure

The following diagram illustrates the object structure of the grammar generated by the parser. Colors distinguish:

  • the base class for all symbols,
  • classes of terminal symbols,
  • classes of non-terminal symbols,
  • helper classes.
classDiagram
classDef terminal fill:#eeffff;
classDef nonterminal fill:#ddeeff;
    Symbol <|-- Terminal
    Symbol <|-- NonTerminal
    Terminal <|-- Token
    Terminal <|-- TerminalString
    Terminal <|-- SpecialSequence
    Terminal <|-- Integer
    Terminal <|-- Identifier
    NonTerminal <|-- Brackets
    NonTerminal <|-- BracketedSequence
    NonTerminal <|-- DefinitionList
    NonTerminal <|-- Definition
    NonTerminal <|-- Factor
    NonTerminal <|-- InfixTerm
    NonTerminal <|-- Rule
    NonTerminal <|-- Grammar
    Comment *-- Terminal
    TerminalBrackets *-- TerminalString
    TerminalBrackets *-- SpecialSequence
    TerminalBrackets *-- Comment
    Rule *-- Grammar
    Identifier *-- Rule
    DefinitionList *-- Rule
    DefinitionList *-- BracketedSequence
    Brackets *-- BracketedSequence
    Definition *-- DefinitionList
    class Symbol
    class Terminal:::terminal { gap: ((string | Comment)[]) }
    class NonTerminal:::nonterminal { children: Symbol[] }
    class Token:::terminal { value: string }
    class Identifier:::terminal { value: string }
    class Integer:::terminal { value: number }
    class Brackets {
        opening_symbol: Token
        closing_symbol: Token
    }
    class TerminalString:::terminal { 
        value: string
        brackets: TerminalBrackets 
    }
    class SpecialSequence:::terminal {
        value: string
        brackets: TerminalBrackets 
    }
    class Comment {
        value: string
        brackets: TerminalBrackets 
    }
    class BracketedSequence:::nonterminal {
        definition_list: DefinitionList
        brackets: Brackets
    }
    class DefinitionList:::nonterminal {
        definitions: Definition[]
        separators: Token[]
    }
    class Definition:::nonterminal {
        factors: Symbol[]
        separators: Token[]
    }
    class Factor:::nonterminal {
        primary: Symbol
        repetition: Integer
        operator: Token
    }
    class InfixTerm:::nonterminal {
        first_primary: Symbol
        second_primary: Symbol
        operator: Token
    }
    class Rule:::nonterminal {
        identifier: Identifier
        definition_list: DefinitionList
        operator: Token
        terminator: Token
    }
    class Grammar:::nonterminal {
        rules: Rule[]
    }

[^1]: The official whitepaper describes the comment expression as having an internal grammatical structure. In this implementation, the comment structure is not parsed. The comment content is represented as a single literal.