Skip to content
forked from kach/nearley

πŸ“œπŸ”œπŸŒ² Simple, fast, powerful parser toolkit for JavaScript.

License

Notifications You must be signed in to change notification settings

oguimbal/nearley

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

This is only a Deno-compatible version of nearley

⚠ It only includes the nearley parser. Not the compiler.

In order to compile your .ne files, you'll have to install the nearley npm package, and follow instructions as if you were running node.

Usage

First, you'll have to compile your grammar

npm install nearley -D
nearleyc my-grammar.ne -o my-compiled-grammar.ts

⚠ You grammar MUST compile to Typescript. To do so, include @preprocessor typescript on top of it.

nb: If you use Moo as a lexer, do it like that:

@{%

import * as moo from "https://deno.land/x/moo@0.5.1-deno.2/mod.ts";

// unfortunately, there will be a typescript error if you dont cast it to any :(
let lexer: any = moo.compile({
    // you lexer
})

%}

@lexer lexer

Then, you can use it in Deno:

import { Parser, Grammar } from "https://deno.land/x/nearley@2.19.7-deno/mod.ts";

import myCompiledGrammar from './my-compiled-grammar.ts';

const grammar = Grammar.fromCompiled(myCompiledGrammar);
const parser = new Parser(grammar);

// use it as you would with node
parser.feed('some valid text');

About

πŸ“œπŸ”œπŸŒ² Simple, fast, powerful parser toolkit for JavaScript.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.5%
  • TypeScript 0.5%