ripen

Ripen: stack-based scripting language focused on cleanliness.

Types

Prim = proc ()
Primitive word implementation.
Sigil = proc (word: string)
Sigil implementation.
Word = object
  case kind*: WordKind
  of primWord:
    prim*: Prim
  of userWord:
    code*: seq[string]
  
WordKind = enum
  primWord, userWord

Vars

alias: Table[string, string]
The alias dictionary.
atLine = 0
buf_to: string
Set to non-nil to start buffering until given word.
buffer: seq[string]
Words accumulate here while buffering.
code: seq[string]
Lists of words are copied here after buffering.
loop: seq[string]
Loop bodies are moved here to free the code.
scratch: string
Scratchpad area for working with strings.
sigil: Table[char, Sigil]
The sigil dictionary.
stack: seq[float]
The Ripen stack; made of floats because why not.
variables: Table[string, float]
The variable dictionary.
words: Table[string, Word]
The main dictionary.

Consts

help_message = """Usage: ripen [options...] [files...]

Options:
        -h, --help:             show this help message and exit
        -v, --version:          show version string and exit
        -t, --test:             run built-in tests and exit
        -i, --interactive:      enter interactive mode after files
        -q, --quiet:            suppress banner, prompt, ok message
"""
version_string = "Ripen Forth 3.0 beta (2023-07-19)"

Procs

proc `$`(w: Word): string {....raises: [], tags: [].}
proc exec(word: Word) {....raises: [Exception], tags: [RootEffect].}
proc included(filename: string) {....raises: [IOError, Exception, KeyError,
    ValueError], tags: [ReadIOEffect, RootEffect].}
proc interpret(code_block: seq[string]) {.
    ...raises: [Exception, KeyError, ValueError], tags: [RootEffect].}
The heart of Ripen.

Templates

template primitive(p: Prim): Word