0.12.1 • Published 4 years ago

math-compiler v0.12.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Quick Start

const compiler = require('math-compiler')

// compiling
const { compile } = compiler

compile.list // [ 'basic-infix -> basic-prefix', 'basic-infix -> basic-postfix' ]
compile('basic-infix', 'basic-postfix', 'a + b^(c - d)')) // 'a b c d - ^ +'

// lexing
const { lex } = compiler

lex.list // [ 'basic-infix', 'basic-prefix', 'basic-postfix' ]
lex('basic-infix', 'a + b^(c - d)') // [ IdentifierToken { value: 'a' }, OperatorToken { value: '+' }, ... ]

// parsing
const { parse } = compiler

parse.list // [ 'basic-infix', 'basic-prefix', 'basic-postfix' ]
parse('basic-infix', 'a + b^(c - d)') // OperationNode { operator: '+', ... }

// transforming
const { transform } = compiler

transform.list // [ 'basic-infix', 'basic-prefix', 'basic-postfix' ]
transform('basic-infix', OperationNode) // AST (abstract syntax tree)

// generating
const { generate } = compiler

generate.list // [ 'basic-infix', 'basic-prefix', 'basic-postfix' ]
generate('basic-infix', AST) // 'a + b ^ ( c - d )'

Formats

KeyFormat
'basic-infix'Basic infix (1)
'basic-prefix'Basic prefix (Polish) (1)
'basic-postfix'Basic postfix (reverse Polish) (1)
'exomath'Exomath
'mathcad-prefix'Mathcad Prime's internal prefix notation

Notes

  1. Formats with the prefix "basic" have limited functionality and are for educational purposes only.

Compilers

fromto
'basic-infix''basic-prefix'
'basic-infix''basic-postfix'
'basic-infix''exomath'
'basic-infix''mathcad-prefix'
'basic-prefix''basic-postfix'
'basic-prefix''exomath'
'basic-prefix''mathcad-prefix'
'basic-postfix''basic-prefix'
'basic-postfix''exomath'
'basic-postfix''mathcad-prefix'
'exomath''mathcad-prefix'
'mathcad-prefix''exomath'

Lexers

from
'basic-infix'
'basic-prefix'
'basic-postfix'
'exomath'
'mathcad-prefix'

Parsers

from
'basic-infix'
'basic-prefix'
'basic-postfix'
'exomath'
'mathcad-prefix'

Transformers

from
'basic-infix'
'basic-prefix'
'basic-postfix'
'exomath'
'mathcad-prefix'

Generators

to
'basic-prefix'
'basic-postfix'
'exomath'
'mathcad-prefix'

Future Formats

KeyFormat
'mathcad-xml'Mathcad Prime's internal XML notation
'mathjs'math.js
'matlab'MATLAB
'octave'GNU Octave

Installation

NPM

$ npm i math-compiler

Yarn

$ yarn add math-compiler
0.12.1

4 years ago

0.12.0

4 years ago

0.11.0

4 years ago

0.10.0

4 years ago

0.9.0

4 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago