Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bnf-parser

Package Overview
Dependencies
Maintainers
0
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bnf-parser

Deterministic BNF compiler/parser

  • 4.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
increased by7.34%
Maintainers
0
Weekly downloads
 
Created
Source

BNF-Parser

Test

Compile your bnfs down to WebAssembly for maximum parsing speed; with generated type definitions to make using the syntax tree outputs a breeze. The compiled output from this library is platform agnostic, so it can run anywhere new WebAssembly.Instance() is a valid function. It bundles the WebAssembly module inside of a single js file so it can be easily incorporated into any bundler. The type definitions for a given bnf are just that, a definitions file - so if you don't want to use typescript or type hints you can go wild by ignoring it.

program ::= chunk+ ;
chunk ::= "a"+ "b"+ ;
npx bnf-compile ./syntax.bnf
import * as syntax from "./bnf/syntax.js";

const tree    = syntax.Parse_Program("abbaabab").root;
const chunk   = program.value[0]; // typescript knows this this **will** be of type `Term_Chunk`
const firstBs = program.value[1];
const bCount: number = firstBs.value.length; // typescript knows this **will** be a number

Built to be a devDependency - if you use the included cli tool to generate your syntax parser you don't need to include this library as your dependency, you can just import those artifacts.

Documentation

See https://bnf-parser.ajanibilby.com/

API

See https://bnf-parser.ajanibilby.com/api

BNF Syntax

See https://bnf-parser.ajanibilby.com/api

Try it Online

Try it in your browser https://bnf-parser.ajanibilby.com/test

Keywords

FAQs

Package last updated on 30 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc