Compiler, linter and formatter for the Hogget programming language
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src refactor(cli): Renamed hogget:hgg, execute:evaluate Feb 16, 2019
test feat: Implemented expressions, function calls and int+str literals Dec 18, 2018
.nvmrc feat: Str now uses single quotes Dec 20, 2018
.travis.yml chore: Added travis badge Dec 20, 2018
cli.js
index.js refactor(cli): Renamed hogget:hgg, execute:evaluate Feb 16, 2019
package.json refactor(cli): Renamed hogget:hgg, execute:evaluate Feb 16, 2019
readme.md

readme.md

Hogget compiler

Build Status

Installation

Requires Node.js v4 or higher. This package has no dependencies.

npm install hogget --global
hgg --version

Compiling

The Hogget compiler needs an input and output to run. To run from the terminal:

hgg --input program.hgg --output program.hgg.js

or, more concisely:

hgg -i program.hgg -o program.hgg.js

To run programatically from Node.js:

import hogget from 'hogget'
const hoggetString = "log('the answer is ' add(12 30))"
console.log(hogget(hoggetString))

The hogget package also exports a parse and an execute method.

Interpreter mode: compile + evaluate

To run from the terminal, either the --evaluate or -e option must be used:

hgg --evaluate --input program.hgg

To run programatically from Node.js:

import { execute } from 'hogget'
const hoggetString = "log('the answer is ' add(12 30))"
execute(hoggetString)

Linting

To run from the terminal, either the --lint or -l option must be used:

hgg --lint --input program.hgg

To run programatically from Node.js:

import { lint } from 'hogget'
const hoggetString = 'let myAdd = (a b) => { let result = add(a b); result; };'
console.log(lint(hoggetString))

Formatting

To run from the terminal, either the --format or -f option must be used:

hgg --format --input program.hgg --output program.hgg

To run programatically from Node.js:

import { format } from 'hogget'
const hoggetString = 'let myAdd = (a b) => { let result = add(a b); result; };'
console.log(format(hoggetString))