1.3.0 • Published 2 years ago

logic-parsers v1.3.0

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

Wasm bindings for the logic-parser

Wasm bindings for the ../logic-parser written in Rust.

Packaging and publishing was achieved thanks to wasm-bindgen!

npm install logic-parsers

Usage

const { parse_expression, generate_svg } = await import('logic-parsers');

const parsed = parse_expression("((p || q)) => (q && ~(r))");

Outputs:

{
    "status": "success",
    "ast": {
        "type": "operator.implies",
        "left": {
            "type": "operator.or",
            "left": {
                "type": "identifier",
                "name": "p"
            },
            "right": {
                "type": "identifier",
                "name": "q"
            }
        },
        "right": {
            "type": "operator.and",
            "left": {
                "type": "identifier",
                "name": "q"
            },
            "right": {
                "type": "operator.not",
                "operand": {
                    "type": "identifier",
                    "name": "r"
                }
            }
        }
    }
}

SVG tree rendering:

const svg_xml = generate_svg(parsed.ast);
document.querySelector("#output").innerHTML = svg_xml;

SVG Result

1.2.3

2 years ago

1.3.0

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.0.1

2 years ago

0.1.0

2 years ago