Giter Site home page Giter Site logo

morpheu5 / inequality-grammar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from isaacphysics/inequality-grammar

0.0 0.0 0.0 867 KB

A grammar for Inequality, the symbolic equation editor.

License: Apache License 2.0

JavaScript 16.42% Nearley 83.58%

inequality-grammar's Introduction

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.

inequality-grammar's People

Contributors

morpheu5 avatar jsharkey13 avatar chrisjpurdy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.