Version 0.3. Everything subject to change.
yoob.js is the HTML5 counterpart to yoob.
Like yoob, yoob.js:
- provides a set of components for implementing visual interpreters for esoteric programming languages (esolangs).
- is written amateurishly.
- has an API that is not particularly good, finalized, or stable.
- will eventually ship with some public-domain implementations of some esolangs (but the approach is different from yoob's; see below.)
Unlike yoob, yoob.js:
- is not limited to providing support for esolang interpreters; it might be better described as a set of components for implementing esolangs "and other bizarre things".
- does not support unbounded integer values (yet; see "Planned", below).
- provides components which are meant to be used as starting points for
further modification. (It's all public domain, so build on it!) For
yoob.sexpParseris meant to be used as an example or basis for a specific grammar of your choice.
yoob.js will eventually:
extend the idea of "a component to help implement an esolang" to encompass esolang implementations themselves. So, for example, yoob.js might include an implementation of brainfuck, but this would not be provided solely as an "end implementation" but also as a component for implementing other brainfuck-derived esolangs, and other mashups.
This emphasizes a thing with yoob, which is that while the yoob distribution may contain implementations of various languages, it does not contain the reference implementation of any language; but the reference implementations of some languages may be written in yoob. yoob allows for this approach, but yoob.js hopes to accomodate it better than just allowing for it.
Other things you should know about yoob.js are that it:
- requires features from HTML5 and related "modern" web standards. It does not try to do any feature detection or polyfilling. If it doesn't work in your browser, it doesn't work in your browser. Try another browser.
- does not rely on jQuery (yet) (possibly to its detriment.)
- does not come minified or agglomerated or anything. I mean, this isn't
production web development, we're not trying to optimize page load time
here, we just want to run us some esolangs, right? You're free to do
this yourself. May we suggest
cat yoob/*.js > yoob.js? (Note: there may one day be a small script to do this sort of thing for you, more intelligently, respecting dependencies and whatnot. Especially if you write it and send a pull request.)
Each yoob.js class is defined in its own
.js file, and each
inserts the class it defines into the
yoob namespace (which it will create
as a new, empty, global namespace if it has not already been defined.)
The classes are currently:
A two-dimensional Cartesian grid of values which dynamically expands as needed. It can be associated with a
<canvas>element, on which it will be depicted, which will also dynamically expand as needed. Objects of this class should be suitable for representing programs in two-dimensional esolangs such as Befunge, as well as cellular automata.
A pointer (position vector) into two-dimensional Cartesian space (typically a
yoob.Playfield) which also has a delta (direction vector) which need not necessarily be used.
A crude simulation of a text-based addressable console on a
<canvas>element. Not recommended for serious use; mainly intended to provide a sort of retro feel to input and ouput.
A subclass of
yoob.TextConsolewhich understands some terminal control codes such as newline and backspace.
A crude simulation of a buffer into which the user can type a line of text. Typically it is associated with a
yoob.TextConsoleobject, on which the text is displayed as the user types it.
A (theoretically) unbounded tape, like you'd find on a Turing machine, optionally associated with a
<canvas>on which it is depicted.
An object representing a position on a Tape.
An object implementing a push-down, first-in-first-out stack of values, optionally associated with a
<canvas>on which it is depicted.
A multi-purpose, n-ary tree, with optional node name (String identifier) and payload (arbitrary value.) Children are indexed by integer, 0-based. It's meant to serve two main purposes:
- as an AST (Abstract Syntax Tree) for the (initial) intermediate representation(s) of a program in an interpreter or compiler, in which case the node name is the node type and the payload is anything that might be handy, such as what the tree evaluated to; and
- as terms, roughly as defined in the science of term rewriting. In
this case the node name is the "constructor" and the payload is
probably not used. For this purpose, the
tree.jsmodule should eventually include facilities for matching and unification.
Trees, with only two children, could also be used as lists a la Lisp. In this case the node name and payload would both go unused.
A simple, inefficient lexical analyzer, parameterized with a table of regexps. Can also serve as a starting point for writing your own, less simple, inefficient lexical analyzer.
A simple recursive-descent parser which parses S-expressions. Uses
yoob.Scannerto analyze the input string and
yoob.ASTto create the parsed version. Can also serve as a starting point for writing your own recursive-descent parser for some other, more complex language.
A controller for animating the evolution and animation of a state (such as an esolang program state or a cellular automaton configuration). Can be hooked up to DOM elements in the UI (typically buttons.)
A set of classes for (somewhat crudely) managing independent things which can be placed, moved, be clicked, and be dragged around a canvas.
A scoped associative structure, suitable for implementing a symbol table or an evaluation context.
For Turtle Graphics. This should probably be a "model" and there should be a separate
yoob.TurtleViewwhich concerns itself with rendering the turtle (and its path) on a canvas.
For error handling. Scanning and Parsing should accumulate a list of these objects before choking and dying. They should be displayable nicely somehow.
A crude simulation of a text-based addressable console in something other than a
<canvas>, but continuing to provide a sort of retro feel. Possibly implemented with a
<pre>element or a
<div>with a fixed-size font and significant whitespace set using CSS3. This will allow text to be rendered more nicely, and selected for copying/pasting in the browser, and so forth.
yoob.TextTerminal, but instead of being a subclass of
yoob.TextConsole, it should be an adapter which can be used with either that class or
yoob.Playfieldshould be a "model" only, and not contain any code concerned with rendering. This class should concern itself with rendering.
unbounded integer support
yoob.js is currently used in the HTML5 implementations of:
...and soon to be used in ALPACA and the various cellular automata defined therein.
yoob.Playfield: made attributes camelCase added support for
loadadded support for default values (
yoob.Tree, and added
substmethods to it.
Added support for
yoob.Playfield, and fixed issue with drawing cursors at wrong offsets.
git clone https://git.catseye.tc/yoob.js/
- Update version numbers and changelog for release of 0.3. catseye 7 years ago
- Add min/max x/y accessors, and offset to cursors. catseye 7 years ago
- Support `select` control (source selection) in yoob.Controller. catseye 7 years ago
- Haha oops. catseye 7 years ago
- Add utility script for converting eg sources to HTML for yoob.js. catseye 7 years ago
- Support `edit` control and (show/hide) display(/source) element. catseye 7 years ago
- Add movement methods to Sprite, foreach to SpriteManager. catseye 7 years ago
- Add .onclick event to Sprites, .onpickup->.ongrab, and such. catseye 7 years ago
- Fix name of example file. catseye 7 years ago
- Add onpickup(), moveToFront(), moveToBack(), getSpriteAt(). catseye 7 years ago