This tool helps typescript developpers parse and generate DVM-BASIC code. DVM-BASIC is the language used by the Dero Virtual Machine on the DERO blockchain.
(website)
This package is written in Typescript and can be used in any Node or browser app.
npmoryarn
- Install package
# with NPM npm install dvm-utils# with yarn yarn add dvm-utils
- Parse a DVM-BASIC program :
import { parse } from 'dvm-utils'
import { Program } from 'dvm-utils/src/types/program'
const code: string = `
Function Initialize() Uint64
10 RETURN 0
End Function
`;
const program: Program = parse(code);
console.log(program)WIP: build a program and generate code. Check out src/tests folders for undocumented examples
- Generate code from the
Programdata structure
import { generate } from "dvm-utils";
import { Program, FunctionType, DVMType } from "dvm-utils/src/types/program";
import { return_value } from "dvm-utils/src/lib/build";
const initializeFunction: FunctionType = {
name: "Initialize",
return: DVMType.Uint64,
args: [],
statements: [return_value(0, 10)],
};
const program: Program = {
functions: [initializeFunction],
};
const { code } = generate(program);
console.log({ code });should output
Function Initialize() Uint64
10 RETURN 0
End Function- Generation options
const { code } = generate(program, {
minify: false, // Minifies the variable/function names. Makes the code harder to read.
optimizeSpace: true, // Removes any unnecessary space
comments: false, // Leaves comments in the code
});- Parsing DVM-BASIC code
- Program building utilities
- Generate code from a Program
See the open issues for a full list of proposed features (and known issues).
Project Link: https://github.com/DaBisounours/dvm-utils