1.5.0 • Published 4 years ago

schemelang v1.5.0

Weekly downloads
18
License
MIT
Repository
github
Last release
4 years ago

Scheme Lang (schemelang)

NodeJS Scheme language interpreter

basic usage

Simply create a new Scheme environnement and use its interpreter method

// ---------

const SchemeLang = require('schemelang')
var my_scheme_env = new SchemeLang()

// ---------

const scheme = my_scheme_env.interpret

// ---------

scheme("(define a 5)")
console.log(scheme("a"))
// -> 5

scheme("(define func (lambda (a b) (+ a b)))")
console.log(scheme("(func 5 3)"))
// -> 8

accessible methods

The schemelang module also gives you access to the parse and handle methods.

  • The parse method transforms string commands into JSON arrays
    const parse = new (require('schemelang'))().parse
    
    let command_array = parse("(define a 5)")
    console.log(command_array)
    // -> ["define", "a", 5]
  • The handle method uses the command array to execute scheme commands

    const handle = new (require('schemelang'))().handle
    
    handle(["define", "a", ["+", 1, 3]])
    let result = handle("a")
    console.log(result)
    // -> 4
  • The interpret method uses the two above methods to parse and handle string scheme commands

    const interpret = new (require('schemelang'))().interpret
    
    interpret('(define a (+ 1 7))')
    let result = interpret('a')
    console.log(result)
    // -> 8
1.5.0

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.1.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

0.1.1

4 years ago

1.0.0

4 years ago