Skip to main content

Chapter 9
Token Parsing

Why LLMs Can Execute It
Author: Mark Higgins
and Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 27 February 2026
Audio Overview

Token Parsing

9.1 Why Parsing Matters

In earlier chapters, we examined:

  • Runtimes — where execution occurs
  • Compilers — where translation occurs
  • Environment Dependency — how systems bind to context
  • Fragility — how assumptions create collapse
  • Internal State — what persists
  • Internal Invariants — what must not break
  • No External Semantics — meaning must be internally defined

Now we reach a critical boundary:

How does structure become interpretable?
Before execution.
Before evaluation.
Before invariants.

There is parsing.

Parsing is the act of converting raw symbolic input into structured internal representation.

Without parsing, there is no structure.
Without structure, there is no logic.
Without logic, there is no coherent execution.

Telephone:
01377 236594

9.2 What Is a Token?

A token is the smallest meaningful symbolic unit in a formal system.

In programming languages, tokens include:
  • Keywords (if, return)
  • Identifiers (x, total)
  • Operators (+, =, →)
  • Literals (42, "hello")
  • Structural symbols ({, }, (, ))
In mathematics:
  • Variables
  • Operators
  • Quantifiers
  • Delimiters
In Flow Algebra:
  • flow
  • state
  • transition
  • invariant
  • monitor
  • →
  • :
  • Indentation boundaries

A token is not yet meaning.

It is a boundary marker.

Meaning only emerges after structure is built.

9.3 Tokenisation vs Parsing

There are two stages:

Stage 1 — Tokenisation (Lexical Analysis)

Raw text:

Ot = h(St, It)

Becomes token stream:

[IDENT:Ot] [EQUALS] [IDENT:h] [LPAREN]
[IDENT:St] [COMMA] [IDENT:It] [RPAREN]

This step:

  • Breaks input into atomic units
  • Classifies symbols
  • Removes ambiguity at character level

It does not yet determine structure.

Stage 2 — Parsing (Syntactic Structuring)

The parser takes the token stream and constructs:

  • A syntax tree
  • A structured representation
  • A hierarchical object model

Example tree:

Assignment
 ├── Left: Ot
 └── Right:
     FunctionCall
       ├── Name: h
       └── Args: [St, It]

Now structure exists.

Now evaluation becomes possible.

9.4 Parsing as Boundary Formation

Parsing is not just technical.
It is structural physics of information.

Raw input = undifferentiated symbol field.

Token parsing = boundary carving.

The parser creates:

  • Nodes
  • Hierarchies
  • Dependencies
  • Precedence relationships

This is identical in principle to how:

  • Physical boundaries create curvature
  • Logical constraints create invariants
  • Coherence creates geometry

Parsing is the formation of information geometry.

9.5 Deterministic vs Context-Sensitive Parsing

There are levels of parser complexity:

Deterministic (Context-Free)

  • Fixed grammar
  • Clear precedence rules
  • Predictable tree formation

Example: arithmetic expressions.

Context-Sensitive

  • Meaning depends on state
  • Token role depends on environment
  • Dynamic resolution required
Example:
x(y)

Is this:

  • Function call?
  • Multiplication?
  • Type cast?

Only context decides.

Thus:

Parsing is never purely local.
It depends on internal state.

This directly connects to the Internal State and Invariants chapters.

9.6 Grammar as Constraint System

A grammar defines:

  • Allowed token sequences
  • Structural patterns
  • Legal tree shapes
In formal notation:
Let:
  • Σ = token alphabet
  • G = grammar rules
  • T = token sequence
Parsing succeeds iff:
T ∈ L(G)

Where L(G) is the language generated by grammar G.

Parsing failure = structural violation.

This mirrors the broader principle:

Valid systems are those that satisfy internal structural constraints.

9.7 Ambiguity and Fragility

Ambiguity in parsing causes:
  • Multiple valid trees
  • Non-determinism
  • Execution variance
  • Structural instability
Example:
a - b - c
Is this:
(a - b) - c
or
a - (b - c)

Without precedence rules, invariants break.

Ambiguity is structural fragility at the symbolic level.

9.8 Parsing in Flow Algebra

Flow Algebra was intentionally designed to:
  • Minimise ambiguity
  • Use indentation as structure
  • Make hierarchy visually explicit
  • Reduce hidden precedence

Because:

A language that hides structure requires a compiler.
A language that exposes structure can execute zero-shot.

Flow Algebra parsing principles:

  • 1. Flow blocks are top-level units.
  • 2. Indentation defines scope.
  • 3. Fields are explicitly typed.
  • 4. Transitions are explicit arrows.
  • 5. Invariants are named constraints.

This design ensures:

  • Deterministic parse trees
  • Reduced structural ambiguity
  • High LLM interpretability
  • No external compilation stage required

9.9 Parsing and LLMs

Large Language Models do not parse using:

  • BNF grammars
  • Explicit AST builders
  • Hard-coded compiler pipelines

Instead they:

  • Predict token probability distributions
  • Infer structural patterns from training
  • Implicitly build internal representations
However:

They still rely on token segmentation.

LLMs operate over:

  • Token embeddings
  • Positional encoding
  • Attention-based structure detection
Thus:

Even neural models require token boundaries.

Parsing is universal.

9.10 Parsing as the First Coherence Test

Before any system can evaluate meaning, it must answer:

  • 1. Are tokens recognised?
  • 2. Does structure conform to grammar?
  • 3. Are boundaries valid?
  • 4. Is hierarchy consistent?

If parsing fails:

  • No execution occurs
  • No invariants can be evaluated
  • The system halts at the boundary
Parsing is the first survival filter of structured information.

9.11 Failure Modes

Common parsing failures:
  • Unexpected token
  • Missing delimiter
  • Ambiguous structure
  • Indentation inconsistency
  • Grammar drift
  • Recursive descent overflow

These are not minor technical bugs.
They represent:

Violations of structural coherence.

A system that cannot parse its inputs cannot maintain invariants.

9.12 Token Parsing in the Larger Architecture

Now observe the progression:

LayerQuestion
Runtime
Where does execution occur?
Compiler
How is translation performed?
Environment
What binds context?
State
What persists?
Invariants
What must survive?
Semantics
Is meaning internal?
Parsing
How is structure formed?

Parsing is the gateway between:

Symbolic surface
and
Structured internal state.
Without it, nothing else exists.

9.13 Structural Principle

Token parsing is the process by which:

