- Notifications
You must be signed in to change notification settings - Fork1
LeetCode-OpenSource/nearley-loader
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This package is a standardwebpack loaderwhich allows you to loadnearleyparser specification files as parser rules directly from webpack.
This branch contains support for the latest nearley version, currentlynearley@^2.0.0. Fornearlet@^1.0.0 check thenearley1 branch in thisrepo.
You need to install bothnearley andnearley-loader, sincenearley is apeer dependency of this package. The major version of thenearley-loaderpackage must match the installed version ofnearley, so if you installnearley@2.13.0, then you need to installnearley-loader@^2.0.0.
Just configure webpack to handle nearley files with this loader:
module:{rules:[{test:/\.nearley$/,use:['nearley-loader',],},]}
If using withcreate-react-app or any other pre-configured webpack, be surethat the.ne extension (or whatever file extension you use above) is notaffected by another loader. For instance,create-react-app will apply aurl-loader to any file extension it doesn't recognize.
Once you've done that, you can now require nearley files in your javascriptmodules and you'll get the compiled parser rules:
import{Parser,Grammar}from'nearley';importgrammarfrom'./grammar.ne';constparser=newParser(Grammar.fromCompiled(grammar));
MIT License
Copyright (c) 2016 Kozily
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.
About
Compiles a grammar from a nearley grammar file.
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Languages
- JavaScript76.6%
- Dockerfile23.4%