class Cell
S-Expression Cell, implements the AST interface.
Consists of a head expression and any number of tail expressions (both AST nodes), a Tag, and optionally the internal whitespace as parsed.
index
static functions
-
Cell\new([tag], children[, white])
– construct a new Cell. -
Cell.parse([tag], parts)
– parse a Cell (for parsing with Lpeg). -
Cell.subst(strings, children)
– apply substitutions to a template string. -
Cell\parse(tag, head, pieces)
– parse a TemplateString (for parsing with Lpeg).
class cell
-
cell\head()
– get the head of the cell. -
cell\tail()
– get the tail of the cell. -
cell.tag
– the parsed Tag. -
cell.children
– sequence of child AST Nodes -
cell.whitespace
– optional sequence of whitespace segments.
ast interface
-
cell\eval(scope)
– evaluate this Cell. -
cell\clone(parent)
– create a clone with its own identity. -
cell\stringify([depth])
– stringify this Cell. -
cell\stringify([depth])
– stringify this TemplateString.
class rootcell
-
Cell\parse(parts)
– parse a root Cell (for parsing with Lpeg).
details
static functions
-
– construct a new Cell.
parameters:
- (optional)
- whitespace strings (optional)
- – parse a Cell (for parsing with Lpeg).
-
– apply substitutions to a template string.
Equivalent to strings[1] .. children[1] .. strings[2] … strings[N+1]
parameters:
- the pieces of template string
- the pieces to substitute
returns:
- (string)
- – parse a TemplateString (for parsing with Lpeg).
class cell
-
– get the head of the cell.
returns:
- (AST)
-
– get the tail of the cell.
returns:
-
– the parsed Tag.
-
– sequence of child AST Nodes
-
– optional sequence of whitespace segments.
If set, whitespace[i] is the whitespace between children[i] and children[i+1], or the closing parenthesis of this Cell. whitespace[0] is the space between the opening parenthesis and children[1].
ast interface
-
– evaluate this Cell.
AST:evaluates the head of the expression, and finds the appropriate Builtin to invoke:
- if head is an opdef, use invoke.op_invoke
- if head is a fndef, use invoke.fn_invoke
- if head is a builtin, unwrap it
then calls Builtin:eval_cell on it.
parameters:
- the scope to evaluate in
returns:
- (RTNode): the evaluation result
-
– create a clone with its own identity.
creates a clone of this Cell with its own identity by prepending a parent to tag and cloning all child expressions recursively.
parameters:
returns:
- (Cell)
-
– stringify this Cell.
if depth is passed, does not faithfully recreate the original string but rather create useful debug output.
parameters:
- the maximum depth, defaults to infinite (optional)
returns:
- (string): the exact string this Cell was parsed from, unless @tag changed
-
– stringify this TemplateString.
if depth is passed, does not faithfully recreate the original string but rather create useful debug output.
parameters:
- the maximum depth, defaults to infinite (optional)
returns:
- (string): the exact string this TemplateString was parsed from
class rootcell
-
– parse a root Cell (for parsing with Lpeg).
Root-Cells are at the root of an ALV document. They have an implicit head of 'do' and a [0] tag.
parameters:
returns:
- (Cell)