1.1.1 • Published 3 months ago

inequality-grammar v1.1.1

Weekly downloads
9
License
Apache-2.0
Repository
github
Last release
3 months ago

Inequality grammar

A grammar to parse linear-text maths and boolean expressions, and produce an AST that Inequality can digest.

Usage

npm i --save inequality-grammar
import { parseMathsExpression } from 'inequality-grammar';

// Use parseBooleanExpression for Boolean algebra.
try {
    const output = parseMathsExpression(this.mathInput);
    enjoy(output);
} catch (error) {
    // Handle error
}

Documentation

This parser turns linear-text maths and boolean expressions into the left-to-right AST format used by Inequality. For more information on the AST, please refer to Inequality's documentation.

This parser is based on nearley.js, a parser toolkit for JavaScript. Nearley uses the Earley algorithm plus clever optimizations to process expressions with high efficiency and low computational effort -- if the grammar rules are specified the right way.

The two grammars are found in the assets folders and contain inline documentation. Some of the processing functions may seem complicated but this is primarily due to the left-to-right nature of the AST they need to produce. Keeping track of the tokens produced by each rule is essential to understand the processing functions, but not the easiest thing. Take it slowly and everything will eventually make sense.

1.1.1

3 months ago

1.1.0

1 year ago

1.0.0

2 years ago

0.11.0

2 years ago

0.10.3

4 years ago

0.10.2

4 years ago

0.10.1

4 years ago

0.10.0

4 years ago

0.9.11

4 years ago

0.9.10

4 years ago

0.9.9

4 years ago

0.9.8

4 years ago

0.9.7

4 years ago

0.9.6

5 years ago

0.9.5

5 years ago

0.9.4

5 years ago

0.9.3

5 years ago

0.9.2

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago