2017-08-27

(sph lang itml *)

an indent-based syntax markup language

part of sph-lib

(sph lang itml read)

library description

parse itml

import name

(sph lang itml read)

exports

path->itml-parsed

procedure

signature

a ->

string -> list

like port ->

description

itml-parsed but takes a path to a file to read from

port->itml-parsed

procedure

signature

a ->

port -> list

description

reads an itml string from port, parses it and returns the abstract syntax tree

sph-lang-itml-read-description

variable

string->itml-parsed

procedure

signature

a ->

string -> list

like port ->

description

itml-parsed but takes a string to parse

(sph lang itml write)

library description

create itml strings from parsed itml

import name

(sph lang itml write)

exports

itml-create-association

procedure

signature

a b ... ->

itml-create-indent-expr

procedure

signature

a ->

itml-create-indent-scm-expr

procedure

signature

a [line-width] ->

itml-create-inline-expr

procedure

signature

a ->

itml-create-inline-scm-expr

procedure

signature

a ->

itml-create-line-expr

procedure

signature

a ->

itml-create-line-scm-expr

procedure

signature

a ->

itml-parsed->itml

procedure

signature

a ->

list list -> sxml

sph-lang-itml-write-description

variable

(sph lang itml eval)

library description

evaluate itml inline code expressions and possibly translate to a new format.

itml inline code expressions can evaluate to non-itml syntax for the target language.

# data structures

itml-state: ((any:source-id ...) integer:depth hashtable:data)

import name

(sph lang itml eval)

exports

itml-eval

procedure

signature

a itml-state descend ascend terminal ->

list:parsed-itml list procedure procedure procedure -> any

itml-eval*

procedure

signature

descend-prefix-ht ascend-prefix-ht [terminal descend-alt ascend-alt] ->

description

hashtable hashtable [procedure procedure procedure] -> procedure

returns a procedure similar to itml-eval that uses expression handler procedures from hashtables.

the -prefix-ht hashtables map list prefixes to tail handlers that map a expression to a result.

if the prefix is not found in one of the hashtables then the corresponding -alt procedure is called

itml-eval-asc-indent-expr

procedure

signature

a b ... ->

itml-eval-asc-inline-expr

procedure

signature

a b ... ->

itml-eval-asc-line-expr

procedure

signature

a b ... ->

itml-eval-call

procedure

signature

input itml-state proc ->

description

any procedure:{any:input list:itml-state} -> any

protects against circular inclusion by checking and updating itml-state

itml-eval-call-proc

procedure

signature

itml-eval-any itml-eval ->

symbol procedure -> procedure

description

extend an itml-eval-* procedure to be passed directly to itml-call-for-*

itml-eval-desc-indent-expr

procedure

signature

a b ... ->

list procedure integer list environment -> any

description

evaluate an inline code expression when all elements are strings or string lists.

converts the prefix to a symbol and prepares lists to evaluate to lists

itml-eval-desc-indent-scm-expr

procedure

signature

a re-descend sources depth data ->

description

evaluate an inline code expression

itml-eval-desc-inline-scm-expr

procedure

signature

a re-descend sources depth data ->

description

evaluate an inline code expression

itml-eval-desc-line-expr

procedure

signature

a b ... ->

list procedure integer list environment -> any

description

evaluate an inline code expression when all elements are strings or string lists.

converts the prefix to a symbol and prepares lists to evaluate to lists

itml-eval-desc-line-scm-expr

procedure

signature

a re-descend sources depth data ->

description

evaluate an inline code expression

itml-eval-descend

procedure

signature

a re-descend sources depth data ->

description

evaluate an inline code expression

itml-eval-descend-string

procedure

signature

a b ... ->

list procedure integer list environment -> any

description

evaluate an inline code expression when all elements are strings or string lists.

converts the prefix to a symbol and prepares lists to evaluate to lists

itml-eval-file

procedure

signature

itml-eval a b ... ->

itml-eval-list

procedure

signature

a env exceptions state ->

(symbol any ...) environment list -> any

description

creates the syntax for a lambda that contains the code from the itml expression,

and uses eval to create a procedure from it.

the procedure is called with the itml state object from the call to evaluate the itml.

this supports the use of syntax in itml expressions

itml-eval-port

procedure

signature

itml-eval a b ... ->

itml-eval-string

procedure

signature

itml-eval a b ... ->

itml-state-copy

procedure

signature

a ->

itml-state-create

procedure

signature

[depth env exceptions data] ->

integer environment hashtable ... -> list

description

data, if passed, will be modified

itml-state-data

procedure

signature

a ->

itml-state-depth

procedure

signature

a ->

sph-lang-itml-eval-description

variable

(sph lang itml eval shtml)

library description

evaluate inline code expressions and translate itml to shtml

import name

(sph lang itml eval shtml)

exports

itml-shtml-eval

procedure

signature

a itml-state ->

list list -> sxml

itml-shtml-eval-file

procedure

signature

a b ... ->

itml-shtml-eval-port

procedure

signature

a b ... ->

itml-shtml-eval-string

procedure

signature

a b ... ->

itml-shtml-false

variable

itml-shtml-lines

procedure

signature

a ->

list integer -> list

description

receives a list of expressions that eventually become separate lines.

rules:

* html inline elements are wrapped with <p>

* html block elements are left as is

* list contents become <p> contents

* other elements are wrapped with <p>

* on the first level of the given list, lists that

do not correspond to html tags are spliced.

these lists are assumed to contain result elements

from dynamic code evaluation

sph-lang-itml-eval-shtml-description

variable

(sph lang itml eval plaintext)

library description

evaluate inline code expressions

import name

(sph lang itml eval plaintext)

exports

itml-plaintext-eval

procedure

signature

a itml-state ->

list list -> sxml

itml-plaintext-eval-file

procedure

signature

a b ... ->

itml-plaintext-eval-port

procedure

signature

a b ... ->

itml-plaintext-eval-string

procedure

signature

a b ... ->

itml-plaintext-false

variable

tags: itml programming guile documentation library scheme sph-lib q1 lang-parser-itml highlight sph-lang-itml