https://github.com/ralekna/peq
JavaScript parsing expressions query library
https://github.com/ralekna/peq
api generator javascript parser peg pegjs
Last synced: about 1 year ago
JSON representation
JavaScript parsing expressions query library
- Host: GitHub
- URL: https://github.com/ralekna/peq
- Owner: ralekna
- License: other
- Created: 2019-08-07T13:17:40.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T18:22:47.000Z (over 3 years ago)
- Last Synced: 2025-03-04T07:40:33.168Z (about 1 year ago)
- Topics: api, generator, javascript, parser, peg, pegjs
- Language: JavaScript
- Homepage:
- Size: 121 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PEQ - JavaScript *P*arsing *E*xpressions *Q*uery library
[](https://travis-ci.com/ralekna/peq)
This library aims to provide a parser generator functionality of [PEG.js](https://github.com/pegjs/pegjs)
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
```javascript
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](https://github.com/ralekna/peq/tree/master/src/examples)
## ToDo
- [x] Setup CI
- [x] 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](https://opensource.org/licenses/Apache-2.0) open source license.