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.


[View source]
def desc(io : IO) #

Appends a string description of this form to io.


[View source]
def desc : String #

Returns a string description of this form.


[View source]
def die(details : String) #

Raises an Error providing details.


[View source]
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.


[View source]
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.


[View source]
def on_open(engine : Engine) : self #

Reacts to this form being opened with engine.


[View source]
def on_parent_open(engine : Engine) : self #

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


[View source]
def onto(block : Block) : self #

Adds this form to block.


[View source]
def sel(a, b) #

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


[View source]
def to_quote : Quote #

Returns this form's quote representation.


[View source]