2.0.0 • Published 1 year ago

@qrvey/formula-lang v2.0.0

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
1 year ago

Qrvey Formula Language

Commitizen friendly

Usage

Transpile function

import { ENGINES, Transpile } from "@qrvey/formula-lang";

const program = "MID(MID(\"This is a test\", 1, 5), 1, 2)"
const transpiled = Transpile(program, ENGINES.ELASTICSEARCH)
console.log(transpiled)

the output will be

'This is a test'.substring(1, 5).substring(1, 2)

TranspileAST function

import { ENGINES, TranspileAST } from "@qrvey/formula-lang";

const ast = {
    "type": "Program",
    "exp": "1 + 2",
    "lang": "QrveyLang",
    "version": "0.0.0",
    "body": {
        "operator": "+",
        "type": "BinaryExpression",
        "left": {
            "type": "Literal",
            "dataType": "number",
            "value": 1
        },
        "right": {
            "type": "Literal",
            "dataType": "number",
            "value": 2
        }
    }
}
const transpiled = TranspileAST(ast, ENGINES.ELASTICSEARCH)
console.log(transpiled)

the output will be

(1 + 2)

codemirror editor

import { EditorState } from "@codemirror/state";
import { basicSetup } from "codemirror";
import { FormulaHighlight, calculateAST } from "@qrvey/formula-lang"

// set the editor state with the QFormula plugin. This adds the support for 
this._state = EditorState.create({
    doc: 'Test formula',
    extensions: [
    basicSetup,
    FormulaHighlight(),
    ...
    ]
})

// On every edit update you can calculate the AST
private dispatchTextUpdate(state: EditorState) {
    const tree = (state as any).tree;
    const text = ((state.doc as any).text as Array<string>).join('\n');
    const ast = calculateAST(text, tree.topNode);
    // dispatch event after return
    return { text, ast }
}
2.0.1-rc.662

1 year ago

2.0.1-rc.665

1 year ago

2.0.1-rc.668

1 year ago

2.0.2

1 year ago

2.0.1-rc.670

1 year ago

2.0.1-rc.622

1 year ago

2.0.1-rc.588

1 year ago

2.0.1-rc.626

1 year ago

2.0.1-rc.629

1 year ago

2.0.1-rc.638

1 year ago

2.0.1-rc.642

1 year ago

2.0.1-rc.646

1 year ago

2.0.1-rc.650

1 year ago

2.0.1-rc.656

1 year ago

2.0.1-rc.659

1 year ago

2.0.1-rc-9.1

1 year ago

2.0.1-rc.565

2 years ago

1.0.1

3 years ago

1.0.0

3 years ago

2.0.1-rc.461

3 years ago

2.0.1-rc.464

3 years ago

2.0.1-rc.420

3 years ago

2.0.1-rc.463

3 years ago

2.0.1-rc.422

3 years ago

2.0.1-rc.542

3 years ago

2.0.1-rc.502

3 years ago

2.0.1-rc.425

3 years ago

2.0.1-rc.506

3 years ago

2.0.1-rc.429

3 years ago

2.0.0

3 years ago

2.0.1-rc.part-5

3 years ago

2.0.1-rc.511

3 years ago

2.0.1-rc.434

3 years ago

2.0.1-rc.514

3 years ago

2.0.1-rc.439

3 years ago

1.1.0

3 years ago

2.0.1-rc.442

3 years ago

2.0.1-rc.523

3 years ago

2.0.1-rc.525

3 years ago

2.0.1-rc.409

3 years ago

2.0.1-rc.491

3 years ago

2.0.1-rc.450

3 years ago

2.0.1-rc.411

3 years ago

2.0.1-rc.498

3 years ago

2.0.1-rc.533

3 years ago

2.0.1-rc.456

3 years ago

2.0.1-rc.415

3 years ago

2.0.1-rc.458

3 years ago

2.0.1-rc.414

3 years ago

2.0.1-rc.537

3 years ago

2.0.1-rc.418

3 years ago

0.8.9

3 years ago

0.8.8

3 years ago

0.8.5

3 years ago

0.8.4

3 years ago

0.8.7

3 years ago

0.8.14-internal

3 years ago

0.8.6

3 years ago

2.0.0-post-mvp

3 years ago

0.11.0

3 years ago

0.11.1

3 years ago

0.11.2

3 years ago

0.11.3

3 years ago

0.11.4

3 years ago

0.11.5

3 years ago

0.8.12-internal

3 years ago

0.9.0

3 years ago

0.9.2

3 years ago

0.9.1

3 years ago

0.7.0

3 years ago

0.9.3

3 years ago

0.8.11-internal

3 years ago

0.8.12

3 years ago

0.8.11

3 years ago

0.8.10

3 years ago

0.10.0

3 years ago

0.8.13-internal

3 years ago

0.8.10-internal

3 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.8.3

3 years ago

0.8.2

3 years ago

0.6.0

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago