Module: Eleven

This module contains classes and mix-ins to compile various stages of a little language using builder actions to represent programs as trees and visitors to interpret, check types, and compile. The details are discussed in chapter 11 and appendix D.

A tree consists of nodes represented as nested Array objects, each consisting of a string tag selecting a method of a visitor, followed by zero or more nodes or other argument values. visit cannot be a tag.

A tree node can have .lineno and .type properties referring to the source line number and the type (bool, number, or string) delivered by the node. visitor._dump(node) displays the properties if they exist.

The module assumes that there are globalThis definitions of puts() for output and prompt() for num which are available to eval().

Version:
  • 2024-08-04
Author:
Source:

Classes

Build
Check
Code
Visit

Mixins

Build_Bool
Build_Cast
Build_Cmps
Build_Dcl
Build_Names
Build_Number
Build_RD
Build_Stmts
Build_String
Check_Bool
Check_Cast
Check_Cmps
Check_Dcl
Check_Names
Check_Number
Check_Stmts
Check_String
Code_Bool
Code_Cast
Code_Cmps
Code_Dcl
Code_Names
Code_Number
Code_Stmts
Code_String
Compile
Eval_Bool
Eval_Cast
Eval_Cmps
Eval_Dcl
Eval_Names
Eval_Number
Eval_Stmts
Eval_String
Main
Symbols

Members


Instructions

Power instruction.

Source:

Methods


Bnzero()

stack: ... bool -> ... | pc: bool? a

Source:

Cast()

stack: ... a -> ... cast a

Source:

Concat()

stack: ... a b -> ... a+b

Source:

IfFalse()

stack: ... bool -> ... bool | pc: !bool? a

Source:

IfTrue()

stack: ... bool -> ... bool | pc: bool? a

Source:

InputString()

stack: ... -> ... val

Source:

Len()

stack: ... a -> ... a.length

Source:

Not()

stack: ... a -> ... !a

Source:

Power()

stack: ... a b -> ... a**b

Source: