module Novika::Form

Overview

Form is an umbrella for words and blocks. Since some words (like numbers, quotes) are just too different from words as we know them, they have their own types directly subordinate to Form.

Make sure to override self.typedesc to avoid weird unrelated Crystal errors. Crystal breaks at class-level inheritance.

Included Modules

Direct including types

Defined in:

novika/forms/form.cr

Instance Method Summary

Instance methods inherited from module Novika::Schedulable

schedule(engine : Engine, stack : Block) schedule, schedule!(engine : Engine, stack : Block) schedule!

Instance Method Detail

def a(type : T.class) : T forall T #

Asserts that this form is of the given type. Dies if it's not.


def desc(io : IO) #

Appends a string description of this form to io.


def desc : String #

Returns a string description of this form.


def die(details : String) #

Raises an Error providing details.


def effect(io) #

Generates and returns a description for the stack effect of this form.

For blocks and builtins, tries to extract a ( ... -- ... ) (but see EFFECT_PATTERN) from their corresponding comment. If could not extract or no comment, returns 'a block' for blocks and 'native code' for builtins.


def effect #

Generates and returns a description for the stack effect of this form.

For blocks and builtins, tries to extract a ( ... -- ... ) (but see EFFECT_PATTERN) from their corresponding comment. If could not extract or no comment, returns 'a block' for blocks and 'native code' for builtins.


def on_open(engine : Engine) : self #

Reacts to this form being opened with engine.


def on_parent_open(engine : Engine) : self #

Reacts to this form's enclosing block being opened with engine.


def onto(block : Block) : self #

Adds this form to block.


def sel(a, b) #

Selects either a or b. Novika defines False to be the only form selecting b. All other forms select a.


def to_quote : Quote #

Returns this form's quote representation.