Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simenkid/dissolve-chunks
A declarative parser generator based on dissolve.
https://github.com/simenkid/dissolve-chunks
Last synced: 3 months ago
JSON representation
A declarative parser generator based on dissolve.
- Host: GitHub
- URL: https://github.com/simenkid/dissolve-chunks
- Owner: simenkid
- License: other
- Created: 2015-09-17T12:32:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-20T06:33:27.000Z (about 8 years ago)
- Last Synced: 2024-09-20T03:42:36.644Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 34.2 KB
- Stars: 10
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dissolve-chunks
A declarative parser generator based on dissolve.[![Travis branch](https://img.shields.io/travis/simenkid/dissolve-chunks/master.svg?maxAge=2592000)](https://travis-ci.org/simenkid/dissolve-chunks)
[![npm](https://img.shields.io/npm/v/dissolve-chunks.svg?maxAge=2592000)](https://www.npmjs.com/package/dissolve-chunks)
[![npm](https://img.shields.io/npm/l/dissolve-chunks.svg?maxAge=2592000)](https://www.npmjs.com/package/dissolve-chunks)
## DocumentationPlease visit the [Wiki](https://github.com/simenkid/dissolve-chunks/wiki).
## Overview
With dissolve-chunks (**DChunks**), you can make a parser by defining the parsing rules for each chunk of the binaries. This means that you need not to write your parsing codes from the beginning to the end of the binaries. You can separate the targeting data into smaller chunks, and then define the parsing rules for each of them. After all rules are ready, you can call the chainable method **join()** to sequentially connect all your rules . Finally, just call **compile()** to get your parser.
Here is an pseudo example:
```javascript
var chunk1_rules = [ rule1, rule2, rule3 ],
chunk2_rules = [ rule4, squash([ rule5_1, rule5_2 ]) ],
chunk3_rule = squash([ rule6, rule7 ]),
chunk4_rule = rule8,
chunk5_rule = squash('key_name', [ rule9, rule10 ]);var parser = DChunks().join(chunk1_rules).join(chunk2_rules)
.join(chunk3_rule).join(chunk4_rule)
.join(chunk5_rule).compile();parser.on('parsed', function (result) {
console.log(result);
});
```
## Features
* Making your parser in a declarative way.
* More manageable by cutting the targeting data into smaller chunks and defining the rules for each of them.
* You can squash some rules into a single rule by using `squash([name,] rules)`. If `name` is specified while squashing, the **DChunks** will automatically put the parsed result under that namespace. It's handy.
* Making a parser is mostly just about declaring rules. Integrating and compiling the parsing rules is easy.
## Installation
> $ npm install dissolve-chunks --save
## Usage
See [Usage](https://github.com/simenkid/dissolve-chunks/wiki#Usage) on the Wiki.
## License
Licensed under [MIT](https://github.com/simenkid/dissolve-chunks/blob/master/LICENSE).