Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mathieucaroff/parcel-transformer-nearley
Parcel transformer plugin for importing nearley grammars as instances
https://github.com/mathieucaroff/parcel-transformer-nearley
grammar nearley parcel transformer
Last synced: 5 days ago
JSON representation
Parcel transformer plugin for importing nearley grammars as instances
- Host: GitHub
- URL: https://github.com/mathieucaroff/parcel-transformer-nearley
- Owner: mathieucaroff
- License: other
- Created: 2022-02-14T11:16:36.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-03-01T23:26:45.000Z (over 2 years ago)
- Last Synced: 2024-08-09T08:51:26.066Z (3 months ago)
- Topics: grammar, nearley, parcel, transformer
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/parcel-transformer-nearley
- Size: 12.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/adam1658/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
```2. Create `.parcelrc` next to your `package.json`, with the following content in it:
```json
{
"extends": "@parcel/config-default",
"transformers": {
"*.ne": ["parcel-transformer-nearley"]
}
}
```3. Now you can import `*.ne` files from javascript:
```js
import { default as nearley } from "nearley"import grammar from "./grammar.ne"
var parser = new nearley.Parser(grammar)
parser.feed("text")
// parser.results[0]
// ...
```4. If you use TypeScript, you'll want to install `@types/nearley` and add a module type declaration somewhere in your project:
`nearley.d.ts`
```ts
declare module "*.ne" {
const value: nearley.Grammar
export default value
}
```