Skip to content
This repository has been archived by the owner on May 3, 2020. It is now read-only.
/ bavary Public archive

🧬 Regular expressions on steroids. Parse anything and everything with a syntax - crafted to parse syntax. A super-set of regular-expressions.

License

Notifications You must be signed in to change notification settings

simonwep/bavary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo


gzip size brotli size Coverage Status Build Status Download count Current version Support me

Checkout related packages

Getting Started

âš  Bavary is currently not stable and heavily under development. The API might change and all 0.0.x releases should be treated as test / preview releases.

Install via npm:

$ npm install @bavary/core

Install via yarn:

$ yarn add @bavary/core

Include directly via jsdelivr:

<script src="https://cdn.jsdelivr.net/npm/@bavary/core/lib/bavary.js"></script>

Usage

import {compile} from '@bavary/core';

// Compile definitions
const parse = compile(`['A' | 'B']`);

// Use compiled definitions to parse a string
const parsed = parse('A');

// Logs "A" to the console
console.log(parsed);

The function compile accepts as second argument a config object.

Compiling in chunks

It's possible to (re-)compile just parts of your entire code-base to speed up the process:

import {compile, compileChunk,} from '@bavary/core';
const entry = compileChunk(`entry [<abc>]`);
const abc = compileChunk(`<abc> = [(a - c)+]`);
const parse = compile([...entry, ...abc]);

console.log(parse('aabbccc')); // Prints 'aabbccc'

What's next?

Check out the documentation to get started or jump directly into one of the examples:

  1. string - Parsing strings and support escaped quotes.
  2. hex-color - Parsing different kinds of color types in the hexadecimal format.
  3. number - Parsing floats and integers with optional scientific notation.

Related packages

About

🧬 Regular expressions on steroids. Parse anything and everything with a syntax - crafted to parse syntax. A super-set of regular-expressions.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published