Skip to content

DaBisounours/dvm-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Logo

dvm-utils

Toolset to parse and generate DVM code
Report Bug · Request Feature

About The Project

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.

Built With

Getting Started

This package is written in Typescript and can be used in any Node or browser app.

Prerequisites

  • npm or yarn

Installation

  • Install package
    # with NPM
    npm install dvm-utils
    # with yarn
    yarn add dvm-utils

(back to top)

Usage

  • 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

(back to top)

  • Generate code from the Program data 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
});

Roadmap

  • 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).

(back to top)

Contact

Project Link: https://github.com/DaBisounours/dvm-utils

(back to top)

About

Toolset to parse and generate DVM code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published