WS2JS

convert Whitespace to JavaScript

Document

We need your help.

Syntax
jscode = WS2JS.convert(code [, complete, toASCII]);
Parameters
  • jscode is a string containing the JavaScript code converted from Whitespace code.
  • code is a string of Whitespace code.
  • complete is a boolean value. If you want to execute the code in environment which is not defined WS2JS, set true.
  • toASCII is a boolean value. If labels in Whitespace code is written by ASCII, set true.

When the converted code run, some methods is called. You can modify them.

Then default setting, output methods use document.write, and input methods use window.prompt.

WS2JS.putc(c)
When a character is outputted, this method is called. c is a integer value of character code.
WS2JS.putn(n)
When a number is outputted, this method is called. n is a signed integer value.
WS2JS.getc(callback)
  • When the program gets a integer value of input character code, this method is called.
  • callback is a function object that format is function (c){}.
  • c is a integer value of input character code.
WS2JS.getn(callback)
  • When the program gets a a signed integer of input value, this method is called.
  • callback is function object that format is function (n){}.
  • n is a signed integer value.

When converted code is executed or whitespace code is converted, below a method is called, and exception occurs.

WS2JS.onExit()
When the program finishes, this method is called.
new Error("Invalid character :" + n)
When Whitespace code includes invalid character, this exception occurs. n is invalid character position.
new Error("Invalid label :" + label)
When Whitespace code includes invalid label, this exception occurs.