8.0.0 • Published 6 years ago

microparser v8.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

microparser NPM version Build Status

Generic text parsing library.

Install

Using npm :

npm install microparser --save

Using yarn :

yarn add microparser

Usage

const microparser = require("microparser");

const Parser = microparser.Parser;
const {multiple, not, optional, optmul, or} = microparser.grammarHelpers;
const parser = new Parser();

// The code to parse.
const code = "green, blue and red";

// Grammar definition
const color = or("green", "blue", "red", "yellow");
const separator = g.or(", ", " and ");
const grammar = multiple(color, separator);

// Parsing
const $ = parser.parse(grammar, code);

console.log("\n#### Last color element value ####");
console.log($.children[0].text());
/* Output :
    #### Last color element value ####
    red
*/

A call to parser.parse() returns a (pseudo) DOM node, which allows you to do complex querying and manipulations.

See the tests/examples content for more complex examples.

Author

Simon Robert

License

Copyright © Simon Robert

Released under the MIT license.

8.0.0

6 years ago

7.0.2

7 years ago

7.0.1

7 years ago

7.0.0

7 years ago

6.1.0

8 years ago

6.0.1

8 years ago

6.0.0

8 years ago

5.0.3

9 years ago

5.0.2

9 years ago

5.0.1

9 years ago

4.0.1

9 years ago

3.0.3

10 years ago

3.0.2

10 years ago

3.0.1

10 years ago

3.0.0

10 years ago

2.0.0

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago