cadence-parser
v1.0.1
Published
The Cadence parser
Downloads
4
Readme
Cadence Parser
The Cadence parser compiled to WebAssembly and bundled as an NPM package, so it can be used in tools written in JavaScript.
Usage
Broswer
import { CadenceParser } from "@onflow/cadence-parser"
const parser = await CadenceParser.create("cadence-parser.wasm")
const ast = parser.parse(`
pub contract HelloWorld {
pub fun hello() {
log("Hello, world!")
}
}
`)
Node.js
const { CadenceParser } = require("@onflow/cadence-parser");
const fs = require("fs");
const path = require("path");
(async () => {
const parser = await CadenceParser.create(
await fs.promises.readFile(
path.join(
__dirname,
"./node_modules/@onflow/cadence-parser/dist/cadence-parser.wasm"
)
)
);
const ast = parser.parse(`
pub contract HelloWorld {
pub fun hello() {
log("Hello, world!")
}
}
`);
})();