EsoKit/EsoKit.nsi.io

From Esolang
Jump to navigation Jump to search
Back to EsoKit

EsoKit.nsi.io is an EsoKit nonstandard interface designed to allow languages such as brainfuck that are severely limited in their capabilities, to the degree of being able to do nothing to interact with extra-program things beyond input and output, to do things like socketry and file IO. Generally, EsoKit.nsi.io will need to be built in to the interpreter, as languages like brainfuck that are limited to this degree tend to lack library support.

Interaction

To interact with EsoKit via EsoKit.nsi.io, data needs to be sent to the standard output to trigger an event, and return values are sent to the standard input as requested with a null terminator. This means that, if an EsoKit function is called in brainfuck that returns the string "walrus", the next six calls to , (brainfuck's getch() command) will return "w", "a", "l", "r", "u", and "s" in that order. The next call to , will return \0 (the null terminator) to alert to the program that the return string is over.

Messages are passed in the following manner:

  • When the EsoKit.nsi.io layer is told to print, it first checks if the character it is told to print is a < (ASCII 0x3C) AND that it is not in "escape" mode. If so, it flips on a boolean putting it into "checking" mode.
    • Once in checking mode, it stops printing until it encounters the > character (ASCII 0x3E) while not in escape mode.
      • Once it has finished the <...> string, it lexes it. It does this by splitting it by the first : (ASCII 0x3A) and then splitting the second value by spaces that are NOT enclosed in unescaped quotes.
      • It then passes the string arguments to the proper function, as indicated by the string before the :
  • Else, if it encounters a backslash and is not in escape mode, it enters escape mode.
  • Else, if it is in escape mode or the character is not a special character, it prints the character and sets escape mode to off.

In other words...

An "execution string" is a string in the code that is delimited by a <. and a > These can be escaped by backslashes to not start or terminate an execution string, and backslashes can be escaped by other backslashes. An execution string is a command, a colon, then a set of arguments separated by spaces. These arguments can contain spaces if delimited by double quotes. Double quotes can be escaped by backslashes, which can be escaped by backslashes, and so on. Strings can contain special characters, such as newlines, simply by putting them between the quotes (just like in LISP).

Commands

Commands are the things before the : in an execution string. They are typically of the form lib.sublib*.command, but can technically be anything. They are followed by a colon, then by space-separated quotable/escapable arguments.


EsoKit.nsi.io.err

EsoKit.nsi.io.err is a variation on EsoKit.nsi.io that is nearly identical in every way, save for one minor difference: messages are passed to the interface through the stderr as opposed to the stdout. Otherwise, they are indistinguishable.