parcel-transformer-lezer
v0.2.1
Published
A Parcel transformer for [@lezer/generator](https://github.com/lezer-parser/generator).
Downloads
30
Readme
parcel-transformer-lezer
A Parcel transformer for @lezer/generator.
Usage:
Install this package and some Lezer packages that will be imported by the generated code
yarn add -D @parcel/config-default parcel-transformer-lezer
yarn add @lezer/common @lezer/lr
Add a .parcelrc
with
{
"extends": "@parcel/config-default",
"transformers": {
"*.grammar": ["parcel-transformer-lezer"]
}
}
Then import it from Javascript.
import { parser } from "./foo.grammar";
let tree = parser.parse("...");
parser
is an instance of LRParser
. Apart from this method, there is also an export for each grammar term mapping to its id.
See the example
folder for a complete example.
You can put this somewhere to make Typescript happy:
declare module "*.grammar" {
import type { LRParser } from "@lezer/lr";
export const parser: LRParser;
}