Skip to content
/ peq Public

JavaScript parsing expressions query library

License

Notifications You must be signed in to change notification settings

ralekna/peq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PEQ - JavaScript Parsing Expressions Query library

alt Build status

This library aims to provide a parser generator functionality of PEG.js but in a way where your constructed grammar is a parser itself instead of generating some human unreadable code. Like with jQuery you can query HTML DOM elements, with PEQ provided matchers you can query a string and transform it to any other data structure.

Usage

Installation

npm i peq

Usage in Node.js

const {grammar, one, oneOf, all, any, not, optional, oneOrMore} = require("peq");

console.log(all([`"`, {name: 'text', matcher: any(/[a-z]/) }, `"`], (all, {text}) => text.join(''))(`"asd"`));
// ^ this will output ['asd', '']

As there's still no more documentation yet, please check examples folder

ToDo

  • Setup CI
  • Add examples in code
  • Add simple usage documentation
  • Research if there's any missing quantifiers
  • Add more human readable CS theory to documentation
  • Try more grammars
  • Convert code to TypeScript

Contribution and issues

Just open a ticket in Github

Licence

This work is licensed under Apache 2.0 open source license.

Releases

No releases published

Packages

No packages published