Checkout related packages
âš 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>
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.
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'
Check out the documentation to get started or jump directly into one of the examples:
- string - Parsing strings and support escaped quotes.
- hex-color - Parsing different kinds of color types in the hexadecimal format.
- number - Parsing floats and integers with optional scientific notation.
- @bavary/core - Parser and compiler.
- @bavary/cli - CLI with development server.
- @bavary/bavary-lib - Standard library with extensions for bavary.
- @bavary/webpack-loader - Webpack loader for declaration files.