1.0.5 • Published 2 years ago

parcel-transformer-nearley v1.0.5

Weekly downloads
-
License
NTP
Repository
github
Last release
2 years ago

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
}
1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago