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
members
-
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.
static functions
-
Cell.parse([tag], parts)
– parse a Cell (for parsing with Lpeg). -
Cell.parse_root(parts)
– parse a root Cell (for parsing with Lpeg).
ast interface
-
cell:eval(scope)
– evaluate this Cell. -
cell:clone(parent)
– create a clone with its own identity. -
cell:stringify([depth])
– stringify this Cell.
details
members
-
– 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 betweenchildren[i]
andchildren[i+1]
, or the closing parenthesis of this Cell.whitespace[0]
is the space between the opening parenthesis andchildren[1]
.
static functions
- – parse a Cell (for parsing with Lpeg).
-
– 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)
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:
- (Result): the evaluation result
- if head is an
- – create a clone with its own identity.
-
– 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