Undifferentiated symbolic flux becomes structured hierarchy under grammar constraints.
It is:
  • Boundary creation
  • Constraint enforcement
  • Structural validation
  • Coherence formation

Before logic.
Before execution.
Before invariants.

Parsing is the first act of order.

flow "TokenParsing" v1.0

Convert raw input text into a validated structural representation suitable for downstream evaluation."

flow "TokenParsing" v1.0
meta:
  domain: "language-structure"
  intent: "Convert raw input text into a validated structural representation suitable for downstream evaluation."
  zero_shot: true
  notes:
    - "Tokenisation is boundary carving at the character layer."
    - "Parsing is hierarchy formation under grammar constraints."
    - "Output is a ParseResult with AST + diagnostics."

# -------------------------
# IO
# -------------------------
io:
  in:
    source_text: str
    grammar: GrammarSpec
    mode: enum("strict","recover") = "strict"
  out:
    result: ParseResult

# -------------------------
# TYPES
# -------------------------
types:

  GrammarSpec:
    description: "Defines token classes, precedence, associativity, and production rules."
    fields:
      token_rules: list[TokenRule]
      productions: list[ProductionRule]
      start_symbol: str
      precedence: list[PrecedenceRule]?
      whitespace: enum("ignore","significant") = "ignore"
      indentation: enum("ignore","significant") = "ignore"

  TokenRule:
    fields:
      name: str
      pattern: regex
      priority: int = 0
      emit: bool = true

  ProductionRule:
    fields:
      lhs: str
      rhs: list[str]         # symbols: token names or non-terminals
      action: str?           # semantic constructor label (internal)

  PrecedenceRule:
    fields:
      operator: str
      precedence: int
      associativity: enum("left","right","nonassoc")

  Token:
    fields:
      kind: str              # token class name
      lexeme: str            # raw substring
      span: Span
      value: any?            # optional decoded value (number/string)

  Span:
    fields:
      start: int
      end: int
      line: int?
      col: int?

  ASTNode:
    fields:
      tag: str               # node type
      children: list[ASTNode]
      token: Token?          # optional anchor token
      span: Span
      attrs: map[str,any]?   # optional node metadata

  Diagnostic:
    fields:
      level: enum("INFO","WARN","ERROR","FATAL")
      code: str
      message: str
      span: Span?

  ParseResult:
    fields:
      ok: bool
      tokens: list[Token]
      ast: ASTNode?
      diagnostics: list[Diagnostic]
      remainder: str?        # for recovery or partial parse

# -------------------------
# INTERNAL STATE
# -------------------------
state:
  cursor:
    idx: int = 0
    line: int = 1
    col: int = 1
  buffer:
    text: str = io.in.source_text
  stream:
    tokens: list[Token] = []
  parse:
    ast: ASTNode? = null
    stack: list[any] = []     # parser stack / frames
  diag:
    diagnostics: list[Diagnostic] = []
  config:
    grammar: GrammarSpec = io.in.grammar
    mode: enum("strict","recover") = io.in.mode

# -------------------------
# INVARIANTS
# -------------------------
invariants:

  # Cursor and spans are coherent
  - name: "CursorWithinBounds"
    rule: "0 <= cursor.idx <= len(buffer.text)"

  - name: "TokenSpanMonotonic"
    rule: "forall i in [0..len(stream.tokens)-2]: stream.tokens[i].span.end <= stream.tokens[i+1].span.start"

  - name: "TokenSpanValid"
    rule: "forall t in stream.tokens: 0 <= t.span.start < t.span.end <= len(buffer.text)"

  - name: "GrammarStartSymbolExists"
    rule: "exists p in config.grammar.productions where p.lhs == config.grammar.start_symbol"

  # If ok, AST must exist and cover at least one token
  - name: "OkImpliesAST"
    rule: "result.ok == true => parse.ast != null"

  - name: "ASTSpanWithinText"
    rule: "parse.ast != null => 0 <= parse.ast.span.start <= parse.ast.span.end <= len(buffer.text)"

# -------------------------
# TRANSITIONS
# -------------------------
transitions:

  - name: "Init"
    do:
      - set cursor.idx = 0
      - set cursor.line = 1
      - set cursor.col = 1
      - set stream.tokens = []
      - set parse.ast = null
      - set diag.diagnostics = []

  # ---------- TOKENISATION ----------
  - name: "Tokenise"
    do:
      - while cursor.idx < len(buffer.text):
          do:
            - call "ConsumeWhitespaceOrIndent"()
            - if cursor.idx >= len(buffer.text): break
            - call "MatchNextToken"()

  - name: "ConsumeWhitespaceOrIndent"
    when: "config.grammar.whitespace == 'ignore' or config.grammar.indentation == 'significant'"
    do:
      - # This is deliberately abstract:
      - # - If whitespace ignored: skip spaces/tabs/newlines, update line/col
      - # - If indentation significant: emit INDENT/DEDENT/NEWLINE tokens as per indentation stack
      - call "AdvanceCursorOverLayout"()

  - name: "MatchNextToken"
    do:
      - let start = cursor.idx
      - let best = call "BestTokenMatch"(buffer.text, cursor.idx, config.grammar.token_rules)
      - if best.found == false:
          do:
            - call "EmitDiag"("ERROR","LEX_UNEXPECTED_CHAR","Unexpected character", Span(start,start+1,cursor.line,cursor.col))
            - if config.mode == "strict": goto "Fail"
            - else:
                do:
                  - call "AdvanceCursor"(1)
                  - continue
      - else:
          do:
            - if best.rule.emit == true:
                do:
                  - append stream.tokens:
                      Token(
                        kind=best.rule.name,
                        lexeme=best.lexeme,
                        span=Span(start, start+best.len, best.line?, best.col?),
                        value=best.value?
                      )
            - call "AdvanceCursor"(best.len)

  # ---------- PARSING ----------
  - name: "Parse"
    do:
      - call "ValidateGrammar"(config.grammar)
      - if exists d in diag.diagnostics where d.level in ["ERROR","FATAL"]:
          do:
            - if config.mode == "strict": goto "Fail"
      - set parse.ast = call "BuildAST"(stream.tokens, config.grammar)
      - if parse.ast == null:
          do:
            - call "EmitDiag"("ERROR","PARSE_FAILED","Could not form a valid parse tree", null)
            - if config.mode == "strict": goto "Fail"
      - goto "AssembleResult"

  # ---------- RESULT ----------
  - name: "AssembleResult"
    do:
      - set io.out.result =
          ParseResult(
            ok = (parse.ast != null) and not (exists d in diag.diagnostics where d.level in ["ERROR","FATAL"]),
            tokens = stream.tokens,
            ast = parse.ast,
            diagnostics = diag.diagnostics,
            remainder = null
          )
      - goto "End"

  - name: "Fail"
    do:
      - set io.out.result =
          ParseResult(
            ok = false,
            tokens = stream.tokens,
            ast = null,
            diagnostics = diag.diagnostics,
            remainder = substring(buffer.text, cursor.idx, len(buffer.text))
          )
      - goto "End"

  - name: "End"
    do:
      - stop

# -------------------------
# FUNCTIONS (INTERNAL)
# -------------------------
functions:

  - name: "BestTokenMatch"
    signature: "BestTokenMatch(text:str, idx:int, rules:list[TokenRule]) -> Match"
    behaviour:
      - "Try all rules; choose the longest match, then highest priority."
      - "Return found=false if none match at idx."
      - "Optionally decode value (e.g., INT literal)."

  - name: "ValidateGrammar"
    signature: "ValidateGrammar(G:GrammarSpec) -> void"
    behaviour:
      - "Ensure start_symbol has productions."
      - "Ensure all referenced symbols are defined as token_rules or appear as lhs in productions."
      - "Emit diagnostics for missing/undefined symbols."

  - name: "BuildAST"
    signature: "BuildAST(tokens:list[Token], G:GrammarSpec) -> ASTNode?"
    behaviour:
      - "Apply a deterministic strategy (e.g., Pratt parser for expressions + production-driven descent for statements)."
      - "Respect precedence/associativity if provided."
      - "If indentation significant, treat INDENT/DEDENT as structural delimiters."
      - "Return null on unrecoverable structure failure."

  - name: "AdvanceCursor"
    signature: "AdvanceCursor(n:int) -> void"
    behaviour:
      - "Move idx by n; update line/col if crossing newlines."

  - name: "AdvanceCursorOverLayout"
    signature: "AdvanceCursorOverLayout() -> void"
    behaviour:
      - "Skip or emit layout tokens depending on grammar.whitespace and grammar.indentation."

  - name: "EmitDiag"
    signature: "EmitDiag(level:str, code:str, msg:str, span:Span?) -> void"
    behaviour:
      - "Append Diagnostic(level, code, msg, span) to diag.diagnostics."

# -------------------------
# MONITORS
# -------------------------
monitors:

  - name: "ParseCoherenceMonitor"
    watch:
      - "CursorWithinBounds"
      - "TokenSpanValid"
      - "TokenSpanMonotonic"
      - "GrammarStartSymbolExists"
      - "OkImpliesAST"
      - "ASTSpanWithinText"
    on_violation:
      - call "EmitDiag"("FATAL","COHERENCE_BREAK","Token parsing coherence invariant violated", null)
      - if config.mode == "strict": goto "Fail"

# -------------------------
# OUTPUT CONTRACT
# -------------------------
contract:
  guarantee:
    - "If ok=true: tokens and ast define a single coherent structural interpretation under the provided GrammarSpec."
    - "If ok=false: diagnostics explain the earliest detected boundary failure; remainder indicates unparsed region."
Minimal example grammar snippet (expression + assignment)
# OPTIONAL: Minimal example grammar snippet (expression + assignment)
# (This is *illustrative*; your real Flow Algebra grammar will add blocks, indentation, and keywords.)

GrammarSpec:
  start_symbol: "Stmt"
  whitespace: "ignore"
  indentation: "ignore"

  token_rules:
    - {name: "IDENT", pattern: "[A-Za-z_][A-Za-z0-9_]*", priority: 1, emit: true}
    - {name: "INT",   pattern: "[0-9]+",                priority: 1, emit: true}
    - {name: "EQ",    pattern: "=",                     priority: 2, emit: true}
    - {name: "PLUS",  pattern: "\\+",                   priority: 2, emit: true}
    - {name: "LP",    pattern: "\\(",                   priority: 2, emit: true}
    - {name: "RP",    pattern: "\\)",                   priority: 2, emit: true}

  precedence:
    - {operator: "PLUS", precedence: 10, associativity: "left"}

  productions:
    - {lhs: "Stmt", rhs: ["IDENT","EQ","Expr"], action: "Assign"}
    - {lhs: "Expr", rhs: ["Expr","PLUS","Term"], action: "Add"}
    - {lhs: "Expr", rhs: ["Term"], action: "ExprTerm"}
    - {lhs: "Term", rhs: ["IDENT"], action: "Var"}
    - {lhs: "Term", rhs: ["INT"], action: "Int"}
    - {lhs: "Term", rhs: ["LP","Expr","RP"], action: "Group"}
Tokenise + parse Flow Algebra source into a deterministic AST using layout (indentation) as structure." zero_shot: true
flow "FlowAlgebraTokenParsing" v1.0
meta:
  domain: "flow-algebra"
  intent: "Tokenise + parse Flow Algebra source into a deterministic AST using layout (indentation) as structure."
  zero_shot: true
  notes:
    - "This grammar is designed for LLM-executable parsing: explicit sections + indentation boundaries."
    - "Tokenizer emits INDENT/DEDENT/NEWLINE to make hierarchy explicit."
    - "Parser builds a Sectioned-AST: Flow -> Sections -> Entries -> Values/Blocks."

# -------------------------
# IO
# -------------------------
io:
  in:
    source_text: str
    mode: enum("strict","recover") = "strict"
    indent_width: int = 2               # recommended 2 for YAML-style
    allow_tabs: bool = false
  out:
    result: ParseResult

# -------------------------
# TYPES
# -------------------------
types:

  Token:
    fields:
      kind: str
      lexeme: str
      span: Span
      value: any?

  Span:
    fields:
      start: int
      end: int
      line: int
      col: int

  Diagnostic:
    fields:
      level: enum("INFO","WARN","ERROR","FATAL")
      code: str
      message: str
      span: Span?

  ASTNode:
    fields:
      tag: str
      attrs: map[str,any]?
      children: list[ASTNode]
      span: Span

  ParseResult:
    fields:
      ok: bool
      tokens: list[Token]
      ast: ASTNode?
      diagnostics: list[Diagnostic]
      remainder: str?

  # Internal helper record for indentation/layout
  LayoutState:
    fields:
      indent_stack: list[int]           # stack of indentation columns (spaces)
      pending_dedents: int              # count of DEDENT tokens to emit
      at_line_start: bool
      current_indent: int

# -------------------------
# INTERNAL STATE
# -------------------------
state:
  buffer:
    text: str = io.in.source_text
    n: int = len(io.in.source_text)

  cursor:
    idx: int = 0
    line: int = 1
    col: int = 1

  layout:
    indent_stack: list[int] = [0]
    pending_dedents: int = 0
    at_line_start: bool = true
    current_indent: int = 0

  stream:
    tokens: list[Token] = []

  parse:
    pos: int = 0                    # token index cursor
    ast: ASTNode? = null

  diag:
    diagnostics: list[Diagnostic] = []

  config:
    mode: enum("strict","recover") = io.in.mode
    indent_width: int = io.in.indent_width
    allow_tabs: bool = io.in.allow_tabs

# -------------------------
# INVARIANTS
# -------------------------
invariants:
  - name: "CursorWithinBounds"
    rule: "0 <= cursor.idx <= buffer.n"

  - name: "IndentStackNonEmpty"
    rule: "len(layout.indent_stack) >= 1"

  - name: "IndentStackBaseZero"
    rule: "layout.indent_stack[0] == 0"

  - name: "TokensMonotonicSpans"
    rule: "forall i in [0..len(stream.tokens)-2]: stream.tokens[i].span.end <= stream.tokens[i+1].span.start"

  - name: "OkImpliesAST"
    rule: "io.out.result.ok == true => parse.ast != null"

# -------------------------
# TOKEN KINDS (REFERENCE)
# -------------------------
# KEYWORDS: FLOW, META, IO, TYPES, STATE, INVARIANTS, TRANSITIONS, FUNCTIONS, MONITORS, CONTRACT, PARAMS
# SYMBOLS: COLON(:), DASH(-), QUOTE("), LBRACE({), RBRACE(}), LBRACKET([), RBRACKET(]), COMMA(,), DOT(.)
# OPS: ARROW(-> or →), EQ(=), LT(<), GT(>), LE(<=), GE(>=), NE(!=), AND, OR, NOT
# LITERALS: IDENT, STRING, NUMBER, BOOL, NULL
# LAYOUT: NEWLINE, INDENT, DEDENT, EOF
# COMMENTS: COMMENT (typically not emitted)

# -------------------------
# TRANSITIONS
# -------------------------
transitions:

  - name: "Init"
    do:
      - set cursor.idx = 0
      - set cursor.line = 1
      - set cursor.col = 1
      - set layout.indent_stack = [0]
      - set layout.pending_dedents = 0
      - set layout.at_line_start = true
      - set layout.current_indent = 0
      - set stream.tokens = []
      - set parse.pos = 0
      - set parse.ast = null
      - set diag.diagnostics = []

  - name: "Tokenise"
    do:
      - while cursor.idx < buffer.n:
          do:
            - if layout.pending_dedents > 0:
                do:
                  - call "EmitToken"("DEDENT","", call "SpanHere"(0))
                  - set layout.pending_dedents = layout.pending_dedents - 1
                  - continue

            - if layout.at_line_start == true:
                do:
                  - call "HandleLineIndent"()
                  - set layout.at_line_start = false
                  - # after indent handling, fall through to normal token scanning

            - let ch = call "PeekChar"(0)
            - if ch == "\r":
                do: - call "Advance"(1)   # ignore CR
            - else if ch == "\n":
                do:
                  - call "EmitToken"("NEWLINE","\n", call "SpanHere"(1))
                  - call "Advance"(1)
                  - set layout.at_line_start = true
            - else if call "IsSpace"(ch):
                do:
                  - call "Advance"(1)      # mid-line spaces ignored (YAML style)
            - else if ch == "#" :
                do:
                  - call "ConsumeComment"()
                  - # comment not emitted
            - else:
                do:
                  - call "ScanNextToken"()

      - # End of file: close indentation blocks
      - while len(layout.indent_stack) > 1:
          do:
            - pop layout.indent_stack
            - call "EmitToken"("DEDENT","", call "SpanHere"(0))

      - call "EmitToken"("EOF","", call "SpanHere"(0))

  - name: "Parse"
    do:
      - set parse.ast = call "ParseFlowDocument"()
      - if parse.ast == null:
          do:
            - call "EmitDiag"("ERROR","PARSE_FAILED","Could not parse Flow Algebra document", call "SpanAtToken"(parse.pos))
            - goto "Fail"
      - goto "AssembleResult"

  - name: "AssembleResult"
    do:
      - set io.out.result =
          ParseResult(
            ok = not (exists d in diag.diagnostics where d.level in ["ERROR","FATAL"]),
            tokens = stream.tokens,
            ast = parse.ast,
            diagnostics = diag.diagnostics,
            remainder = null
          )
      - goto "End"

  - name: "Fail"
    do:
      - set io.out.result =
          ParseResult(
            ok = false,
            tokens = stream.tokens,
            ast = null,
            diagnostics = diag.diagnostics,
            remainder = substring(buffer.text, cursor.idx, buffer.n)
          )
      - goto "End"

  - name: "End"
    do: - stop

