MCPcopy Index your code
hub / github.com/kach/nearley

github.com/kach/nearley @main sqlite

repository ↗ · DeepWiki ↗
101 symbols 207 edges 35 files 0 documented · 0% 2 cross-repo links
README

nearley ↗️

JS.ORG npm version

nearley is a simple, fast and powerful parsing toolkit. It consists of: 1. A powerful, modular DSL for describing languages 2. An efficient, lightweight Earley parser 3. Loads of tools, editor plug-ins, and other goodies!

nearley is a streaming parser with support for catching errors gracefully and providing all parsings for ambiguous grammars. It is compatible with a variety of lexers (we recommend moo). It comes with tools for creating tests, railroad diagrams and fuzzers from your grammars, and has support for a variety of editors and platforms. It works in both node and the browser.

Unlike most other parser generators, nearley can handle any grammar you can define in BNF (and more!). In particular, while most existing JS parsers such as PEGjs and Jison choke on certain grammars (e.g. left recursive ones), nearley handles them easily and efficiently by using the Earley parsing algorithm.

nearley is used by a wide variety of projects:

nearley is an npm staff pick.

Documentation

Please visit our website https://nearley.js.org to get started! You will find a tutorial, detailed reference documents, and links to several real-world examples to get inspired.

Contributing

Please read this document before working on nearley. If you are interested in contributing but unsure where to start, take a look at the issues labeled "up for grabs" on the issue tracker, or message a maintainer (@kach or @tjvr on Github).

nearley is MIT licensed.

A big thanks to Nathan Dinsmore for teaching me how to Earley, Aria Stewart for helping structure nearley into a mature module, and Robin Windels for bootstrapping the grammar. Additionally, Jacob Edelman wrote an experimental JavaScript parser with nearley and contributed ideas for EBNF support. Joshua T. Corbin refactored the compiler to be much, much prettier. Bojidar Marinov implemented postprocessors-in-other-languages. Shachar Itzhaky fixed a subtle bug with nullables.

Citing nearley

If you are citing nearley in academic work, please use the following BibTeX entry.

@misc{nearley,
    author = "Kartik Chandra and Tim Radvan",
    title  = "{nearley}: a parsing toolkit for {JavaScript}",
    year   = {2014},
    doi    = {10.5281/zenodo.3897993},
    url    = {https://github.com/kach/nearley}
}

Core symbols most depended-on inside this repo

rule
called by 42
examples/old-language-specification.js
parse
called by 39
test/_shared.js
compile
called by 29
test/_shared.js
m
called by 17
examples/old-language-specification.js
nspace
called by 10
test/profile.js
externalNearleyc
called by 9
test/external.js
produceRules
called by 8
lib/compile.js
unique
called by 7
lib/compile.js

Shape

Function 101

Languages

TypeScript100%

Modules by API surface

lib/compile.js13 symbols
lib/nearley.js9 symbols
lib/unparse.js7 symbols
lib/generate.js6 symbols
examples/js/numberstring.js6 symbols
test/_shared.js5 symbols
examples/js/csv.js5 symbols
test/nearleyc.test.js4 symbols
test/bootstrap.test.js4 symbols
lib/nearley-language-bootstrapped.js4 symbols
examples/railroad-experimental/custom-canvas.js4 symbols
test/external.js3 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

@types/moo0.3.0 · 1×
@types/node7.0.27 · 1×
babel-cli6.18.0 · 1×
babel-preset-env1.6.0 · 1×
benchr3.2.0 · 1×
coffee-script1.10.0 · 1×
commander2.19.0 · 1×
doctoc1.3.0 · 1×
expect1.20.2 · 1×
handlebars4.0.10 · 1×
http-server0.12.3 · 1×
metalsmith2.3.0 · 1×

For agents

$ claude mcp add nearley \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact