npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vultlib

v0.4.15

Published

A node.js module providing all the functionality of the Vult compiler.

Downloads

99

Readme

Vult

A node.js module providing all the functionality of the Vult compiler. For the command line application install vult.

You can find the full project in https://github.com/modlfo/vult

Tutorials and documentation can be found the main site http://modlfo.github.io/vult/

Usage

var vult = require('vultlib')

// Example to generate C/C++ code
var result = vult.generateC([{ file : 'test.vult', code : 'fun foo() return 0;' }], { output : "Test" });

API

Types (description of the objects)

Input and output files

Files are represented with an object containing the fields file and (optionally) code.

input_file =
   {
      file : String, // required
      code : String  // optional
   }

For example:

var test1 = { file : 'test.vult', code : 'fun foo() return 0;' }

test is an input file that provides it's contents and there's no need to read it.

Contrary to:

var test2 = { file : 'test.vult' }

when test2 is given as input, the file 'test.vult' will be read from the file system.

The generated code is returned in the same form:

{
   file : "foo.cpp",      // File name or extension
   code : ".. my code .." // Generated code
}

Code generation options

This object is expected by all function that generate code (Js, C++, or Lua).

options =
   {
      output   : String,
      real     : String,
      template : String,
      includes : String Array
   }

All the fields are optional. For example:

var options = { output : 'Main', real : 'fixed', includes = ['/home/leonardo'] }

These options correspond to the command line options shown in Command Line Options.

Errors

When errors in the code are found they are returned in the following form:

error =
   {
      msg  : String,
      file : String,
      line : Number,
      col  : Number
   }

For example:

Methods

version()

Returns a string with the version of the compiler

generateC(files, options)

generateJs(files, options)

generateLua(files, options)

Takes an array of input files and options and generates the corresponding code.

The input and output files are in the form described above ({ file : 'name'} or { file : 'name', code : '...' }).

The options are described above as well.

IMPORTANT: if no special options are required you need to pass an empty object {}.

The output will be either an array of output file objects or an array of errors.

Examples

// Read the file 'test.vult' and generate C code
var result1 = vult.generateC([{ file : 'test.vult'}], {});

// Generate C code out of the given input vult code
var result2 = vult.generateC([{ file : 'test.vult', code : "fun foo() return "}], {});

// Printing 'result2' will show:
console.log(result2);
/*
[ { file: '.h',
    code: '#ifndef VULT_H\n#define VULT_H\n#include <stdint.h>\n#include <math.h>\n#include "vultin.h"\n\nint Live_foo();\n\n\n\n#endif // VULT_H\n' },
 { file: '.cpp',
    code: '#include "Vult.h"\n\nint Live_foo(){\n   return 0;\n}\n\n\n' } ]
*/

// The input code has an error
var errors = vult.generateC([ { code : "fun foo() { return 0;", file : "test.vult" } ], {})

// The result will be instead:
console.log(errors);
/*
[ { msg: 'Expecting a \'}\' but the file ended\nfun foo() { return 0; \n                     ^\n',
    file: '',
    line: 1,
    col: 21 } ]
*/