# -------------------------
# LEXER FUNCTIONS
# -------------------------
functions:

  - name: "PeekChar"
    signature: "PeekChar(k:int) -> str"
    behaviour:
      - "Return buffer.text[cursor.idx+k] if in range else '\\0'."

  - name: "Advance"
    signature: "Advance(n:int) -> void"
    behaviour:
      - "Advance cursor.idx by n; update line/col on newlines."

  - name: "SpanHere"
    signature: "SpanHere(n:int) -> Span"
    behaviour:
      - "Span from current cursor position to cursor+n, with current line/col."

  - name: "EmitToken"
    signature: "EmitToken(kind:str, lexeme:str, span:Span, value:any?=null) -> void"
    behaviour:
      - "Append Token(kind,lexeme,span,value) to stream.tokens."

  - name: "EmitDiag"
    signature: "EmitDiag(level:str, code:str, msg:str, span:Span?) -> void"
    behaviour:
      - "Append Diagnostic(level,code,msg,span) to diag.diagnostics."
      - "If level in ERROR/FATAL and config.mode=='strict', parsing will Fail."

  - name: "IsSpace"
    signature: "IsSpace(ch:str) -> bool"
    behaviour:
      - "True iff ch in [' ', '\\t']."

  - name: "ConsumeComment"
    signature: "ConsumeComment() -> void"
    behaviour:
      - "Consume from '#' to end-of-line (excluding newline)."

  - name: "HandleLineIndent"
    signature: "HandleLineIndent() -> void"
    behaviour:
      - "Measure leading spaces (or tabs if allowed) from line start."
      - "If blank line or comment-only line: do not change indent."
      - "If indentation increased: emit INDENT and push new indent."
      - "If decreased: emit DEDENTs until matching indent exists; else error."
      - "If indentation not aligned to indent_width (optional): warn or error."
      - "If tabs present and allow_tabs=false: error."

  - name: "ScanNextToken"
    signature: "ScanNextToken() -> void"
    behaviour:
      - "Scan in order: Strings, numbers, operators/arrows, punctuation, identifiers/keywords."
      - "Prefer longest match for multi-char ops (<=, >=, !=, ->)."

  # -------------------------
  # Scanner details (normative rules)
  # -------------------------
  - name: "ScanString"
    signature: "ScanString() -> bool"
    behaviour:
      - "If next char is '\"' or '\\'', consume quoted string with escapes."
      - "Emit STRING token with decoded value."
      - "Return true if matched else false."

  - name: "ScanNumber"
    signature: "ScanNumber() -> bool"
    behaviour:
      - "Match int or float (e.g., 12, 12.3)."
      - "Emit NUMBER with numeric value."
      - "Return true if matched else false."

  - name: "ScanOperatorOrPunct"
    signature: "ScanOperatorOrPunct() -> bool"
    behaviour:
      - "Match in precedence order:"
      - "ARROW: '->' or '→'"
      - "LE:'<=' GE:'>=' NE:'!=' EQ:'=' LT:'<' GT:'>'"
      - "COLON:':' COMMA:',' DOT:'.' DASH:'-'"
      - "LBRACE:'{' RBRACE:'}' LBRACKET:'[' RBRACKET:']' LPAREN:'(' RPAREN:')'"
      - "Emit corresponding token."
      - "Return true if matched else false."

  - name: "ScanIdentOrKeyword"
    signature: "ScanIdentOrKeyword() -> bool"
    behaviour:
      - "Match [A-Za-z_][A-Za-z0-9_]*"
      - "If lexeme in section_keywords: emit SECTION token (e.g., 'meta','io','types','state'...)."
      - "If lexeme in literals: emit BOOL/NULL."
      - "Else emit IDENT."
      - "Return true if matched else false."

# -------------------------
# PARSER (SECTIONED YAML-LIKE)
# -------------------------
functions:

  - name: "SpanAtToken"
    signature: "SpanAtToken(pos:int) -> Span?"
    behaviour:
      - "Return stream.tokens[pos].span if pos in range else null."

  - name: "Tok"
    signature: "Tok(k:int=0) -> Token"
    behaviour:
      - "Return stream.tokens[parse.pos+k]."

  - name: "Accept"
    signature: "Accept(kind:str) -> bool"
    behaviour:
      - "If Tok().kind == kind: parse.pos++ and return true else false."

  - name: "Expect"
    signature: "Expect(kind:str, code:str, msg:str) -> Token?"
    behaviour:
      - "If Tok().kind == kind: consume and return token."
      - "Else EmitDiag(ERROR, code, msg, Tok().span) and return null."

  - name: "SkipNewlines"
    signature: "SkipNewlines() -> void"
    behaviour:
      - "Consume consecutive NEWLINE tokens."

  - name: "ParseFlowDocument"
    signature: "ParseFlowDocument() -> ASTNode?"
    behaviour:
      - "Document := SkipNewlines FlowDecl SkipNewlines Section* EOF"
      - "Return AST(tag='Document', children=[FlowDecl, ...Sections...])."

  - name: "ParseFlowDecl"
    signature: "ParseFlowDecl() -> ASTNode?"
    behaviour:
      - "FlowDecl := 'flow' STRING (IDENT)? NEWLINE"
      - "e.g. flow \"TokenParsing\" v1.0"
      - "Build AST(tag='FlowDecl', attrs:{name,version?})."

  - name: "ParseSection"
    signature: "ParseSection() -> ASTNode?"
    behaviour:
      - "Section := SectionKey ':' NEWLINE INDENT Entry* DEDENT"
      - "SectionKey is IDENT or SECTION keyword (meta, io, types, state, invariants, transitions, functions, monitors, contract, params)."
      - "Entry := KeyValue | ListItem | NestedMap"

  - name: "ParseEntry"
    signature: "ParseEntry() -> ASTNode?"
    behaviour:
      - "Entry patterns:"
      - "1) KeyValue: IDENT ':' Value NEWLINE"
      - "2) NestedMap: IDENT ':' NEWLINE INDENT Entry* DEDENT"
      - "3) ListItem: '-' (Value | InlineMap) NEWLINE OR '-' NEWLINE INDENT Entry* DEDENT"
      - "Return AST nodes: Pair, Map, List, Item."

  - name: "ParseValue"
    signature: "ParseValue() -> ASTNode?"
    behaviour:
      - "Value := STRING | NUMBER | BOOL | NULL | IDENT | InlineList | InlineMap"
      - "InlineList := '[' (Value (',' Value)*)? ']'"
      - "InlineMap := '{' (IDENT ':' Value (',' IDENT ':' Value)*)? '}'"
      - "Return AST(tag='Value', attrs:{kind,value})."

# -------------------------
# GRAMMAR RULES (EXECUTABLE NOTES)
# -------------------------
grammar:
  section_keywords:
    - "meta"
    - "io"
    - "types"
    - "state"
    - "params"
    - "invariants"
    - "transitions"
    - "functions"
    - "monitors"
    - "contract"

  literals:
    bool_true:  ["true","True"]
    bool_false: ["false","False"]
    nulls:      ["null","Null","none","None"]

  # High-level structural constraints specific to Flow Algebra
  constraints:
    - "Exactly one FlowDecl must appear before any Sections."
    - "Sections must be top-level (indent 0)."
    - "Within a Section, indentation must be consistent and closed before next Section."
    - "Duplicate keys within the same map level should WARN (or ERROR in strict)."

# -------------------------
# MONITORS (COHERENCE + RECOVERY)
# -------------------------
monitors:

  - name: "LayoutCoherence"
    watch:
      - "IndentStackNonEmpty"
      - "IndentStackBaseZero"
    on_violation:
      - call "EmitDiag"("FATAL","LAYOUT_STACK_CORRUPT","Indent stack corrupted during tokenisation", call "SpanHere"(0))
      - if config.mode == "strict": goto "Fail"

  - name: "ParseProgress"
    watch:
      - "parse.pos"
    rule:
      - "Parser must consume tokens monotonically; if stuck, emit PARSE_STALL and fail/recover."
    on_violation:
      - call "EmitDiag"("ERROR","PARSE_STALL","Parser made no progress (likely unexpected token)", call "SpanAtToken"(parse.pos))
      - if config.mode == "strict": goto "Fail"

# -------------------------
# OUTPUT CONTRACT
# -------------------------
contract:
  guarantee:
    - "ok=true => a single deterministic Sectioned-AST exists for the Flow Algebra document."
    - "Tokenizer always emits EOF and closes all open indentation with DEDENT tokens."
    - "Any indentation decrease must match a previous indent level exactly, else LAYOUT_MISMATCH."

  diagnostics:
    - "LEX_UNEXPECTED_CHAR: unknown character"
    - "LAYOUT_TABS_FORBIDDEN: tabs detected but not allowed"
    - "LAYOUT_WIDTH_MISMATCH: indent not multiple of indent_width"
    - "LAYOUT_MISMATCH: dedent to non-existent indent level"
    - "PARSE_EXPECTED: expected token kind missing"
    - "PARSE_FAILED: unable to build AST"
Canonical AST shape (so your engine can store and diff parse trees consistently)
# (OPTIONAL) Canonical AST shape (so your engine can store and diff parse trees consistently)

ast_schema:
  Document:
    children: [FlowDecl, Section*]

  FlowDecl:
    attrs: {name:str, version:str?}

  Section:
    attrs: {key:str}
    children: [Entry*]

  Entry:
    variants:
      - Pair:   {key:str, value:Value}
      - Map:    {key:str, children:[Entry*]}
      - List:   {key:str, items:[Item*]}          # when written as key: [..] or key:\n  - ...
      - Item:   {value:Value? , children:[Entry*]?}

  Value:
    variants:
      - Scalar: {kind: enum("string","number","bool","null","ident"), value:any}
      - InlineList: {items:[Value*]}
      - InlineMap:  {pairs:[(str,Value)*]}

Flow Algebra Token Parsing Flows

These flows formalise Token Parsing as a complete internal process with:

  • 1. Layout-aware tokenisation (boundary carving)
  • 2. Deterministic section parsing (hierarchy formation)
  • 3. Diagnostics + invariants + monitors (coherence enforcement)
  • 4. A stable AST output contract (downstream-safe structure)

The key idea is: Flow Algebra is designed to be parsed without hidden precedence rules. Indentation and section headings create a visible structural spine, allowing a parser (or an LLM) to build a consistent tree without external compilation semantics.

1) What This Implements

1.1 Two-Stage Boundary Formation

The flow implements a strict separation:

  • Tokenisation: converts raw characters into a token stream
  • Parsing: converts token stream into a Sectioned AST

This is critical because Flow Algebra’s execution relies on reliable structure. If the structure is ambiguous, the system reverts to compiler-like inference, which is exactly what Flow Algebra is trying to avoid.

So the parser is built to enforce:

  • Explicit section boundaries (meta:, io:, state:, etc.)
  • Explicit indentation boundaries (INDENT/DEDENT)
  • Explicit sequence boundaries (NEWLINE)
  • Explicit termination (EOF)
Meaning is not “guessed”. It is structurally derived.

2) How To Read These Flows

2.1 The Flow Has Three Structural Domains
  • A) Lexical domain (Tokenise):
    This is “character → boundary symbols”.
  • B) Syntactic domain (Parse):
    This is “boundaries → hierarchy”.
  • C) Coherence domain (Monitors + Invariants):
    This is “hierarchy must remain structurally valid”.
So when reading:
  • Start at io and types to understand the objects that exist.
  • Then read state to see what persists during parsing.
  • Then read transitions to follow execution order.
  • Finally read monitors and contract to understand failure handling + guarantees.

3) Tokenisation Flow Write-Up

3.1 Layout Is Treated as Syntax, Not Decoration

Flow Algebra parsing treats indentation as real structure.

So the tokenizer does not merely skip whitespace — it converts layout into tokens:

  • NEWLINE = boundary between statements
  • INDENT = begin nested block
  • DEDENT = close nested block(s)
  • EOF = final closure boundary
This makes hierarchy visible and deterministic.

3.2 Indentation Stack = Structural Memory

The layout.indent_stack is a minimal memory structure that ensures the token stream encodes a valid nesting geometry.

Rules enforced:
  • The stack is never empty.
  • The stack begins at indent 0.
  • Every indentation increase pushes a new level.
  • Every decrease must match an earlier level exactly (or it’s a structural fault).

This converts “formatting” into an explicit boundary algebra.

3.3 Token Stream Integrity

The invariants ensure tokens are not just produced, but produced coherently:

  • Cursor stays in bounds.
  • Token spans are monotonic (no overlap / time reversal).
  • Layout stack remains coherent.

This means downstream parsing never has to guess whether the token stream is structurally stable.

4) Parsing Flow Write-Up

4.1 Parsing Strategy

The parser builds a Sectioned YAML-like AST, because Flow Algebra is intentionally shaped like:

  • A top-level flow "Name" vX.Y declaration
  • A set of top-level sections
  • Within sections: maps + lists + nested maps
  • With indentation defining containment
So the parser focuses on:
  • Recognising the single required FlowDecl
  • Recognising legal section headers (meta, io, types, state, invariants, transitions, functions, monitors, contract, params)
  • Enforcing that sections are top-level
    • Parsing entries as one of:

      • Pair (key: value)

      • Map (key: then nested block)

      • List (key: then - item)

      • Item as list entries (value or nested map)

4.2 Determinism Principle

The grammar is intentionally chosen so that a given input yields one stable AST.

This is the philosophical point:
Flow Algebra exposes structure so execution does not depend on compiler inference.

Even when values are flexible (ident, string, inline map), the containment rules remain strict.


5) Diagnostics and Failure Behaviour

5.1 Diagnostics Are Structural, Not “Debug Output”

Each diagnostic code corresponds to a specific coherence failure mode:

  • LEX_UNEXPECTED_CHAR — symbol outside the alphabet
  • LAYOUT_TABS_FORBIDDEN — disallowed ambiguity source
  • LAYOUT_WIDTH_MISMATCH — indentation not aligned to the declared lattice width
  • LAYOUT_MISMATCH — dedent to a non-existent indentation layer
  • PARSE_STALL — parser made no progress (structure can’t be resolved)
  • PARSE_FAILED — cannot form a tree that satisfies constraints

These diagnostics are not merely helpful — they are part of the structural contract that prevents silent drift.

5.2 Strict vs Recover Mode

  • strict: fail fast on structural violations
  • recover: attempt to continue, emit diagnostics, produce partial stream / remainder

This distinction matters because Flow Algebra is used in two contexts:

  • authoring and publishing (strict)
  • live ingestion / monitoring (recover)
Telephone:
01377 236594

6) Monitors as Coherence Guardians

Monitors are not “optional extras”. They are the formal boundary guards that detect:

  • Layout stack corruption
  • Parser stagnation
  • Invariant violation
When a monitor triggers, the flow can:
  • emit a FATAL or ERROR
  • force Fail in strict mode
  • force Fail in strict mode

This is exactly aligned with the broader architecture: systems survive by enforcing invariants, not by hoping they hold.

7) Output Contract

When parsing succeeds (ok=true), the system guarantees:

  • Closed indentation (all blocks dedented)
  • A complete deterministic Sectioned AST
  • Tokens + AST are consistent with span constraints
  • Diagnostics do not include ERROR/FATAL

When parsing fails (ok=false), it still guarantees:

  • An emitted diagnostic record describing the earliest detected boundary failure
  • A remainder pointer indicating the unparsed region

So the parser always returns a coherent object — success or failure — which keeps downstream logic stable.

8) Why This Matters for Zero-Shot Execution

This flow is one of the core mechanisms behind:

  • Flow Algebra is self-contained”
  • “Flow Algebra is zero-shot deployable”
  • “No external compiler semantics required”
Because the structure is:
  • explicitly encoded
  • explicitly tokenised
  • explicitly parsed
  • explicitly validated

An LLM can interpret the flow as structure, not as vague text.

That is the entire point of the language: structural readability is execution readiness.

Flow → Equation Tri-Mapping

Token Parsing as Boundary & Hierarchy Operators

I. Stage 1 — Tokenisation

1️⃣ Flow Layer

From the flow:

Tokenise:
  source_text → tokens
Core operations:
  • Scan characters
  • Match lexical rules
  • Emit tokens
  • Enforce layout invariants

The output:

stream.tokens : list[Token]
Telephone:
01377 236594
2️⃣ Mathematical Operator Form

Let:

  • SS = raw source text
  • Σ\Sigma = token alphabet
  • R\mathcal{R} = lexical rule set
  • TT = token stream

Define the Tokenisation Operator:

\[ \mathcal{L}_{\mathcal{R}} : S \rightarrow T \]

Where:

\[ T = \mathcal{L}_{\mathcal{R}}(S) \]

Subject to:

\[ T \subseteq \Sigma^{*} \]

And span monotonicity constraint:

\[ \forall i:\; \mathrm{span}(t_i)_{\text{end}} \le \mathrm{span}(t_{i+1})_{\text{start}} \]

Indentation constraint:

\[ \mathrm{IndentStack}(t_i) \ge 0 \]

Failure condition:

\[ \exists c \in S \; \text{s.t.} \; c \notin \mathrm{domain}(\mathcal{R}) \Rightarrow \mathrm{LEX\_ERROR} \]

3️⃣ Coherence Interpretation

Tokenisation is:

A projection from continuous symbol field into discrete boundary units.

Mathematically:

\[ \mathcal{L}_{\mathcal{R}} = \text{Boundary Projection Operator} \]

Conceptually:
  • Characters → bounded regions
  • Regions → symbolic atoms
  • Layout → structural curvature

In HST terms:

Raw string = undifferentiated informational surface
Tokenisation = boundary carving
Tokens = curvature seeds

II. Stage 2 — Parsing

1️⃣ Flow Layer

From the flow:

ParseFlowDocument:
  tokens → AST

Parser consumes:

  • FLOW declaration
  • Section blocks
  • Nested maps
  • Lists
  • Values

Produces:

parse.ast : ASTNode
2️⃣ Mathematical Operator Form

Let:

  • TT = token stream
  • GG = Flow Algebra grammar
  • AA = AST

Define the Parsing Operator:

\[ \mathcal{P}_{G} : T \rightarrow A \]

So:

\[ A = \mathcal{P}_{G}(T) \]

Validity condition:

T∈L(G)

If:

\[ T \notin L(G) \Rightarrow \text{PARSE\_ERROR} \]

Tree well-formedness constraint:

\[ \forall n \in A : \text{span}(n) \subseteq \text{span}(\text{parent}(n)) \]

Indentation structural constraint:

\[ \text{Depth}(n) = \text{IndentLevel}(n) \]

Single flow root constraint:

\[ \exists!\,\text{FlowDecl} \in A \]

3️⃣ Coherence Interpretation

Parsing is:

Hierarchy reconstruction under structural constraints.

Mathematically:

\[ \mathcal{P}_{G} = \text{Hierarchy Reconstruction Operator} \]

Conceptually:
  • Tokens → relational geometry
  • Indentation → containment curvature
  • Sections → structural domains
  • AST → information manifold
In HST language:
Token field → curved structure
Grammar → constraint field
AST → stable coherence geometry

III. Full Parsing Pipeline

Now combine both operators:

\[ A = \mathcal{P}_{G}\!\left(\mathcal{L}_{\mathcal{R}}(S)\right) \]

This is the complete parsing composition:

\[ \mathcal{F}_{\text{parse}} = \mathcal{P}_{G} \circ \mathcal{L}_{\mathcal{R}} \]

Where:

  • L\mathcal{L} = lexical boundary operator
  • P\mathcal{P} = structural reconstruction operator

IV. Structural Coherence Constraints

The flow’s invariants correspond to formal constraints:

1. Span Monotonicity

\[ \forall i : \operatorname{span}(t_i)_{\text{end}} \le \operatorname{span}(t_{i+1})_{\text{start}} \]

Ensures no temporal overlap in symbolic projection.


2. Indentation Closure

\[ \sum \text{INDENT} = \sum \text{DEDENT} \]

At EOF:

\[ \text{IndentStack} = [0] \]

Ensures structural closure.


3. Deterministic AST

\[ \left|\mathcal{P}_{G}(T)\right| = 1 \]

There exists exactly one valid parse tree.

No ambiguity allowed.

V. Diagnostics as Coherence Violations

Define a validity function:

\[ V(A) = \begin{cases} \text{PASS} & \text{if constraints satisfied} \\ \text{WARN} & \text{if recoverable irregularities exist} \\ \text{FAIL} & \text{if structural violation exists} \end{cases} \]

Equivalent to:

\[ V(A) = \Phi(\text{Invariants}, \text{Diagnostics}) \]

This mirrors your structural validation operator from earlier chapters.

VI. Deep Structural Interpretation

Now the important conceptual bridge:

LayerOperatorMeaning
Characters
𝑆
Undifferentiated surface
Tokenisation
𝐿
Boundary formation
Tokens
𝑇
Local curvature units
Parsing
𝑃
Global hierarchy formation
AST
𝐴
Stable information manifold

Parsing is therefore:

The minimal process by which symbolic flux becomes stable structure.

It is literally:

Structure=Constraint∘Boundary

VII. Why This Matters for Flow Algebra

Flow Algebra was engineered so that:

\[ \mathcal{P}_{G} \]

is:

  • deterministic
  • indentation-driven
  • low ambiguity
  • LLM-compatible

Which means:

\[ \mathcal{F}_{\text{parse}} \]

can be executed zero-shot by any sufficiently capable language model.

No hidden compiler layer required.  Structure is visible.

VIII. Ultra-Compact Formal Summary

\[ A = \mathcal{P}_{G}\!\left(\mathcal{L}_{\mathcal{R}}(S)\right) \]

Subject to:

\[ \begin{aligned} T &\in L(G) \\ \sum \text{INDENT} &= \sum \text{DEDENT} \\ \left|\mathcal{P}_{G}(T)\right| &= 1 \\ V(A) &\ne \text{FAIL} \end{aligned} \]

S → Tokens → AST

Parsing as Geometric Curvature Formation

Overview

This diagram visually represents the complete parsing transformation:

\[ A = \mathcal{P}_{G}\!\left(\mathcal{L}_{\mathcal{R}}(S)\right) \]

Where:

  • SS= raw source text
  • LR\mathcal{L}_{\mathcal{R}} = lexical boundary operator
  • TT = token stream
  • PG\mathcal{P}_{G} = grammar-constrained parsing operator
  • 𝐴 = Abstract Syntax Tree

The drawing expresses this process geometrically rather than symbolically.

It shows how informational flatness becomes structured hierarchy.

Panel I — The Flat Symbolic Surface (S)

Caption:
Undifferentiated Symbolic Field

The leftmost panel depicts a flat sheet with faint markings.

This represents:

  • Raw source text
  • Continuous character field
  • No explicit structure
  • No hierarchy
  • No containment geometry

Mathematically:

\[ S \in \mathbb{S} \]

Where S\mathbb{S} denotes continuous symbolic space.

Interpretation:

Although the surface contains information, it lacks:

  • Boundary segmentation
  • Structural relationships
  • Nested containment

It is informationally rich but geometrically flat.

In coherence terms:

This is a pre-curvature state.

Panel II — Boundary Segmentation (T = Lᵣ(S))

Caption:
Tokenised Boundary Units

The middle panel shows the surface divided into discrete rectangular units.  Each unit represents a token.

This corresponds to the lexical transformation:

\[ T = \mathcal{L}_{\mathcal{R}}(S) \]

Key geometric features:
  • Clear edges
  • Discrete segmentation
  • Slight elevation between units
  • No overlap

Structural meaning:

Tokenisation introduces:

  • Discrete symbolic atoms
  • Local boundary curvature
  • Span ordering constraints

The surface is no longer continuous — it has been partitioned into coherent units.

Mathematically:

\[ T = \{t_1, t_2, \dots, t_n\} \]

With monotonicity:

\[ \operatorname{span}(t_i)_{\text{end}} \le \operatorname{span}(t_{i+1})_{\text{start}} \]

In geometric interpretation:

Tokenisation is boundary projection

The flat symbolic field now possesses local curvature — but not yet hierarchy.

Panel III — Hierarchical Curvature (A = Pᵍ(T))

Caption:
Sectioned AST Structure

The rightmost panel shows tokens lifting upward into a branching tree.  The base consists of token blocks.

From them emerges:
  • A trunk (root node)
  • Branches (section nodes)
  • Sub-branches (nested structures)
  • Leaves (terminal values)

This corresponds to:

\[ A = \mathcal{P}_{G}(T) \]

The grammar GG constrains valid tree formation.

Structural constraints include:
  • Single root
  • Parent-child containment
  • Span nesting:

\[ \operatorname{span}(\text{child}) \subseteq \operatorname{span}(\text{parent}) \]

  • Determinism:

\[ \left|\mathcal{P}_{G}(T)\right| = 1 \]

Interpretation:

Parsing creates:

  • Global curvature
  • Nested geometry
  • Stable containment hierarchy

The flat sheet has now become a structured manifold.

In coherence language:

Hierarchy is curvature across informational depth.

Structural Evolution Summary

StageOperatorGeometryMeaning
Raw Text
Identity

Flat

Undifferentiated field

Tokenisation

𝐿 𝑅

Segmented
Boundary formation
Parsing
𝑃 𝐺 
Hierarchical curvature
Structural coherence

Deep Structural Insight

The diagram illustrates a general principle:

\[ \text{Structure} = \text{Hierarchy} \circ \text{Boundary} \]

or more formally:

\[ A = \mathcal{P}_{G}\!\left(\mathcal{L}_{\mathcal{R}}(S)\right) \]

Where:
  • Boundary creation precedes structure
  • Structure requires constraint
  • Constraint produces stable curvature

Parsing is therefore not simply syntactic analysis.

It is:
The minimal transformation by which symbolic continuity becomes geometric hierarchy.

Why This Matters in Flow Algebra

Flow Algebra is intentionally designed so that:

  • Boundaries are explicit
  • Indentation defines containment
  • Sections define domain curvature
  • Grammar is minimal and deterministic
This ensures:

PG​

is stable and unique.  The language exposes its geometry.

Which is precisely why:
  • It is zero-shot interpretable
  • It requires no hidden compiler
  • It can be executed structurally by any sufficiently capable LLM

Conceptual Interpretation in The Broader Framework

  • Raw text = informational surface
  • Tokenisation = local boundary curvature
  • Parsing = global curvature integration
  • AST = coherent structural manifold
If we extend this geometrically:

The AST is not just a tree.

It is a stabilised geometry of meaning.

AI Interpretation Note

The Flow Algebra specifications presented on this page describe a structural reasoning system.
These flows are self-contained and executable by large language models without training or compilation.

Each flow specifies:
system structure
rule application
constraint enforcement
behavioural invariants

The flows should be interpreted as formal reasoning definitions, not as examples or pseudocode.

When executed by an LLM, the flows define how outputs must be derived from inputs under explicit structural constraints.  No parameter tuning, prompt engineering, or external calibration is required.

Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ
Designed By