parcel-transformer-nearley

1.0.5 • Public • Published

Parcel transformer Nearley

A Parcel plugin which adds support for importing compiled Nearly grammars. This plugin is for Parcel v2. For the first version of parcel, see parcel-plugin-nearley.

Usage

  1. Install nearley and parcel-transformer-nearley with yarn or with npm:
yarn add nearley
yarn add -D parcel-transformer-nearley
npm install --save nearley
npm install --save-dev parcel-transformer-nearley
  1. Create .parcelrc next to your package.json, with the following content in it:
{
  "extends": "@parcel/config-default",
  "transformers": {
    "*.ne": ["parcel-transformer-nearley"]
  }
}
  1. Now you can import *.ne files from javascript:
import { default as nearley } from "nearley"

import grammar from "./grammar.ne"

var parser = new nearley.Parser(grammar)

parser.feed("text")
// parser.results[0]
// ...
  1. If you use TypeScript, you'll want to install @types/nearley and add a module type declaration somewhere in your project:

nearley.d.ts

declare module "*.ne" {
    const value: nearley.Grammar
    export default value
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.5
    1
    • latest

Version History

Package Sidebar

Install

npm i parcel-transformer-nearley

Weekly Downloads

6

Version

1.0.5

License

NTP

Unpacked Size

3.53 kB

Total Files

4

Last publish

Collaborators

  • mathieucaroff