2.0.0 • Published 9 months ago

@qrvey/formula-lang v2.0.0

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
9 months 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.565

9 months ago

1.0.1

2 years ago

1.0.0

2 years ago

2.0.1-rc.461

2 years ago

2.0.1-rc.464

2 years ago

2.0.1-rc.420

2 years ago

2.0.1-rc.463

2 years ago

2.0.1-rc.422

2 years ago

2.0.1-rc.542

2 years ago

2.0.1-rc.502

2 years ago

2.0.1-rc.425

2 years ago

2.0.1-rc.506

2 years ago

2.0.1-rc.429

2 years ago

2.0.0

2 years ago

2.0.1-rc.part-5

2 years ago

2.0.1-rc.511

2 years ago

2.0.1-rc.434

2 years ago

2.0.1-rc.514

2 years ago

2.0.1-rc.439

2 years ago

1.1.0

2 years ago

2.0.1-rc.442

2 years ago

2.0.1-rc.523

2 years ago

2.0.1-rc.525

2 years ago

2.0.1-rc.409

2 years ago

2.0.1-rc.491

2 years ago

2.0.1-rc.450

2 years ago

2.0.1-rc.411

2 years ago

2.0.1-rc.498

2 years ago

2.0.1-rc.533

2 years ago

2.0.1-rc.456

2 years ago

2.0.1-rc.415

2 years ago

2.0.1-rc.458

2 years ago

2.0.1-rc.414

2 years ago

2.0.1-rc.537

2 years ago

2.0.1-rc.418

2 years ago

0.8.9

2 years ago

0.8.8

2 years ago

0.8.5

2 years ago

0.8.4

2 years ago

0.8.7

2 years ago

0.8.14-internal

2 years ago

0.8.6

2 years ago

2.0.0-post-mvp

2 years ago

0.11.0

2 years ago

0.11.1

2 years ago

0.11.2

2 years ago

0.11.3

2 years ago

0.11.4

2 years ago

0.11.5

2 years ago

0.8.12-internal

2 years ago

0.9.0

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.7.0

2 years ago

0.9.3

2 years ago

0.8.11-internal

2 years ago

0.8.12

2 years ago

0.8.11

2 years ago

0.8.10

2 years ago

0.10.0

2 years ago

0.8.13-internal

2 years ago

0.8.10-internal

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.8.3

2 years ago

0.8.2

2 years ago

0.6.0

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago