Module: reefmarker.ast
Source: ./reefmarker/ast.reef
Overview
reefmarker/ast — FTL tokens and AST node shapes (veemarker subset).
Recursive children live only in arrays (BUG-267). Parser (Task 6) fills Expression/Node fields; the lexer stores raw strings on Token.
Usage: import reefmarker.ast as ast let e = ast.expr_new(ExprKind_Variable(), span)
Types
TokenKind (enum)
Variants:
TextEofInterpolationStartInterpolationEndDirectiveStartDirectiveEndDirectiveCloseCommentStartCommentEndMacroCallStartMacroCallEndIdentifierDotLBracketRBracketLParenRParenCommaQuestionColonStringLitNumberLitBoolLitEqualsNotEqualsLessThanLessEqualGreaterThanGreaterEqualPlusMinusStarSlashPercentAndOpOrOpNotOpAssignEqKwIfKwElseifKwElseKwListKwAsKwAssignKwIncludeKwNoparseKwAttemptKwRecoverKwMacroKwStopKwReturnKwSepKwSwitchKwCaseKwDefault
Token
Fields:
| Name | Type |
|---|---|
kind |
TokenKind |
value |
string |
pos |
source.SourcePos |
ExprKind (enum)
Variants:
VariablePropertyMethodCallLiteralBinaryOpUnaryOpArrayAccessDefaultTemplateStringTernary
Expression
Expression tree. args layout by kind:
Property: args[0] = object
MethodCall: args[0] = object, args[1..] = call args; name = method
BinaryOp: args[0] left, args[1] right; name = operator (+, ==, …)
UnaryOp: args[0]; name = ! or -
ArrayAccess: args[0] object, args[1] index
Default: args[0] expr, args[1] default
Ternary: args[0] cond, args[1] then, args[2] else
Literal: literal holds the Value
Variable: name
TemplateString: name = raw content
Fields:
| Name | Type |
|---|---|
kind |
ExprKind |
span |
source.SourcePos |
name |
string |
literal |
value.Value |
args |
[Expression] |
NodeKind (enum)
Variants:
TextInterpolationIfListAssignCommentIncludeNoParseMacroMacroCallAttemptStopReturnSwitchElseIfCase
Node
Template AST node. Field roles by kind: Interpolation: expr, has_default + default_expr If: expr = condition, nodes = then, alt_nodes = else, extra_nodes = elseif nodes (each ElseIf with expr + nodes) List: expr = collection, text = item var, nodes = body, alt_nodes = else, extra_nodes = sep Assign: text = name, expr = value; multi-line: nodes = body, expr.kind unused / name empty Include: text = loader name Macro: text = name, extra_text = param names, extra_exprs = default exprs (same length). Interpolation is the only kind that uses has_default; a param with no default is an Expression of kind Literal whose literal is Value_Null. MacroCall: text = name, extra_text = arg names, extra_exprs = arg exprs Attempt: nodes = try, alt_nodes = recover Stop/Return: text = message, expr optional Switch: expr scrutinee, extra_nodes = Case nodes (expr + nodes), alt_nodes = default body
Fields:
| Name | Type |
|---|---|
kind |
NodeKind |
span |
source.SourcePos |
text |
string |
expr |
Expression |
default_expr |
Expression |
has_default |
bool |
nodes |
[Node] |
alt_nodes |
[Node] |
extra_nodes |
[Node] |
extra_exprs |
[Expression] |
extra_text |
[string] |
Functions
fn token_new(kind: TokenKind, value: string, pos: source.SourcePos): Token
fn expr_new(kind: ExprKind, span: source.SourcePos): Expression
fn node_new(kind: NodeKind, span: source.SourcePos): Node
Generated by reefc doc